]>
git.wh0rd.org - tt-rss.git/blob - prefs.js
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;
9 var active_tab
= false;
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.
16 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
19 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
26 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
27 xmlhttp
= new XMLHttpRequest();
30 function feedlist_callback() {
31 if (xmlhttp
.readyState
== 4) {
32 var container
= document
.getElementById('prefContent');
33 container
.innerHTML
=xmlhttp
.responseText
;
35 var row
= document
.getElementById("FEEDR-" + active_feed
);
37 if (!row
.className
.match("Selected")) {
38 row
.className
= row
.className
+ "Selected";
41 var checkbox
= document
.getElementById("FRCHK-" + active_feed
);
43 checkbox
.checked
= true;
50 function filterlist_callback() {
51 var container
= document
.getElementById('prefContent');
52 if (xmlhttp
.readyState
== 4) {
54 container
.innerHTML
=xmlhttp
.responseText
;
57 var row
= document
.getElementById("FILRR-" + active_filter
);
59 if (!row
.className
.match("Selected")) {
60 row
.className
= row
.className
+ "Selected";
63 var checkbox
= document
.getElementById("FICHK-" + active_filter
);
66 checkbox
.checked
= true;
73 function labellist_callback() {
74 var container
= document
.getElementById('prefContent');
75 if (xmlhttp
.readyState
== 4) {
76 container
.innerHTML
=xmlhttp
.responseText
;
79 var row
= document
.getElementById("LILRR-" + active_label
);
81 if (!row
.className
.match("Selected")) {
82 row
.className
= row
.className
+ "Selected";
85 var checkbox
= document
.getElementById("LICHK-" + active_label
);
88 checkbox
.checked
= true;
95 function userlist_callback() {
96 var container
= document
.getElementById('prefContent');
97 if (xmlhttp
.readyState
== 4) {
98 container
.innerHTML
=xmlhttp
.responseText
;
101 var row
= document
.getElementById("UMRR-" + active_user
);
103 if (!row
.className
.match("Selected")) {
104 row
.className
= row
.className
+ "Selected";
107 var checkbox
= document
.getElementById("UMCHK-" + active_user
);
110 checkbox
.checked
= true;
118 function infobox_callback() {
119 if (xmlhttp
.readyState
== 4) {
120 var box
= document
.getElementById('infoBox');
121 var shadow
= document
.getElementById('infoBoxShadow');
124 box
.innerHTML
=xmlhttp
.responseText
;
126 shadow
.style
.display
= "block";
128 box
.style
.display
= "block";
135 function prefslist_callback() {
136 var container
= document
.getElementById('prefContent');
137 if (xmlhttp
.readyState
== 4) {
139 container
.innerHTML
=xmlhttp
.responseText
;
145 function gethelp_callback() {
146 var container
= document
.getElementById('prefHelpBox');
147 if (xmlhttp
.readyState
== 4) {
149 container
.innerHTML
= xmlhttp
.responseText
;
150 container
.style
.display
= "block";
156 function notify_callback() {
157 var container
= document
.getElementById('notify');
158 if (xmlhttp
.readyState
== 4) {
159 container
.innerHTML
=xmlhttp
.responseText
;
163 function updateFeedList(sort_key
) {
165 if (!xmlhttp_ready(xmlhttp
)) {
170 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
172 p_notify("Loading, please wait...");
174 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
175 "&sort=" + param_escape(sort_key
), true);
176 xmlhttp
.onreadystatechange
=feedlist_callback
;
181 function updateUsersList() {
183 if (!xmlhttp_ready(xmlhttp
)) {
188 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
190 p_notify("Loading, please wait...");
192 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
193 xmlhttp
.onreadystatechange
=userlist_callback
;
198 function toggleSelectRow(sender
) {
199 var parent_row
= sender
.parentNode
.parentNode
;
201 if (sender
.checked
) {
202 if (!parent_row
.className
.match("Selected")) {
203 parent_row
.className
= parent_row
.className
+ "Selected";
206 if (parent_row
.className
.match("Selected")) {
207 parent_row
.className
= parent_row
.className
.replace("Selected", "");
212 function addLabel() {
214 if (!xmlhttp_ready(xmlhttp
)) {
219 var sqlexp
= document
.getElementById("ladd_expr");
221 if (sqlexp
.value
.length
== 0) {
222 notify("Missing SQL expression.");
224 notify("Adding label...");
226 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
227 param_escape(sqlexp
.value
), true);
229 xmlhttp
.onreadystatechange
=labellist_callback
;
237 function addFilter() {
239 if (!xmlhttp_ready(xmlhttp
)) {
244 var regexp
= document
.getElementById("fadd_regexp");
245 var match
= document
.getElementById("fadd_match");
246 var feed
= document
.getElementById("fadd_feed");
248 if (regexp
.value
.length
== 0) {
249 notify("Missing filter expression.");
251 notify("Adding filter...");
253 var v_match
= match
[match
.selectedIndex
].text
;
255 var feed_id
= feed
[feed
.selectedIndex
].id
;
257 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
258 param_escape(regexp
.value
) + "&match=" + v_match
+
259 "&fid=" + param_escape(feed_id
), true);
261 xmlhttp
.onreadystatechange
=filterlist_callback
;
271 if (!xmlhttp_ready(xmlhttp
)) {
276 var link
= document
.getElementById("fadd_link");
278 if (link
.value
.length
== 0) {
279 notify("Missing feed URL.");
281 notify("Adding feed...");
283 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
284 param_escape(link
.value
), true);
285 xmlhttp
.onreadystatechange
=feedlist_callback
;
294 function addFeedCat() {
296 if (!xmlhttp_ready(xmlhttp
)) {
301 var cat
= document
.getElementById("fadd_cat");
303 if (cat
.value
.length
== 0) {
304 notify("Missing feed category.");
306 notify("Adding feed category...");
308 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
309 param_escape(cat
.value
), true);
310 xmlhttp
.onreadystatechange
=feedlist_callback
;
320 if (!xmlhttp_ready(xmlhttp
)) {
325 var sqlexp
= document
.getElementById("uadd_box");
327 if (sqlexp
.value
.length
== 0) {
328 notify("Missing user login.");
330 notify("Adding user...");
332 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
333 param_escape(sqlexp
.value
), true);
335 xmlhttp
.onreadystatechange
=userlist_callback
;
343 function editLabel(id
) {
345 if (!xmlhttp_ready(xmlhttp
)) {
352 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
353 param_escape(id
), true);
354 xmlhttp
.onreadystatechange
=labellist_callback
;
359 function editUser(id
) {
361 if (!xmlhttp_ready(xmlhttp
)) {
368 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
369 param_escape(id
), true);
370 xmlhttp
.onreadystatechange
=userlist_callback
;
375 function editFilter(id
) {
377 if (!xmlhttp_ready(xmlhttp
)) {
384 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
385 param_escape(id
), true);
386 xmlhttp
.onreadystatechange
=filterlist_callback
;
391 function editFeed(feed
) {
393 // notify("Editing feed...");
395 if (!xmlhttp_ready(xmlhttp
)) {
402 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
403 param_escape(feed
), true);
404 xmlhttp
.onreadystatechange
=feedlist_callback
;
409 function editFeedCat(cat
) {
411 if (!xmlhttp_ready(xmlhttp
)) {
416 active_feed_cat
= cat
;
418 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
419 param_escape(cat
), true);
420 xmlhttp
.onreadystatechange
=feedlist_callback
;
425 function getSelectedLabels() {
426 return getSelectedTableRowIds("prefLabelList", "LILRR");
429 function getSelectedUsers() {
430 return getSelectedTableRowIds("prefUserList", "UMRR");
433 function getSelectedFeeds() {
434 return getSelectedTableRowIds("prefFeedList", "FEEDR");
437 function getSelectedFilters() {
438 return getSelectedTableRowIds("prefFilterList", "FILRR");
441 function getSelectedFeedCats() {
442 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
446 function readSelectedFeeds(read
) {
448 if (!xmlhttp_ready(xmlhttp
)) {
453 var sel_rows
= getSelectedFeeds();
455 if (sel_rows
.length
> 0) {
463 notify("Marking selected feeds as " + op
+ "...");
465 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=" + op
+ "&ids="+
466 param_escape(sel_rows
.toString()), true);
467 xmlhttp
.onreadystatechange
=notify_callback
;
472 notify("Please select some feeds first.");
477 function removeSelectedLabels() {
479 if (!xmlhttp_ready(xmlhttp
)) {
484 var sel_rows
= getSelectedLabels();
486 if (sel_rows
.length
> 0) {
488 notify("Removing selected labels...");
490 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
491 param_escape(sel_rows
.toString()), true);
492 xmlhttp
.onreadystatechange
=labellist_callback
;
496 notify("Please select some labels first.");
500 function removeSelectedUsers() {
502 if (!xmlhttp_ready(xmlhttp
)) {
507 var sel_rows
= getSelectedUsers();
509 if (sel_rows
.length
> 0) {
511 notify("Removing selected users...");
513 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
514 param_escape(sel_rows
.toString()), true);
515 xmlhttp
.onreadystatechange
=userlist_callback
;
519 notify("Please select some labels first.");
523 function removeSelectedFilters() {
525 if (!xmlhttp_ready(xmlhttp
)) {
530 var sel_rows
= getSelectedFilters();
532 if (sel_rows
.length
> 0) {
534 notify("Removing selected filters...");
536 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
537 param_escape(sel_rows
.toString()), true);
538 xmlhttp
.onreadystatechange
=filterlist_callback
;
542 notify("Please select some filters first.");
547 function removeSelectedFeeds() {
549 if (!xmlhttp_ready(xmlhttp
)) {
554 var sel_rows
= getSelectedFeeds();
556 if (sel_rows
.length
> 0) {
558 notify("Removing selected feeds...");
560 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
561 param_escape(sel_rows
.toString()), true);
562 xmlhttp
.onreadystatechange
=feedlist_callback
;
567 notify("Please select some feeds first.");
573 function removeSelectedFeedCats() {
575 if (!xmlhttp_ready(xmlhttp
)) {
580 var sel_rows
= getSelectedFeedCats();
582 if (sel_rows
.length
> 0) {
584 notify("Removing selected categories...");
586 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
587 param_escape(sel_rows
.toString()), true);
588 xmlhttp
.onreadystatechange
=feedlist_callback
;
593 notify("Please select some feeds first.");
599 function feedEditCancel() {
601 if (!xmlhttp_ready(xmlhttp
)) {
608 notify("Operation cancelled.");
610 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
611 xmlhttp
.onreadystatechange
=feedlist_callback
;
616 function feedCatEditCancel() {
618 if (!xmlhttp_ready(xmlhttp
)) {
623 active_feed_cat
= false;
625 notify("Operation cancelled.");
627 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
628 xmlhttp
.onreadystatechange
=feedlist_callback
;
633 function feedEditSave() {
635 var feed
= active_feed
;
637 if (!xmlhttp_ready(xmlhttp
)) {
642 var link
= document
.getElementById("iedit_link").value
;
643 var title
= document
.getElementById("iedit_title").value
;
644 var upd_intl
= document
.getElementById("iedit_updintl").value
;
645 var purge_intl
= document
.getElementById("iedit_purgintl").value
;
646 var fcat
= document
.getElementById("iedit_fcat");
648 var fcat_id
= fcat
[fcat
.selectedIndex
].id
;
650 // notify("Saving feed.");
652 /* if (upd_intl < 0) {
653 notify("Update interval must be >= 0 (0 = default)");
657 if (purge_intl < 0) {
658 notify("Purge days must be >= 0 (0 = default)");
662 if (link
.length
== 0) {
663 notify("Feed link cannot be blank.");
667 if (title
.length
== 0) {
668 notify("Feed title cannot be blank.");
676 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
677 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) +
678 "&ui=" + param_escape(upd_intl
) + "&pi=" + param_escape(purge_intl
) +
679 "&catid=" + param_escape(fcat_id
), true);
680 xmlhttp
.onreadystatechange
=feedlist_callback
;
685 function labelTest() {
687 var sqlexp
= document
.getElementById("iedit_expr").value
;
688 var descr
= document
.getElementById("iedit_descr").value
;
690 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
691 param_escape(sqlexp
) + "&descr=" + param_escape(descr
), true);
693 xmlhttp
.onreadystatechange
=infobox_callback
;
698 function labelEditCancel() {
700 if (!xmlhttp_ready(xmlhttp
)) {
705 active_label
= false;
707 notify("Operation cancelled.");
709 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
710 xmlhttp
.onreadystatechange
=labellist_callback
;
715 function userEditCancel() {
717 if (!xmlhttp_ready(xmlhttp
)) {
724 notify("Operation cancelled.");
726 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
727 xmlhttp
.onreadystatechange
=userlist_callback
;
732 function filterEditCancel() {
734 if (!xmlhttp_ready(xmlhttp
)) {
739 active_filter
= false;
741 notify("Operation cancelled.");
743 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
744 xmlhttp
.onreadystatechange
=filterlist_callback
;
749 function labelEditSave() {
751 var label
= active_label
;
753 if (!xmlhttp_ready(xmlhttp
)) {
758 var sqlexp
= document
.getElementById("iedit_expr").value
;
759 var descr
= document
.getElementById("iedit_descr").value
;
761 // notify("Saving label " + sqlexp + ": " + descr);
763 if (sqlexp
.length
== 0) {
764 notify("SQL expression cannot be blank.");
768 if (descr
.length
== 0) {
769 notify("Caption cannot be blank.");
775 active_label
= false;
777 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
778 label
+ "&s=" + param_escape(sqlexp
) + "&d=" + param_escape(descr
),
781 xmlhttp
.onreadystatechange
=labellist_callback
;
786 function userEditSave() {
788 var user
= active_user
;
790 if (!xmlhttp_ready(xmlhttp
)) {
795 var login
= document
.getElementById("iedit_ulogin").value
;
796 var level
= document
.getElementById("iedit_ulevel").value
;
798 if (login
.length
== 0) {
799 notify("Login cannot be blank.");
803 if (level
.length
== 0) {
804 notify("User level cannot be blank.");
812 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
813 user
+ "&l=" + param_escape(login
) + "&al=" + param_escape(level
),
816 xmlhttp
.onreadystatechange
=userlist_callback
;
822 function filterEditSave() {
824 var filter
= active_filter
;
826 if (!xmlhttp_ready(xmlhttp
)) {
831 var regexp
= document
.getElementById("iedit_regexp").value
;
832 var descr
= document
.getElementById("iedit_descr").value
;
833 var match
= document
.getElementById("iedit_match");
835 var v_match
= match
[match
.selectedIndex
].text
;
837 var feed
= document
.getElementById("iedit_feed");
838 var feed_id
= feed
[feed
.selectedIndex
].id
;
840 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
842 if (regexp
.length
== 0) {
843 notify("Filter expression cannot be blank.");
847 active_filter
= false;
849 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
850 filter
+ "&r=" + param_escape(regexp
) + "&d=" + param_escape(descr
) +
851 "&m=" + param_escape(v_match
) + "&fid=" + param_escape(feed_id
), true);
855 xmlhttp
.onreadystatechange
=filterlist_callback
;
860 function editSelectedLabel() {
861 var rows
= getSelectedLabels();
863 if (rows
.length
== 0) {
864 notify("No labels are selected.");
868 if (rows
.length
> 1) {
869 notify("Please select one label.");
879 function editSelectedUser() {
880 var rows
= getSelectedUsers();
882 if (rows
.length
== 0) {
883 notify("No users are selected.");
887 if (rows
.length
> 1) {
888 notify("Please select one user.");
897 function resetSelectedUserPass() {
898 var rows
= getSelectedUsers();
900 if (rows
.length
== 0) {
901 notify("No users are selected.");
905 if (rows
.length
> 1) {
906 notify("Please select one user.");
910 notify("Resetting password for selected user...");
914 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
915 param_escape(id
), true);
916 xmlhttp
.onreadystatechange
=userlist_callback
;
921 function selectedUserDetails() {
923 if (!xmlhttp_ready(xmlhttp
)) {
928 var rows
= getSelectedUsers();
930 if (rows
.length
== 0) {
931 notify("No users are selected.");
935 if (rows
.length
> 1) {
936 notify("Please select one user.");
944 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
945 xmlhttp
.onreadystatechange
=infobox_callback
;
950 function selectedFeedDetails() {
952 if (!xmlhttp_ready(xmlhttp
)) {
957 var rows
= getSelectedFeeds();
959 if (rows
.length
== 0) {
960 notify("No feeds are selected.");
964 if (rows
.length
> 1) {
965 notify("Please select one feed.");
973 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" + id
, true);
974 xmlhttp
.onreadystatechange
=infobox_callback
;
979 function editSelectedFilter() {
980 var rows
= getSelectedFilters();
982 if (rows
.length
== 0) {
983 notify("No filters are selected.");
987 if (rows
.length
> 1) {
988 notify("Please select one filter.");
999 function editSelectedFeed() {
1000 var rows
= getSelectedFeeds();
1002 if (rows
.length
== 0) {
1003 notify("No feeds are selected.");
1007 if (rows
.length
> 1) {
1008 notify("Please select one feed.");
1018 function editSelectedFeedCat() {
1019 var rows
= getSelectedFeedCats();
1021 if (rows
.length
== 0) {
1022 notify("No categories are selected.");
1026 if (rows
.length
> 1) {
1027 notify("Please select one category.");
1033 editFeedCat(rows
[0]);
1037 function localPiggieFunction(enable
) {
1039 piggie
.style
.display
= "block";
1041 notify("I loveded it!!!");
1043 piggie
.style
.display
= "none";
1048 function validateOpmlImport() {
1050 var opml_file
= document
.getElementById("opml_file");
1052 if (opml_file
.value
.length
== 0) {
1053 notify("Please select OPML file to upload.");
1060 function updateFilterList() {
1062 if (!xmlhttp_ready(xmlhttp
)) {
1063 printLockingError();
1067 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1069 p_notify("Loading, please wait...");
1071 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
1072 xmlhttp
.onreadystatechange
=filterlist_callback
;
1077 function updateLabelList() {
1079 if (!xmlhttp_ready(xmlhttp
)) {
1080 printLockingError();
1084 p_notify("Loading, please wait...");
1086 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1088 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
1089 xmlhttp
.onreadystatechange
=labellist_callback
;
1093 function updatePrefsList() {
1095 if (!xmlhttp_ready(xmlhttp
)) {
1096 printLockingError();
1100 p_notify("Loading, please wait...");
1102 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1103 xmlhttp
.onreadystatechange
=prefslist_callback
;
1108 function selectTab(id
) {
1110 if (!xmlhttp_ready(xmlhttp
)) {
1111 printLockingError();
1115 if (id
== "feedConfig") {
1117 } else if (id
== "filterConfig") {
1119 } else if (id
== "labelConfig") {
1121 } else if (id
== "genConfig") {
1123 } else if (id
== "userConfig") {
1127 var tab
= document
.getElementById(active_tab
+ "Tab");
1130 if (tab
.className
.match("Selected")) {
1131 tab
.className
= "prefsTab";
1135 tab
= document
.getElementById(id
+ "Tab");
1138 if (!tab
.className
.match("Selected")) {
1139 tab
.className
= tab
.className
+ "Selected";
1153 document
.getElementById("prefContent").innerHTML
=
1154 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1155 "to function properly. Your browser doesn't seem to support it.";
1159 selectTab("genConfig");
1161 document
.onkeydown
= hotkey_handler
;
1164 exception_error("init", e
);
1168 function closeInfoBox() {
1169 var box
= document
.getElementById('infoBox');
1170 var shadow
= document
.getElementById('infoBoxShadow');
1173 shadow
.style
.display
= "none";
1175 box
.style
.display
= "none";