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