]> git.wh0rd.org - tt-rss.git/blob - prefs.js
fix empty num_comments handling
[tt-rss.git] / prefs.js
1 var xmlhttp = false;
2
3 var active_feed = false;
4 var active_feed_cat = false;
5 var active_filter = false;
6 var active_label = false;
7 var active_user = false;
8
9 var active_tab = false;
10
11 /*@cc_on @*/
12 /*@if (@_jscript_version >= 5)
13 // JScript gives us Conditional compilation, we can cope with old IE versions.
14 // and security blocked creation of the objects.
15 try {
16 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
17 } catch (e) {
18 try {
19 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
20 } catch (E) {
21 xmlhttp = false;
22 }
23 }
24 @end @*/
25
26 if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
27 xmlhttp = new XMLHttpRequest();
28 }
29
30 function feedlist_callback() {
31 if (xmlhttp.readyState == 4) {
32 var container = document.getElementById('prefContent');
33 container.innerHTML=xmlhttp.responseText;
34 if (active_feed) {
35 var row = document.getElementById("FEEDR-" + active_feed);
36 if (row) {
37 if (!row.className.match("Selected")) {
38 row.className = row.className + "Selected";
39 }
40 }
41 var checkbox = document.getElementById("FRCHK-" + active_feed);
42 if (checkbox) {
43 checkbox.checked = true;
44 }
45 }
46 p_notify("");
47 }
48 }
49
50 function filterlist_callback() {
51 var container = document.getElementById('prefContent');
52 if (xmlhttp.readyState == 4) {
53
54 container.innerHTML=xmlhttp.responseText;
55
56 if (active_filter) {
57 var row = document.getElementById("FILRR-" + active_filter);
58 if (row) {
59 if (!row.className.match("Selected")) {
60 row.className = row.className + "Selected";
61 }
62 }
63 var checkbox = document.getElementById("FICHK-" + active_filter);
64
65 if (checkbox) {
66 checkbox.checked = true;
67 }
68 }
69 p_notify("");
70 }
71 }
72
73 function labellist_callback() {
74 var container = document.getElementById('prefContent');
75 if (xmlhttp.readyState == 4) {
76 container.innerHTML=xmlhttp.responseText;
77
78 if (active_label) {
79 var row = document.getElementById("LILRR-" + active_label);
80 if (row) {
81 if (!row.className.match("Selected")) {
82 row.className = row.className + "Selected";
83 }
84 }
85 var checkbox = document.getElementById("LICHK-" + active_label);
86
87 if (checkbox) {
88 checkbox.checked = true;
89 }
90 }
91 p_notify("");
92 }
93 }
94
95 function userlist_callback() {
96 var container = document.getElementById('prefContent');
97 if (xmlhttp.readyState == 4) {
98 container.innerHTML=xmlhttp.responseText;
99
100 if (active_user) {
101 var row = document.getElementById("UMRR-" + active_user);
102 if (row) {
103 if (!row.className.match("Selected")) {
104 row.className = row.className + "Selected";
105 }
106 }
107 var checkbox = document.getElementById("UMCHK-" + active_user);
108
109 if (checkbox) {
110 checkbox.checked = true;
111 }
112 }
113
114 p_notify("");
115 }
116 }
117
118 function infobox_callback() {
119 if (xmlhttp.readyState == 4) {
120 var box = document.getElementById('infoBox');
121 var shadow = document.getElementById('infoBoxShadow');
122
123 if (box) {
124 box.innerHTML=xmlhttp.responseText;
125 if (shadow) {
126 shadow.style.display = "block";
127 } else {
128 box.style.display = "block";
129 }
130 }
131 }
132 }
133
134
135 function prefslist_callback() {
136 var container = document.getElementById('prefContent');
137 if (xmlhttp.readyState == 4) {
138
139 container.innerHTML=xmlhttp.responseText;
140
141 p_notify("");
142 }
143 }
144
145 function gethelp_callback() {
146 var container = document.getElementById('prefHelpBox');
147 if (xmlhttp.readyState == 4) {
148
149 container.innerHTML = xmlhttp.responseText;
150 container.style.display = "block";
151
152 }
153 }
154
155
156 function notify_callback() {
157 var container = document.getElementById('notify');
158 if (xmlhttp.readyState == 4) {
159 container.innerHTML=xmlhttp.responseText;
160 }
161 }
162
163 function updateFeedList(sort_key) {
164
165 if (!xmlhttp_ready(xmlhttp)) {
166 printLockingError();
167 return
168 }
169
170 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
171
172 p_notify("Loading, please wait...");
173
174 var feed_search = document.getElementById("feed_search");
175 var search = "";
176 if (feed_search) { search = feed_search.value; }
177
178 xmlhttp.open("GET", "backend.php?op=pref-feeds" +
179 "&sort=" + param_escape(sort_key) +
180 "&search=" + param_escape(search), true);
181 xmlhttp.onreadystatechange=feedlist_callback;
182 xmlhttp.send(null);
183
184 }
185
186 function updateUsersList() {
187
188 if (!xmlhttp_ready(xmlhttp)) {
189 printLockingError();
190 return
191 }
192
193 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
194
195 p_notify("Loading, please wait...");
196
197 xmlhttp.open("GET", "backend.php?op=pref-users", true);
198 xmlhttp.onreadystatechange=userlist_callback;
199 xmlhttp.send(null);
200
201 }
202
203 function addLabel() {
204
205 if (!xmlhttp_ready(xmlhttp)) {
206 printLockingError();
207 return
208 }
209
210 var sqlexp = document.getElementById("ladd_expr");
211
212 if (sqlexp.value.length == 0) {
213 notify("Missing SQL expression.");
214 } else {
215 notify("Adding label...");
216
217 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
218 param_escape(sqlexp.value), true);
219
220 xmlhttp.onreadystatechange=labellist_callback;
221 xmlhttp.send(null);
222
223 sqlexp.value = "";
224 }
225
226 }
227
228 function addFilter() {
229
230 if (!xmlhttp_ready(xmlhttp)) {
231 printLockingError();
232 return
233 }
234
235 var regexp = document.getElementById("fadd_regexp");
236 var match = document.getElementById("fadd_match");
237 var feed = document.getElementById("fadd_feed");
238 var action = document.getElementById("fadd_action");
239
240 if (regexp.value.length == 0) {
241 notify("Missing filter expression.");
242 } else {
243 notify("Adding filter...");
244
245 var v_match = match[match.selectedIndex].text;
246 var feed_id = feed[feed.selectedIndex].id;
247 var action_id = action[action.selectedIndex].id;
248
249 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add&regexp=" +
250 param_escape(regexp.value) + "&match=" + v_match +
251 "&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
252
253 xmlhttp.onreadystatechange=filterlist_callback;
254 xmlhttp.send(null);
255
256 regexp.value = "";
257 }
258
259 }
260
261 function addFeed() {
262
263 if (!xmlhttp_ready(xmlhttp)) {
264 printLockingError();
265 return
266 }
267
268 var link = document.getElementById("fadd_link");
269
270 if (link.value.length == 0) {
271 notify("Missing feed URL.");
272 } else {
273 notify("Adding feed...");
274
275 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
276 param_escape(link.value), true);
277 xmlhttp.onreadystatechange=feedlist_callback;
278 xmlhttp.send(null);
279
280 link.value = "";
281
282 }
283
284 }
285
286 function addFeedCat() {
287
288 if (!xmlhttp_ready(xmlhttp)) {
289 printLockingError();
290 return
291 }
292
293 var cat = document.getElementById("fadd_cat");
294
295 if (cat.value.length == 0) {
296 notify("Missing feed category.");
297 } else {
298 notify("Adding feed category...");
299
300 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
301 param_escape(cat.value), true);
302 xmlhttp.onreadystatechange=feedlist_callback;
303 xmlhttp.send(null);
304
305 link.value = "";
306
307 }
308
309 }
310 function addUser() {
311
312 if (!xmlhttp_ready(xmlhttp)) {
313 printLockingError();
314 return
315 }
316
317 var sqlexp = document.getElementById("uadd_box");
318
319 if (sqlexp.value.length == 0) {
320 notify("Missing user login.");
321 } else {
322 notify("Adding user...");
323
324 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
325 param_escape(sqlexp.value), true);
326
327 xmlhttp.onreadystatechange=userlist_callback;
328 xmlhttp.send(null);
329
330 sqlexp.value = "";
331 }
332
333 }
334
335 function editLabel(id) {
336
337 if (!xmlhttp_ready(xmlhttp)) {
338 printLockingError();
339 return
340 }
341
342 active_label = id;
343
344 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
345 param_escape(id), true);
346 xmlhttp.onreadystatechange=labellist_callback;
347 xmlhttp.send(null);
348
349 }
350
351 function editUser(id) {
352
353 if (!xmlhttp_ready(xmlhttp)) {
354 printLockingError();
355 return
356 }
357
358 active_user = id;
359
360 xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
361 param_escape(id), true);
362 xmlhttp.onreadystatechange=userlist_callback;
363 xmlhttp.send(null);
364
365 }
366
367 function editFilter(id) {
368
369 if (!xmlhttp_ready(xmlhttp)) {
370 printLockingError();
371 return
372 }
373
374 active_filter = id;
375
376 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
377 param_escape(id), true);
378 xmlhttp.onreadystatechange=filterlist_callback;
379 xmlhttp.send(null);
380
381 }
382
383 function editFeed(feed) {
384
385 // notify("Editing feed...");
386
387 if (!xmlhttp_ready(xmlhttp)) {
388 printLockingError();
389 return
390 }
391
392 active_feed = feed;
393
394 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
395 param_escape(feed), true);
396 xmlhttp.onreadystatechange=feedlist_callback;
397 xmlhttp.send(null);
398
399 }
400
401 function editFeedCat(cat) {
402
403 if (!xmlhttp_ready(xmlhttp)) {
404 printLockingError();
405 return
406 }
407
408 active_feed_cat = cat;
409
410 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
411 param_escape(cat), true);
412 xmlhttp.onreadystatechange=feedlist_callback;
413 xmlhttp.send(null);
414
415 }
416
417 function getSelectedLabels() {
418 return getSelectedTableRowIds("prefLabelList", "LILRR");
419 }
420
421 function getSelectedUsers() {
422 return getSelectedTableRowIds("prefUserList", "UMRR");
423 }
424
425 function getSelectedFeeds() {
426 return getSelectedTableRowIds("prefFeedList", "FEEDR");
427 }
428
429 function getSelectedFilters() {
430 return getSelectedTableRowIds("prefFilterList", "FILRR");
431 }
432
433 function getSelectedFeedCats() {
434 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
435 }
436
437
438 function readSelectedFeeds(read) {
439
440 if (!xmlhttp_ready(xmlhttp)) {
441 printLockingError();
442 return
443 }
444
445 var sel_rows = getSelectedFeeds();
446
447 if (sel_rows.length > 0) {
448
449 if (!read) {
450 op = "unread";
451 } else {
452 op = "read";
453 }
454
455 notify("Marking selected feeds as " + op + "...");
456
457 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=" + op + "&ids="+
458 param_escape(sel_rows.toString()), true);
459 xmlhttp.onreadystatechange=notify_callback;
460 xmlhttp.send(null);
461
462 } else {
463
464 notify("Please select some feeds first.");
465
466 }
467 }
468
469 function removeSelectedLabels() {
470
471 if (!xmlhttp_ready(xmlhttp)) {
472 printLockingError();
473 return
474 }
475
476 var sel_rows = getSelectedLabels();
477
478 if (sel_rows.length > 0) {
479
480 notify("Removing selected labels...");
481
482 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
483 param_escape(sel_rows.toString()), true);
484 xmlhttp.onreadystatechange=labellist_callback;
485 xmlhttp.send(null);
486
487 } else {
488 notify("Please select some labels first.");
489 }
490 }
491
492 function removeSelectedUsers() {
493
494 if (!xmlhttp_ready(xmlhttp)) {
495 printLockingError();
496 return
497 }
498
499 var sel_rows = getSelectedUsers();
500
501 if (sel_rows.length > 0) {
502
503 notify("Removing selected users...");
504
505 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
506 param_escape(sel_rows.toString()), true);
507 xmlhttp.onreadystatechange=userlist_callback;
508 xmlhttp.send(null);
509
510 } else {
511 notify("Please select some labels first.");
512 }
513 }
514
515 function removeSelectedFilters() {
516
517 if (!xmlhttp_ready(xmlhttp)) {
518 printLockingError();
519 return
520 }
521
522 var sel_rows = getSelectedFilters();
523
524 if (sel_rows.length > 0) {
525
526 notify("Removing selected filters...");
527
528 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
529 param_escape(sel_rows.toString()), true);
530 xmlhttp.onreadystatechange=filterlist_callback;
531 xmlhttp.send(null);
532
533 } else {
534 notify("Please select some filters first.");
535 }
536 }
537
538
539 function removeSelectedFeeds() {
540
541 if (!xmlhttp_ready(xmlhttp)) {
542 printLockingError();
543 return
544 }
545
546 var sel_rows = getSelectedFeeds();
547
548 if (sel_rows.length > 0) {
549
550 notify("Removing selected feeds...");
551
552 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
553 param_escape(sel_rows.toString()), true);
554 xmlhttp.onreadystatechange=feedlist_callback;
555 xmlhttp.send(null);
556
557 } else {
558
559 notify("Please select some feeds first.");
560
561 }
562
563 }
564
565 function removeSelectedFeedCats() {
566
567 if (!xmlhttp_ready(xmlhttp)) {
568 printLockingError();
569 return
570 }
571
572 var sel_rows = getSelectedFeedCats();
573
574 if (sel_rows.length > 0) {
575
576 notify("Removing selected categories...");
577
578 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
579 param_escape(sel_rows.toString()), true);
580 xmlhttp.onreadystatechange=feedlist_callback;
581 xmlhttp.send(null);
582
583 } else {
584
585 notify("Please select some feeds first.");
586
587 }
588
589 }
590
591 function feedEditCancel() {
592
593 if (!xmlhttp_ready(xmlhttp)) {
594 printLockingError();
595 return
596 }
597
598 active_feed = false;
599
600 notify("Operation cancelled.");
601
602 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
603 xmlhttp.onreadystatechange=feedlist_callback;
604 xmlhttp.send(null);
605
606 }
607
608 function feedCatEditCancel() {
609
610 if (!xmlhttp_ready(xmlhttp)) {
611 printLockingError();
612 return
613 }
614
615 active_feed_cat = false;
616
617 notify("Operation cancelled.");
618
619 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
620 xmlhttp.onreadystatechange=feedlist_callback;
621 xmlhttp.send(null);
622
623 }
624
625 function feedEditSave() {
626
627 var feed = active_feed;
628
629 if (!xmlhttp_ready(xmlhttp)) {
630 printLockingError();
631 return
632 }
633
634 var link = document.getElementById("iedit_link").value;
635 var title = document.getElementById("iedit_title").value;
636 var upd_intl = document.getElementById("iedit_updintl").value;
637 var purge_intl = document.getElementById("iedit_purgintl").value;
638 var fcat = document.getElementById("iedit_fcat");
639
640 var fcat_id = fcat[fcat.selectedIndex].id;
641
642 // notify("Saving feed.");
643
644 /* if (upd_intl < 0) {
645 notify("Update interval must be &gt;= 0 (0 = default)");
646 return;
647 }
648
649 if (purge_intl < 0) {
650 notify("Purge days must be &gt;= 0 (0 = default)");
651 return;
652 } */
653
654 if (link.length == 0) {
655 notify("Feed link cannot be blank.");
656 return;
657 }
658
659 if (title.length == 0) {
660 notify("Feed title cannot be blank.");
661 return;
662 }
663
664 active_feed = false;
665
666 notify("");
667
668 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
669 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
670 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
671 "&catid=" + param_escape(fcat_id), true);
672 xmlhttp.onreadystatechange=feedlist_callback;
673 xmlhttp.send(null);
674
675 }
676
677 function labelTest() {
678
679 var sqlexp = document.getElementById("iedit_expr").value;
680 var descr = document.getElementById("iedit_descr").value;
681
682 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
683 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
684
685 xmlhttp.onreadystatechange=infobox_callback;
686 xmlhttp.send(null);
687
688 }
689
690 function displayHelpInfobox(topic_id) {
691
692 xmlhttp.open("GET", "backend.php?op=help&tid=" +
693 param_escape(topic_id) + "&noheaders=1", true);
694
695 xmlhttp.onreadystatechange=infobox_callback;
696 xmlhttp.send(null);
697
698 }
699
700 function labelEditCancel() {
701
702 if (!xmlhttp_ready(xmlhttp)) {
703 printLockingError();
704 return
705 }
706
707 active_label = false;
708
709 notify("Operation cancelled.");
710
711 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
712 xmlhttp.onreadystatechange=labellist_callback;
713 xmlhttp.send(null);
714
715 }
716
717 function userEditCancel() {
718
719 if (!xmlhttp_ready(xmlhttp)) {
720 printLockingError();
721 return
722 }
723
724 active_user = false;
725
726 notify("Operation cancelled.");
727
728 xmlhttp.open("GET", "backend.php?op=pref-users", true);
729 xmlhttp.onreadystatechange=userlist_callback;
730 xmlhttp.send(null);
731
732 }
733
734 function filterEditCancel() {
735
736 if (!xmlhttp_ready(xmlhttp)) {
737 printLockingError();
738 return
739 }
740
741 active_filter = false;
742
743 notify("Operation cancelled.");
744
745 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
746 xmlhttp.onreadystatechange=filterlist_callback;
747 xmlhttp.send(null);
748
749 }
750
751 function labelEditSave() {
752
753 var label = active_label;
754
755 if (!xmlhttp_ready(xmlhttp)) {
756 printLockingError();
757 return
758 }
759
760 var sqlexp = document.getElementById("iedit_expr").value;
761 var descr = document.getElementById("iedit_descr").value;
762
763 // notify("Saving label " + sqlexp + ": " + descr);
764
765 if (sqlexp.length == 0) {
766 notify("SQL expression cannot be blank.");
767 return;
768 }
769
770 if (descr.length == 0) {
771 notify("Caption cannot be blank.");
772 return;
773 }
774
775 notify("");
776
777 active_label = false;
778
779 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
780 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
781 true);
782
783 xmlhttp.onreadystatechange=labellist_callback;
784 xmlhttp.send(null);
785
786 }
787
788 function userEditSave() {
789
790 var user = active_user;
791
792 if (!xmlhttp_ready(xmlhttp)) {
793 printLockingError();
794 return
795 }
796
797 var login = document.getElementById("iedit_ulogin").value;
798 var level = document.getElementById("iedit_ulevel").value;
799
800 if (login.length == 0) {
801 notify("Login cannot be blank.");
802 return;
803 }
804
805 if (level.length == 0) {
806 notify("User level cannot be blank.");
807 return;
808 }
809
810 active_user = false;
811
812 notify("");
813
814 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
815 user + "&l=" + param_escape(login) + "&al=" + param_escape(level),
816 true);
817
818 xmlhttp.onreadystatechange=userlist_callback;
819 xmlhttp.send(null);
820
821 }
822
823
824 function filterEditSave() {
825
826 var filter = active_filter;
827
828 if (!xmlhttp_ready(xmlhttp)) {
829 printLockingError();
830 return
831 }
832
833 var regexp = document.getElementById("iedit_regexp").value;
834 var descr = document.getElementById("iedit_descr").value;
835 var match = document.getElementById("iedit_match");
836
837 var v_match = match[match.selectedIndex].text;
838
839 var feed = document.getElementById("iedit_feed");
840 var feed_id = feed[feed.selectedIndex].id;
841
842 var action = document.getElementById("iedit_filter_action");
843 var action_id = action[action.selectedIndex].id;
844
845 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
846
847 if (regexp.length == 0) {
848 notify("Filter expression cannot be blank.");
849 return;
850 }
851
852 active_filter = false;
853
854 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
855 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
856 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id) +
857 "&aid=" + param_escape(action_id), true);
858
859 notify("");
860
861 xmlhttp.onreadystatechange=filterlist_callback;
862 xmlhttp.send(null);
863
864 }
865
866 function editSelectedLabel() {
867 var rows = getSelectedLabels();
868
869 if (rows.length == 0) {
870 notify("No labels are selected.");
871 return;
872 }
873
874 if (rows.length > 1) {
875 notify("Please select one label.");
876 return;
877 }
878
879 notify("");
880
881 editLabel(rows[0]);
882
883 }
884
885 function editSelectedUser() {
886 var rows = getSelectedUsers();
887
888 if (rows.length == 0) {
889 notify("No users are selected.");
890 return;
891 }
892
893 if (rows.length > 1) {
894 notify("Please select one user.");
895 return;
896 }
897
898 notify("");
899
900 editUser(rows[0]);
901 }
902
903 function resetSelectedUserPass() {
904 var rows = getSelectedUsers();
905
906 if (rows.length == 0) {
907 notify("No users are selected.");
908 return;
909 }
910
911 if (rows.length > 1) {
912 notify("Please select one user.");
913 return;
914 }
915
916 notify("Resetting password for selected user...");
917
918 var id = rows[0];
919
920 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
921 param_escape(id), true);
922 xmlhttp.onreadystatechange=userlist_callback;
923 xmlhttp.send(null);
924
925 }
926
927 function selectedUserDetails() {
928
929 if (!xmlhttp_ready(xmlhttp)) {
930 printLockingError();
931 return
932 }
933
934 var rows = getSelectedUsers();
935
936 if (rows.length == 0) {
937 notify("No users are selected.");
938 return;
939 }
940
941 if (rows.length > 1) {
942 notify("Please select one user.");
943 return;
944 }
945
946 var id = rows[0];
947
948 notify("");
949
950 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
951 xmlhttp.onreadystatechange=infobox_callback;
952 xmlhttp.send(null);
953
954 }
955
956 function selectedFeedDetails() {
957
958 if (!xmlhttp_ready(xmlhttp)) {
959 printLockingError();
960 return
961 }
962
963 var rows = getSelectedFeeds();
964
965 if (rows.length == 0) {
966 notify("No feeds are selected.");
967 return;
968 }
969
970 if (rows.length > 1) {
971 notify("Please select one feed.");
972 return;
973 }
974
975 var id = rows[0];
976
977 notify("");
978
979 xmlhttp.open("GET", "backend.php?op=feed-details&id=" + id, true);
980 xmlhttp.onreadystatechange=infobox_callback;
981 xmlhttp.send(null);
982
983 }
984
985 function editSelectedFilter() {
986 var rows = getSelectedFilters();
987
988 if (rows.length == 0) {
989 notify("No filters are selected.");
990 return;
991 }
992
993 if (rows.length > 1) {
994 notify("Please select one filter.");
995 return;
996 }
997
998 notify("");
999
1000 editFilter(rows[0]);
1001
1002 }
1003
1004
1005 function editSelectedFeed() {
1006 var rows = getSelectedFeeds();
1007
1008 if (rows.length == 0) {
1009 notify("No feeds are selected.");
1010 return;
1011 }
1012
1013 if (rows.length > 1) {
1014 notify("Please select one feed.");
1015 return;
1016 }
1017
1018 notify("");
1019
1020 editFeed(rows[0]);
1021
1022 }
1023
1024 function editSelectedFeedCat() {
1025 var rows = getSelectedFeedCats();
1026
1027 if (rows.length == 0) {
1028 notify("No categories are selected.");
1029 return;
1030 }
1031
1032 if (rows.length > 1) {
1033 notify("Please select one category.");
1034 return;
1035 }
1036
1037 notify("");
1038
1039 editFeedCat(rows[0]);
1040
1041 }
1042
1043 function localPiggieFunction(enable) {
1044 if (enable) {
1045 piggie.style.display = "block";
1046 seq = "";
1047 notify("I loveded it!!!");
1048 } else {
1049 piggie.style.display = "none";
1050 notify("");
1051 }
1052 }
1053
1054 function validateOpmlImport() {
1055
1056 var opml_file = document.getElementById("opml_file");
1057
1058 if (opml_file.value.length == 0) {
1059 notify("Please select OPML file to upload.");
1060 return false;
1061 } else {
1062 return true;
1063 }
1064 }
1065
1066 function updateFilterList() {
1067
1068 if (!xmlhttp_ready(xmlhttp)) {
1069 printLockingError();
1070 return
1071 }
1072
1073 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1074
1075 p_notify("Loading, please wait...");
1076
1077 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1078 xmlhttp.onreadystatechange=filterlist_callback;
1079 xmlhttp.send(null);
1080
1081 }
1082
1083 function updateLabelList() {
1084
1085 if (!xmlhttp_ready(xmlhttp)) {
1086 printLockingError();
1087 return
1088 }
1089
1090 p_notify("Loading, please wait...");
1091
1092 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1093
1094 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1095 xmlhttp.onreadystatechange=labellist_callback;
1096 xmlhttp.send(null);
1097 }
1098
1099 function updatePrefsList() {
1100
1101 if (!xmlhttp_ready(xmlhttp)) {
1102 printLockingError();
1103 return
1104 }
1105
1106 p_notify("Loading, please wait...");
1107
1108 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1109 xmlhttp.onreadystatechange=prefslist_callback;
1110 xmlhttp.send(null);
1111
1112 }
1113
1114 function selectTab(id) {
1115
1116 if (!xmlhttp_ready(xmlhttp)) {
1117 printLockingError();
1118 return
1119 }
1120
1121 if (id == "feedConfig") {
1122 updateFeedList();
1123 } else if (id == "filterConfig") {
1124 updateFilterList();
1125 } else if (id == "labelConfig") {
1126 updateLabelList();
1127 } else if (id == "genConfig") {
1128 updatePrefsList();
1129 } else if (id == "userConfig") {
1130 updateUsersList();
1131 }
1132
1133 var tab = document.getElementById(active_tab + "Tab");
1134
1135 if (tab) {
1136 if (tab.className.match("Selected")) {
1137 tab.className = "prefsTab";
1138 }
1139 }
1140
1141 tab = document.getElementById(id + "Tab");
1142
1143 if (tab) {
1144 if (!tab.className.match("Selected")) {
1145 tab.className = tab.className + "Selected";
1146 }
1147 }
1148
1149 active_tab = id;
1150
1151 }
1152
1153 function init() {
1154
1155 try {
1156
1157 // IE kludge
1158 if (!xmlhttp) {
1159 document.getElementById("prefContent").innerHTML =
1160 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1161 "to function properly. Your browser doesn't seem to support it.";
1162 return;
1163 }
1164
1165 selectTab("genConfig");
1166
1167 document.onkeydown = hotkey_handler;
1168 notify("");
1169 } catch (e) {
1170 exception_error("init", e);
1171 }
1172 }
1173
1174 function closeInfoBox() {
1175 var box = document.getElementById('infoBox');
1176 var shadow = document.getElementById('infoBoxShadow');
1177
1178 if (shadow) {
1179 shadow.style.display = "none";
1180 } else if (box) {
1181 box.style.display = "none";
1182 }
1183 }
1184
1185 function categorizeSelectedFeeds() {
1186
1187 if (!xmlhttp_ready(xmlhttp)) {
1188 printLockingError();
1189 return
1190 }
1191
1192 var sel_rows = getSelectedFeeds();
1193
1194 var cat_sel = document.getElementById("sfeed_set_fcat");
1195 var cat_id = cat_sel[cat_sel.selectedIndex].id;
1196
1197 if (sel_rows.length > 0) {
1198
1199 notify("Changing category of selected feeds...");
1200
1201 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1202 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1203 xmlhttp.onreadystatechange=feedlist_callback;
1204 xmlhttp.send(null);
1205
1206 } else {
1207
1208 notify("Please select some feeds first.");
1209
1210 }
1211
1212 }