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