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