]> git.wh0rd.org - tt-rss.git/blame - prefs.js
sortable label editor
[tt-rss.git] / prefs.js
CommitLineData
007bda35
AD
1var xmlhttp = false;
2
91ff844a 3var active_feed_cat = false;
48f0adb0 4var active_label = false;
f5a50b25 5var active_tab = false;
c6232e43 6var feed_to_expand = false;
f5a50b25 7
1cac3c31
AD
8var piggie_top = -400;
9var piggie_fwd = true;
10
a58069db 11var xmlhttp = Ajax.getTransport();
007bda35 12
a7565293
AD
13var init_params = new Array();
14
c6232e43
AD
15function expand_feed_callback() {
16 if (xmlhttp.readyState == 4) {
17 try {
18 var container = document.getElementById("BRDET-" + feed_to_expand);
19 container.innerHTML=xmlhttp.responseText;
20 container.style.display = "block";
4d4200a8 21// p_notify("");
c6232e43
AD
22 } catch (e) {
23 exception_error("expand_feed_callback", e);
24 }
25 }
26}
27
007bda35 28function feedlist_callback() {
007bda35 29 if (xmlhttp.readyState == 4) {
47c6c988
AD
30 try {
31 var container = document.getElementById('prefContent');
32 container.innerHTML=xmlhttp.responseText;
a7f22b70
AD
33 selectTab("feedConfig", true);
34
3c5783b7
AD
35 if (active_feed_cat) {
36 var row = document.getElementById("FCATR-" + active_feed_cat);
47c6c988
AD
37 if (row) {
38 if (!row.className.match("Selected")) {
39 row.className = row.className + "Selected";
40 }
41 }
3c5783b7 42 var checkbox = document.getElementById("FCCHK-" + active_feed_cat);
47c6c988
AD
43 if (checkbox) {
44 checkbox.checked = true;
45 }
961513a3 46 }
3c5783b7 47
7f74a9da 48 notify("");
47c6c988
AD
49 } catch (e) {
50 exception_error("feedlist_callback", e);
961513a3 51 }
007bda35
AD
52 }
53}
54
a0d53889 55function filterlist_callback() {
f5a50b25 56 var container = document.getElementById('prefContent');
a0d53889
AD
57 if (xmlhttp.readyState == 4) {
58 container.innerHTML=xmlhttp.responseText;
7f74a9da 59 notify("");
a0d53889
AD
60 }
61}
62
48f0adb0 63function labellist_callback() {
f5a50b25 64 var container = document.getElementById('prefContent');
48f0adb0 65 if (xmlhttp.readyState == 4) {
f156fd00 66 closeInfoBox();
48f0adb0 67 container.innerHTML=xmlhttp.responseText;
967955b7 68 if (active_label) {
48f0adb0
AD
69 var row = document.getElementById("LILRR-" + active_label);
70 if (row) {
71 if (!row.className.match("Selected")) {
72 row.className = row.className + "Selected";
73 }
74 }
75 var checkbox = document.getElementById("LICHK-" + active_label);
76
77 if (checkbox) {
78 checkbox.checked = true;
79 }
80 }
7f74a9da 81 notify("");
48f0adb0
AD
82 }
83}
4255b24c 84
a4dbc524
AD
85function labeltest_callback() {
86 var container = document.getElementById('label_test_result');
87 if (xmlhttp.readyState == 4) {
88 container.innerHTML=xmlhttp.responseText;
89 notify("");
90 }
91}
92
c6232e43
AD
93function feed_browser_callback() {
94 var container = document.getElementById('prefContent');
95 if (xmlhttp.readyState == 4) {
96 container.innerHTML=xmlhttp.responseText;
7f74a9da 97 notify("");
c6232e43
AD
98 }
99}
100
e6cb77a0
AD
101function userlist_callback() {
102 var container = document.getElementById('prefContent');
103 if (xmlhttp.readyState == 4) {
104 container.innerHTML=xmlhttp.responseText;
7f74a9da 105 notify("");
e6cb77a0
AD
106 }
107}
108
4255b24c
AD
109function prefslist_callback() {
110 var container = document.getElementById('prefContent');
111 if (xmlhttp.readyState == 4) {
112
113 container.innerHTML=xmlhttp.responseText;
7f74a9da
AD
114
115 notify("");
4255b24c
AD
116 }
117}
118
b1895692
AD
119function gethelp_callback() {
120 var container = document.getElementById('prefHelpBox');
121 if (xmlhttp.readyState == 4) {
122
123 container.innerHTML = xmlhttp.responseText;
124 container.style.display = "block";
125
126 }
127}
4255b24c
AD
128
129
0e091d38
AD
130function notify_callback() {
131 var container = document.getElementById('notify');
132 if (xmlhttp.readyState == 4) {
133 container.innerHTML=xmlhttp.responseText;
134 }
135}
136
b83c7545 137function updateFeedList(sort_key) {
007bda35 138
c0e5a40e 139 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
140 printLockingError();
141 return
142 }
143
f5a50b25
AD
144// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
145
ce3bf408 146// p_notify("Loading, please wait...");
007bda35 147
f932bc9f
AD
148 var feed_search = document.getElementById("feed_search");
149 var search = "";
150 if (feed_search) { search = feed_search.value; }
151
b83c7545 152 xmlhttp.open("GET", "backend.php?op=pref-feeds" +
f932bc9f
AD
153 "&sort=" + param_escape(sort_key) +
154 "&search=" + param_escape(search), true);
007bda35
AD
155 xmlhttp.onreadystatechange=feedlist_callback;
156 xmlhttp.send(null);
157
158}
159
e6cb77a0
AD
160function updateUsersList() {
161
162 if (!xmlhttp_ready(xmlhttp)) {
163 printLockingError();
164 return
165 }
166
167// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
168
ce3bf408 169// p_notify("Loading, please wait...");
e6cb77a0
AD
170
171 xmlhttp.open("GET", "backend.php?op=pref-users", true);
172 xmlhttp.onreadystatechange=userlist_callback;
173 xmlhttp.send(null);
174
175}
176
48f0adb0
AD
177function addLabel() {
178
179 if (!xmlhttp_ready(xmlhttp)) {
180 printLockingError();
181 return
182 }
183
f156fd00 184 var form = document.forms['label_edit_form'];
48f0adb0 185
f156fd00
AD
186 var sql_exp = form.sql_exp.value;
187 var description = form.description.value;
48f0adb0 188
f156fd00
AD
189 if (sql_exp == "") {
190 alert("Can't create label: missing SQL expression.");
191 return false;
48f0adb0
AD
192 }
193
f156fd00
AD
194 if (description == "") {
195 alert("Can't create label: missing caption.");
196 return false;
de435974
AD
197 }
198
f156fd00 199 var query = Form.serialize("label_edit_form");
de435974 200
f156fd00
AD
201 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true);
202 xmlhttp.onreadystatechange=infobox_submit_callback;
203 xmlhttp.send(null);
de435974 204}
48f0adb0 205
71ad3959
AD
206function addFeed() {
207
c0e5a40e 208 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
209 printLockingError();
210 return
211 }
212
331900c6
AD
213 var link = document.getElementById("fadd_link");
214
83fe4d6d 215 if (link.value.length == 0) {
0ceded7a 216 alert("Error: No feed URL given.");
605f7d46 217 } else if (!isValidURL(link.value)) {
2371c520 218 alert("Error: Invalid feed URL.");
331900c6
AD
219 } else {
220 notify("Adding feed...");
221
07eb9178 222 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&feed_url=" +
331900c6
AD
223 param_escape(link.value), true);
224 xmlhttp.onreadystatechange=feedlist_callback;
225 xmlhttp.send(null);
226
227 link.value = "";
228
229 }
230
231}
232
91ff844a
AD
233function addFeedCat() {
234
235 if (!xmlhttp_ready(xmlhttp)) {
236 printLockingError();
237 return
238 }
239
240 var cat = document.getElementById("fadd_cat");
241
242 if (cat.value.length == 0) {
01b3e191 243 alert("Can't add category: no name specified.");
91ff844a
AD
244 } else {
245 notify("Adding feed category...");
246
247 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
248 param_escape(cat.value), true);
249 xmlhttp.onreadystatechange=feedlist_callback;
250 xmlhttp.send(null);
251
252 link.value = "";
253
254 }
255
256}
e6cb77a0
AD
257function addUser() {
258
259 if (!xmlhttp_ready(xmlhttp)) {
260 printLockingError();
261 return
262 }
263
264 var sqlexp = document.getElementById("uadd_box");
265
266 if (sqlexp.value.length == 0) {
01b3e191 267 alert("Can't add user: no login specified.");
e6cb77a0
AD
268 } else {
269 notify("Adding user...");
270
271 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
272 param_escape(sqlexp.value), true);
273
274 xmlhttp.onreadystatechange=userlist_callback;
275 xmlhttp.send(null);
276
277 sqlexp.value = "";
278 }
279
280}
281
48f0adb0
AD
282function editLabel(id) {
283
284 if (!xmlhttp_ready(xmlhttp)) {
285 printLockingError();
286 return
287 }
288
f156fd00
AD
289 document.getElementById("label_create_btn").disabled = true;
290
48f0adb0
AD
291 active_label = id;
292
a4dbc524
AD
293 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
294 selectTableRowById('LILRR-'+id, 'LICHK-'+id, true);
295
48f0adb0
AD
296 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
297 param_escape(id), true);
a4dbc524 298 xmlhttp.onreadystatechange=infobox_callback;
48f0adb0
AD
299 xmlhttp.send(null);
300
301}
302
e6cb77a0
AD
303function editUser(id) {
304
305 if (!xmlhttp_ready(xmlhttp)) {
306 printLockingError();
307 return
308 }
309
3c5783b7
AD
310 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
311 selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true);
e6cb77a0
AD
312
313 xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
314 param_escape(id), true);
3c5783b7 315 xmlhttp.onreadystatechange=infobox_callback;
e6cb77a0
AD
316 xmlhttp.send(null);
317
318}
319
a0d53889
AD
320function editFilter(id) {
321
322 if (!xmlhttp_ready(xmlhttp)) {
323 printLockingError();
324 return
325 }
326
4220b0bd
AD
327 document.getElementById("create_filter_btn").disabled = true;
328
07164479
AD
329 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
330 selectTableRowById('FILRR-'+id, 'FICHK-'+id, true);
a0d53889 331
07164479
AD
332 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id), true);
333 xmlhttp.onreadystatechange=infobox_callback;
a0d53889 334 xmlhttp.send(null);
a0d53889
AD
335}
336
331900c6
AD
337function editFeed(feed) {
338
508a81e1
AD
339// notify("Editing feed...");
340
c0e5a40e 341 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
342 printLockingError();
343 return
344 }
331900c6 345
673d54ca 346 // clean selection from all rows & select row being edited
0ea4fb50 347 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
6c12c809 348 selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
0ea4fb50
AD
349
350 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
3c5783b7 351 param_escape(feed), true);
0ea4fb50
AD
352
353 xmlhttp.onreadystatechange=infobox_callback;
331900c6
AD
354 xmlhttp.send(null);
355
356}
357
91ff844a 358function editFeedCat(cat) {
48f0adb0 359
91ff844a
AD
360 if (!xmlhttp_ready(xmlhttp)) {
361 printLockingError();
362 return
48f0adb0
AD
363 }
364
91ff844a 365 active_feed_cat = cat;
e6cb77a0 366
91ff844a
AD
367 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
368 param_escape(cat), true);
369 xmlhttp.onreadystatechange=feedlist_callback;
370 xmlhttp.send(null);
e6cb77a0 371
e6cb77a0
AD
372}
373
91ff844a
AD
374function getSelectedLabels() {
375 return getSelectedTableRowIds("prefLabelList", "LILRR");
376}
48f0adb0 377
91ff844a
AD
378function getSelectedUsers() {
379 return getSelectedTableRowIds("prefUserList", "UMRR");
a0d53889
AD
380}
381
83fe4d6d 382function getSelectedFeeds() {
91ff844a
AD
383 return getSelectedTableRowIds("prefFeedList", "FEEDR");
384}
331900c6 385
91ff844a
AD
386function getSelectedFilters() {
387 return getSelectedTableRowIds("prefFilterList", "FILRR");
388}
331900c6 389
91ff844a
AD
390function getSelectedFeedCats() {
391 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
83fe4d6d
AD
392}
393
c0ae0fdb
AD
394function getSelectedFeedsFromBrowser() {
395
396 var list = document.getElementById("browseFeedList");
397 if (!list) list = document.getElementById("browseBigFeedList");
398
399 var selected = new Array();
400
401 for (i = 0; i < list.childNodes.length; i++) {
402 var child = list.childNodes[i];
403 if (child.id && child.id.match("FBROW-")) {
404 var id = child.id.replace("FBROW-", "");
405
406 var cb = document.getElementById("FBCHK-" + id);
407
408 if (cb.checked) {
409 selected.push(id);
410 }
411 }
412 }
413
414 return selected;
415}
416
48f0adb0
AD
417function removeSelectedLabels() {
418
419 if (!xmlhttp_ready(xmlhttp)) {
420 printLockingError();
421 return
422 }
423
424 var sel_rows = getSelectedLabels();
425
426 if (sel_rows.length > 0) {
427
69668465 428 var ok = confirm("Remove selected labels?");
48f0adb0 429
69668465
AD
430 if (ok) {
431 notify("Removing selected labels...");
432
433 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
434 param_escape(sel_rows.toString()), true);
435 xmlhttp.onreadystatechange=labellist_callback;
436 xmlhttp.send(null);
437 }
48f0adb0 438 } else {
01b3e191 439 alert("No labels are selected.");
48f0adb0 440 }
90ac84df
AD
441
442 return false;
48f0adb0
AD
443}
444
e6cb77a0
AD
445function removeSelectedUsers() {
446
447 if (!xmlhttp_ready(xmlhttp)) {
448 printLockingError();
449 return
450 }
451
452 var sel_rows = getSelectedUsers();
453
454 if (sel_rows.length > 0) {
455
69668465 456 var ok = confirm("Remove selected users?");
e6cb77a0 457
69668465
AD
458 if (ok) {
459 notify("Removing selected users...");
460
461 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
462 param_escape(sel_rows.toString()), true);
463 xmlhttp.onreadystatechange=userlist_callback;
464 xmlhttp.send(null);
465 }
e6cb77a0
AD
466
467 } else {
01b3e191 468 alert("No users are selected.");
e6cb77a0 469 }
90ac84df
AD
470
471 return false;
e6cb77a0
AD
472}
473
48f0adb0
AD
474function removeSelectedFilters() {
475
476 if (!xmlhttp_ready(xmlhttp)) {
477 printLockingError();
478 return
479 }
480
481 var sel_rows = getSelectedFilters();
482
483 if (sel_rows.length > 0) {
484
69668465 485 var ok = confirm("Remove selected filters?");
48f0adb0 486
69668465
AD
487 if (ok) {
488 notify("Removing selected filters...");
489
490 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
491 param_escape(sel_rows.toString()), true);
492 xmlhttp.onreadystatechange=filterlist_callback;
493 xmlhttp.send(null);
494 }
48f0adb0 495 } else {
01b3e191 496 alert("No filters are selected.");
48f0adb0 497 }
90ac84df
AD
498
499 return false;
48f0adb0
AD
500}
501
502
83fe4d6d
AD
503function removeSelectedFeeds() {
504
c0e5a40e 505 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
506 printLockingError();
507 return
508 }
509
83fe4d6d
AD
510 var sel_rows = getSelectedFeeds();
511
331900c6
AD
512 if (sel_rows.length > 0) {
513
1d7bf5a0 514 var ok = confirm("Unsubscribe from selected feeds?");
331900c6 515
69668465
AD
516 if (ok) {
517
1d7bf5a0 518 notify("Unsubscribing from selected feeds...");
69668465
AD
519
520 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
521 param_escape(sel_rows.toString()), true);
522 xmlhttp.onreadystatechange=feedlist_callback;
523 xmlhttp.send(null);
524 }
71ad3959 525
71ad3959 526 } else {
331900c6 527
01b3e191 528 alert("No feeds are selected.");
331900c6 529
71ad3959 530 }
90ac84df
AD
531
532 return false;
71ad3959 533}
007bda35 534
91ff844a
AD
535function removeSelectedFeedCats() {
536
537 if (!xmlhttp_ready(xmlhttp)) {
538 printLockingError();
539 return
540 }
541
542 var sel_rows = getSelectedFeedCats();
543
544 if (sel_rows.length > 0) {
545
69668465 546 var ok = confirm("Remove selected categories?");
91ff844a 547
69668465
AD
548 if (ok) {
549 notify("Removing selected categories...");
550
551 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
552 param_escape(sel_rows.toString()), true);
553 xmlhttp.onreadystatechange=feedlist_callback;
554 xmlhttp.send(null);
555 }
91ff844a
AD
556
557 } else {
558
01b3e191 559 alert("No categories are selected.");
91ff844a
AD
560
561 }
562
90ac84df 563 return false;
91ff844a
AD
564}
565
508a81e1
AD
566function feedEditCancel() {
567
c0e5a40e 568 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
569 printLockingError();
570 return
571 }
572
327a3bbe
AD
573 closeInfoBox();
574
673d54ca 575 selectPrefRows('feed', false); // cleanup feed selection
508a81e1 576
90ac84df 577 return false;
508a81e1
AD
578}
579
91ff844a
AD
580function feedCatEditCancel() {
581
582 if (!xmlhttp_ready(xmlhttp)) {
583 printLockingError();
584 return
585 }
586
587 active_feed_cat = false;
588
0ceded7a 589// notify("Operation cancelled.");
91ff844a
AD
590
591 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
592 xmlhttp.onreadystatechange=feedlist_callback;
593 xmlhttp.send(null);
594
90ac84df 595 return false;
91ff844a
AD
596}
597
603c27f8
AD
598function feedEditSave() {
599
47c6c988 600 try {
47c6c988
AD
601
602 if (!xmlhttp_ready(xmlhttp)) {
603 printLockingError();
604 return
605 }
ad815c71 606
14f69488 607 // FIXME: add parameter validation
e3c99f3b 608
14f69488 609 var query = Form.serialize("edit_feed_form");
b0da3a7b 610
14f69488 611 notify("Saving feed...");
673d54ca 612
47c6c988
AD
613 xmlhttp.open("POST", "backend.php", true);
614 xmlhttp.onreadystatechange=feedlist_callback;
615 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
14f69488
AD
616 xmlhttp.send(query);
617
59a543f0
AD
618 closeInfoBox();
619
c14b5566
AD
620 return false;
621
47c6c988
AD
622 } catch (e) {
623 exception_error("feedEditSave", e);
b0da3a7b 624 }
508a81e1
AD
625}
626
5ddadb4c
AD
627function feedCatEditSave() {
628
629 if (!xmlhttp_ready(xmlhttp)) {
630 printLockingError();
631 return
632 }
633
f0e81ffe 634 notify("Saving category...");
5ddadb4c 635
0666e120
AD
636 var query = Form.serialize("feed_cat_edit_form");
637
638 xmlhttp.open("GET", "backend.php?" + query, true);
5ddadb4c
AD
639 xmlhttp.onreadystatechange=feedlist_callback;
640 xmlhttp.send(null);
641
642 active_feed_cat = false;
643
90ac84df 644 return false;
5ddadb4c
AD
645}
646
647
d9dde1d6
AD
648function labelTest() {
649
a4dbc524
AD
650 var container = document.getElementById('label_test_result');
651 container.style.display = "block";
652 container.innerHTML = "<p>Loading, please wait...</p>";
653
f3120e5a
AD
654 var form = document.forms['label_edit_form'];
655
656 var sql_exp = form.sql_exp.value;
657 var description = form.description.value;
d9dde1d6
AD
658
659 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
f3120e5a 660 param_escape(sql_exp) + "&descr=" + param_escape(description), true);
d9dde1d6 661
a4dbc524 662 xmlhttp.onreadystatechange=labeltest_callback;
d9dde1d6
AD
663 xmlhttp.send(null);
664
90ac84df 665 return false;
d9dde1d6
AD
666}
667
01c9c74a
AD
668function displayHelpInfobox(topic_id) {
669
670 xmlhttp.open("GET", "backend.php?op=help&tid=" +
671 param_escape(topic_id) + "&noheaders=1", true);
672
673 xmlhttp.onreadystatechange=infobox_callback;
674 xmlhttp.send(null);
675
676}
677
48f0adb0
AD
678function labelEditCancel() {
679
680 if (!xmlhttp_ready(xmlhttp)) {
681 printLockingError();
682 return
683 }
684
f156fd00
AD
685 document.getElementById("label_create_btn").disabled = false;
686
48f0adb0
AD
687 active_label = false;
688
a4dbc524 689 selectPrefRows('label', false); // cleanup feed selection
50bad812
AD
690 closeInfoBox();
691
90ac84df 692 return false;
48f0adb0
AD
693}
694
e6cb77a0
AD
695function userEditCancel() {
696
697 if (!xmlhttp_ready(xmlhttp)) {
698 printLockingError();
699 return
700 }
701
3c5783b7 702 selectPrefRows('user', false); // cleanup feed selection
3c5783b7 703 closeInfoBox();
90ac84df
AD
704
705 return false;
e6cb77a0 706}
48f0adb0 707
a0d53889
AD
708function filterEditCancel() {
709
710 if (!xmlhttp_ready(xmlhttp)) {
711 printLockingError();
712 return
713 }
4220b0bd
AD
714
715 document.getElementById("create_filter_btn").disabled = false;
07164479
AD
716
717 selectPrefRows('filter', false); // cleanup feed selection
718 closeInfoBox();
90ac84df
AD
719
720 return false;
a0d53889
AD
721}
722
48f0adb0
AD
723function labelEditSave() {
724
725 var label = active_label;
726
727 if (!xmlhttp_ready(xmlhttp)) {
728 printLockingError();
729 return
730 }
731
7c620da8 732 if (!is_opera()) {
48f0adb0 733
7c620da8
AD
734 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
735 var description = document.forms["label_edit_form"].description.value;
736
737 if (sql_exp.length == 0) {
738 alert("SQL Expression cannot be blank.");
739 return false;
740 }
741
742 if (description.length == 0) {
743 alert("Caption field cannot be blank.");
744 return false;
745 }
3c5783b7 746 }
48f0adb0 747
50bad812
AD
748 closeInfoBox();
749
f0e81ffe 750 notify("Saving label...");
dbd9e2f1 751
48f0adb0
AD
752 active_label = false;
753
f3120e5a
AD
754 query = Form.serialize("label_edit_form");
755
50bad812 756 xmlhttp.open("GET", "backend.php?" + query, true);
48f0adb0
AD
757 xmlhttp.onreadystatechange=labellist_callback;
758 xmlhttp.send(null);
759
90ac84df 760 return false;
48f0adb0
AD
761}
762
e6cb77a0
AD
763function userEditSave() {
764
e6cb77a0
AD
765 if (!xmlhttp_ready(xmlhttp)) {
766 printLockingError();
767 return
768 }
769
3c5783b7 770 var login = document.forms["user_edit_form"].login.value;
e6cb77a0
AD
771
772 if (login.length == 0) {
3c5783b7 773 alert("Login field cannot be blank.");
e6cb77a0
AD
774 return;
775 }
3c5783b7 776
f0e81ffe 777 notify("Saving user...");
4220b0bd
AD
778
779 closeInfoBox();
780
3c5783b7
AD
781 var query = Form.serialize("user_edit_form");
782
783 xmlhttp.open("GET", "backend.php?" + query, true);
dbd9e2f1 784 xmlhttp.onreadystatechange=userlist_callback;
e6cb77a0 785 xmlhttp.send(null);
90ac84df
AD
786
787 return false;
e6cb77a0
AD
788}
789
790
a0d53889
AD
791function filterEditSave() {
792
a0d53889
AD
793 if (!xmlhttp_ready(xmlhttp)) {
794 printLockingError();
795 return
796 }
797
7c620da8
AD
798 if (!is_opera()) {
799 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
800
801 if (reg_exp.length == 0) {
802 alert("Filter expression field cannot be blank.");
803 return;
804 }
3c5783b7 805 }
a0d53889 806
7e939457 807 notify("Saving filter...");
a0d53889 808
7e939457 809 var query = Form.serialize("filter_edit_form");
dbd9e2f1 810
07164479
AD
811 closeInfoBox();
812
4220b0bd
AD
813 document.getElementById("create_filter_btn").disabled = false;
814
7e939457 815 xmlhttp.open("GET", "backend.php?" + query, true);
a0d53889 816 xmlhttp.onreadystatechange=filterlist_callback;
7e939457 817 xmlhttp.send(null);
a0d53889 818
90ac84df 819 return false;
a0d53889
AD
820}
821
48f0adb0
AD
822function editSelectedLabel() {
823 var rows = getSelectedLabels();
a0d53889 824
48f0adb0 825 if (rows.length == 0) {
01b3e191 826 alert("No labels are selected.");
48f0adb0 827 return;
a0d53889
AD
828 }
829
48f0adb0 830 if (rows.length > 1) {
01b3e191 831 alert("Please select only one label.");
48f0adb0
AD
832 return;
833 }
a0d53889 834
dbd9e2f1
AD
835 notify("");
836
48f0adb0 837 editLabel(rows[0]);
a0d53889 838
a0d53889
AD
839}
840
e6cb77a0
AD
841function editSelectedUser() {
842 var rows = getSelectedUsers();
843
844 if (rows.length == 0) {
01b3e191 845 alert("No users are selected.");
e6cb77a0
AD
846 return;
847 }
848
849 if (rows.length > 1) {
01b3e191 850 alert("Please select only one user.");
e6cb77a0
AD
851 return;
852 }
853
dbd9e2f1
AD
854 notify("");
855
e6cb77a0
AD
856 editUser(rows[0]);
857}
858
859function resetSelectedUserPass() {
860 var rows = getSelectedUsers();
861
862 if (rows.length == 0) {
01b3e191 863 alert("No users are selected.");
e6cb77a0
AD
864 return;
865 }
866
867 if (rows.length > 1) {
01b3e191 868 alert("Please select only one user.");
e6cb77a0
AD
869 return;
870 }
871
69668465 872 var ok = confirm("Reset password of selected user?");
e6cb77a0 873
69668465
AD
874 if (ok) {
875 notify("Resetting password for selected user...");
876
877 var id = rows[0];
878
879 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
880 param_escape(id), true);
881 xmlhttp.onreadystatechange=userlist_callback;
882 xmlhttp.send(null);
883 }
e6cb77a0
AD
884}
885
717f5e64 886function selectedUserDetails() {
e6cb77a0 887
1a7572cb
AD
888 if (!xmlhttp_ready(xmlhttp)) {
889 printLockingError();
890 return
891 }
892
717f5e64
AD
893 var rows = getSelectedUsers();
894
895 if (rows.length == 0) {
01b3e191 896 alert("No users are selected.");
717f5e64
AD
897 return;
898 }
899
900 if (rows.length > 1) {
01b3e191 901 alert("Please select only one user.");
717f5e64
AD
902 return;
903 }
904
905 var id = rows[0];
906
dbd9e2f1
AD
907 notify("");
908
1a7572cb 909 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
c6c3a07f
AD
910 xmlhttp.onreadystatechange=infobox_callback;
911 xmlhttp.send(null);
912
913}
914
915function selectedFeedDetails() {
916
917 if (!xmlhttp_ready(xmlhttp)) {
918 printLockingError();
919 return
920 }
921
922 var rows = getSelectedFeeds();
923
924 if (rows.length == 0) {
01b3e191 925 alert("No feeds are selected.");
c6c3a07f
AD
926 return;
927 }
928
01b3e191
AD
929 if (rows.length > 1) {
930 notify("Please select only one feed.");
931 return;
932 }
c6c3a07f 933
df268d47 934// var id = rows[0];
c6c3a07f 935
dbd9e2f1
AD
936 notify("");
937
df268d47
AD
938 xmlhttp.open("GET", "backend.php?op=feed-details&id=" +
939 param_escape(rows.toString()), true);
c6c3a07f 940 xmlhttp.onreadystatechange=infobox_callback;
1a7572cb 941 xmlhttp.send(null);
717f5e64
AD
942
943}
a0d53889
AD
944
945function editSelectedFilter() {
946 var rows = getSelectedFilters();
947
948 if (rows.length == 0) {
01b3e191 949 alert("No filters are selected.");
a0d53889
AD
950 return;
951 }
952
953 if (rows.length > 1) {
01b3e191 954 alert("Please select only one filter.");
a0d53889
AD
955 return;
956 }
957
dbd9e2f1
AD
958 notify("");
959
a0d53889
AD
960 editFilter(rows[0]);
961
962}
963
964
508a81e1
AD
965function editSelectedFeed() {
966 var rows = getSelectedFeeds();
967
968 if (rows.length == 0) {
969 notify("No feeds are selected.");
970 return;
971 }
972
973 if (rows.length > 1) {
974 notify("Please select one feed.");
975 return;
976 }
977
dbd9e2f1
AD
978 notify("");
979
508a81e1 980 editFeed(rows[0]);
91ff844a
AD
981
982}
983
984function editSelectedFeedCat() {
985 var rows = getSelectedFeedCats();
986
987 if (rows.length == 0) {
01b3e191 988 alert("No categories are selected.");
91ff844a
AD
989 return;
990 }
991
992 if (rows.length > 1) {
01b3e191 993 alert("Please select only one category.");
91ff844a
AD
994 return;
995 }
996
997 notify("");
998
999 editFeedCat(rows[0]);
508a81e1
AD
1000
1001}
1002
1cac3c31
AD
1003function piggie_callback() {
1004 var piggie = document.getElementById("piggie");
1005
1006 piggie.style.top = piggie_top;
e0b6a737
AD
1007 piggie.style.backgroundColor = "white";
1008 piggie.style.borderWidth = "1px";
1cac3c31
AD
1009
1010 if (piggie_fwd && piggie_top < 0) {
1011 setTimeout("piggie_callback()", 50);
1012 piggie_top = piggie_top + 10;
1013 } else if (piggie_fwd && piggie_top >= 0) {
1014 piggie_fwd = false;
1015 setTimeout("piggie_callback()", 50);
1016 } else if (!piggie_fwd && piggie_top > -400) {
1017 setTimeout("piggie_callback()", 50);
1018 piggie_top = piggie_top - 10;
1019 } else if (!piggie_fwd && piggie_top <= -400) {
1020 piggie.style.display = "none";
1021 piggie_fwd = true;
1022 }
1023}
1024
33377ef3
AD
1025var piggie_opacity = 0;
1026
1027function piggie2_callback() {
1028 var piggie = document.getElementById("piggie");
1029 piggie.style.top = 0;
1030 piggie.style.opacity = piggie_opacity;
e0b6a737
AD
1031 piggie.style.backgroundColor = "transparent";
1032 piggie.style.borderWidth = "0px";
33377ef3
AD
1033
1034 if (piggie_fwd && piggie_opacity < 1) {
1035 setTimeout("piggie2_callback()", 50);
1036 piggie_opacity = piggie_opacity + 0.03;
1037 } else if (piggie_fwd && piggie_opacity >= 1) {
1038 piggie_fwd = false;
1039 setTimeout("piggie2_callback()", 50);
1040 } else if (!piggie_fwd && piggie_opacity > 0) {
1041 setTimeout("piggie2_callback()", 50);
1042 piggie_opacity = piggie_opacity - 0.03;
1043 } else if (!piggie_fwd && piggie_opacity <= 0) {
1044 piggie.style.display = "none";
1045 piggie_fwd = true;
1046 }
1047}
1048
13ad9102
AD
1049function localPiggieFunction(enable) {
1050 if (enable) {
d437c8cf 1051 debug("I LOVEDED IT!");
1cac3c31 1052 var piggie = document.getElementById("piggie");
508a81e1 1053 piggie.style.display = "block";
33377ef3 1054
292a8a12 1055 if (navigator.userAgent.match("Gecko") && Math.random(1) > 0.5) {
33377ef3
AD
1056 piggie2_callback();
1057 } else {
1058 piggie_callback();
1059 }
508a81e1 1060 }
508a81e1
AD
1061}
1062
9f311df6
AD
1063function validateOpmlImport() {
1064
1065 var opml_file = document.getElementById("opml_file");
1066
1067 if (opml_file.value.length == 0) {
01b3e191 1068 alert("No OPML file to upload.");
9f311df6
AD
1069 return false;
1070 } else {
1071 return true;
1072 }
1073}
1074
0e317f9d 1075function updateFilterList(sort_key) {
a0d53889
AD
1076
1077 if (!xmlhttp_ready(xmlhttp)) {
1078 printLockingError();
1079 return
1080 }
1081
f5a50b25
AD
1082// document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1083
ce3bf408 1084// p_notify("Loading, please wait...");
a0d53889 1085
e161a2cc
AD
1086 xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" +
1087 param_escape(sort_key), true);
a0d53889
AD
1088 xmlhttp.onreadystatechange=filterlist_callback;
1089 xmlhttp.send(null);
1090
1091}
1092
e161a2cc 1093function updateLabelList(sort_key) {
48f0adb0
AD
1094
1095 if (!xmlhttp_ready(xmlhttp)) {
1096 printLockingError();
1097 return
1098 }
1099
ce3bf408 1100// p_notify("Loading, please wait...");
f5a50b25
AD
1101
1102// document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
48f0adb0 1103
e161a2cc
AD
1104 xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" +
1105 param_escape(sort_key), true);
48f0adb0
AD
1106 xmlhttp.onreadystatechange=labellist_callback;
1107 xmlhttp.send(null);
48f0adb0
AD
1108}
1109
4255b24c
AD
1110function updatePrefsList() {
1111
1112 if (!xmlhttp_ready(xmlhttp)) {
1113 printLockingError();
1114 return
1115 }
1116
ce3bf408 1117// p_notify("Loading, please wait...");
4255b24c
AD
1118
1119 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1120 xmlhttp.onreadystatechange=prefslist_callback;
1121 xmlhttp.send(null);
1122
1123}
1124
a7f22b70
AD
1125function selectTab(id, noupdate) {
1126
1127// alert(id);
48f0adb0 1128
b2caf812 1129 if (!id) id = active_tab;
7f74a9da 1130
b2caf812 1131 try {
59a543f0 1132
b2caf812
AD
1133 if (!xmlhttp_ready(xmlhttp)) {
1134 printLockingError();
1135 return
a7f22b70 1136 }
f5a50b25 1137
b2caf812 1138 if (!noupdate) {
f5a50b25 1139
b2caf812
AD
1140 debug("selectTab: " + id + "(NU: " + noupdate + ")");
1141
95322e12 1142// notify("Loading, please wait...", true);
b2caf812
AD
1143
1144 // close active infobox if needed
1145 closeInfoBox();
1146
1147 // clean up all current selections, just in case
1148 active_feed_cat = false;
1149 active_label = false;
1150
1151 if (id == "feedConfig") {
1152 updateFeedList();
1153 } else if (id == "filterConfig") {
1154 updateFilterList();
1155 } else if (id == "labelConfig") {
1156 updateLabelList();
1157 } else if (id == "genConfig") {
1158 updatePrefsList();
1159 } else if (id == "userConfig") {
1160 updateUsersList();
1161 } else if (id == "feedBrowser") {
1162 updateBigFeedBrowser();
1163 }
f5a50b25 1164 }
b2caf812
AD
1165
1166 var tab = document.getElementById(active_tab + "Tab");
1167
1168 if (tab) {
1169 if (tab.className.match("Selected")) {
1170 tab.className = "prefsTab";
1171 }
f5a50b25 1172 }
b2caf812
AD
1173
1174 tab = document.getElementById(id + "Tab");
1175
1176 if (tab) {
1177 if (!tab.className.match("Selected")) {
1178 tab.className = tab.className + "Selected";
1179 }
1180 }
1181
1182 if (active_tab != id) {
1183 storeInitParam("prefs_active_tab", id);
1184 }
1185
1186 active_tab = id;
f5a50b25 1187
b2caf812
AD
1188 } catch (e) {
1189 exception_error("selectTab", e);
a7565293 1190 }
a7565293
AD
1191}
1192
1193function backend_sanity_check_callback() {
f5a50b25 1194
a7565293
AD
1195 if (xmlhttp.readyState == 4) {
1196
1197 try {
1198
1199 if (!xmlhttp.responseXML) {
1200 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText);
1201 return;
1202 }
1203
1204 var reply = xmlhttp.responseXML.firstChild.firstChild;
1205
1206 if (!reply) {
1207 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText);
1208 return;
1209 }
1210
1211 var error_code = reply.getAttribute("error-code");
1212
1213 if (error_code && error_code != 0) {
1214 return fatalError(error_code, reply.getAttribute("error-msg"));
1215 }
1216
1217 debug("sanity check ok");
1218
1219 var params = reply.nextSibling;
1220
1221 if (params) {
1222 debug('reading init-params...');
1223 var param = params.firstChild;
1224
1225 while (param) {
1226 var k = param.getAttribute("key");
1227 var v = param.getAttribute("value");
1228 debug(k + " => " + v);
1229 init_params[k] = v;
1230 param = param.nextSibling;
1231 }
1232 }
1233
1234 init_second_stage();
1235
1236 } catch (e) {
1237 exception_error("backend_sanity_check_callback", e);
1238 }
1239 }
1240}
1241
1242function init_second_stage() {
1243
b2caf812
AD
1244 try {
1245 active_tab = getInitParam("prefs_active_tab");
1246 if (!active_tab) active_tab = "genConfig";
4da47970 1247
d437c8cf
AD
1248 document.onkeydown = pref_hotkey_handler;
1249
b2caf812
AD
1250 if (navigator.userAgent.match("Opera")) {
1251 setTimeout("selectTab()", 500);
1252 } else {
1253 selectTab(active_tab);
1254 }
1255 notify("");
1256 } catch (e) {
1257 exception_error("init_second_stage", e);
1258 }
a0d53889
AD
1259}
1260
007bda35 1261function init() {
e2ec66a8 1262
7719618b
AD
1263 try {
1264
97dcd654
AD
1265 if (arguments.callee.done) return;
1266 arguments.callee.done = true;
1267
a7565293
AD
1268 if (getURLParam('debug')) {
1269 document.getElementById('debug_output').style.display = 'block';
1270 debug('debug mode activated');
1271 }
1272
7719618b
AD
1273 // IE kludge
1274 if (!xmlhttp) {
1275 document.getElementById("prefContent").innerHTML =
1276 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1277 "to function properly. Your browser doesn't seem to support it.";
1278 return;
1279 }
4da47970 1280
a7565293
AD
1281 xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1282 xmlhttp.onreadystatechange=backend_sanity_check_callback;
1283 xmlhttp.send(null);
1284
7719618b
AD
1285 } catch (e) {
1286 exception_error("init", e);
e2ec66a8 1287 }
007bda35 1288}
b1895692 1289
f932bc9f
AD
1290function categorizeSelectedFeeds() {
1291
1292 if (!xmlhttp_ready(xmlhttp)) {
1293 printLockingError();
1294 return
1295 }
1296
1297 var sel_rows = getSelectedFeeds();
1298
1299 var cat_sel = document.getElementById("sfeed_set_fcat");
79f3553b 1300 var cat_id = cat_sel[cat_sel.selectedIndex].value;
f932bc9f
AD
1301
1302 if (sel_rows.length > 0) {
1303
1304 notify("Changing category of selected feeds...");
1305
1306 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1307 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1308 xmlhttp.onreadystatechange=feedlist_callback;
1309 xmlhttp.send(null);
1310
1311 } else {
1312
01b3e191 1313 alert("No feeds are selected.");
f932bc9f
AD
1314
1315 }
1316
1317}
69668465
AD
1318
1319function validatePrefsReset() {
1320 return confirm("Reset to defaults?");
1321}
f9cb39ac 1322
6311acbe 1323function browseFeeds(limit) {
f9cb39ac
AD
1324
1325 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1326 xmlhttp.onreadystatechange=infobox_callback;
1327 xmlhttp.send(null);
1328
1329}
a0476535
AD
1330
1331function feedBrowserSubscribe() {
1332 try {
a0476535 1333
c0ae0fdb 1334 var selected = getSelectedFeedsFromBrowser();
a0476535
AD
1335
1336 if (selected.length > 0) {
1337 closeInfoBox();
1338 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1339 param_escape(selected.toString()), true);
1340 xmlhttp.onreadystatechange=feedlist_callback;
1341 xmlhttp.send(null);
1342 } else {
1343 alert("No feeds are selected.");
1344 }
1345
1346 } catch (e) {
1347 exception_error("feedBrowserSubscribe", e);
1348 }
1349}
c6232e43 1350
6311acbe 1351function updateBigFeedBrowser(limit) {
c6232e43
AD
1352
1353 if (!xmlhttp_ready(xmlhttp)) {
1354 printLockingError();
1355 return
1356 }
1357
ce3bf408 1358// p_notify("Loading, please wait...");
c6232e43 1359
6311acbe
AD
1360 var query = "backend.php?op=pref-feed-browser";
1361
1362 var limit_sel = document.getElementById("feedBrowserLimit");
1363
1364 if (limit_sel) {
1365 var limit = limit_sel[limit_sel.selectedIndex].value;
1366 query = query + "&limit=" + param_escape(limit);
1367 }
1368
1369 xmlhttp.open("GET", query, true);
c6232e43
AD
1370 xmlhttp.onreadystatechange=feed_browser_callback;
1371 xmlhttp.send(null);
c6232e43
AD
1372}
1373
c2b2aee0 1374function browserToggleExpand(id) {
c6232e43
AD
1375 try {
1376/* if (feed_to_expand && feed_to_expand != id) {
1377 var d = document.getElementById("BRDET-" + feed_to_expand);
1378 d.style.display = "none";
1379 } */
c2b2aee0 1380
ff725e9b
AD
1381 if (!xmlhttp_ready(xmlhttp)) {
1382 printLockingError();
1383 return
1384 }
1385
c2b2aee0
AD
1386 var d = document.getElementById("BRDET-" + id);
1387
1388 if (d.style.display == "block") {
1389 d.style.display = "none";
1390
1391 } else {
c6232e43 1392
c2b2aee0 1393 feed_to_expand = id;
c6232e43 1394
ff725e9b
AD
1395 d.style.display = "block";
1396 d.innerHTML = "Loading, please wait...";
1397
c2b2aee0
AD
1398 xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1399 + param_escape(id), true);
1400 xmlhttp.onreadystatechange=expand_feed_callback;
1401 xmlhttp.send(null);
1402 }
c6232e43
AD
1403
1404 } catch (e) {
1405 exception_error("browserExpand", e);
1406 }
1407}
64dc5976
AD
1408
1409function validateNewPassword(form) {
1410 if (form.OLD_PASSWORD.value == "") {
88103301 1411 alert("Old password cannot be blank");
64dc5976
AD
1412 return false;
1413 }
1414 if (form.NEW_PASSWORD.value == "") {
1415 alert("New password cannot be blank");
1416 return false;
1417 }
1418 return true;
1419}
ce3bf408
AD
1420
1421function selectPrefRows(kind, select) {
1422
1423 if (kind) {
1424 var opbarid = false;
1425 var nchk = false;
1426 var nrow = false;
1427 var lname = false;
1428
1429 if (kind == "feed") {
1430 opbarid = "feedOpToolbar";
1431 nrow = "FEEDR-";
1432 nchk = "FRCHK-";
1433 lname = "prefFeedList";
1434 } else if (kind == "fcat") {
1435 opbarid = "catOpToolbar";
1436 nrow = "FCATR-";
1437 nchk = "FCHK-";
1438 lname = "prefFeedCatList";
1439 } else if (kind == "filter") {
1440 opbarid = "filterOpToolbar";
1441 nrow = "FILRR-";
1442 nchk = "FICHK-";
1443 lname = "prefFilterList";
1444 } else if (kind == "label") {
1445 opbarid = "labelOpToolbar";
1446 nrow = "LILRR-";
a4dbc524 1447 nchk = "LICHK-";
ce3bf408
AD
1448 lname = "prefLabelList";
1449 } else if (kind == "user") {
1450 opbarid = "userOpToolbar";
1451 nrow = "UMRR-";
1452 nchk = "UMCHK-";
1453 lname = "prefUserList";
1454 }
1455
1456 if (opbarid) {
1457 selectTableRowsByIdPrefix(lname, nrow, nchk, select);
1458 disableContainerChildren(opbarid, !select);
1459 }
1460
1461 }
1462}
1463
1464
1465function toggleSelectPrefRow(sender, kind) {
1466
1467 toggleSelectRow(sender);
1468
1469 if (kind) {
1470 var opbarid = false;
1471 var nsel = -1;
1472
1473 if (kind == "feed") {
1474 opbarid = "feedOpToolbar";
1475 nsel = getSelectedFeeds();
1476 } else if (kind == "fcat") {
1477 opbarid = "catOpToolbar";
1478 nsel = getSelectedFeedCats();
1479 } else if (kind == "filter") {
1480 opbarid = "filterOpToolbar";
1481 nsel = getSelectedFilters();
1482 } else if (kind == "label") {
1483 opbarid = "labelOpToolbar";
1484 nsel = getSelectedLabels();
1485 } else if (kind == "user") {
1486 opbarid = "userOpToolbar";
1487 nsel = getSelectedUsers();
1488 }
1489
1490 if (opbarid && nsel != -1) {
1491 disableContainerChildren(opbarid, nsel == false);
1492 }
1493
1494 }
1495}
1496
c0ae0fdb
AD
1497function toggleSelectFBListRow(sender) {
1498 toggleSelectListRow(sender);
1499 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1500}
d437c8cf
AD
1501
1502var seq = "";
1503
1504function pref_hotkey_handler(e) {
1505 try {
1506
1507 var keycode;
1508
1509 if (!hotkeys_enabled) return;
1510
1511 if (window.event) {
1512 keycode = window.event.keyCode;
1513 } else if (e) {
1514 keycode = e.which;
1515 }
1516
1517 if (keycode == 13 || keycode == 27) {
1518 seq = "";
1519 } else {
1520 seq = seq + "" + keycode;
1521 }
1522
1523
1524 if (document.getElementById("piggie")) {
1525
1526 if (seq.match("807371717369")) {
1527 seq = "";
1528 localPiggieFunction(true);
1529 } else {
1530 localPiggieFunction(false);
1531 }
1532 }
1533
1534 } catch (e) {
1535 exception_error("pref_hotkey_handler", e);
1536 }
1537}
1538
1539