3 var active_feed_cat
= false;
4 var active_label
= false;
5 var active_tab
= false;
6 var feed_to_expand
= false;
11 var xmlhttp
= Ajax
.getTransport();
13 var init_params
= new Array();
15 function expand_feed_callback() {
16 if (xmlhttp
.readyState
== 4) {
18 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
19 container
.innerHTML
=xmlhttp
.responseText
;
20 container
.style
.display
= "block";
23 exception_error("expand_feed_callback", e
);
28 function feedlist_callback() {
29 if (xmlhttp
.readyState
== 4) {
31 var container
= document
.getElementById('prefContent');
32 container
.innerHTML
=xmlhttp
.responseText
;
33 selectTab("feedConfig", true);
35 if (active_feed_cat
) {
36 var row
= document
.getElementById("FCATR-" + active_feed_cat
);
38 if (!row
.className
.match("Selected")) {
39 row
.className
= row
.className
+ "Selected";
42 var checkbox
= document
.getElementById("FCCHK-" + active_feed_cat
);
44 checkbox
.checked
= true;
50 exception_error("feedlist_callback", e
);
55 function filterlist_callback() {
56 var container
= document
.getElementById('prefContent');
57 if (xmlhttp
.readyState
== 4) {
58 container
.innerHTML
=xmlhttp
.responseText
;
63 function labellist_callback() {
64 var container
= document
.getElementById('prefContent');
65 if (xmlhttp
.readyState
== 4) {
66 container
.innerHTML
=xmlhttp
.responseText
;
69 var row
= document
.getElementById("LILRR-" + active_label
);
71 if (!row
.className
.match("Selected")) {
72 row
.className
= row
.className
+ "Selected";
75 var checkbox
= document
.getElementById("LICHK-" + active_label
);
78 checkbox
.checked
= true;
85 function labeltest_callback() {
86 var container
= document
.getElementById('label_test_result');
87 if (xmlhttp
.readyState
== 4) {
88 container
.innerHTML
=xmlhttp
.responseText
;
93 function feed_browser_callback() {
94 var container
= document
.getElementById('prefContent');
95 if (xmlhttp
.readyState
== 4) {
96 container
.innerHTML
=xmlhttp
.responseText
;
101 function userlist_callback() {
102 var container
= document
.getElementById('prefContent');
103 if (xmlhttp
.readyState
== 4) {
104 container
.innerHTML
=xmlhttp
.responseText
;
109 function prefslist_callback() {
110 var container
= document
.getElementById('prefContent');
111 if (xmlhttp
.readyState
== 4) {
113 container
.innerHTML
=xmlhttp
.responseText
;
119 function gethelp_callback() {
120 var container
= document
.getElementById('prefHelpBox');
121 if (xmlhttp
.readyState
== 4) {
123 container
.innerHTML
= xmlhttp
.responseText
;
124 container
.style
.display
= "block";
130 function notify_callback() {
131 var container
= document
.getElementById('notify');
132 if (xmlhttp
.readyState
== 4) {
133 container
.innerHTML
=xmlhttp
.responseText
;
137 function updateFeedList(sort_key
) {
139 if (!xmlhttp_ready(xmlhttp
)) {
144 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
146 // p_notify("Loading, please wait...");
148 var feed_search
= document
.getElementById("feed_search");
150 if (feed_search
) { search
= feed_search
.value
; }
152 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
153 "&sort=" + param_escape(sort_key
) +
154 "&search=" + param_escape(search
), true);
155 xmlhttp
.onreadystatechange
=feedlist_callback
;
160 function updateUsersList() {
162 if (!xmlhttp_ready(xmlhttp
)) {
167 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
169 // p_notify("Loading, please wait...");
171 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
172 xmlhttp
.onreadystatechange
=userlist_callback
;
177 function addLabel() {
179 if (!xmlhttp_ready(xmlhttp
)) {
184 var sqlexp
= document
.getElementById("ladd_expr");
186 if (sqlexp
.value
.length
== 0) {
187 alert("Can't add label: missing SQL expression.");
189 notify("Adding label...");
191 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
192 param_escape(sqlexp
.value
), true);
194 xmlhttp
.onreadystatechange
=labellist_callback
;
202 function addFilter() {
204 if (!xmlhttp_ready(xmlhttp
)) {
209 var regexp
= document
.getElementById("fadd_regexp");
210 var match
= document
.getElementById("fadd_match");
211 var feed
= document
.getElementById("fadd_feed");
212 var action
= document
.getElementById("fadd_action");
214 if (regexp
.value
.length
== 0) {
215 alert("Can't add filter: missing filter expression.");
217 notify("Adding filter...");
219 var v_match
= match
[match
.selectedIndex
].text
;
220 var feed_id
= feed
[feed
.selectedIndex
].id
;
221 var action_id
= action
[action
.selectedIndex
].id
;
223 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
224 param_escape(regexp
.value
) + "&match=" + v_match
+
225 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
227 xmlhttp
.onreadystatechange
=filterlist_callback
;
237 if (!xmlhttp_ready(xmlhttp
)) {
242 var link
= document
.getElementById("fadd_link");
244 if (link
.value
.length
== 0) {
245 alert("Error: No feed URL given.");
246 } else if (!isValidURL(link
.value
)) {
247 alert("Error: Invalid feed URL.");
249 notify("Adding feed...");
251 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&feed_url=" +
252 param_escape(link
.value
), true);
253 xmlhttp
.onreadystatechange
=feedlist_callback
;
262 function addFeedCat() {
264 if (!xmlhttp_ready(xmlhttp
)) {
269 var cat
= document
.getElementById("fadd_cat");
271 if (cat
.value
.length
== 0) {
272 alert("Can't add category: no name specified.");
274 notify("Adding feed category...");
276 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
277 param_escape(cat
.value
), true);
278 xmlhttp
.onreadystatechange
=feedlist_callback
;
288 if (!xmlhttp_ready(xmlhttp
)) {
293 var sqlexp
= document
.getElementById("uadd_box");
295 if (sqlexp
.value
.length
== 0) {
296 alert("Can't add user: no login specified.");
298 notify("Adding user...");
300 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
301 param_escape(sqlexp
.value
), true);
303 xmlhttp
.onreadystatechange
=userlist_callback
;
311 function editLabel(id
) {
313 if (!xmlhttp_ready(xmlhttp
)) {
320 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
321 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
323 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
324 param_escape(id
), true);
325 xmlhttp
.onreadystatechange
=infobox_callback
;
330 function editUser(id
) {
332 if (!xmlhttp_ready(xmlhttp
)) {
337 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
338 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
340 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
341 param_escape(id
), true);
342 xmlhttp
.onreadystatechange
=infobox_callback
;
347 function editFilter(id
) {
349 if (!xmlhttp_ready(xmlhttp
)) {
354 document
.getElementById("create_filter_btn").disabled
= true;
356 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
357 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
359 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
360 xmlhttp
.onreadystatechange
=infobox_callback
;
364 function editFeed(feed
) {
366 // notify("Editing feed...");
368 if (!xmlhttp_ready(xmlhttp
)) {
373 // clean selection from all rows & select row being edited
374 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
375 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
377 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
378 param_escape(feed
), true);
380 xmlhttp
.onreadystatechange
=infobox_callback
;
385 function editFeedCat(cat
) {
387 if (!xmlhttp_ready(xmlhttp
)) {
392 active_feed_cat
= cat
;
394 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
395 param_escape(cat
), true);
396 xmlhttp
.onreadystatechange
=feedlist_callback
;
401 function getSelectedLabels() {
402 return getSelectedTableRowIds("prefLabelList", "LILRR");
405 function getSelectedUsers() {
406 return getSelectedTableRowIds("prefUserList", "UMRR");
409 function getSelectedFeeds() {
410 return getSelectedTableRowIds("prefFeedList", "FEEDR");
413 function getSelectedFilters() {
414 return getSelectedTableRowIds("prefFilterList", "FILRR");
417 function getSelectedFeedCats() {
418 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
421 function getSelectedFeedsFromBrowser() {
423 var list
= document
.getElementById("browseFeedList");
424 if (!list
) list
= document
.getElementById("browseBigFeedList");
426 var selected
= new Array();
428 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
429 var child
= list
.childNodes
[i
];
430 if (child
.id
&& child
.id
.match("FBROW-")) {
431 var id
= child
.id
.replace("FBROW-", "");
433 var cb
= document
.getElementById("FBCHK-" + id
);
444 function removeSelectedLabels() {
446 if (!xmlhttp_ready(xmlhttp
)) {
451 var sel_rows
= getSelectedLabels();
453 if (sel_rows
.length
> 0) {
455 var ok
= confirm("Remove selected labels?");
458 notify("Removing selected labels...");
460 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
461 param_escape(sel_rows
.toString()), true);
462 xmlhttp
.onreadystatechange
=labellist_callback
;
466 alert("No labels are selected.");
472 function removeSelectedUsers() {
474 if (!xmlhttp_ready(xmlhttp
)) {
479 var sel_rows
= getSelectedUsers();
481 if (sel_rows
.length
> 0) {
483 var ok
= confirm("Remove selected users?");
486 notify("Removing selected users...");
488 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
489 param_escape(sel_rows
.toString()), true);
490 xmlhttp
.onreadystatechange
=userlist_callback
;
495 alert("No users are selected.");
501 function removeSelectedFilters() {
503 if (!xmlhttp_ready(xmlhttp
)) {
508 var sel_rows
= getSelectedFilters();
510 if (sel_rows
.length
> 0) {
512 var ok
= confirm("Remove selected filters?");
515 notify("Removing selected filters...");
517 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
518 param_escape(sel_rows
.toString()), true);
519 xmlhttp
.onreadystatechange
=filterlist_callback
;
523 alert("No filters are selected.");
530 function removeSelectedFeeds() {
532 if (!xmlhttp_ready(xmlhttp
)) {
537 var sel_rows
= getSelectedFeeds();
539 if (sel_rows
.length
> 0) {
541 var ok
= confirm("Unsubscribe from selected feeds?");
545 notify("Unsubscribing from selected feeds...");
547 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
548 param_escape(sel_rows
.toString()), true);
549 xmlhttp
.onreadystatechange
=feedlist_callback
;
555 alert("No feeds are selected.");
562 function removeSelectedFeedCats() {
564 if (!xmlhttp_ready(xmlhttp
)) {
569 var sel_rows
= getSelectedFeedCats();
571 if (sel_rows
.length
> 0) {
573 var ok
= confirm("Remove selected categories?");
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
;
586 alert("No categories are selected.");
593 function feedEditCancel() {
595 if (!xmlhttp_ready(xmlhttp
)) {
602 selectPrefRows('feed', false); // cleanup feed selection
607 function feedCatEditCancel() {
609 if (!xmlhttp_ready(xmlhttp
)) {
614 active_feed_cat
= false;
616 // notify("Operation cancelled.");
618 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
619 xmlhttp
.onreadystatechange
=feedlist_callback
;
625 function feedEditSave() {
629 if (!xmlhttp_ready(xmlhttp
)) {
634 // FIXME: add parameter validation
636 var query
= Form
.serialize("edit_feed_form");
638 notify("Saving feed...");
640 xmlhttp
.open("POST", "backend.php", true);
641 xmlhttp
.onreadystatechange
=feedlist_callback
;
642 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
650 exception_error("feedEditSave", e
);
654 function feedCatEditSave() {
656 if (!xmlhttp_ready(xmlhttp
)) {
661 notify("Saving category...");
663 var query
= Form
.serialize("feed_cat_edit_form");
665 xmlhttp
.open("GET", "backend.php?" + query
, true);
666 xmlhttp
.onreadystatechange
=feedlist_callback
;
669 active_feed_cat
= false;
675 function labelTest() {
677 var container
= document
.getElementById('label_test_result');
678 container
.style
.display
= "block";
679 container
.innerHTML
= "<p>Loading, please wait...</p>";
681 var form
= document
.forms
['label_edit_form'];
683 var sql_exp
= form
.sql_exp
.value
;
684 var description
= form
.description
.value
;
686 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
687 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
689 xmlhttp
.onreadystatechange
=labeltest_callback
;
695 function displayHelpInfobox(topic_id
) {
697 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
698 param_escape(topic_id
) + "&noheaders=1", true);
700 xmlhttp
.onreadystatechange
=infobox_callback
;
705 function labelEditCancel() {
707 if (!xmlhttp_ready(xmlhttp
)) {
712 active_label
= false;
714 selectPrefRows('label', false); // cleanup feed selection
720 function userEditCancel() {
722 if (!xmlhttp_ready(xmlhttp
)) {
727 selectPrefRows('user', false); // cleanup feed selection
733 function filterEditCancel() {
735 if (!xmlhttp_ready(xmlhttp
)) {
740 document
.getElementById("create_filter_btn").disabled
= false;
742 selectPrefRows('filter', false); // cleanup feed selection
748 function labelEditSave() {
750 var label
= active_label
;
752 if (!xmlhttp_ready(xmlhttp
)) {
757 var sql_exp
= document
.forms
["label_edit_form"].sql_exp
.value
;
758 var description
= document
.forms
["label_edit_form"].description
.value
;
760 if (sql_exp
.length
== 0) {
761 alert("SQL Expression cannot be blank.");
765 if (description
.length
== 0) {
766 alert("Caption field cannot be blank.");
772 notify("Saving label...");
774 active_label
= false;
776 query
= Form
.serialize("label_edit_form");
778 xmlhttp
.open("GET", "backend.php?" + query
, true);
779 xmlhttp
.onreadystatechange
=labellist_callback
;
785 function userEditSave() {
787 if (!xmlhttp_ready(xmlhttp
)) {
792 var login
= document
.forms
["user_edit_form"].login
.value
;
794 if (login
.length
== 0) {
795 alert("Login field cannot be blank.");
799 notify("Saving user...");
803 var query
= Form
.serialize("user_edit_form");
805 xmlhttp
.open("GET", "backend.php?" + query
, true);
806 xmlhttp
.onreadystatechange
=userlist_callback
;
813 function filterEditSave() {
815 if (!xmlhttp_ready(xmlhttp
)) {
820 var reg_exp
= document
.forms
["filter_edit_form"].reg_exp
.value
;
822 if (reg_exp
.length
== 0) {
823 alert("Filter expression field cannot be blank.");
827 notify("Saving filter...");
829 var query
= Form
.serialize("filter_edit_form");
833 document
.getElementById("create_filter_btn").disabled
= false;
835 xmlhttp
.open("GET", "backend.php?" + query
, true);
836 xmlhttp
.onreadystatechange
=filterlist_callback
;
842 function editSelectedLabel() {
843 var rows
= getSelectedLabels();
845 if (rows
.length
== 0) {
846 alert("No labels are selected.");
850 if (rows
.length
> 1) {
851 alert("Please select only one label.");
861 function editSelectedUser() {
862 var rows
= getSelectedUsers();
864 if (rows
.length
== 0) {
865 alert("No users are selected.");
869 if (rows
.length
> 1) {
870 alert("Please select only one user.");
879 function resetSelectedUserPass() {
880 var rows
= getSelectedUsers();
882 if (rows
.length
== 0) {
883 alert("No users are selected.");
887 if (rows
.length
> 1) {
888 alert("Please select only one user.");
892 var ok
= confirm("Reset password of selected user?");
895 notify("Resetting password for selected user...");
899 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
900 param_escape(id
), true);
901 xmlhttp
.onreadystatechange
=userlist_callback
;
906 function selectedUserDetails() {
908 if (!xmlhttp_ready(xmlhttp
)) {
913 var rows
= getSelectedUsers();
915 if (rows
.length
== 0) {
916 alert("No users are selected.");
920 if (rows
.length
> 1) {
921 alert("Please select only one user.");
929 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
930 xmlhttp
.onreadystatechange
=infobox_callback
;
935 function selectedFeedDetails() {
937 if (!xmlhttp_ready(xmlhttp
)) {
942 var rows
= getSelectedFeeds();
944 if (rows
.length
== 0) {
945 alert("No feeds are selected.");
949 if (rows
.length
> 1) {
950 notify("Please select only one feed.");
958 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
959 param_escape(rows
.toString()), true);
960 xmlhttp
.onreadystatechange
=infobox_callback
;
965 function editSelectedFilter() {
966 var rows
= getSelectedFilters();
968 if (rows
.length
== 0) {
969 alert("No filters are selected.");
973 if (rows
.length
> 1) {
974 alert("Please select only one filter.");
985 function editSelectedFeed() {
986 var rows
= getSelectedFeeds();
988 if (rows
.length
== 0) {
989 notify("No feeds are selected.");
993 if (rows
.length
> 1) {
994 notify("Please select one feed.");
1004 function editSelectedFeedCat() {
1005 var rows
= getSelectedFeedCats();
1007 if (rows
.length
== 0) {
1008 alert("No categories are selected.");
1012 if (rows
.length
> 1) {
1013 alert("Please select only one category.");
1019 editFeedCat(rows
[0]);
1023 function piggie_callback() {
1024 var piggie
= document
.getElementById("piggie");
1026 piggie
.style
.top
= piggie_top
;
1027 piggie
.style
.backgroundColor
= "white";
1028 piggie
.style
.borderWidth
= "1px";
1030 if (piggie_fwd
&& piggie_top
< 0) {
1031 setTimeout("piggie_callback()", 50);
1032 piggie_top
= piggie_top
+ 10;
1033 } else if (piggie_fwd
&& piggie_top
>= 0) {
1035 setTimeout("piggie_callback()", 50);
1036 } else if (!piggie_fwd
&& piggie_top
> -400) {
1037 setTimeout("piggie_callback()", 50);
1038 piggie_top
= piggie_top
- 10;
1039 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1040 piggie
.style
.display
= "none";
1045 var piggie_opacity
= 0;
1047 function piggie2_callback() {
1048 var piggie
= document
.getElementById("piggie");
1049 piggie
.style
.top
= 0;
1050 piggie
.style
.opacity
= piggie_opacity
;
1051 piggie
.style
.backgroundColor
= "transparent";
1052 piggie
.style
.borderWidth
= "0px";
1054 if (piggie_fwd
&& piggie_opacity
< 1) {
1055 setTimeout("piggie2_callback()", 50);
1056 piggie_opacity
= piggie_opacity
+ 0.03;
1057 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1059 setTimeout("piggie2_callback()", 50);
1060 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1061 setTimeout("piggie2_callback()", 50);
1062 piggie_opacity
= piggie_opacity
- 0.03;
1063 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1064 piggie
.style
.display
= "none";
1069 function localPiggieFunction(enable
) {
1071 debug("I LOVEDED IT!");
1072 var piggie
= document
.getElementById("piggie");
1073 piggie
.style
.display
= "block";
1075 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1083 function validateOpmlImport() {
1085 var opml_file
= document
.getElementById("opml_file");
1087 if (opml_file
.value
.length
== 0) {
1088 alert("No OPML file to upload.");
1095 function updateFilterList() {
1097 if (!xmlhttp_ready(xmlhttp
)) {
1098 printLockingError();
1102 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1104 // p_notify("Loading, please wait...");
1106 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
1107 xmlhttp
.onreadystatechange
=filterlist_callback
;
1112 function updateLabelList() {
1114 if (!xmlhttp_ready(xmlhttp
)) {
1115 printLockingError();
1119 // p_notify("Loading, please wait...");
1121 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1123 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
1124 xmlhttp
.onreadystatechange
=labellist_callback
;
1128 function updatePrefsList() {
1130 if (!xmlhttp_ready(xmlhttp
)) {
1131 printLockingError();
1135 // p_notify("Loading, please wait...");
1137 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1138 xmlhttp
.onreadystatechange
=prefslist_callback
;
1143 function selectTab(id
, noupdate
) {
1147 if (!id
) id
= active_tab
;
1151 if (!xmlhttp_ready(xmlhttp
)) {
1152 printLockingError();
1158 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1160 notify("Loading, please wait...", true);
1162 // close active infobox if needed
1165 // clean up all current selections, just in case
1166 active_feed_cat
= false;
1167 active_label
= false;
1169 if (id
== "feedConfig") {
1171 } else if (id
== "filterConfig") {
1173 } else if (id
== "labelConfig") {
1175 } else if (id
== "genConfig") {
1177 } else if (id
== "userConfig") {
1179 } else if (id
== "feedBrowser") {
1180 updateBigFeedBrowser();
1184 var tab
= document
.getElementById(active_tab
+ "Tab");
1187 if (tab
.className
.match("Selected")) {
1188 tab
.className
= "prefsTab";
1192 tab
= document
.getElementById(id
+ "Tab");
1195 if (!tab
.className
.match("Selected")) {
1196 tab
.className
= tab
.className
+ "Selected";
1200 if (active_tab
!= id
) {
1201 storeInitParam("prefs_active_tab", id
);
1207 exception_error("selectTab", e
);
1211 function backend_sanity_check_callback() {
1213 if (xmlhttp
.readyState
== 4) {
1217 if (!xmlhttp
.responseXML
) {
1218 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1222 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1225 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1229 var error_code
= reply
.getAttribute("error-code");
1231 if (error_code
&& error_code
!= 0) {
1232 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1235 debug("sanity check ok");
1237 var params
= reply
.nextSibling
;
1240 debug('reading init-params...');
1241 var param
= params
.firstChild
;
1244 var k
= param
.getAttribute("key");
1245 var v
= param
.getAttribute("value");
1246 debug(k
+ " => " + v
);
1248 param
= param
.nextSibling
;
1252 init_second_stage();
1255 exception_error("backend_sanity_check_callback", e
);
1260 function init_second_stage() {
1263 active_tab
= getInitParam("prefs_active_tab");
1264 if (!active_tab
) active_tab
= "genConfig";
1266 document
.onkeydown
= pref_hotkey_handler
;
1268 if (navigator
.userAgent
.match("Opera")) {
1269 setTimeout("selectTab()", 500);
1271 selectTab(active_tab
);
1275 exception_error("init_second_stage", e
);
1283 if (arguments
.callee
.done
) return;
1284 arguments
.callee
.done
= true;
1286 if (getURLParam('debug')) {
1287 document
.getElementById('debug_output').style
.display
= 'block';
1288 debug('debug mode activated');
1293 document
.getElementById("prefContent").innerHTML
=
1294 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1295 "to function properly. Your browser doesn't seem to support it.";
1299 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1300 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1304 exception_error("init", e
);
1308 function categorizeSelectedFeeds() {
1310 if (!xmlhttp_ready(xmlhttp
)) {
1311 printLockingError();
1315 var sel_rows
= getSelectedFeeds();
1317 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1318 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1320 if (sel_rows
.length
> 0) {
1322 notify("Changing category of selected feeds...");
1324 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1325 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1326 xmlhttp
.onreadystatechange
=feedlist_callback
;
1331 alert("No feeds are selected.");
1337 function validatePrefsReset() {
1338 return confirm("Reset to defaults?");
1341 function browseFeeds(limit
) {
1343 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1344 xmlhttp
.onreadystatechange
=infobox_callback
;
1349 function feedBrowserSubscribe() {
1352 var selected
= getSelectedFeedsFromBrowser();
1354 if (selected
.length
> 0) {
1356 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1357 param_escape(selected
.toString()), true);
1358 xmlhttp
.onreadystatechange
=feedlist_callback
;
1361 alert("No feeds are selected.");
1365 exception_error("feedBrowserSubscribe", e
);
1369 function updateBigFeedBrowser(limit
) {
1371 if (!xmlhttp_ready(xmlhttp
)) {
1372 printLockingError();
1376 // p_notify("Loading, please wait...");
1378 var query
= "backend.php?op=pref-feed-browser";
1380 var limit_sel
= document
.getElementById("feedBrowserLimit");
1383 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1384 query
= query
+ "&limit=" + param_escape(limit
);
1387 xmlhttp
.open("GET", query
, true);
1388 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1392 function browserToggleExpand(id
) {
1394 /* if (feed_to_expand && feed_to_expand != id) {
1395 var d = document.getElementById("BRDET-" + feed_to_expand);
1396 d.style.display = "none";
1399 if (!xmlhttp_ready(xmlhttp
)) {
1400 printLockingError();
1404 var d
= document
.getElementById("BRDET-" + id
);
1406 if (d
.style
.display
== "block") {
1407 d
.style
.display
= "none";
1411 feed_to_expand
= id
;
1413 d
.style
.display
= "block";
1414 d
.innerHTML
= "Loading, please wait...";
1416 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1417 + param_escape(id
), true);
1418 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1423 exception_error("browserExpand", e
);
1427 function validateNewPassword(form
) {
1428 if (form
.OLD_PASSWORD
.value
== "") {
1429 alert("Old password cannot be blank");
1432 if (form
.NEW_PASSWORD
.value
== "") {
1433 alert("New password cannot be blank");
1439 function selectPrefRows(kind
, select
) {
1442 var opbarid
= false;
1447 if (kind
== "feed") {
1448 opbarid
= "feedOpToolbar";
1451 lname
= "prefFeedList";
1452 } else if (kind
== "fcat") {
1453 opbarid
= "catOpToolbar";
1456 lname
= "prefFeedCatList";
1457 } else if (kind
== "filter") {
1458 opbarid
= "filterOpToolbar";
1461 lname
= "prefFilterList";
1462 } else if (kind
== "label") {
1463 opbarid
= "labelOpToolbar";
1466 lname
= "prefLabelList";
1467 } else if (kind
== "user") {
1468 opbarid
= "userOpToolbar";
1471 lname
= "prefUserList";
1475 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1476 disableContainerChildren(opbarid
, !select
);
1483 function toggleSelectPrefRow(sender
, kind
) {
1485 toggleSelectRow(sender
);
1488 var opbarid
= false;
1491 if (kind
== "feed") {
1492 opbarid
= "feedOpToolbar";
1493 nsel
= getSelectedFeeds();
1494 } else if (kind
== "fcat") {
1495 opbarid
= "catOpToolbar";
1496 nsel
= getSelectedFeedCats();
1497 } else if (kind
== "filter") {
1498 opbarid
= "filterOpToolbar";
1499 nsel
= getSelectedFilters();
1500 } else if (kind
== "label") {
1501 opbarid
= "labelOpToolbar";
1502 nsel
= getSelectedLabels();
1503 } else if (kind
== "user") {
1504 opbarid
= "userOpToolbar";
1505 nsel
= getSelectedUsers();
1508 if (opbarid
&& nsel
!= -1) {
1509 disableContainerChildren(opbarid
, nsel
== false);
1515 function toggleSelectFBListRow(sender
) {
1516 toggleSelectListRow(sender
);
1517 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1522 function pref_hotkey_handler(e
) {
1527 if (!hotkeys_enabled
) return;
1530 keycode
= window
.event
.keyCode
;
1535 if (keycode
== 13 || keycode
== 27) {
1538 seq
= seq
+ "" + keycode
;
1542 if (document
.getElementById("piggie")) {
1544 if (seq
.match("807371717369")) {
1546 localPiggieFunction(true);
1548 localPiggieFunction(false);
1553 exception_error("pref_hotkey_handler", e
);