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;
401 function editFeedCat(cat) {
403 if (!xmlhttp_ready(xmlhttp)) {
408 active_feed_cat = cat;
410 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
411 param_escape(cat), true);
412 xmlhttp.onreadystatechange=feedlist_callback;
417 function getSelectedLabels() {
418 return getSelectedTableRowIds("prefLabelList", "LILRR");
421 function getSelectedUsers() {
422 return getSelectedTableRowIds("prefUserList", "UMRR");
425 function getSelectedFeeds() {
426 return getSelectedTableRowIds("prefFeedList", "FEEDR");
429 function getSelectedFilters() {
430 return getSelectedTableRowIds("prefFilterList", "FILRR");
433 function getSelectedFeedCats() {
434 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
438 function readSelectedFeeds(read) {
440 if (!xmlhttp_ready(xmlhttp)) {
445 var sel_rows = getSelectedFeeds();
447 if (sel_rows.length > 0) {
455 notify("Marking selected feeds as " + op + "...");
457 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=" + op + "&ids="+
458 param_escape(sel_rows.toString()), true);
459 xmlhttp.onreadystatechange=notify_callback;
464 notify("Please select some feeds first.");
469 function removeSelectedLabels() {
471 if (!xmlhttp_ready(xmlhttp)) {
476 var sel_rows = getSelectedLabels();
478 if (sel_rows.length > 0) {
480 notify("Removing selected labels...");
482 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
483 param_escape(sel_rows.toString()), true);
484 xmlhttp.onreadystatechange=labellist_callback;
488 notify("Please select some labels first.");
492 function removeSelectedUsers() {
494 if (!xmlhttp_ready(xmlhttp)) {
499 var sel_rows = getSelectedUsers();
501 if (sel_rows.length > 0) {
503 notify("Removing selected users...");
505 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
506 param_escape(sel_rows.toString()), true);
507 xmlhttp.onreadystatechange=userlist_callback;
511 notify("Please select some labels first.");
515 function removeSelectedFilters() {
517 if (!xmlhttp_ready(xmlhttp)) {
522 var sel_rows = getSelectedFilters();
524 if (sel_rows.length > 0) {
526 notify("Removing selected filters...");
528 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
529 param_escape(sel_rows.toString()), true);
530 xmlhttp.onreadystatechange=filterlist_callback;
534 notify("Please select some filters first.");
539 function removeSelectedFeeds() {
541 if (!xmlhttp_ready(xmlhttp)) {
546 var sel_rows = getSelectedFeeds();
548 if (sel_rows.length > 0) {
550 notify("Removing selected feeds...");
552 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
553 param_escape(sel_rows.toString()), true);
554 xmlhttp.onreadystatechange=feedlist_callback;
559 notify("Please select some feeds first.");
565 function removeSelectedFeedCats() {
567 if (!xmlhttp_ready(xmlhttp)) {
572 var sel_rows = getSelectedFeedCats();
574 if (sel_rows.length > 0) {
576 notify("Removing selected categories...");
578 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
579 param_escape(sel_rows.toString()), true);
580 xmlhttp.onreadystatechange=feedlist_callback;
585 notify("Please select some feeds first.");
591 function feedEditCancel() {
593 if (!xmlhttp_ready(xmlhttp)) {
600 notify("Operation cancelled.");
602 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
603 xmlhttp.onreadystatechange=feedlist_callback;
608 function feedCatEditCancel() {
610 if (!xmlhttp_ready(xmlhttp)) {
615 active_feed_cat = false;
617 notify("Operation cancelled.");
619 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
620 xmlhttp.onreadystatechange=feedlist_callback;
625 function feedEditSave() {
627 var feed = active_feed;
629 if (!xmlhttp_ready(xmlhttp)) {
634 var link = document.getElementById("iedit_link").value;
635 var title = document.getElementById("iedit_title").value;
636 var upd_intl = document.getElementById("iedit_updintl").value;
637 var purge_intl = document.getElementById("iedit_purgintl").value;
638 var fcat = document.getElementById("iedit_fcat");
640 var fcat_id = fcat[fcat.selectedIndex].id;
642 // notify("Saving feed.");
644 /* if (upd_intl < 0) {
645 notify("Update interval must be >= 0 (0 = default)");
649 if (purge_intl < 0) {
650 notify("Purge days must be >= 0 (0 = default)");
654 if (link.length == 0) {
655 notify("Feed link cannot be blank.");
659 if (title.length == 0) {
660 notify("Feed title cannot be blank.");
668 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
669 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
670 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
671 "&catid=" + param_escape(fcat_id), true);
672 xmlhttp.onreadystatechange=feedlist_callback;
677 function labelTest() {
679 var sqlexp = document.getElementById("iedit_expr").value;
680 var descr = document.getElementById("iedit_descr").value;
682 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
683 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
685 xmlhttp.onreadystatechange=infobox_callback;
690 function displayHelpInfobox(topic_id) {
692 xmlhttp.open("GET", "backend.php?op=help&tid=" +
693 param_escape(topic_id) + "&noheaders=1", true);
695 xmlhttp.onreadystatechange=infobox_callback;
700 function labelEditCancel() {
702 if (!xmlhttp_ready(xmlhttp)) {
707 active_label = false;
709 notify("Operation cancelled.");
711 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
712 xmlhttp.onreadystatechange=labellist_callback;
717 function userEditCancel() {
719 if (!xmlhttp_ready(xmlhttp)) {
726 notify("Operation cancelled.");
728 xmlhttp.open("GET", "backend.php?op=pref-users", true);
729 xmlhttp.onreadystatechange=userlist_callback;
734 function filterEditCancel() {
736 if (!xmlhttp_ready(xmlhttp)) {
741 active_filter = false;
743 notify("Operation cancelled.");
745 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
746 xmlhttp.onreadystatechange=filterlist_callback;
751 function labelEditSave() {
753 var label = active_label;
755 if (!xmlhttp_ready(xmlhttp)) {
760 var sqlexp = document.getElementById("iedit_expr").value;
761 var descr = document.getElementById("iedit_descr").value;
763 // notify("Saving label " + sqlexp + ": " + descr);
765 if (sqlexp.length == 0) {
766 notify("SQL expression cannot be blank.");
770 if (descr.length == 0) {
771 notify("Caption cannot be blank.");
777 active_label = false;
779 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
780 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
783 xmlhttp.onreadystatechange=labellist_callback;
788 function userEditSave() {
790 var user = active_user;
792 if (!xmlhttp_ready(xmlhttp)) {
797 var login = document.getElementById("iedit_ulogin").value;
798 var level = document.getElementById("iedit_ulevel").value;
800 if (login.length == 0) {
801 notify("Login cannot be blank.");
805 if (level.length == 0) {
806 notify("User level cannot be blank.");
814 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
815 user + "&l=" + param_escape(login) + "&al=" + param_escape(level),
818 xmlhttp.onreadystatechange=userlist_callback;
824 function filterEditSave() {
826 var filter = active_filter;
828 if (!xmlhttp_ready(xmlhttp)) {
833 var regexp = document.getElementById("iedit_regexp").value;
834 var descr = document.getElementById("iedit_descr").value;
835 var match = document.getElementById("iedit_match");
837 var v_match = match[match.selectedIndex].text;
839 var feed = document.getElementById("iedit_feed");
840 var feed_id = feed[feed.selectedIndex].id;
842 var action = document.getElementById("iedit_filter_action");
843 var action_id = action[action.selectedIndex].id;
845 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
847 if (regexp.length == 0) {
848 notify("Filter expression cannot be blank.");
852 active_filter = false;
854 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
855 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
856 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id) +
857 "&aid=" + param_escape(action_id), true);
861 xmlhttp.onreadystatechange=filterlist_callback;
866 function editSelectedLabel() {
867 var rows = getSelectedLabels();
869 if (rows.length == 0) {
870 notify("No labels are selected.");
874 if (rows.length > 1) {
875 notify("Please select one label.");
885 function editSelectedUser() {
886 var rows = getSelectedUsers();
888 if (rows.length == 0) {
889 notify("No users are selected.");
893 if (rows.length > 1) {
894 notify("Please select one user.");
903 function resetSelectedUserPass() {
904 var rows = getSelectedUsers();
906 if (rows.length == 0) {
907 notify("No users are selected.");
911 if (rows.length > 1) {
912 notify("Please select one user.");
916 notify("Resetting password for selected user...");
920 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
921 param_escape(id), true);
922 xmlhttp.onreadystatechange=userlist_callback;
927 function selectedUserDetails() {
929 if (!xmlhttp_ready(xmlhttp)) {
934 var rows = getSelectedUsers();
936 if (rows.length == 0) {
937 notify("No users are selected.");
941 if (rows.length > 1) {
942 notify("Please select one user.");
950 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
951 xmlhttp.onreadystatechange=infobox_callback;
956 function selectedFeedDetails() {
958 if (!xmlhttp_ready(xmlhttp)) {
963 var rows = getSelectedFeeds();
965 if (rows.length == 0) {
966 notify("No feeds are selected.");
970 if (rows.length > 1) {
971 notify("Please select one feed.");
979 xmlhttp.open("GET", "backend.php?op=feed-details&id=" + id, true);
980 xmlhttp.onreadystatechange=infobox_callback;
985 function editSelectedFilter() {
986 var rows = getSelectedFilters();
988 if (rows.length == 0) {
989 notify("No filters are selected.");
993 if (rows.length > 1) {
994 notify("Please select one filter.");
1000 editFilter(rows[0]);
1005 function editSelectedFeed() {
1006 var rows = getSelectedFeeds();
1008 if (rows.length == 0) {
1009 notify("No feeds are selected.");
1013 if (rows.length > 1) {
1014 notify("Please select one feed.");
1024 function editSelectedFeedCat() {
1025 var rows = getSelectedFeedCats();
1027 if (rows.length == 0) {
1028 notify("No categories are selected.");
1032 if (rows.length > 1) {
1033 notify("Please select one category.");
1039 editFeedCat(rows[0]);
1043 function localPiggieFunction(enable) {
1045 piggie.style.display = "block";
1047 notify("I loveded it!!!");
1049 piggie.style.display = "none";
1054 function validateOpmlImport() {
1056 var opml_file = document.getElementById("opml_file");
1058 if (opml_file.value.length == 0) {
1059 notify("Please select OPML file to upload.");
1066 function updateFilterList() {
1068 if (!xmlhttp_ready(xmlhttp)) {
1069 printLockingError();
1073 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1075 p_notify("Loading, please wait...");
1077 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1078 xmlhttp.onreadystatechange=filterlist_callback;
1083 function updateLabelList() {
1085 if (!xmlhttp_ready(xmlhttp)) {
1086 printLockingError();
1090 p_notify("Loading, please wait...");
1092 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1094 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1095 xmlhttp.onreadystatechange=labellist_callback;
1099 function updatePrefsList() {
1101 if (!xmlhttp_ready(xmlhttp)) {
1102 printLockingError();
1106 p_notify("Loading, please wait...");
1108 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1109 xmlhttp.onreadystatechange=prefslist_callback;
1114 function selectTab(id) {
1116 if (!xmlhttp_ready(xmlhttp)) {
1117 printLockingError();
1121 if (id == "feedConfig") {
1123 } else if (id == "filterConfig") {
1125 } else if (id == "labelConfig") {
1127 } else if (id == "genConfig") {
1129 } else if (id == "userConfig") {
1133 var tab = document.getElementById(active_tab + "Tab");
1136 if (tab.className.match("Selected")) {
1137 tab.className = "prefsTab";
1141 tab = document.getElementById(id + "Tab");
1144 if (!tab.className.match("Selected")) {
1145 tab.className = tab.className + "Selected";
1159 document.getElementById("prefContent").innerHTML =
1160 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1161 "to function properly. Your browser doesn't seem to support it.";
1165 selectTab("genConfig");
1167 document.onkeydown = hotkey_handler;
1170 exception_error("init", e);
1174 function closeInfoBox() {
1175 var box = document.getElementById('infoBox');
1176 var shadow = document.getElementById('infoBoxShadow');
1179 shadow.style.display = "none";
1181 box.style.display = "none";
1185 function categorizeSelectedFeeds() {
1187 if (!xmlhttp_ready(xmlhttp)) {
1188 printLockingError();
1192 var sel_rows = getSelectedFeeds();
1194 var cat_sel = document.getElementById("sfeed_set_fcat");
1195 var cat_id = cat_sel[cat_sel.selectedIndex].id;
1197 if (sel_rows.length > 0) {
1199 notify("Changing category of selected feeds...");
1201 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1202 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1203 xmlhttp.onreadystatechange=feedlist_callback;
1208 notify("Please select some feeds first.");