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