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