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