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