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