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