2 This program is Copyright (c) 2003-2005 Andrew Dolgov <cthulhoo@gmail.com>
3 Licensed under GPL v.2 or (at your preference) any later version.
8 var active_feed = false;
9 var active_feed_cat = false;
10 var active_filter = false;
11 var active_label = false;
12 var active_user = false;
14 var active_tab = false;
17 /*@if (@_jscript_version >= 5)
18 // JScript gives us Conditional compilation, we can cope with old IE versions.
19 // and security blocked creation of the objects.
21 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
24 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
31 if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
32 xmlhttp = new XMLHttpRequest();
35 function feedlist_callback() {
36 var container = document.getElementById('prefContent');
37 if (xmlhttp.readyState == 4) {
38 container.innerHTML=xmlhttp.responseText;
40 var row = document.getElementById("FEEDR-" + active_feed);
42 if (!row.className.match("Selected")) {
43 row.className = row.className + "Selected";
46 var checkbox = document.getElementById("FRCHK-" + active_feed);
48 checkbox.checked = true;
55 function filterlist_callback() {
56 var container = document.getElementById('prefContent');
57 if (xmlhttp.readyState == 4) {
59 container.innerHTML=xmlhttp.responseText;
62 var row = document.getElementById("FILRR-" + active_filter);
64 if (!row.className.match("Selected")) {
65 row.className = row.className + "Selected";
68 var checkbox = document.getElementById("FICHK-" + active_filter);
71 checkbox.checked = true;
78 function labellist_callback() {
79 var container = document.getElementById('prefContent');
80 if (xmlhttp.readyState == 4) {
81 container.innerHTML=xmlhttp.responseText;
84 var row = document.getElementById("LILRR-" + active_label);
86 if (!row.className.match("Selected")) {
87 row.className = row.className + "Selected";
90 var checkbox = document.getElementById("LICHK-" + active_label);
93 checkbox.checked = true;
100 function userlist_callback() {
101 var container = document.getElementById('prefContent');
102 if (xmlhttp.readyState == 4) {
103 container.innerHTML=xmlhttp.responseText;
106 var row = document.getElementById("UMRR-" + active_user);
108 if (!row.className.match("Selected")) {
109 row.className = row.className + "Selected";
112 var checkbox = document.getElementById("UMCHK-" + active_user);
115 checkbox.checked = true;
123 function infobox_callback() {
124 if (xmlhttp.readyState == 4) {
125 var box = document.getElementById('infoBox');
126 var shadow = document.getElementById('infoBoxShadow');
129 box.innerHTML=xmlhttp.responseText;
131 shadow.style.display = "block";
133 box.style.display = "block";
140 function prefslist_callback() {
141 var container = document.getElementById('prefContent');
142 if (xmlhttp.readyState == 4) {
144 container.innerHTML=xmlhttp.responseText;
150 function gethelp_callback() {
151 var container = document.getElementById('prefHelpBox');
152 if (xmlhttp.readyState == 4) {
154 container.innerHTML = xmlhttp.responseText;
155 container.style.display = "block";
161 function notify_callback() {
162 var container = document.getElementById('notify');
163 if (xmlhttp.readyState == 4) {
164 container.innerHTML=xmlhttp.responseText;
169 function updateFeedList() {
171 if (!xmlhttp_ready(xmlhttp)) {
176 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
178 p_notify("Loading, please wait...");
180 xmlhttp.open("GET", "backend.php?op=pref-feeds", 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 toggleSelectRow(sender) {
204 var parent_row = sender.parentNode.parentNode;
206 if (sender.checked) {
207 if (!parent_row.className.match("Selected")) {
208 parent_row.className = parent_row.className + "Selected";
211 if (parent_row.className.match("Selected")) {
212 parent_row.className = parent_row.className.replace("Selected", "");
217 function addLabel() {
219 if (!xmlhttp_ready(xmlhttp)) {
224 var sqlexp = document.getElementById("ladd_expr");
226 if (sqlexp.value.length == 0) {
227 notify("Missing SQL expression.");
229 notify("Adding label...");
231 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
232 param_escape(sqlexp.value), true);
234 xmlhttp.onreadystatechange=labellist_callback;
242 function addFilter() {
244 if (!xmlhttp_ready(xmlhttp)) {
249 var regexp = document.getElementById("fadd_regexp");
250 var match = document.getElementById("fadd_match");
251 var feed = document.getElementById("fadd_feed");
253 if (regexp.value.length == 0) {
254 notify("Missing filter expression.");
256 notify("Adding filter...");
258 var v_match = match[match.selectedIndex].text;
260 var feed_id = feed[feed.selectedIndex].id;
262 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
263 param_escape(regexp.value) + "&match=" + v_match +
264 "&fid=" + param_escape(feed_id), true);
266 xmlhttp.onreadystatechange=filterlist_callback;
276 if (!xmlhttp_ready(xmlhttp)) {
281 var link = document.getElementById("fadd_link");
283 if (link.value.length == 0) {
284 notify("Missing feed URL.");
286 notify("Adding feed...");
288 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
289 param_escape(link.value), true);
290 xmlhttp.onreadystatechange=feedlist_callback;
299 function addFeedCat() {
301 if (!xmlhttp_ready(xmlhttp)) {
306 var cat = document.getElementById("fadd_cat");
308 if (cat.value.length == 0) {
309 notify("Missing feed category.");
311 notify("Adding feed category...");
313 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
314 param_escape(cat.value), true);
315 xmlhttp.onreadystatechange=feedlist_callback;
325 if (!xmlhttp_ready(xmlhttp)) {
330 var sqlexp = document.getElementById("uadd_box");
332 if (sqlexp.value.length == 0) {
333 notify("Missing user login.");
335 notify("Adding user...");
337 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
338 param_escape(sqlexp.value), true);
340 xmlhttp.onreadystatechange=userlist_callback;
348 function editLabel(id) {
350 if (!xmlhttp_ready(xmlhttp)) {
357 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
358 param_escape(id), true);
359 xmlhttp.onreadystatechange=labellist_callback;
364 function editUser(id) {
366 if (!xmlhttp_ready(xmlhttp)) {
373 xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
374 param_escape(id), true);
375 xmlhttp.onreadystatechange=userlist_callback;
380 function editFilter(id) {
382 if (!xmlhttp_ready(xmlhttp)) {
389 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
390 param_escape(id), true);
391 xmlhttp.onreadystatechange=filterlist_callback;
396 function editFeed(feed) {
398 // notify("Editing feed...");
400 if (!xmlhttp_ready(xmlhttp)) {
407 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
408 param_escape(feed), true);
409 xmlhttp.onreadystatechange=feedlist_callback;
414 function editFeedCat(cat) {
416 if (!xmlhttp_ready(xmlhttp)) {
421 active_feed_cat = cat;
423 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
424 param_escape(cat), true);
425 xmlhttp.onreadystatechange=feedlist_callback;
430 function getSelectedLabels() {
431 return getSelectedTableRowIds("prefLabelList", "LILRR");
434 function getSelectedUsers() {
435 return getSelectedTableRowIds("prefUserList", "UMRR");
438 function getSelectedFeeds() {
439 return getSelectedTableRowIds("prefFeedList", "FEEDR");
442 function getSelectedFilters() {
443 return getSelectedTableRowIds("prefFilterList", "FILRR");
446 function getSelectedFeedCats() {
447 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
451 function readSelectedFeeds() {
453 if (!xmlhttp_ready(xmlhttp)) {
458 var sel_rows = getSelectedFeeds();
460 if (sel_rows.length > 0) {
462 notify("Marking selected feeds as read...");
464 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
465 param_escape(sel_rows.toString()), true);
466 xmlhttp.onreadystatechange=notify_callback;
471 notify("Please select some feeds first.");
476 function unreadSelectedFeeds() {
478 if (!xmlhttp_ready(xmlhttp)) {
483 var sel_rows = getSelectedFeeds();
485 if (sel_rows.length > 0) {
487 notify("Marking selected feeds as unread...");
489 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
490 param_escape(sel_rows.toString()), true);
491 xmlhttp.onreadystatechange=notify_callback;
496 notify("Please select some feeds first.");
501 function removeSelectedLabels() {
503 if (!xmlhttp_ready(xmlhttp)) {
508 var sel_rows = getSelectedLabels();
510 if (sel_rows.length > 0) {
512 notify("Removing selected labels...");
514 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
515 param_escape(sel_rows.toString()), true);
516 xmlhttp.onreadystatechange=labellist_callback;
520 notify("Please select some labels first.");
524 function removeSelectedUsers() {
526 if (!xmlhttp_ready(xmlhttp)) {
531 var sel_rows = getSelectedUsers();
533 if (sel_rows.length > 0) {
535 notify("Removing selected users...");
537 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
538 param_escape(sel_rows.toString()), true);
539 xmlhttp.onreadystatechange=userlist_callback;
543 notify("Please select some labels first.");
547 function removeSelectedFilters() {
549 if (!xmlhttp_ready(xmlhttp)) {
554 var sel_rows = getSelectedFilters();
556 if (sel_rows.length > 0) {
558 notify("Removing selected filters...");
560 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
561 param_escape(sel_rows.toString()), true);
562 xmlhttp.onreadystatechange=filterlist_callback;
566 notify("Please select some filters first.");
571 function removeSelectedFeeds() {
573 if (!xmlhttp_ready(xmlhttp)) {
578 var sel_rows = getSelectedFeeds();
580 if (sel_rows.length > 0) {
582 notify("Removing selected feeds...");
584 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
585 param_escape(sel_rows.toString()), true);
586 xmlhttp.onreadystatechange=feedlist_callback;
591 notify("Please select some feeds first.");
597 function removeSelectedFeedCats() {
599 if (!xmlhttp_ready(xmlhttp)) {
604 var sel_rows = getSelectedFeedCats();
606 if (sel_rows.length > 0) {
608 notify("Removing selected categories...");
610 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
611 param_escape(sel_rows.toString()), true);
612 xmlhttp.onreadystatechange=feedlist_callback;
617 notify("Please select some feeds first.");
623 function feedEditCancel() {
625 if (!xmlhttp_ready(xmlhttp)) {
632 notify("Operation cancelled.");
634 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
635 xmlhttp.onreadystatechange=feedlist_callback;
640 function feedCatEditCancel() {
642 if (!xmlhttp_ready(xmlhttp)) {
647 active_feed_cat = false;
649 notify("Operation cancelled.");
651 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
652 xmlhttp.onreadystatechange=feedlist_callback;
657 function feedEditSave() {
659 var feed = active_feed;
661 if (!xmlhttp_ready(xmlhttp)) {
666 var link = document.getElementById("iedit_link").value;
667 var title = document.getElementById("iedit_title").value;
668 var upd_intl = document.getElementById("iedit_updintl").value;
669 var purge_intl = document.getElementById("iedit_purgintl").value;
670 var fcat = document.getElementById("iedit_fcat");
672 var fcat_id = fcat[fcat.selectedIndex].id;
674 // notify("Saving feed.");
676 /* if (upd_intl < 0) {
677 notify("Update interval must be >= 0 (0 = default)");
681 if (purge_intl < 0) {
682 notify("Purge days must be >= 0 (0 = default)");
686 if (link.length == 0) {
687 notify("Feed link cannot be blank.");
691 if (title.length == 0) {
692 notify("Feed title cannot be blank.");
700 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
701 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
702 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
703 "&catid=" + param_escape(fcat_id), true);
704 xmlhttp.onreadystatechange=feedlist_callback;
709 function labelEditCancel() {
711 if (!xmlhttp_ready(xmlhttp)) {
716 active_label = false;
718 notify("Operation cancelled.");
720 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
721 xmlhttp.onreadystatechange=labellist_callback;
726 function userEditCancel() {
728 if (!xmlhttp_ready(xmlhttp)) {
735 notify("Operation cancelled.");
737 xmlhttp.open("GET", "backend.php?op=pref-users", true);
738 xmlhttp.onreadystatechange=userlist_callback;
743 function filterEditCancel() {
745 if (!xmlhttp_ready(xmlhttp)) {
750 active_filter = false;
752 notify("Operation cancelled.");
754 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
755 xmlhttp.onreadystatechange=filterlist_callback;
760 function labelEditSave() {
762 var label = active_label;
764 if (!xmlhttp_ready(xmlhttp)) {
769 var sqlexp = document.getElementById("iedit_expr").value;
770 var descr = document.getElementById("iedit_descr").value;
772 // notify("Saving label " + sqlexp + ": " + descr);
774 if (sqlexp.length == 0) {
775 notify("SQL expression cannot be blank.");
779 if (descr.length == 0) {
780 notify("Caption cannot be blank.");
786 active_label = false;
788 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
789 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
792 xmlhttp.onreadystatechange=labellist_callback;
797 function userEditSave() {
799 var user = active_user;
801 if (!xmlhttp_ready(xmlhttp)) {
806 var login = document.getElementById("iedit_ulogin").value;
807 var level = document.getElementById("iedit_ulevel").value;
809 if (login.length == 0) {
810 notify("Login cannot be blank.");
814 if (level.length == 0) {
815 notify("User level cannot be blank.");
823 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
824 user + "&l=" + param_escape(login) + "&al=" + param_escape(level),
827 xmlhttp.onreadystatechange=userlist_callback;
833 function filterEditSave() {
835 var filter = active_filter;
837 if (!xmlhttp_ready(xmlhttp)) {
842 var regexp = document.getElementById("iedit_regexp").value;
843 var descr = document.getElementById("iedit_descr").value;
844 var match = document.getElementById("iedit_match");
846 var v_match = match[match.selectedIndex].text;
848 var feed = document.getElementById("iedit_feed");
849 var feed_id = feed[feed.selectedIndex].id;
851 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
853 if (regexp.length == 0) {
854 notify("Filter expression cannot be blank.");
858 active_filter = false;
860 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
861 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
862 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id), true);
866 xmlhttp.onreadystatechange=filterlist_callback;
871 function editSelectedLabel() {
872 var rows = getSelectedLabels();
874 if (rows.length == 0) {
875 notify("No labels are selected.");
879 if (rows.length > 1) {
880 notify("Please select one label.");
890 function editSelectedUser() {
891 var rows = getSelectedUsers();
893 if (rows.length == 0) {
894 notify("No users are selected.");
898 if (rows.length > 1) {
899 notify("Please select one user.");
908 function resetSelectedUserPass() {
909 var rows = getSelectedUsers();
911 if (rows.length == 0) {
912 notify("No users are selected.");
916 if (rows.length > 1) {
917 notify("Please select one user.");
921 notify("Resetting password for selected user...");
925 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
926 param_escape(id), true);
927 xmlhttp.onreadystatechange=userlist_callback;
932 function selectedUserDetails() {
934 if (!xmlhttp_ready(xmlhttp)) {
939 var rows = getSelectedUsers();
941 if (rows.length == 0) {
942 notify("No users are selected.");
946 if (rows.length > 1) {
947 notify("Please select one user.");
955 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
956 xmlhttp.onreadystatechange=infobox_callback;
961 function selectedFeedDetails() {
963 if (!xmlhttp_ready(xmlhttp)) {
968 var rows = getSelectedFeeds();
970 if (rows.length == 0) {
971 notify("No feeds are selected.");
975 if (rows.length > 1) {
976 notify("Please select one feed.");
984 xmlhttp.open("GET", "backend.php?op=feed-details&id=" + id, true);
985 xmlhttp.onreadystatechange=infobox_callback;
990 function editSelectedFilter() {
991 var rows = getSelectedFilters();
993 if (rows.length == 0) {
994 notify("No filters are selected.");
998 if (rows.length > 1) {
999 notify("Please select one filter.");
1005 editFilter(rows[0]);
1010 function editSelectedFeed() {
1011 var rows = getSelectedFeeds();
1013 if (rows.length == 0) {
1014 notify("No feeds are selected.");
1018 if (rows.length > 1) {
1019 notify("Please select one feed.");
1029 function editSelectedFeedCat() {
1030 var rows = getSelectedFeedCats();
1032 if (rows.length == 0) {
1033 notify("No categories are selected.");
1037 if (rows.length > 1) {
1038 notify("Please select one category.");
1044 editFeedCat(rows[0]);
1048 function localPiggieFunction(enable) {
1050 piggie.style.display = "block";
1052 notify("I loveded it!!!");
1054 piggie.style.display = "none";
1059 function validateOpmlImport() {
1061 var opml_file = document.getElementById("opml_file");
1063 if (opml_file.value.length == 0) {
1064 notify("Please select OPML file to upload.");
1071 function updateFilterList() {
1073 if (!xmlhttp_ready(xmlhttp)) {
1074 printLockingError();
1078 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1080 p_notify("Loading, please wait...");
1082 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1083 xmlhttp.onreadystatechange=filterlist_callback;
1088 function updateLabelList() {
1090 if (!xmlhttp_ready(xmlhttp)) {
1091 printLockingError();
1095 p_notify("Loading, please wait...");
1097 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1099 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1100 xmlhttp.onreadystatechange=labellist_callback;
1104 function updatePrefsList() {
1106 if (!xmlhttp_ready(xmlhttp)) {
1107 printLockingError();
1111 p_notify("Loading, please wait...");
1113 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1114 xmlhttp.onreadystatechange=prefslist_callback;
1119 function selectTab(id) {
1121 if (!xmlhttp_ready(xmlhttp)) {
1122 printLockingError();
1126 if (id == "feedConfig") {
1128 } else if (id == "filterConfig") {
1130 } else if (id == "labelConfig") {
1132 } else if (id == "genConfig") {
1134 } else if (id == "userConfig") {
1138 var tab = document.getElementById(active_tab + "Tab");
1141 if (tab.className.match("Selected")) {
1142 tab.className = "prefsTab";
1146 tab = document.getElementById(id + "Tab");
1149 if (!tab.className.match("Selected")) {
1150 tab.className = tab.className + "Selected";
1163 document.getElementById("prefContent").innerHTML =
1164 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1165 "to function properly. Your browser doesn't seem to support it.";
1169 selectTab("genConfig");
1171 document.onkeydown = hotkey_handler;
1177 var help_topic_id = false;
1179 function do_dispOptionHelp() {
1181 if (!xmlhttp_ready(xmlhttp))
1184 xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" +
1185 param_escape(help_topic_id), true);
1186 xmlhttp.onreadystatechange=gethelp_callback;
1191 function dispOptionHelp(event, sender) {
1193 help_topic_id = sender.id;
1195 // document.setTimeout("do_dispOptionHelp()", 100);
1199 function closeInfoBox() {
1200 var box = document.getElementById('infoBox');
1201 var shadow = document.getElementById('infoBoxShadow');
1204 shadow.style.display = "none";
1206 box.style.display = "none";