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