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