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