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 notify("Removing selected labels...");
491 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
492 param_escape(sel_rows.toString()), true);
493 xmlhttp.onreadystatechange=labellist_callback;
497 notify("Please select some labels first.");
501 function removeSelectedUsers() {
503 if (!xmlhttp_ready(xmlhttp)) {
508 var sel_rows = getSelectedUsers();
510 if (sel_rows.length > 0) {
512 notify("Removing selected users...");
514 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
515 param_escape(sel_rows.toString()), true);
516 xmlhttp.onreadystatechange=userlist_callback;
520 notify("Please select some labels first.");
524 function removeSelectedFilters() {
526 if (!xmlhttp_ready(xmlhttp)) {
531 var sel_rows = getSelectedFilters();
533 if (sel_rows.length > 0) {
535 notify("Removing selected filters...");
537 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
538 param_escape(sel_rows.toString()), true);
539 xmlhttp.onreadystatechange=filterlist_callback;
543 notify("Please select some filters first.");
548 function removeSelectedFeeds() {
550 if (!xmlhttp_ready(xmlhttp)) {
555 var sel_rows = getSelectedFeeds();
557 if (sel_rows.length > 0) {
559 notify("Removing selected feeds...");
561 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
562 param_escape(sel_rows.toString()), true);
563 xmlhttp.onreadystatechange=feedlist_callback;
568 notify("Please select some feeds first.");
574 function removeSelectedFeedCats() {
576 if (!xmlhttp_ready(xmlhttp)) {
581 var sel_rows = getSelectedFeedCats();
583 if (sel_rows.length > 0) {
585 notify("Removing selected categories...");
587 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
588 param_escape(sel_rows.toString()), true);
589 xmlhttp.onreadystatechange=feedlist_callback;
594 notify("Please select some feeds first.");
600 function feedEditCancel() {
602 if (!xmlhttp_ready(xmlhttp)) {
611 notify("Operation cancelled.");
613 /* xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
614 xmlhttp.onreadystatechange=feedlist_callback;
615 xmlhttp.send(null); */
619 function feedCatEditCancel() {
621 if (!xmlhttp_ready(xmlhttp)) {
626 active_feed_cat = false;
628 notify("Operation cancelled.");
630 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
631 xmlhttp.onreadystatechange=feedlist_callback;
636 function feedEditSave() {
638 var feed = active_feed;
640 if (!xmlhttp_ready(xmlhttp)) {
645 var link = document.getElementById("iedit_link").value;
646 var title = document.getElementById("iedit_title").value;
647 var upd_intl = document.getElementById("iedit_updintl").value;
648 var purge_intl = document.getElementById("iedit_purgintl").value;
649 var fcat = document.getElementById("iedit_fcat");
651 var fcat_id = fcat[fcat.selectedIndex].id;
653 // notify("Saving feed.");
655 /* if (upd_intl < 0) {
656 notify("Update interval must be >= 0 (0 = default)");
660 if (purge_intl < 0) {
661 notify("Purge days must be >= 0 (0 = default)");
665 if (link.length == 0) {
666 notify("Feed link cannot be blank.");
670 if (title.length == 0) {
671 notify("Feed title cannot be blank.");
679 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
680 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
681 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
682 "&catid=" + param_escape(fcat_id), true);
683 xmlhttp.onreadystatechange=feedlist_callback;
688 function feedCatEditSave() {
690 if (!xmlhttp_ready(xmlhttp)) {
697 var cat_title = document.getElementById("iedit_title").value;
699 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=saveCat&id=" +
700 param_escape(active_feed_cat) + "&title=" + param_escape(cat_title),
702 xmlhttp.onreadystatechange=feedlist_callback;
705 active_feed_cat = false;
710 function labelTest() {
712 var sqlexp = document.getElementById("iedit_expr").value;
713 var descr = document.getElementById("iedit_descr").value;
715 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
716 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
718 xmlhttp.onreadystatechange=infobox_callback;
723 function displayHelpInfobox(topic_id) {
725 xmlhttp.open("GET", "backend.php?op=help&tid=" +
726 param_escape(topic_id) + "&noheaders=1", true);
728 xmlhttp.onreadystatechange=infobox_callback;
733 function labelEditCancel() {
735 if (!xmlhttp_ready(xmlhttp)) {
740 active_label = false;
742 notify("Operation cancelled.");
744 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
745 xmlhttp.onreadystatechange=labellist_callback;
750 function userEditCancel() {
752 if (!xmlhttp_ready(xmlhttp)) {
759 notify("Operation cancelled.");
761 xmlhttp.open("GET", "backend.php?op=pref-users", true);
762 xmlhttp.onreadystatechange=userlist_callback;
767 function filterEditCancel() {
769 if (!xmlhttp_ready(xmlhttp)) {
774 active_filter = false;
776 notify("Operation cancelled.");
778 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
779 xmlhttp.onreadystatechange=filterlist_callback;
784 function labelEditSave() {
786 var label = active_label;
788 if (!xmlhttp_ready(xmlhttp)) {
793 var sqlexp = document.getElementById("iedit_expr").value;
794 var descr = document.getElementById("iedit_descr").value;
796 // notify("Saving label " + sqlexp + ": " + descr);
798 if (sqlexp.length == 0) {
799 notify("SQL expression cannot be blank.");
803 if (descr.length == 0) {
804 notify("Caption cannot be blank.");
810 active_label = false;
812 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
813 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
816 xmlhttp.onreadystatechange=labellist_callback;
821 function userEditSave() {
823 var user = active_user;
825 if (!xmlhttp_ready(xmlhttp)) {
830 var login = document.getElementById("iedit_ulogin").value;
831 var level = document.getElementById("iedit_ulevel").value;
833 if (login.length == 0) {
834 notify("Login cannot be blank.");
838 if (level.length == 0) {
839 notify("User level cannot be blank.");
847 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
848 user + "&l=" + param_escape(login) + "&al=" + param_escape(level),
851 xmlhttp.onreadystatechange=userlist_callback;
857 function filterEditSave() {
859 var filter = active_filter;
861 if (!xmlhttp_ready(xmlhttp)) {
866 var regexp = document.getElementById("iedit_regexp").value;
867 var descr = document.getElementById("iedit_descr").value;
868 var match = document.getElementById("iedit_match");
870 var v_match = match[match.selectedIndex].text;
872 var feed = document.getElementById("iedit_feed");
873 var feed_id = feed[feed.selectedIndex].id;
875 var action = document.getElementById("iedit_filter_action");
876 var action_id = action[action.selectedIndex].id;
878 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
880 if (regexp.length == 0) {
881 notify("Filter expression cannot be blank.");
885 active_filter = false;
887 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
888 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
889 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id) +
890 "&aid=" + param_escape(action_id), true);
894 xmlhttp.onreadystatechange=filterlist_callback;
899 function editSelectedLabel() {
900 var rows = getSelectedLabels();
902 if (rows.length == 0) {
903 notify("No labels are selected.");
907 if (rows.length > 1) {
908 notify("Please select one label.");
918 function editSelectedUser() {
919 var rows = getSelectedUsers();
921 if (rows.length == 0) {
922 notify("No users are selected.");
926 if (rows.length > 1) {
927 notify("Please select one user.");
936 function resetSelectedUserPass() {
937 var rows = getSelectedUsers();
939 if (rows.length == 0) {
940 notify("No users are selected.");
944 if (rows.length > 1) {
945 notify("Please select one user.");
949 notify("Resetting password for selected user...");
953 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
954 param_escape(id), true);
955 xmlhttp.onreadystatechange=userlist_callback;
960 function selectedUserDetails() {
962 if (!xmlhttp_ready(xmlhttp)) {
967 var rows = getSelectedUsers();
969 if (rows.length == 0) {
970 notify("No users are selected.");
974 if (rows.length > 1) {
975 notify("Please select one user.");
983 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
984 xmlhttp.onreadystatechange=infobox_callback;
989 function selectedFeedDetails() {
991 if (!xmlhttp_ready(xmlhttp)) {
996 var rows = getSelectedFeeds();
998 if (rows.length == 0) {
999 notify("No feeds are selected.");
1003 if (rows.length > 1) {
1004 notify("Please select one feed.");
1012 xmlhttp.open("GET", "backend.php?op=feed-details&id=" + id, true);
1013 xmlhttp.onreadystatechange=infobox_callback;
1018 function editSelectedFilter() {
1019 var rows = getSelectedFilters();
1021 if (rows.length == 0) {
1022 notify("No filters are selected.");
1026 if (rows.length > 1) {
1027 notify("Please select one filter.");
1033 editFilter(rows[0]);
1038 function editSelectedFeed() {
1039 var rows = getSelectedFeeds();
1041 if (rows.length == 0) {
1042 notify("No feeds are selected.");
1046 if (rows.length > 1) {
1047 notify("Please select one feed.");
1057 function editSelectedFeedCat() {
1058 var rows = getSelectedFeedCats();
1060 if (rows.length == 0) {
1061 notify("No categories are selected.");
1065 if (rows.length > 1) {
1066 notify("Please select one category.");
1072 editFeedCat(rows[0]);
1076 function localPiggieFunction(enable) {
1078 piggie.style.display = "block";
1080 notify("I loveded it!!!");
1082 piggie.style.display = "none";
1087 function validateOpmlImport() {
1089 var opml_file = document.getElementById("opml_file");
1091 if (opml_file.value.length == 0) {
1092 notify("Please select OPML file to upload.");
1099 function updateFilterList() {
1101 if (!xmlhttp_ready(xmlhttp)) {
1102 printLockingError();
1106 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1108 p_notify("Loading, please wait...");
1110 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1111 xmlhttp.onreadystatechange=filterlist_callback;
1116 function updateLabelList() {
1118 if (!xmlhttp_ready(xmlhttp)) {
1119 printLockingError();
1123 p_notify("Loading, please wait...");
1125 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1127 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1128 xmlhttp.onreadystatechange=labellist_callback;
1132 function updatePrefsList() {
1134 if (!xmlhttp_ready(xmlhttp)) {
1135 printLockingError();
1139 p_notify("Loading, please wait...");
1141 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1142 xmlhttp.onreadystatechange=prefslist_callback;
1147 function selectTab(id) {
1149 if (!xmlhttp_ready(xmlhttp)) {
1150 printLockingError();
1154 if (id == "feedConfig") {
1156 } else if (id == "filterConfig") {
1158 } else if (id == "labelConfig") {
1160 } else if (id == "genConfig") {
1162 } else if (id == "userConfig") {
1166 var tab = document.getElementById(active_tab + "Tab");
1169 if (tab.className.match("Selected")) {
1170 tab.className = "prefsTab";
1174 tab = document.getElementById(id + "Tab");
1177 if (!tab.className.match("Selected")) {
1178 tab.className = tab.className + "Selected";
1192 document.getElementById("prefContent").innerHTML =
1193 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1194 "to function properly. Your browser doesn't seem to support it.";
1198 selectTab("genConfig");
1200 document.onkeydown = hotkey_handler;
1203 exception_error("init", e);
1207 function closeInfoBox() {
1208 var box = document.getElementById('infoBox');
1209 var shadow = document.getElementById('infoBoxShadow');
1212 shadow.style.display = "none";
1214 box.style.display = "none";
1218 function categorizeSelectedFeeds() {
1220 if (!xmlhttp_ready(xmlhttp)) {
1221 printLockingError();
1225 var sel_rows = getSelectedFeeds();
1227 var cat_sel = document.getElementById("sfeed_set_fcat");
1228 var cat_id = cat_sel[cat_sel.selectedIndex].id;
1230 if (sel_rows.length > 0) {
1232 notify("Changing category of selected feeds...");
1234 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1235 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1236 xmlhttp.onreadystatechange=feedlist_callback;
1241 notify("Please select some feeds first.");