]> git.wh0rd.org - tt-rss.git/blame - prefs.js
sortable filter list
[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
0e317f9d 1086 xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" + param_escape(sort_key), true);
a0d53889
AD
1087 xmlhttp.onreadystatechange=filterlist_callback;
1088 xmlhttp.send(null);
1089
1090}
1091
48f0adb0
AD
1092function updateLabelList() {
1093
1094 if (!xmlhttp_ready(xmlhttp)) {
1095 printLockingError();
1096 return
1097 }
1098
ce3bf408 1099// p_notify("Loading, please wait...");
f5a50b25
AD
1100
1101// document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
48f0adb0
AD
1102
1103 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1104 xmlhttp.onreadystatechange=labellist_callback;
1105 xmlhttp.send(null);
48f0adb0
AD
1106}
1107
4255b24c
AD
1108function updatePrefsList() {
1109
1110 if (!xmlhttp_ready(xmlhttp)) {
1111 printLockingError();
1112 return
1113 }
1114
ce3bf408 1115// p_notify("Loading, please wait...");
4255b24c
AD
1116
1117 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1118 xmlhttp.onreadystatechange=prefslist_callback;
1119 xmlhttp.send(null);
1120
1121}
1122
a7f22b70
AD
1123function selectTab(id, noupdate) {
1124
1125// alert(id);
48f0adb0 1126
b2caf812 1127 if (!id) id = active_tab;
7f74a9da 1128
b2caf812 1129 try {
59a543f0 1130
b2caf812
AD
1131 if (!xmlhttp_ready(xmlhttp)) {
1132 printLockingError();
1133 return
a7f22b70 1134 }
f5a50b25 1135
b2caf812 1136 if (!noupdate) {
f5a50b25 1137
b2caf812
AD
1138 debug("selectTab: " + id + "(NU: " + noupdate + ")");
1139
95322e12 1140// notify("Loading, please wait...", true);
b2caf812
AD
1141
1142 // close active infobox if needed
1143 closeInfoBox();
1144
1145 // clean up all current selections, just in case
1146 active_feed_cat = false;
1147 active_label = false;
1148
1149 if (id == "feedConfig") {
1150 updateFeedList();
1151 } else if (id == "filterConfig") {
1152 updateFilterList();
1153 } else if (id == "labelConfig") {
1154 updateLabelList();
1155 } else if (id == "genConfig") {
1156 updatePrefsList();
1157 } else if (id == "userConfig") {
1158 updateUsersList();
1159 } else if (id == "feedBrowser") {
1160 updateBigFeedBrowser();
1161 }
f5a50b25 1162 }
b2caf812
AD
1163
1164 var tab = document.getElementById(active_tab + "Tab");
1165
1166 if (tab) {
1167 if (tab.className.match("Selected")) {
1168 tab.className = "prefsTab";
1169 }
f5a50b25 1170 }
b2caf812
AD
1171
1172 tab = document.getElementById(id + "Tab");
1173
1174 if (tab) {
1175 if (!tab.className.match("Selected")) {
1176 tab.className = tab.className + "Selected";
1177 }
1178 }
1179
1180 if (active_tab != id) {
1181 storeInitParam("prefs_active_tab", id);
1182 }
1183
1184 active_tab = id;
f5a50b25 1185
b2caf812
AD
1186 } catch (e) {
1187 exception_error("selectTab", e);
a7565293 1188 }
a7565293
AD
1189}
1190
1191function backend_sanity_check_callback() {
f5a50b25 1192
a7565293
AD
1193 if (xmlhttp.readyState == 4) {
1194
1195 try {
1196
1197 if (!xmlhttp.responseXML) {
1198 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText);
1199 return;
1200 }
1201
1202 var reply = xmlhttp.responseXML.firstChild.firstChild;
1203
1204 if (!reply) {
1205 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText);
1206 return;
1207 }
1208
1209 var error_code = reply.getAttribute("error-code");
1210
1211 if (error_code && error_code != 0) {
1212 return fatalError(error_code, reply.getAttribute("error-msg"));
1213 }
1214
1215 debug("sanity check ok");
1216
1217 var params = reply.nextSibling;
1218
1219 if (params) {
1220 debug('reading init-params...');
1221 var param = params.firstChild;
1222
1223 while (param) {
1224 var k = param.getAttribute("key");
1225 var v = param.getAttribute("value");
1226 debug(k + " => " + v);
1227 init_params[k] = v;
1228 param = param.nextSibling;
1229 }
1230 }
1231
1232 init_second_stage();
1233
1234 } catch (e) {
1235 exception_error("backend_sanity_check_callback", e);
1236 }
1237 }
1238}
1239
1240function init_second_stage() {
1241
b2caf812
AD
1242 try {
1243 active_tab = getInitParam("prefs_active_tab");
1244 if (!active_tab) active_tab = "genConfig";
4da47970 1245
d437c8cf
AD
1246 document.onkeydown = pref_hotkey_handler;
1247
b2caf812
AD
1248 if (navigator.userAgent.match("Opera")) {
1249 setTimeout("selectTab()", 500);
1250 } else {
1251 selectTab(active_tab);
1252 }
1253 notify("");
1254 } catch (e) {
1255 exception_error("init_second_stage", e);
1256 }
a0d53889
AD
1257}
1258
007bda35 1259function init() {
e2ec66a8 1260
7719618b
AD
1261 try {
1262
97dcd654
AD
1263 if (arguments.callee.done) return;
1264 arguments.callee.done = true;
1265
a7565293
AD
1266 if (getURLParam('debug')) {
1267 document.getElementById('debug_output').style.display = 'block';
1268 debug('debug mode activated');
1269 }
1270
7719618b
AD
1271 // IE kludge
1272 if (!xmlhttp) {
1273 document.getElementById("prefContent").innerHTML =
1274 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1275 "to function properly. Your browser doesn't seem to support it.";
1276 return;
1277 }
4da47970 1278
a7565293
AD
1279 xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1280 xmlhttp.onreadystatechange=backend_sanity_check_callback;
1281 xmlhttp.send(null);
1282
7719618b
AD
1283 } catch (e) {
1284 exception_error("init", e);
e2ec66a8 1285 }
007bda35 1286}
b1895692 1287
f932bc9f
AD
1288function categorizeSelectedFeeds() {
1289
1290 if (!xmlhttp_ready(xmlhttp)) {
1291 printLockingError();
1292 return
1293 }
1294
1295 var sel_rows = getSelectedFeeds();
1296
1297 var cat_sel = document.getElementById("sfeed_set_fcat");
79f3553b 1298 var cat_id = cat_sel[cat_sel.selectedIndex].value;
f932bc9f
AD
1299
1300 if (sel_rows.length > 0) {
1301
1302 notify("Changing category of selected feeds...");
1303
1304 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1305 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1306 xmlhttp.onreadystatechange=feedlist_callback;
1307 xmlhttp.send(null);
1308
1309 } else {
1310
01b3e191 1311 alert("No feeds are selected.");
f932bc9f
AD
1312
1313 }
1314
1315}
69668465
AD
1316
1317function validatePrefsReset() {
1318 return confirm("Reset to defaults?");
1319}
f9cb39ac 1320
6311acbe 1321function browseFeeds(limit) {
f9cb39ac
AD
1322
1323 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1324 xmlhttp.onreadystatechange=infobox_callback;
1325 xmlhttp.send(null);
1326
1327}
a0476535
AD
1328
1329function feedBrowserSubscribe() {
1330 try {
a0476535 1331
c0ae0fdb 1332 var selected = getSelectedFeedsFromBrowser();
a0476535
AD
1333
1334 if (selected.length > 0) {
1335 closeInfoBox();
1336 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1337 param_escape(selected.toString()), true);
1338 xmlhttp.onreadystatechange=feedlist_callback;
1339 xmlhttp.send(null);
1340 } else {
1341 alert("No feeds are selected.");
1342 }
1343
1344 } catch (e) {
1345 exception_error("feedBrowserSubscribe", e);
1346 }
1347}
c6232e43 1348
6311acbe 1349function updateBigFeedBrowser(limit) {
c6232e43
AD
1350
1351 if (!xmlhttp_ready(xmlhttp)) {
1352 printLockingError();
1353 return
1354 }
1355
ce3bf408 1356// p_notify("Loading, please wait...");
c6232e43 1357
6311acbe
AD
1358 var query = "backend.php?op=pref-feed-browser";
1359
1360 var limit_sel = document.getElementById("feedBrowserLimit");
1361
1362 if (limit_sel) {
1363 var limit = limit_sel[limit_sel.selectedIndex].value;
1364 query = query + "&limit=" + param_escape(limit);
1365 }
1366
1367 xmlhttp.open("GET", query, true);
c6232e43
AD
1368 xmlhttp.onreadystatechange=feed_browser_callback;
1369 xmlhttp.send(null);
c6232e43
AD
1370}
1371
c2b2aee0 1372function browserToggleExpand(id) {
c6232e43
AD
1373 try {
1374/* if (feed_to_expand && feed_to_expand != id) {
1375 var d = document.getElementById("BRDET-" + feed_to_expand);
1376 d.style.display = "none";
1377 } */
c2b2aee0 1378
ff725e9b
AD
1379 if (!xmlhttp_ready(xmlhttp)) {
1380 printLockingError();
1381 return
1382 }
1383
c2b2aee0
AD
1384 var d = document.getElementById("BRDET-" + id);
1385
1386 if (d.style.display == "block") {
1387 d.style.display = "none";
1388
1389 } else {
c6232e43 1390
c2b2aee0 1391 feed_to_expand = id;
c6232e43 1392
ff725e9b
AD
1393 d.style.display = "block";
1394 d.innerHTML = "Loading, please wait...";
1395
c2b2aee0
AD
1396 xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1397 + param_escape(id), true);
1398 xmlhttp.onreadystatechange=expand_feed_callback;
1399 xmlhttp.send(null);
1400 }
c6232e43
AD
1401
1402 } catch (e) {
1403 exception_error("browserExpand", e);
1404 }
1405}
64dc5976
AD
1406
1407function validateNewPassword(form) {
1408 if (form.OLD_PASSWORD.value == "") {
88103301 1409 alert("Old password cannot be blank");
64dc5976
AD
1410 return false;
1411 }
1412 if (form.NEW_PASSWORD.value == "") {
1413 alert("New password cannot be blank");
1414 return false;
1415 }
1416 return true;
1417}
ce3bf408
AD
1418
1419function selectPrefRows(kind, select) {
1420
1421 if (kind) {
1422 var opbarid = false;
1423 var nchk = false;
1424 var nrow = false;
1425 var lname = false;
1426
1427 if (kind == "feed") {
1428 opbarid = "feedOpToolbar";
1429 nrow = "FEEDR-";
1430 nchk = "FRCHK-";
1431 lname = "prefFeedList";
1432 } else if (kind == "fcat") {
1433 opbarid = "catOpToolbar";
1434 nrow = "FCATR-";
1435 nchk = "FCHK-";
1436 lname = "prefFeedCatList";
1437 } else if (kind == "filter") {
1438 opbarid = "filterOpToolbar";
1439 nrow = "FILRR-";
1440 nchk = "FICHK-";
1441 lname = "prefFilterList";
1442 } else if (kind == "label") {
1443 opbarid = "labelOpToolbar";
1444 nrow = "LILRR-";
a4dbc524 1445 nchk = "LICHK-";
ce3bf408
AD
1446 lname = "prefLabelList";
1447 } else if (kind == "user") {
1448 opbarid = "userOpToolbar";
1449 nrow = "UMRR-";
1450 nchk = "UMCHK-";
1451 lname = "prefUserList";
1452 }
1453
1454 if (opbarid) {
1455 selectTableRowsByIdPrefix(lname, nrow, nchk, select);
1456 disableContainerChildren(opbarid, !select);
1457 }
1458
1459 }
1460}
1461
1462
1463function toggleSelectPrefRow(sender, kind) {
1464
1465 toggleSelectRow(sender);
1466
1467 if (kind) {
1468 var opbarid = false;
1469 var nsel = -1;
1470
1471 if (kind == "feed") {
1472 opbarid = "feedOpToolbar";
1473 nsel = getSelectedFeeds();
1474 } else if (kind == "fcat") {
1475 opbarid = "catOpToolbar";
1476 nsel = getSelectedFeedCats();
1477 } else if (kind == "filter") {
1478 opbarid = "filterOpToolbar";
1479 nsel = getSelectedFilters();
1480 } else if (kind == "label") {
1481 opbarid = "labelOpToolbar";
1482 nsel = getSelectedLabels();
1483 } else if (kind == "user") {
1484 opbarid = "userOpToolbar";
1485 nsel = getSelectedUsers();
1486 }
1487
1488 if (opbarid && nsel != -1) {
1489 disableContainerChildren(opbarid, nsel == false);
1490 }
1491
1492 }
1493}
1494
c0ae0fdb
AD
1495function toggleSelectFBListRow(sender) {
1496 toggleSelectListRow(sender);
1497 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1498}
d437c8cf
AD
1499
1500var seq = "";
1501
1502function pref_hotkey_handler(e) {
1503 try {
1504
1505 var keycode;
1506
1507 if (!hotkeys_enabled) return;
1508
1509 if (window.event) {
1510 keycode = window.event.keyCode;
1511 } else if (e) {
1512 keycode = e.which;
1513 }
1514
1515 if (keycode == 13 || keycode == 27) {
1516 seq = "";
1517 } else {
1518 seq = seq + "" + keycode;
1519 }
1520
1521
1522 if (document.getElementById("piggie")) {
1523
1524 if (seq.match("807371717369")) {
1525 seq = "";
1526 localPiggieFunction(true);
1527 } else {
1528 localPiggieFunction(false);
1529 }
1530 }
1531
1532 } catch (e) {
1533 exception_error("pref_hotkey_handler", e);
1534 }
1535}
1536
1537