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