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 var feed_search = document.getElementById("feed_search");
176 if (feed_search) { search = feed_search.value; }
178 xmlhttp.open("GET", "backend.php?op=pref-feeds" +
179 "&sort=" + param_escape(sort_key) +
180 "&search=" + param_escape(search), true);
181 xmlhttp.onreadystatechange=feedlist_callback;
186 function updateUsersList() {
188 if (!xmlhttp_ready(xmlhttp)) {
193 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
195 p_notify("Loading, please wait...");
197 xmlhttp.open("GET", "backend.php?op=pref-users", true);
198 xmlhttp.onreadystatechange=userlist_callback;
203 function addLabel() {
205 if (!xmlhttp_ready(xmlhttp)) {
210 var sqlexp = document.getElementById("ladd_expr");
212 if (sqlexp.value.length == 0) {
213 notify("Missing SQL expression.");
215 notify("Adding label...");
217 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
218 param_escape(sqlexp.value), true);
220 xmlhttp.onreadystatechange=labellist_callback;
228 function addFilter() {
230 if (!xmlhttp_ready(xmlhttp)) {
235 var regexp = document.getElementById("fadd_regexp");
236 var match = document.getElementById("fadd_match");
237 var feed = document.getElementById("fadd_feed");
238 var action = document.getElementById("fadd_action");
240 if (regexp.value.length == 0) {
241 notify("Missing filter expression.");
243 notify("Adding filter...");
245 var v_match = match[match.selectedIndex].text;
246 var feed_id = feed[feed.selectedIndex].id;
247 var action_id = action[action.selectedIndex].id;
249 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
250 param_escape(regexp.value) + "&match=" + v_match +
251 "&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
253 xmlhttp.onreadystatechange=filterlist_callback;
263 if (!xmlhttp_ready(xmlhttp)) {
268 var link = document.getElementById("fadd_link");
270 if (link.value.length == 0) {
271 notify("Missing feed URL.");
273 notify("Adding feed...");
275 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
276 param_escape(link.value), true);
277 xmlhttp.onreadystatechange=feedlist_callback;
286 function addFeedCat() {
288 if (!xmlhttp_ready(xmlhttp)) {
293 var cat = document.getElementById("fadd_cat");
295 if (cat.value.length == 0) {
296 notify("Missing feed category.");
298 notify("Adding feed category...");
300 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
301 param_escape(cat.value), true);
302 xmlhttp.onreadystatechange=feedlist_callback;
312 if (!xmlhttp_ready(xmlhttp)) {
317 var sqlexp = document.getElementById("uadd_box");
319 if (sqlexp.value.length == 0) {
320 notify("Missing user login.");
322 notify("Adding user...");
324 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
325 param_escape(sqlexp.value), true);
327 xmlhttp.onreadystatechange=userlist_callback;
335 function editLabel(id) {
337 if (!xmlhttp_ready(xmlhttp)) {
344 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
345 param_escape(id), true);
346 xmlhttp.onreadystatechange=labellist_callback;
351 function editUser(id) {
353 if (!xmlhttp_ready(xmlhttp)) {
360 xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
361 param_escape(id), true);
362 xmlhttp.onreadystatechange=userlist_callback;
367 function editFilter(id) {
369 if (!xmlhttp_ready(xmlhttp)) {
376 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
377 param_escape(id), true);
378 xmlhttp.onreadystatechange=filterlist_callback;
383 function editFeed(feed) {
385 // notify("Editing feed...");
387 if (!xmlhttp_ready(xmlhttp)) {
394 /* xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
395 param_escape(feed), true);
396 xmlhttp.onreadystatechange=feedlist_callback;
397 xmlhttp.send(null); */
399 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
400 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-'+feed, 'FRCHK-'+feed, true);
402 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
403 param_escape(active_feed), true);
405 xmlhttp.onreadystatechange=infobox_callback;
410 function editFeedCat(cat) {
412 if (!xmlhttp_ready(xmlhttp)) {
417 active_feed_cat = cat;
419 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
420 param_escape(cat), true);
421 xmlhttp.onreadystatechange=feedlist_callback;
426 function getSelectedLabels() {
427 return getSelectedTableRowIds("prefLabelList", "LILRR");
430 function getSelectedUsers() {
431 return getSelectedTableRowIds("prefUserList", "UMRR");
434 function getSelectedFeeds() {
435 return getSelectedTableRowIds("prefFeedList", "FEEDR");
438 function getSelectedFilters() {
439 return getSelectedTableRowIds("prefFilterList", "FILRR");
442 function getSelectedFeedCats() {
443 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
447 function readSelectedFeeds(read) {
449 if (!xmlhttp_ready(xmlhttp)) {
454 var sel_rows = getSelectedFeeds();
456 if (sel_rows.length > 0) {
464 notify("Marking selected feeds as " + op + "...");
466 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=" + op + "&ids="+
467 param_escape(sel_rows.toString()), true);
468 xmlhttp.onreadystatechange=notify_callback;
473 notify("Please select some feeds first.");
478 function removeSelectedLabels() {
480 if (!xmlhttp_ready(xmlhttp)) {
485 var sel_rows = getSelectedLabels();
487 if (sel_rows.length > 0) {
489 var ok = confirm("Remove selected labels?");
492 notify("Removing selected labels...");
494 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
495 param_escape(sel_rows.toString()), true);
496 xmlhttp.onreadystatechange=labellist_callback;
500 notify("Please select some labels first.");
504 function removeSelectedUsers() {
506 if (!xmlhttp_ready(xmlhttp)) {
511 var sel_rows = getSelectedUsers();
513 if (sel_rows.length > 0) {
515 var ok = confirm("Remove selected users?");
518 notify("Removing selected users...");
520 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
521 param_escape(sel_rows.toString()), true);
522 xmlhttp.onreadystatechange=userlist_callback;
527 notify("Please select some labels first.");
531 function removeSelectedFilters() {
533 if (!xmlhttp_ready(xmlhttp)) {
538 var sel_rows = getSelectedFilters();
540 if (sel_rows.length > 0) {
542 var ok = confirm("Remove selected filters?");
545 notify("Removing selected filters...");
547 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
548 param_escape(sel_rows.toString()), true);
549 xmlhttp.onreadystatechange=filterlist_callback;
553 notify("Please select some filters first.");
558 function removeSelectedFeeds() {
560 if (!xmlhttp_ready(xmlhttp)) {
565 var sel_rows = getSelectedFeeds();
567 if (sel_rows.length > 0) {
569 var ok = confirm("Remove selected feeds?");
573 notify("Removing selected feeds...");
575 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
576 param_escape(sel_rows.toString()), true);
577 xmlhttp.onreadystatechange=feedlist_callback;
583 notify("Please select some feeds first.");
589 function removeSelectedFeedCats() {
591 if (!xmlhttp_ready(xmlhttp)) {
596 var sel_rows = getSelectedFeedCats();
598 if (sel_rows.length > 0) {
600 var ok = confirm("Remove selected categories?");
603 notify("Removing selected categories...");
605 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
606 param_escape(sel_rows.toString()), true);
607 xmlhttp.onreadystatechange=feedlist_callback;
613 notify("Please select some feeds first.");
619 function feedEditCancel() {
621 if (!xmlhttp_ready(xmlhttp)) {
630 notify("Operation cancelled.");
632 /* xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
633 xmlhttp.onreadystatechange=feedlist_callback;
634 xmlhttp.send(null); */
638 function feedCatEditCancel() {
640 if (!xmlhttp_ready(xmlhttp)) {
645 active_feed_cat = false;
647 notify("Operation cancelled.");
649 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
650 xmlhttp.onreadystatechange=feedlist_callback;
655 function feedEditSave() {
657 var feed = active_feed;
659 if (!xmlhttp_ready(xmlhttp)) {
664 var link = document.getElementById("iedit_link").value;
665 var title = document.getElementById("iedit_title").value;
666 var upd_intl = document.getElementById("iedit_updintl").value;
667 var purge_intl = document.getElementById("iedit_purgintl").value;
668 var fcat = document.getElementById("iedit_fcat");
670 var fcat_id = fcat[fcat.selectedIndex].id;
672 // notify("Saving feed.");
674 /* if (upd_intl < 0) {
675 notify("Update interval must be >= 0 (0 = default)");
679 if (purge_intl < 0) {
680 notify("Purge days must be >= 0 (0 = default)");
684 if (link.length == 0) {
685 notify("Feed link cannot be blank.");
689 if (title.length == 0) {
690 notify("Feed title cannot be blank.");
696 notify("Saving feed...");
698 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
699 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
700 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
701 "&catid=" + param_escape(fcat_id), true);
702 xmlhttp.onreadystatechange=feedlist_callback;
707 function feedCatEditSave() {
709 if (!xmlhttp_ready(xmlhttp)) {
714 notify("Saving category...");
716 var cat_title = document.getElementById("iedit_title").value;
718 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=saveCat&id=" +
719 param_escape(active_feed_cat) + "&title=" + param_escape(cat_title),
721 xmlhttp.onreadystatechange=feedlist_callback;
724 active_feed_cat = false;
729 function labelTest() {
731 var sqlexp = document.getElementById("iedit_expr").value;
732 var descr = document.getElementById("iedit_descr").value;
734 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
735 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
737 xmlhttp.onreadystatechange=infobox_callback;
742 function displayHelpInfobox(topic_id) {
744 xmlhttp.open("GET", "backend.php?op=help&tid=" +
745 param_escape(topic_id) + "&noheaders=1", true);
747 xmlhttp.onreadystatechange=infobox_callback;
752 function labelEditCancel() {
754 if (!xmlhttp_ready(xmlhttp)) {
759 active_label = false;
761 notify("Operation cancelled.");
763 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
764 xmlhttp.onreadystatechange=labellist_callback;
769 function userEditCancel() {
771 if (!xmlhttp_ready(xmlhttp)) {
778 notify("Operation cancelled.");
780 xmlhttp.open("GET", "backend.php?op=pref-users", true);
781 xmlhttp.onreadystatechange=userlist_callback;
786 function filterEditCancel() {
788 if (!xmlhttp_ready(xmlhttp)) {
793 active_filter = false;
795 notify("Operation cancelled.");
797 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
798 xmlhttp.onreadystatechange=filterlist_callback;
803 function labelEditSave() {
805 var label = active_label;
807 if (!xmlhttp_ready(xmlhttp)) {
812 var sqlexp = document.getElementById("iedit_expr").value;
813 var descr = document.getElementById("iedit_descr").value;
815 // notify("Saving label " + sqlexp + ": " + descr);
817 if (sqlexp.length == 0) {
818 notify("SQL expression cannot be blank.");
822 if (descr.length == 0) {
823 notify("Caption cannot be blank.");
827 notify("Saving label...");
829 active_label = false;
831 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
832 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
835 xmlhttp.onreadystatechange=labellist_callback;
840 function userEditSave() {
842 var user = active_user;
844 if (!xmlhttp_ready(xmlhttp)) {
849 var login = document.getElementById("iedit_ulogin").value;
850 var level = document.getElementById("iedit_ulevel").value;
852 if (login.length == 0) {
853 notify("Login cannot be blank.");
857 if (level.length == 0) {
858 notify("User level cannot be blank.");
864 notify("Saving user...");
866 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
867 user + "&l=" + param_escape(login) + "&al=" + param_escape(level),
870 xmlhttp.onreadystatechange=userlist_callback;
876 function filterEditSave() {
878 var filter = active_filter;
880 if (!xmlhttp_ready(xmlhttp)) {
885 var regexp = document.getElementById("iedit_regexp").value;
886 var descr = document.getElementById("iedit_descr").value;
887 var match = document.getElementById("iedit_match");
889 var v_match = match[match.selectedIndex].text;
891 var feed = document.getElementById("iedit_feed");
892 var feed_id = feed[feed.selectedIndex].id;
894 var action = document.getElementById("iedit_filter_action");
895 var action_id = action[action.selectedIndex].id;
897 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
899 if (regexp.length == 0) {
900 notify("Filter expression cannot be blank.");
904 active_filter = false;
906 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
907 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
908 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id) +
909 "&aid=" + param_escape(action_id), true);
911 notify("Saving filter...");
913 xmlhttp.onreadystatechange=filterlist_callback;
918 function editSelectedLabel() {
919 var rows = getSelectedLabels();
921 if (rows.length == 0) {
922 notify("No labels are selected.");
926 if (rows.length > 1) {
927 notify("Please select one label.");
937 function editSelectedUser() {
938 var rows = getSelectedUsers();
940 if (rows.length == 0) {
941 notify("No users are selected.");
945 if (rows.length > 1) {
946 notify("Please select one user.");
955 function resetSelectedUserPass() {
956 var rows = getSelectedUsers();
958 if (rows.length == 0) {
959 notify("No users are selected.");
963 if (rows.length > 1) {
964 notify("Please select one user.");
968 var ok = confirm("Reset password of selected user?");
971 notify("Resetting password for selected user...");
975 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
976 param_escape(id), true);
977 xmlhttp.onreadystatechange=userlist_callback;
982 function selectedUserDetails() {
984 if (!xmlhttp_ready(xmlhttp)) {
989 var rows = getSelectedUsers();
991 if (rows.length == 0) {
992 notify("No users are selected.");
996 if (rows.length > 1) {
997 notify("Please select one user.");
1005 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
1006 xmlhttp.onreadystatechange=infobox_callback;
1011 function selectedFeedDetails() {
1013 if (!xmlhttp_ready(xmlhttp)) {
1014 printLockingError();
1018 var rows = getSelectedFeeds();
1020 if (rows.length == 0) {
1021 notify("No feeds are selected.");
1025 // if (rows.length > 1) {
1026 // notify("Please select one feed.");
1030 // var id = rows[0];
1034 xmlhttp.open("GET", "backend.php?op=feed-details&id=" +
1035 param_escape(rows.toString()), true);
1036 xmlhttp.onreadystatechange=infobox_callback;
1041 function editSelectedFilter() {
1042 var rows = getSelectedFilters();
1044 if (rows.length == 0) {
1045 notify("No filters are selected.");
1049 if (rows.length > 1) {
1050 notify("Please select one filter.");
1056 editFilter(rows[0]);
1061 function editSelectedFeed() {
1062 var rows = getSelectedFeeds();
1064 if (rows.length == 0) {
1065 notify("No feeds are selected.");
1069 if (rows.length > 1) {
1070 notify("Please select one feed.");
1080 function editSelectedFeedCat() {
1081 var rows = getSelectedFeedCats();
1083 if (rows.length == 0) {
1084 notify("No categories are selected.");
1088 if (rows.length > 1) {
1089 notify("Please select one category.");
1095 editFeedCat(rows[0]);
1099 function localPiggieFunction(enable) {
1101 piggie.style.display = "block";
1103 notify("I loveded it!!!");
1105 piggie.style.display = "none";
1110 function validateOpmlImport() {
1112 var opml_file = document.getElementById("opml_file");
1114 if (opml_file.value.length == 0) {
1115 notify("Please select OPML file to upload.");
1122 function updateFilterList() {
1124 if (!xmlhttp_ready(xmlhttp)) {
1125 printLockingError();
1129 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1131 p_notify("Loading, please wait...");
1133 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1134 xmlhttp.onreadystatechange=filterlist_callback;
1139 function updateLabelList() {
1141 if (!xmlhttp_ready(xmlhttp)) {
1142 printLockingError();
1146 p_notify("Loading, please wait...");
1148 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1150 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1151 xmlhttp.onreadystatechange=labellist_callback;
1155 function updatePrefsList() {
1157 if (!xmlhttp_ready(xmlhttp)) {
1158 printLockingError();
1162 p_notify("Loading, please wait...");
1164 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1165 xmlhttp.onreadystatechange=prefslist_callback;
1170 function selectTab(id) {
1172 if (!xmlhttp_ready(xmlhttp)) {
1173 printLockingError();
1177 if (id == "feedConfig") {
1179 } else if (id == "filterConfig") {
1181 } else if (id == "labelConfig") {
1183 } else if (id == "genConfig") {
1185 } else if (id == "userConfig") {
1189 var tab = document.getElementById(active_tab + "Tab");
1192 if (tab.className.match("Selected")) {
1193 tab.className = "prefsTab";
1197 tab = document.getElementById(id + "Tab");
1200 if (!tab.className.match("Selected")) {
1201 tab.className = tab.className + "Selected";
1207 setCookie('ttrss_pref_acttab', active_tab);
1217 document.getElementById("prefContent").innerHTML =
1218 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1219 "to function properly. Your browser doesn't seem to support it.";
1223 active_tab = getCookie("ttrss_pref_acttab");
1224 if (!active_tab) active_tab = "genConfig";
1225 selectTab(active_tab);
1227 document.onkeydown = hotkey_handler;
1230 exception_error("init", e);
1234 function closeInfoBox() {
1235 var box = document.getElementById('infoBox');
1236 var shadow = document.getElementById('infoBoxShadow');
1239 shadow.style.display = "none";
1241 box.style.display = "none";
1245 function categorizeSelectedFeeds() {
1247 if (!xmlhttp_ready(xmlhttp)) {
1248 printLockingError();
1252 var sel_rows = getSelectedFeeds();
1254 var cat_sel = document.getElementById("sfeed_set_fcat");
1255 var cat_id = cat_sel[cat_sel.selectedIndex].id;
1257 if (sel_rows.length > 0) {
1259 notify("Changing category of selected feeds...");
1261 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1262 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1263 xmlhttp.onreadystatechange=feedlist_callback;
1268 notify("Please select some feeds first.");
1274 function validatePrefsReset() {
1275 return confirm("Reset to defaults?");