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