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