]> git.wh0rd.org Git - tt-rss.git/blob - prefs.js
category support for OPML export (fix again)
[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 function updateFeedList(sort_key) {
169
170         if (!xmlhttp_ready(xmlhttp)) {
171                 printLockingError();
172                 return
173         }
174
175 //      document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
176
177         p_notify("Loading, please wait...");
178
179         xmlhttp.open("GET", "backend.php?op=pref-feeds" +
180                 "&sort=" + param_escape(sort_key), 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 labelTest() {
710
711         var sqlexp = document.getElementById("iedit_expr").value;
712         var descr = document.getElementById("iedit_descr").value;
713
714         xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
715                 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
716
717         xmlhttp.onreadystatechange=infobox_callback;
718         xmlhttp.send(null);
719
720 }
721
722 function labelEditCancel() {
723
724         if (!xmlhttp_ready(xmlhttp)) {
725                 printLockingError();
726                 return
727         }
728
729         active_label = false;
730
731         notify("Operation cancelled.");
732
733         xmlhttp.open("GET", "backend.php?op=pref-labels", true);
734         xmlhttp.onreadystatechange=labellist_callback;
735         xmlhttp.send(null);
736
737 }
738
739 function userEditCancel() {
740
741         if (!xmlhttp_ready(xmlhttp)) {
742                 printLockingError();
743                 return
744         }
745
746         active_user = false;
747
748         notify("Operation cancelled.");
749
750         xmlhttp.open("GET", "backend.php?op=pref-users", true);
751         xmlhttp.onreadystatechange=userlist_callback;
752         xmlhttp.send(null);
753
754 }
755
756 function filterEditCancel() {
757
758         if (!xmlhttp_ready(xmlhttp)) {
759                 printLockingError();
760                 return
761         }
762
763         active_filter = false;
764
765         notify("Operation cancelled.");
766
767         xmlhttp.open("GET", "backend.php?op=pref-filters", true);
768         xmlhttp.onreadystatechange=filterlist_callback;
769         xmlhttp.send(null);
770
771 }
772
773 function labelEditSave() {
774
775         var label = active_label;
776
777         if (!xmlhttp_ready(xmlhttp)) {
778                 printLockingError();
779                 return
780         }
781
782         var sqlexp = document.getElementById("iedit_expr").value;
783         var descr = document.getElementById("iedit_descr").value;
784
785 //      notify("Saving label " + sqlexp + ": " + descr);
786
787         if (sqlexp.length == 0) {
788                 notify("SQL expression cannot be blank.");
789                 return;
790         }
791
792         if (descr.length == 0) {
793                 notify("Caption cannot be blank.");
794                 return;
795         }
796
797         notify("");
798
799         active_label = false;
800
801         xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
802                 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
803                 true);
804                 
805         xmlhttp.onreadystatechange=labellist_callback;
806         xmlhttp.send(null);
807
808 }
809
810 function userEditSave() {
811
812         var user = active_user;
813
814         if (!xmlhttp_ready(xmlhttp)) {
815                 printLockingError();
816                 return
817         }
818
819         var login = document.getElementById("iedit_ulogin").value;
820         var level = document.getElementById("iedit_ulevel").value;
821
822         if (login.length == 0) {
823                 notify("Login cannot be blank.");
824                 return;
825         }
826
827         if (level.length == 0) {
828                 notify("User level cannot be blank.");
829                 return;
830         }
831
832         active_user = false;
833
834         notify("");
835
836         xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
837                 user + "&l=" + param_escape(login) + "&al=" + param_escape(level),
838                 true);
839                 
840         xmlhttp.onreadystatechange=userlist_callback;
841         xmlhttp.send(null);
842
843 }
844
845
846 function filterEditSave() {
847
848         var filter = active_filter;
849
850         if (!xmlhttp_ready(xmlhttp)) {
851                 printLockingError();
852                 return
853         }
854
855         var regexp = document.getElementById("iedit_regexp").value;
856         var descr = document.getElementById("iedit_descr").value;
857         var match = document.getElementById("iedit_match");
858         
859         var v_match = match[match.selectedIndex].text;
860
861         var feed = document.getElementById("iedit_feed");
862         var feed_id = feed[feed.selectedIndex].id;
863
864 //      notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
865
866         if (regexp.length == 0) {
867                 notify("Filter expression cannot be blank.");
868                 return;
869         }
870
871         active_filter = false;
872
873         xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
874                 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
875                 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id), true);
876
877         notify("");
878
879         xmlhttp.onreadystatechange=filterlist_callback;
880         xmlhttp.send(null); 
881
882 }
883
884 function editSelectedLabel() {
885         var rows = getSelectedLabels();
886
887         if (rows.length == 0) {
888                 notify("No labels are selected.");
889                 return;
890         }
891
892         if (rows.length > 1) {
893                 notify("Please select one label.");
894                 return;
895         }
896
897         notify("");
898
899         editLabel(rows[0]);
900
901 }
902
903 function editSelectedUser() {
904         var rows = getSelectedUsers();
905
906         if (rows.length == 0) {
907                 notify("No users are selected.");
908                 return;
909         }
910
911         if (rows.length > 1) {
912                 notify("Please select one user.");
913                 return;
914         }
915
916         notify("");
917
918         editUser(rows[0]);
919 }
920
921 function resetSelectedUserPass() {
922         var rows = getSelectedUsers();
923
924         if (rows.length == 0) {
925                 notify("No users are selected.");
926                 return;
927         }
928
929         if (rows.length > 1) {
930                 notify("Please select one user.");
931                 return;
932         }
933
934         notify("Resetting password for selected user...");
935
936         var id = rows[0];
937
938         xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
939                 param_escape(id), true);
940         xmlhttp.onreadystatechange=userlist_callback;
941         xmlhttp.send(null);
942
943 }
944
945 function selectedUserDetails() {
946
947         if (!xmlhttp_ready(xmlhttp)) {
948                 printLockingError();
949                 return
950         }
951
952         var rows = getSelectedUsers();
953
954         if (rows.length == 0) {
955                 notify("No users are selected.");
956                 return;
957         }
958
959         if (rows.length > 1) {
960                 notify("Please select one user.");
961                 return;
962         }
963
964         var id = rows[0];
965
966         notify("");
967
968         xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
969         xmlhttp.onreadystatechange=infobox_callback;
970         xmlhttp.send(null);
971
972 }
973
974 function selectedFeedDetails() {
975
976         if (!xmlhttp_ready(xmlhttp)) {
977                 printLockingError();
978                 return
979         }
980
981         var rows = getSelectedFeeds();
982
983         if (rows.length == 0) {
984                 notify("No feeds are selected.");
985                 return;
986         }
987
988         if (rows.length > 1) {
989                 notify("Please select one feed.");
990                 return;
991         }
992
993         var id = rows[0];
994
995         notify("");
996
997         xmlhttp.open("GET", "backend.php?op=feed-details&id=" + id, true);
998         xmlhttp.onreadystatechange=infobox_callback;
999         xmlhttp.send(null);
1000
1001 }
1002
1003 function editSelectedFilter() {
1004         var rows = getSelectedFilters();
1005
1006         if (rows.length == 0) {
1007                 notify("No filters are selected.");
1008                 return;
1009         }
1010
1011         if (rows.length > 1) {
1012                 notify("Please select one filter.");
1013                 return;
1014         }
1015
1016         notify("");
1017
1018         editFilter(rows[0]);
1019
1020 }
1021
1022
1023 function editSelectedFeed() {
1024         var rows = getSelectedFeeds();
1025
1026         if (rows.length == 0) {
1027                 notify("No feeds are selected.");
1028                 return;
1029         }
1030
1031         if (rows.length > 1) {
1032                 notify("Please select one feed.");
1033                 return;
1034         }
1035
1036         notify("");
1037
1038         editFeed(rows[0]);
1039
1040 }
1041
1042 function editSelectedFeedCat() {
1043         var rows = getSelectedFeedCats();
1044
1045         if (rows.length == 0) {
1046                 notify("No categories are selected.");
1047                 return;
1048         }
1049
1050         if (rows.length > 1) {
1051                 notify("Please select one category.");
1052                 return;
1053         }
1054
1055         notify("");
1056
1057         editFeedCat(rows[0]);
1058
1059 }
1060
1061 function localPiggieFunction(enable) {
1062         if (enable) {
1063                 piggie.style.display = "block";
1064                 seq = "";
1065                 notify("I loveded it!!!");
1066         } else {
1067                 piggie.style.display = "none";
1068                 notify("");
1069         }
1070 }
1071
1072 function validateOpmlImport() {
1073         
1074         var opml_file = document.getElementById("opml_file");
1075
1076         if (opml_file.value.length == 0) {
1077                 notify("Please select OPML file to upload.");
1078                 return false;
1079         } else {
1080                 return true;
1081         }
1082 }
1083
1084 function updateFilterList() {
1085
1086         if (!xmlhttp_ready(xmlhttp)) {
1087                 printLockingError();
1088                 return
1089         }
1090
1091 //      document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1092
1093         p_notify("Loading, please wait...");
1094
1095         xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1096         xmlhttp.onreadystatechange=filterlist_callback;
1097         xmlhttp.send(null);
1098
1099 }
1100
1101 function updateLabelList() {
1102
1103         if (!xmlhttp_ready(xmlhttp)) {
1104                 printLockingError();
1105                 return
1106         }
1107
1108         p_notify("Loading, please wait...");
1109
1110 //      document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1111
1112         xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1113         xmlhttp.onreadystatechange=labellist_callback;
1114         xmlhttp.send(null);
1115 }
1116
1117 function updatePrefsList() {
1118
1119         if (!xmlhttp_ready(xmlhttp)) {
1120                 printLockingError();
1121                 return
1122         }
1123
1124         p_notify("Loading, please wait...");
1125
1126         xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1127         xmlhttp.onreadystatechange=prefslist_callback;
1128         xmlhttp.send(null);
1129
1130 }
1131
1132 function selectTab(id) {
1133
1134         if (!xmlhttp_ready(xmlhttp)) {
1135                 printLockingError();
1136                 return
1137         }
1138
1139         if (id == "feedConfig") {
1140                 updateFeedList();
1141         } else if (id == "filterConfig") {
1142                 updateFilterList();
1143         } else if (id == "labelConfig") {
1144                 updateLabelList();
1145         } else if (id == "genConfig") {
1146                 updatePrefsList();
1147         } else if (id == "userConfig") {
1148                 updateUsersList();
1149         }
1150
1151         var tab = document.getElementById(active_tab + "Tab");
1152
1153         if (tab) {
1154                 if (tab.className.match("Selected")) {
1155                         tab.className = "prefsTab";
1156                 }
1157         }
1158
1159         tab = document.getElementById(id + "Tab");
1160
1161         if (tab) {
1162                 if (!tab.className.match("Selected")) {
1163                         tab.className = tab.className + "Selected";
1164                 }
1165         }
1166
1167         active_tab = id;
1168
1169 }
1170
1171 function init() {
1172
1173         // IE kludge
1174
1175         if (!xmlhttp) {
1176                 document.getElementById("prefContent").innerHTML = 
1177                         "<b>Fatal error:</b> This program needs XmlHttpRequest " + 
1178                         "to function properly. Your browser doesn't seem to support it.";
1179                 return;
1180         }
1181
1182         selectTab("genConfig");
1183
1184         document.onkeydown = hotkey_handler;
1185         notify("");
1186
1187 }
1188
1189 /*
1190 var help_topic_id = false;
1191
1192 function do_dispOptionHelp() {
1193
1194         if (!xmlhttp_ready(xmlhttp))
1195                 return;
1196
1197         xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" +
1198                 param_escape(help_topic_id), true);
1199         xmlhttp.onreadystatechange=gethelp_callback;
1200         xmlhttp.send(null);
1201
1202 }
1203
1204 function dispOptionHelp(event, sender) {
1205
1206         help_topic_id = sender.id;
1207
1208 //      document.setTimeout("do_dispOptionHelp()", 100);
1209
1210 } */
1211
1212 function closeInfoBox() {
1213         var box = document.getElementById('infoBox');
1214         var shadow = document.getElementById('infoBoxShadow');
1215
1216         if (shadow) {
1217                 shadow.style.display = "none";
1218         } else if (box) {
1219                 box.style.display = "none";
1220         }
1221 }