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