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