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