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