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