-
Notifications
You must be signed in to change notification settings - Fork 8
/
options.html
467 lines (437 loc) · 12.7 KB
/
options.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
<!--
* Copyright 2012 Sven Werlen
*
* This file is part of Noojee Click.
*
* Noojee Click is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Noojee Click is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with Noojee Click. If not, see http://www.gnu.org/licenses/.
-->
<html>
<head><title>Noojee Click - Options</title>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.17.custom.css" />
<link rel="stylesheet" type="text/css" href="css/options.css" />
<script type="text/javascript" src="js/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="js/preferences.js"></script>
<script type="text/javascript" src="js/noojee/defaults/preferences.js"></script>
<script type="text/javascript">
// Removes all options from storage
function clearStorage() {
for (var key in localStorage) {
localStorage.removeItem(key);
}
}
// Saves options to localStorage.
function save_options() {
clearStorage();
// Phone
localStorage['extension'] = $("#extension").val();
localStorage['enableAutoAnswer'] = $("#auto-answer").attr('checked') == "checked";
localStorage['handsetType'] = $("#phone-type").val();
localStorage['internationalPrefix'] = $("#international-prefix").val();
localStorage['dialPrefix'] = $("#dial-prefix").val();
localStorage['localPrefix'] = $("#local-prefix-1").val();
localStorage['localPrefixSubstitution'] = $("#local-prefix-2").val();
// Patterns
localStorage['pattern'] = $("#pattern").val();
// Exclusions
localStorage['exclusions'] = $("#exclusions").val();
// Asterisk
localStorage['serverType'] = $("#server-type").val();
localStorage['host'] = $("#host").val();
localStorage['port'] = $("#port").val();
localStorage['username'] = $("#username").val();
localStorage['password'] = $("#password").val();
localStorage['context'] = $("#context").val();
localStorage['useHttps'] = $("#use-https").attr('checked') == "checked";
// Advanced
localStorage['httpPrefix'] = $("#http-prefix").val();
localStorage['callerId'] = $("#caller-id").val();
localStorage['delimiters'] = $("#delimiters").val();
localStorage['enableLogging'] = $("#enable-logging").attr('checked') == "checked";
localStorage['enableDebugging'] = $("#enable-debugging").attr('checked') == "checked";
localStorage['debugFilter'] = $("#debug-filters").val();
}
// Restores select box state to saved value from localStorage.
function restore_options() {
// Phone
$("#extension").val(localStorage['extension']);
$("#auto-answer").attr('checked', localStorage['enableAutoAnswer'] == "true");
$("#phone-type").val(localStorage['handsetType']);
$("#international-prefix").val(localStorage['internationalPrefix']);
$("#dial-prefix").val(localStorage['dialPrefix']);
$("#local-prefix-1").val(localStorage['localPrefix']);
$("#local-prefix-2").val(localStorage['localPrefixSubstitution']);
// Patterns
$("#pattern").val(localStorage['pattern']);
// Exclusions
$("#exclusions").val(localStorage['exclusions']);
// Asterisk
$("#server-type").val(localStorage['serverType']);
$("#host").val(localStorage['host']);
$("#port").val(localStorage['port']);
$("#username").val(localStorage['username']);
$("#password").val(localStorage['password']);
$("#context").val(localStorage['context']);
$("#use-https").attr('checked', localStorage['useHttps'] == "true");
// Advanced
$("#http-prefix").val(localStorage['httpPrefix']);
$("#caller-id").val(localStorage['callerId']);
$("#delimiters").val(localStorage['delimiters']);
$("#enable-logging").attr('checked', localStorage['enableLogging'] == "true");
$("#enable-debugging").attr('checked', localStorage['enableDebugging'] == "true");
$("#debug-filters").val(localStorage['debugFilter']);
}
// Import data
function importOptions() {
var importData = $( "#importoptions" ).val();
var options = importData.split("\n");
// read options line by line
for(var i=0; i < options.length; i++) {
var option = options[i];
// split key from values
var keyval = option.split("=");
if(keyval.length == 2) {
var key = keyval[0];
var value = keyval[1];
// replace ~ by \n
value = value.replace(/~/g, "\n");
// make sure that key is a valid setting
if(localStorage[key] != null) {
localStorage[key] = value;
}
}
}
}
// Generate export data
function getExport() {
var data = "";
for (var key in localStorage) {
if(key != "password") {
var val = localStorage[key];
data += key + "=" + val.replace(/\n/g, "~") + "\n";
}
}
return data;
}
$(function() {
$( "#tabs" ).tabs();
$( "button", ".actions" ).button();
//callback function to bring a hidden box back
function callback() {
setTimeout(function() {
$( "#status:visible" ).removeAttr( "style" ).fadeOut();
}, 1000 );
};
// action on "save"
$( "#status" ).hide();
$( "#save" ).click(function() {
var options = {};
$( "#status" ).show( "pulsate", options, 500, callback );
save_options();
return false;
});
// action on "reset"
$( "#dialog-reset" ).hide();
$( "#reset" ).click(function() {
$( "#dialog-reset" ).dialog({
resizable: false,
height:220,
width: 500,
modal: true,
buttons: {
"Reset values": function() {
clearStorage();
$( this ).dialog( "close" );
// force reload
window.location.reload();
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
// action on "import"
$( "#dialog-import" ).hide();
$( "#import" ).click(function() {
$( "#exportoptions" ).select();
$( "#dialog-import" ).dialog({
resizable: false,
height:380,
width: 700,
modal: true,
buttons: {
"Import": function() {
importOptions();
restore_options();
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
// action on "export"
$( "#dialog-export" ).hide();
$( "#export" ).click(function() {
$( "#exportoptions" ).val( getExport() );
$( "#dialog-export" ).dialog({
resizable: false,
height:420,
width: 700,
modal: true,
buttons: {
Done: function() {
$( this ).dialog( "close" );
}
}
});
});
});
</script>
</head>
<body onload="restore_options()">
<div class="options">
<img src="../img/noojeeclick.png" style="float: left;"/>
<img src="../img/asterisk.png" width="100px" style="float: right;"/>
<h1>Noojee Click</h1>
<!-- Status box -->
<div class="toggler">
<div id="status" class="ui-widget-header ui-corner-all">
<h2>Options successfully saved!</h3>
</div>
</div>
<!-- Confirm dialog -->
<div id="dialog-reset" title="Reset options?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This action will replace your saved options with extension defaults.
Confirm to proceed.</p>
</div>
<!-- Import dialog -->
<div id="dialog-import" title="Import options">
<p>
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Paste the options data (as exported) and click on button "Import".</p>
<textarea id="importoptions" rows="9" cols="60"></textarea>
</p>
</div>
<!-- Export dialog -->
<div id="dialog-export" title="Export options">
<p>
<ul>
<li>Select all text (Ctrl+A)</li>
<li>Copy to clipboard (Ctrl+C)</li>
<li>Paste it somewhere (wiki, text file, etc...).</li>
</ul>
<textarea id="exportoptions" rows="9" cols="60"></textarea>
</p>
</div>
<!-- Options -->
<div id="tabs">
<ul>
<li><a href="#tabs-1">Phone</a></li>
<li><a href="#tabs-2">Patterns</a></li>
<li><a href="#tabs-3">Exclusions</a></li>
<li><a href="#tabs-4">Asterisk</a></li>
<li><a href="#tabs-5">Advanced</a></li>
<li><a href="#tabs-6">About</a></li>
</ul>
<!-- ================================ -->
<div id="tabs-1">
<table>
<tr><th>Phone:</th></tr>
<tr class="content">
<td class="label">Extension:</td>
<td class="option">
<input id="extension" type="text" />
</td>
</tr>
<tr class="content">
<td class="label">Auto Answer:</td>
<td class="option">
<input id="auto-answer" type="checkbox" />
</td>
</tr>
<tr class="content">
<td class="label">Phone Type:</td>
<td class="option">
<select id="phone-type">
<option>Aestra</option>
<option>Grandstream</option>
<option>Linksys</option>
<option>Polycom</option>
<option>Snom</option>
<option>Yealink</option>
</select>
</td>
</tr>
<tr class="content">
<td class="label">International Prefix:</td>
<td class="option">
<input id="international-prefix" type="text" />
</td>
</tr>
<tr class="content">
<td class="label">Dial Prefix:</td>
<td class="option">
<input id="dial-prefix" type="text" />
</td>
</tr>
<tr class="content">
<td class="label">Local Prefix:</td>
<td class="option">
<input id="local-prefix-1" type="text" />
<input id="local-prefix-2" type="text" />
</td>
</tr>
</table>
</div>
<!-- ================================ -->
<div id="tabs-2">
<table>
<tr><th>Patterns:</th></tr>
<tr class="content">
<td class="option">
<textarea id="pattern" rows="9" cols="30">
</textarea>
</td>
</tr>
</table>
</div>
<!-- ================================ -->
<div id="tabs-3">
<table>
<tr><th>Exclusions:</th></tr>
<tr class="content">
<td class="option">
<textarea id="exclusions" rows="9" cols="100">
</textarea>
</td>
</tr>
</table>
</div>
<!-- ================================ -->
<div id="tabs-4">
<table>
<tr><th>Asterisk:</th></tr>
<tr class="content">
<td class="label">Server Type:</td>
<td class="option">
<select id="server-type">
<option value="AJAM">AJAM (Asterisk 1.4+)</option>
<option value="Astmanproxy">Astmanproxy</option>
<option value="Noojee">Noojee Vision</option>
</select>
</td>
</tr>
<tr class="content">
<td class="label">Host:</td>
<td class="option">
<input id="host" type="text" />
</td>
</tr>
<tr class="content">
<td class="label">Port:</td>
<td class="option">
<input id="port" type="text" />
</td>
</tr>
<tr class="content">
<td class="label">Username:</td>
<td class="option">
<input id="username" type="text" />
</td>
</tr>
<tr class="content">
<td class="label">Password:</td>
<td class="option">
<input id="password" type="password" />
</td>
</tr>
<tr class="content">
<td class="label">Context:</td>
<td class="option">
<input id="context" type="text" />
</td>
</tr>
<tr class="content">
<td class="label">Use HTTPS:</td>
<td class="option">
<input id="use-https" type="checkbox" />
</td>
</tr>
</table>
</div>
<!-- ================================ -->
<div id="tabs-5">
<table>
<tr><th>Advanced:</th></tr>
<tr class="content">
<td class="label">HTTP Prefix:</td>
<td class="option">
<input id="http-prefix" type="text" />
</td>
</tr>
<tr class="content">
<td class="label">Caller ID:</td>
<td class="option">
<input id="caller-id" type="text" />
</td>
</tr>
<tr class="content">
<td class="label">Delimiters:</td>
<td class="option">
<input id="delimiters" type="text" />
</td>
</tr>
<tr class="content">
<td class="label">Enable Logging:</td>
<td class="option">
<input id="enable-logging" type="checkbox" />
</td>
</tr>
<tr class="content">
<td class="label">Enable Debugging:</td>
<td class="option">
<input id="enable-debugging" type="checkbox" />
</td>
</tr>
<tr class="content">
<td class="label">Debug Filters:</td>
<td class="option">
<input id="debug-filters" type="text" />
</td>
</tr>
</table>
</div>
<!-- ================================ -->
<div id="tabs-6">
Developed by <a href="http://www.noojee.com.au">Noojee Telephony Solutions</a>.<br />
Copyright Brett Sutton<br /><br />
Adapted for Google Chrome by Sven Werlen.<br />
<b>License</b>: GNU Public License v.3 (<a href="http://www.gnu.org/licenses/gpl.html">read</a>)
<br />
<br />
Thank you for using Noojee Click!
</div>
<!-- ================================ -->
</div>
<br />
<div class="actions">
<button id="save">Save Options</button>
<button id="reset">Reset Defaults</button>
<button id="import">Import</button>
<button id="export">Export</button>
</div>
</body>
</html>