]> git.wh0rd.org - tt-rss.git/blob - prefs.js
feedlist fixes
[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 private = document.getElementById("iedit_private").checked;
703
704 var fcat_id = 0;
705
706 if (fcat) {
707 fcat_id = fcat[fcat.selectedIndex].id;
708 }
709
710 var pfeed = document.getElementById("iedit_parent_feed");
711 var parent_feed_id = pfeed[pfeed.selectedIndex].id;
712
713 if (link.length == 0) {
714 notify("Feed link cannot be blank.");
715 return;
716 }
717
718 if (title.length == 0) {
719 notify("Feed title cannot be blank.");
720 return;
721 }
722
723 var auth_login = document.getElementById("iedit_login").value;
724 var auth_pass = document.getElementById("iedit_pass").value;
725
726 active_feed = false;
727
728 notify("Saving feed...");
729
730 var query = "op=pref-feeds&subop=editSave&id=" +
731 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
732 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
733 "&catid=" + param_escape(fcat_id) + "&login=" + param_escape(auth_login) +
734 "&pfeed=" + param_escape(parent_feed_id) + "&pass=" + param_escape(auth_pass) +
735 "&private=" + param_escape(private);
736
737 xmlhttp.open("POST", "backend.php", true);
738 xmlhttp.onreadystatechange=feedlist_callback;
739 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
740 xmlhttp.send(query);
741
742 } catch (e) {
743 exception_error("feedEditSave", e);
744 }
745 }
746
747 function feedCatEditSave() {
748
749 if (!xmlhttp_ready(xmlhttp)) {
750 printLockingError();
751 return
752 }
753
754 notify("Saving category...");
755
756 var cat_title = document.getElementById("iedit_title").value;
757
758 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=saveCat&id=" +
759 param_escape(active_feed_cat) + "&title=" + param_escape(cat_title),
760 true);
761 xmlhttp.onreadystatechange=feedlist_callback;
762 xmlhttp.send(null);
763
764 active_feed_cat = false;
765
766 }
767
768
769 function labelTest() {
770
771 var sqlexp = document.getElementById("iedit_expr").value;
772 var descr = document.getElementById("iedit_descr").value;
773
774 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
775 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
776
777 xmlhttp.onreadystatechange=infobox_callback;
778 xmlhttp.send(null);
779
780 }
781
782 function displayHelpInfobox(topic_id) {
783
784 xmlhttp.open("GET", "backend.php?op=help&tid=" +
785 param_escape(topic_id) + "&noheaders=1", true);
786
787 xmlhttp.onreadystatechange=infobox_callback;
788 xmlhttp.send(null);
789
790 }
791
792 function labelEditCancel() {
793
794 if (!xmlhttp_ready(xmlhttp)) {
795 printLockingError();
796 return
797 }
798
799 active_label = false;
800
801 notify("Operation cancelled.");
802
803 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
804 xmlhttp.onreadystatechange=labellist_callback;
805 xmlhttp.send(null);
806
807 }
808
809 function userEditCancel() {
810
811 if (!xmlhttp_ready(xmlhttp)) {
812 printLockingError();
813 return
814 }
815
816 active_user = false;
817
818 notify("Operation cancelled.");
819
820 xmlhttp.open("GET", "backend.php?op=pref-users", true);
821 xmlhttp.onreadystatechange=userlist_callback;
822 xmlhttp.send(null);
823
824 }
825
826 function filterEditCancel() {
827
828 if (!xmlhttp_ready(xmlhttp)) {
829 printLockingError();
830 return
831 }
832
833 active_filter = false;
834
835 notify("Operation cancelled.");
836
837 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
838 xmlhttp.onreadystatechange=filterlist_callback;
839 xmlhttp.send(null);
840
841 }
842
843 function labelEditSave() {
844
845 var label = active_label;
846
847 if (!xmlhttp_ready(xmlhttp)) {
848 printLockingError();
849 return
850 }
851
852 var sqlexp = document.getElementById("iedit_expr").value;
853 var descr = document.getElementById("iedit_descr").value;
854
855 // notify("Saving label " + sqlexp + ": " + descr);
856
857 if (sqlexp.length == 0) {
858 notify("SQL expression cannot be blank.");
859 return;
860 }
861
862 if (descr.length == 0) {
863 notify("Caption cannot be blank.");
864 return;
865 }
866
867 notify("Saving label...");
868
869 active_label = false;
870
871 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
872 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
873 true);
874
875 xmlhttp.onreadystatechange=labellist_callback;
876 xmlhttp.send(null);
877
878 }
879
880 function userEditSave() {
881
882 var user = active_user;
883
884 if (!xmlhttp_ready(xmlhttp)) {
885 printLockingError();
886 return
887 }
888
889 var login = document.getElementById("iedit_ulogin").value;
890 var level = document.getElementById("iedit_ulevel").value;
891 var email = document.getElementById("iedit_email").value;
892
893 if (login.length == 0) {
894 notify("Login cannot be blank.");
895 return;
896 }
897
898 if (level.length == 0) {
899 notify("User level cannot be blank.");
900 return;
901 }
902
903 active_user = false;
904
905 notify("Saving user...");
906
907 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
908 user + "&l=" + param_escape(login) + "&al=" + param_escape(level) +
909 "&e=" + param_escape(email), true);
910
911 xmlhttp.onreadystatechange=userlist_callback;
912 xmlhttp.send(null);
913
914 }
915
916
917 function filterEditSave() {
918
919 var filter = active_filter;
920
921 if (!xmlhttp_ready(xmlhttp)) {
922 printLockingError();
923 return
924 }
925
926 var regexp = document.getElementById("iedit_regexp").value;
927 var descr = document.getElementById("iedit_descr").value;
928 var match = document.getElementById("iedit_match");
929
930 var v_match = match[match.selectedIndex].text;
931
932 var feed = document.getElementById("iedit_feed");
933 var feed_id = feed[feed.selectedIndex].id;
934
935 var action = document.getElementById("iedit_filter_action");
936 var action_id = action[action.selectedIndex].id;
937
938 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
939
940 if (regexp.length == 0) {
941 notify("Filter expression cannot be blank.");
942 return;
943 }
944
945 active_filter = false;
946
947 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
948 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
949 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id) +
950 "&aid=" + param_escape(action_id), true);
951
952 notify("Saving filter...");
953
954 xmlhttp.onreadystatechange=filterlist_callback;
955 xmlhttp.send(null);
956
957 }
958
959 function editSelectedLabel() {
960 var rows = getSelectedLabels();
961
962 if (rows.length == 0) {
963 notify("No labels are selected.");
964 return;
965 }
966
967 if (rows.length > 1) {
968 notify("Please select one label.");
969 return;
970 }
971
972 notify("");
973
974 editLabel(rows[0]);
975
976 }
977
978 function editSelectedUser() {
979 var rows = getSelectedUsers();
980
981 if (rows.length == 0) {
982 notify("No users are selected.");
983 return;
984 }
985
986 if (rows.length > 1) {
987 notify("Please select one user.");
988 return;
989 }
990
991 notify("");
992
993 editUser(rows[0]);
994 }
995
996 function resetSelectedUserPass() {
997 var rows = getSelectedUsers();
998
999 if (rows.length == 0) {
1000 notify("No users are selected.");
1001 return;
1002 }
1003
1004 if (rows.length > 1) {
1005 notify("Please select one user.");
1006 return;
1007 }
1008
1009 var ok = confirm("Reset password of selected user?");
1010
1011 if (ok) {
1012 notify("Resetting password for selected user...");
1013
1014 var id = rows[0];
1015
1016 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1017 param_escape(id), true);
1018 xmlhttp.onreadystatechange=userlist_callback;
1019 xmlhttp.send(null);
1020 }
1021 }
1022
1023 function selectedUserDetails() {
1024
1025 if (!xmlhttp_ready(xmlhttp)) {
1026 printLockingError();
1027 return
1028 }
1029
1030 var rows = getSelectedUsers();
1031
1032 if (rows.length == 0) {
1033 notify("No users are selected.");
1034 return;
1035 }
1036
1037 if (rows.length > 1) {
1038 notify("Please select one user.");
1039 return;
1040 }
1041
1042 var id = rows[0];
1043
1044 notify("");
1045
1046 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
1047 xmlhttp.onreadystatechange=infobox_callback;
1048 xmlhttp.send(null);
1049
1050 }
1051
1052 function selectedFeedDetails() {
1053
1054 if (!xmlhttp_ready(xmlhttp)) {
1055 printLockingError();
1056 return
1057 }
1058
1059 var rows = getSelectedFeeds();
1060
1061 if (rows.length == 0) {
1062 notify("No feeds are selected.");
1063 return;
1064 }
1065
1066 // if (rows.length > 1) {
1067 // notify("Please select one feed.");
1068 // return;
1069 // }
1070
1071 // var id = rows[0];
1072
1073 notify("");
1074
1075 xmlhttp.open("GET", "backend.php?op=feed-details&id=" +
1076 param_escape(rows.toString()), true);
1077 xmlhttp.onreadystatechange=infobox_callback;
1078 xmlhttp.send(null);
1079
1080 }
1081
1082 function editSelectedFilter() {
1083 var rows = getSelectedFilters();
1084
1085 if (rows.length == 0) {
1086 notify("No filters are selected.");
1087 return;
1088 }
1089
1090 if (rows.length > 1) {
1091 notify("Please select one filter.");
1092 return;
1093 }
1094
1095 notify("");
1096
1097 editFilter(rows[0]);
1098
1099 }
1100
1101
1102 function editSelectedFeed() {
1103 var rows = getSelectedFeeds();
1104
1105 if (rows.length == 0) {
1106 notify("No feeds are selected.");
1107 return;
1108 }
1109
1110 if (rows.length > 1) {
1111 notify("Please select one feed.");
1112 return;
1113 }
1114
1115 notify("");
1116
1117 editFeed(rows[0]);
1118
1119 }
1120
1121 function editSelectedFeedCat() {
1122 var rows = getSelectedFeedCats();
1123
1124 if (rows.length == 0) {
1125 notify("No categories are selected.");
1126 return;
1127 }
1128
1129 if (rows.length > 1) {
1130 notify("Please select one category.");
1131 return;
1132 }
1133
1134 notify("");
1135
1136 editFeedCat(rows[0]);
1137
1138 }
1139
1140 function localPiggieFunction(enable) {
1141 if (enable) {
1142 piggie.style.display = "block";
1143 seq = "";
1144 notify("I loveded it!!!");
1145 } else {
1146 piggie.style.display = "none";
1147 notify("");
1148 }
1149 }
1150
1151 function validateOpmlImport() {
1152
1153 var opml_file = document.getElementById("opml_file");
1154
1155 if (opml_file.value.length == 0) {
1156 notify("Please select OPML file to upload.");
1157 return false;
1158 } else {
1159 return true;
1160 }
1161 }
1162
1163 function updateFilterList() {
1164
1165 if (!xmlhttp_ready(xmlhttp)) {
1166 printLockingError();
1167 return
1168 }
1169
1170 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1171
1172 p_notify("Loading, please wait...");
1173
1174 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1175 xmlhttp.onreadystatechange=filterlist_callback;
1176 xmlhttp.send(null);
1177
1178 }
1179
1180 function updateLabelList() {
1181
1182 if (!xmlhttp_ready(xmlhttp)) {
1183 printLockingError();
1184 return
1185 }
1186
1187 p_notify("Loading, please wait...");
1188
1189 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1190
1191 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1192 xmlhttp.onreadystatechange=labellist_callback;
1193 xmlhttp.send(null);
1194 }
1195
1196 function updatePrefsList() {
1197
1198 if (!xmlhttp_ready(xmlhttp)) {
1199 printLockingError();
1200 return
1201 }
1202
1203 p_notify("Loading, please wait...");
1204
1205 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1206 xmlhttp.onreadystatechange=prefslist_callback;
1207 xmlhttp.send(null);
1208
1209 }
1210
1211 function selectTab(id, noupdate) {
1212
1213 // alert(id);
1214
1215 if (!xmlhttp_ready(xmlhttp)) {
1216 printLockingError();
1217 return
1218 }
1219
1220 if (!noupdate) {
1221
1222 if (id == "feedConfig") {
1223 updateFeedList();
1224 } else if (id == "filterConfig") {
1225 updateFilterList();
1226 } else if (id == "labelConfig") {
1227 updateLabelList();
1228 } else if (id == "genConfig") {
1229 updatePrefsList();
1230 } else if (id == "userConfig") {
1231 updateUsersList();
1232 } else if (id == "feedBrowser") {
1233 updateBigFeedBrowser();
1234 }
1235 }
1236
1237 var tab = document.getElementById(active_tab + "Tab");
1238
1239 if (tab) {
1240 if (tab.className.match("Selected")) {
1241 tab.className = "prefsTab";
1242 }
1243 }
1244
1245 tab = document.getElementById(id + "Tab");
1246
1247 if (tab) {
1248 if (!tab.className.match("Selected")) {
1249 tab.className = tab.className + "Selected";
1250 }
1251 }
1252
1253 active_tab = id;
1254
1255 setCookie('ttrss_pref_acttab', active_tab);
1256
1257 }
1258
1259 function init() {
1260
1261 try {
1262
1263 // IE kludge
1264 if (!xmlhttp) {
1265 document.getElementById("prefContent").innerHTML =
1266 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1267 "to function properly. Your browser doesn't seem to support it.";
1268 return;
1269 }
1270
1271 active_tab = getCookie("ttrss_pref_acttab");
1272 if (!active_tab) active_tab = "genConfig";
1273 selectTab(active_tab);
1274
1275 document.onkeydown = hotkey_handler;
1276 notify("");
1277 } catch (e) {
1278 exception_error("init", e);
1279 }
1280 }
1281
1282 function closeInfoBox() {
1283 var box = document.getElementById('infoBox');
1284 var shadow = document.getElementById('infoBoxShadow');
1285
1286 if (shadow) {
1287 shadow.style.display = "none";
1288 } else if (box) {
1289 box.style.display = "none";
1290 }
1291 }
1292
1293 function categorizeSelectedFeeds() {
1294
1295 if (!xmlhttp_ready(xmlhttp)) {
1296 printLockingError();
1297 return
1298 }
1299
1300 var sel_rows = getSelectedFeeds();
1301
1302 var cat_sel = document.getElementById("sfeed_set_fcat");
1303 var cat_id = cat_sel[cat_sel.selectedIndex].id;
1304
1305 if (sel_rows.length > 0) {
1306
1307 notify("Changing category of selected feeds...");
1308
1309 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1310 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1311 xmlhttp.onreadystatechange=feedlist_callback;
1312 xmlhttp.send(null);
1313
1314 } else {
1315
1316 notify("Please select some feeds first.");
1317
1318 }
1319
1320 }
1321
1322 function validatePrefsReset() {
1323 return confirm("Reset to defaults?");
1324 }
1325
1326 function browseFeeds() {
1327
1328 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1329 xmlhttp.onreadystatechange=infobox_callback;
1330 xmlhttp.send(null);
1331
1332 }
1333
1334 function feedBrowserSubscribe() {
1335 try {
1336 var list = document.getElementById("browseFeedList");
1337
1338 if (!list) list = document.getElementById("browseBigFeedList");
1339
1340 var selected = new Array();
1341
1342 for (i = 0; i < list.childNodes.length; i++) {
1343 var child = list.childNodes[i];
1344 if (child.id && child.id.match("FBROW-")) {
1345 var id = child.id.replace("FBROW-", "");
1346
1347 var cb = document.getElementById("FBCHK-" + id);
1348
1349 if (cb.checked) {
1350 selected.push(id);
1351 }
1352 }
1353 }
1354
1355 if (selected.length > 0) {
1356 closeInfoBox();
1357 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1358 param_escape(selected.toString()), true);
1359 xmlhttp.onreadystatechange=feedlist_callback;
1360 xmlhttp.send(null);
1361 } else {
1362 alert("No feeds are selected.");
1363 }
1364
1365 } catch (e) {
1366 exception_error("feedBrowserSubscribe", e);
1367 }
1368 }
1369
1370 function updateBigFeedBrowser() {
1371
1372 if (!xmlhttp_ready(xmlhttp)) {
1373 printLockingError();
1374 return
1375 }
1376
1377 p_notify("Loading, please wait...");
1378
1379 xmlhttp.open("GET", "backend.php?op=pref-feed-browser", true);
1380 xmlhttp.onreadystatechange=feed_browser_callback;
1381 xmlhttp.send(null);
1382
1383 }
1384
1385 function browserToggleExpand(id) {
1386 try {
1387 /* if (feed_to_expand && feed_to_expand != id) {
1388 var d = document.getElementById("BRDET-" + feed_to_expand);
1389 d.style.display = "none";
1390 } */
1391
1392 var d = document.getElementById("BRDET-" + id);
1393
1394 if (d.style.display == "block") {
1395 d.style.display = "none";
1396
1397 } else {
1398
1399 feed_to_expand = id;
1400
1401 xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1402 + param_escape(id), true);
1403 xmlhttp.onreadystatechange=expand_feed_callback;
1404 xmlhttp.send(null);
1405 }
1406
1407 } catch (e) {
1408 exception_error("browserExpand", e);
1409 }
1410 }