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);
36 exception_error("feedlist_callback", e
);
41 function filterlist_callback() {
42 var container
= document
.getElementById('prefContent');
43 if (xmlhttp
.readyState
== 4) {
44 container
.innerHTML
=xmlhttp
.responseText
;
49 function labellist_callback() {
50 var container
= document
.getElementById('prefContent');
51 if (xmlhttp
.readyState
== 4) {
53 container
.innerHTML
=xmlhttp
.responseText
;
55 var row
= document
.getElementById("LILRR-" + active_label
);
57 if (!row
.className
.match("Selected")) {
58 row
.className
= row
.className
+ "Selected";
61 var checkbox
= document
.getElementById("LICHK-" + active_label
);
64 checkbox
.checked
= true;
71 function labeltest_callback() {
72 var container
= document
.getElementById('label_test_result');
73 if (xmlhttp
.readyState
== 4) {
74 container
.innerHTML
=xmlhttp
.responseText
;
79 function feed_browser_callback() {
80 var container
= document
.getElementById('prefContent');
81 if (xmlhttp
.readyState
== 4) {
82 container
.innerHTML
=xmlhttp
.responseText
;
87 function userlist_callback() {
88 var container
= document
.getElementById('prefContent');
89 if (xmlhttp
.readyState
== 4) {
90 container
.innerHTML
=xmlhttp
.responseText
;
95 function prefslist_callback() {
96 var container
= document
.getElementById('prefContent');
97 if (xmlhttp
.readyState
== 4) {
99 container
.innerHTML
=xmlhttp
.responseText
;
105 function gethelp_callback() {
106 var container
= document
.getElementById('prefHelpBox');
107 if (xmlhttp
.readyState
== 4) {
109 container
.innerHTML
= xmlhttp
.responseText
;
110 container
.style
.display
= "block";
116 function notify_callback() {
117 var container
= document
.getElementById('notify');
118 if (xmlhttp
.readyState
== 4) {
119 container
.innerHTML
=xmlhttp
.responseText
;
123 function updateFeedList(sort_key
) {
125 if (!xmlhttp_ready(xmlhttp
)) {
130 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
132 // p_notify("Loading, please wait...");
134 var feed_search
= document
.getElementById("feed_search");
136 if (feed_search
) { search
= feed_search
.value
; }
138 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
139 "&sort=" + param_escape(sort_key
) +
140 "&search=" + param_escape(search
), true);
141 xmlhttp
.onreadystatechange
=feedlist_callback
;
146 function updateUsersList(sort_key
) {
148 if (!xmlhttp_ready(xmlhttp
)) {
153 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
155 // p_notify("Loading, please wait...");
157 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
158 + param_escape(sort_key
), true);
159 xmlhttp
.onreadystatechange
=userlist_callback
;
164 function addLabel() {
166 if (!xmlhttp_ready(xmlhttp
)) {
171 var form
= document
.forms
['label_edit_form'];
173 var sql_exp
= form
.sql_exp
.value
;
174 var description
= form
.description
.value
;
177 alert("Can't create label: missing SQL expression.");
181 if (description
== "") {
182 alert("Can't create label: missing caption.");
186 var query
= Form
.serialize("label_edit_form");
188 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
189 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
195 if (!xmlhttp_ready(xmlhttp
)) {
200 var link
= document
.getElementById("fadd_link");
202 if (link
.value
.length
== 0) {
203 alert("Error: No feed URL given.");
204 } else if (!isValidURL(link
.value
)) {
205 alert("Error: Invalid feed URL.");
207 notify("Adding feed...");
209 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&feed_url=" +
210 param_escape(link
.value
), true);
211 xmlhttp
.onreadystatechange
=feedlist_callback
;
220 function addFeedCat() {
222 if (!xmlhttp_ready(xmlhttp
)) {
227 var cat
= document
.getElementById("fadd_cat");
229 if (cat
.value
.length
== 0) {
230 alert("Can't add category: no name specified.");
232 notify("Adding feed category...");
234 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
235 param_escape(cat
.value
), true);
236 xmlhttp
.onreadystatechange
=infobox_callback
;
246 if (!xmlhttp_ready(xmlhttp
)) {
251 var sqlexp
= document
.getElementById("uadd_box");
253 if (sqlexp
.value
.length
== 0) {
254 alert("Can't add user: no login specified.");
256 notify("Adding user...");
258 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
259 param_escape(sqlexp
.value
), true);
261 xmlhttp
.onreadystatechange
=userlist_callback
;
269 function editLabel(id
) {
271 if (!xmlhttp_ready(xmlhttp
)) {
276 document
.getElementById("label_create_btn").disabled
= true;
280 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
281 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
283 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
284 param_escape(id
), true);
285 xmlhttp
.onreadystatechange
=infobox_callback
;
290 function editUser(id
) {
292 if (!xmlhttp_ready(xmlhttp
)) {
297 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
298 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
300 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
301 param_escape(id
), true);
302 xmlhttp
.onreadystatechange
=infobox_callback
;
307 function editFilter(id
) {
309 if (!xmlhttp_ready(xmlhttp
)) {
314 document
.getElementById("create_filter_btn").disabled
= true;
316 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
317 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
319 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
320 xmlhttp
.onreadystatechange
=infobox_callback
;
324 function editFeed(feed
) {
326 // notify("Editing feed...");
328 if (!xmlhttp_ready(xmlhttp
)) {
333 // clean selection from all rows & select row being edited
334 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
335 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
337 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
338 param_escape(feed
), true);
340 xmlhttp
.onreadystatechange
=infobox_callback
;
345 function editFeedCat(cat
) {
347 if (!xmlhttp_ready(xmlhttp
)) {
352 active_feed_cat
= cat
;
354 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
355 param_escape(cat
), true);
356 xmlhttp
.onreadystatechange
=infobox_callback
;
361 function getSelectedLabels() {
362 return getSelectedTableRowIds("prefLabelList", "LILRR");
365 function getSelectedUsers() {
366 return getSelectedTableRowIds("prefUserList", "UMRR");
369 function getSelectedFeeds() {
370 return getSelectedTableRowIds("prefFeedList", "FEEDR");
373 function getSelectedFilters() {
374 return getSelectedTableRowIds("prefFilterList", "FILRR");
377 function getSelectedFeedCats() {
378 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
381 function getSelectedFeedsFromBrowser() {
383 var list
= document
.getElementById("browseFeedList");
384 if (!list
) list
= document
.getElementById("browseBigFeedList");
386 var selected
= new Array();
388 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
389 var child
= list
.childNodes
[i
];
390 if (child
.id
&& child
.id
.match("FBROW-")) {
391 var id
= child
.id
.replace("FBROW-", "");
393 var cb
= document
.getElementById("FBCHK-" + id
);
404 function removeSelectedLabels() {
406 if (!xmlhttp_ready(xmlhttp
)) {
411 var sel_rows
= getSelectedLabels();
413 if (sel_rows
.length
> 0) {
415 var ok
= confirm("Remove selected labels?");
418 notify("Removing selected labels...");
420 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
421 param_escape(sel_rows
.toString()), true);
422 xmlhttp
.onreadystatechange
=labellist_callback
;
426 alert("No labels are selected.");
432 function removeSelectedUsers() {
434 if (!xmlhttp_ready(xmlhttp
)) {
439 var sel_rows
= getSelectedUsers();
441 if (sel_rows
.length
> 0) {
443 var ok
= confirm("Remove selected users?");
446 notify("Removing selected users...");
448 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
449 param_escape(sel_rows
.toString()), true);
450 xmlhttp
.onreadystatechange
=userlist_callback
;
455 alert("No users are selected.");
461 function removeSelectedFilters() {
463 if (!xmlhttp_ready(xmlhttp
)) {
468 var sel_rows
= getSelectedFilters();
470 if (sel_rows
.length
> 0) {
472 var ok
= confirm("Remove selected filters?");
475 notify("Removing selected filters...");
477 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
478 param_escape(sel_rows
.toString()), true);
479 xmlhttp
.onreadystatechange
=filterlist_callback
;
483 alert("No filters are selected.");
490 function removeSelectedFeeds() {
492 if (!xmlhttp_ready(xmlhttp
)) {
497 var sel_rows
= getSelectedFeeds();
499 if (sel_rows
.length
> 0) {
501 var ok
= confirm("Unsubscribe from selected feeds?");
505 notify("Unsubscribing from selected feeds...");
507 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
508 param_escape(sel_rows
.toString()), true);
509 xmlhttp
.onreadystatechange
=feedlist_callback
;
515 alert("No feeds are selected.");
522 function removeSelectedFeedCats() {
524 if (!xmlhttp_ready(xmlhttp
)) {
529 var sel_rows
= getSelectedFeedCats();
531 if (sel_rows
.length
> 0) {
533 var ok
= confirm("Remove selected categories?");
536 notify("Removing selected categories...");
538 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
539 param_escape(sel_rows
.toString()), true);
540 xmlhttp
.onreadystatechange
=infobox_callback
;
546 alert("No categories are selected.");
553 function feedEditCancel() {
555 if (!xmlhttp_ready(xmlhttp
)) {
562 selectPrefRows('feed', false); // cleanup feed selection
567 function feedCatEditCancel() {
569 if (!xmlhttp_ready(xmlhttp
)) {
574 active_feed_cat
= false;
576 // notify("Operation cancelled.");
578 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
579 xmlhttp
.onreadystatechange
=infobox_callback
;
585 function feedEditSave() {
589 if (!xmlhttp_ready(xmlhttp
)) {
594 // FIXME: add parameter validation
596 var query
= Form
.serialize("edit_feed_form");
598 notify("Saving feed...");
600 xmlhttp
.open("POST", "backend.php", true);
601 xmlhttp
.onreadystatechange
=feedlist_callback
;
602 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
610 exception_error("feedEditSave", e
);
614 function feedCatEditSave() {
616 if (!xmlhttp_ready(xmlhttp
)) {
621 notify("Saving category...");
623 var query
= Form
.serialize("feed_cat_edit_form");
625 xmlhttp
.open("GET", "backend.php?" + query
, true);
626 xmlhttp
.onreadystatechange
=infobox_callback
;
629 active_feed_cat
= false;
635 function labelTest() {
637 var container
= document
.getElementById('label_test_result');
638 container
.style
.display
= "block";
639 container
.innerHTML
= "<p>Loading, please wait...</p>";
641 var form
= document
.forms
['label_edit_form'];
643 var sql_exp
= form
.sql_exp
.value
;
644 var description
= form
.description
.value
;
646 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
647 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
649 xmlhttp
.onreadystatechange
=labeltest_callback
;
655 function displayHelpInfobox(topic_id
) {
657 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
658 param_escape(topic_id
) + "&noheaders=1", true);
660 xmlhttp
.onreadystatechange
=infobox_callback
;
665 function labelEditCancel() {
667 if (!xmlhttp_ready(xmlhttp
)) {
672 document
.getElementById("label_create_btn").disabled
= false;
674 active_label
= false;
676 selectPrefRows('label', false); // cleanup feed selection
682 function userEditCancel() {
684 if (!xmlhttp_ready(xmlhttp
)) {
689 selectPrefRows('user', false); // cleanup feed selection
695 function filterEditCancel() {
697 if (!xmlhttp_ready(xmlhttp
)) {
702 document
.getElementById("create_filter_btn").disabled
= false;
704 selectPrefRows('filter', false); // cleanup feed selection
710 function labelEditSave() {
712 var label
= active_label
;
714 if (!xmlhttp_ready(xmlhttp
)) {
719 /* if (!is_opera()) {
721 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
722 var description = document.forms["label_edit_form"].description.value;
724 if (sql_exp.length == 0) {
725 alert("SQL Expression cannot be blank.");
729 if (description.length == 0) {
730 alert("Caption field cannot be blank.");
737 notify("Saving label...");
739 active_label
= false;
741 query
= Form
.serialize("label_edit_form");
743 xmlhttp
.open("GET", "backend.php?" + query
, true);
744 xmlhttp
.onreadystatechange
=labellist_callback
;
750 function userEditSave() {
752 if (!xmlhttp_ready(xmlhttp
)) {
757 var login
= document
.forms
["user_edit_form"].login
.value
;
759 if (login
.length
== 0) {
760 alert("Login field cannot be blank.");
764 notify("Saving user...");
768 var query
= Form
.serialize("user_edit_form");
770 xmlhttp
.open("GET", "backend.php?" + query
, true);
771 xmlhttp
.onreadystatechange
=userlist_callback
;
778 function filterEditSave() {
780 if (!xmlhttp_ready(xmlhttp
)) {
785 /* if (!is_opera()) {
786 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
788 if (reg_exp.length == 0) {
789 alert("Filter expression field cannot be blank.");
794 notify("Saving filter...");
796 var query
= Form
.serialize("filter_edit_form");
800 document
.getElementById("create_filter_btn").disabled
= false;
802 xmlhttp
.open("GET", "backend.php?" + query
, true);
803 xmlhttp
.onreadystatechange
=filterlist_callback
;
809 function editSelectedLabel() {
810 var rows
= getSelectedLabels();
812 if (rows
.length
== 0) {
813 alert("No labels are selected.");
817 if (rows
.length
> 1) {
818 alert("Please select only one label.");
828 function editSelectedUser() {
829 var rows
= getSelectedUsers();
831 if (rows
.length
== 0) {
832 alert("No users are selected.");
836 if (rows
.length
> 1) {
837 alert("Please select only one user.");
846 function resetSelectedUserPass() {
847 var rows
= getSelectedUsers();
849 if (rows
.length
== 0) {
850 alert("No users are selected.");
854 if (rows
.length
> 1) {
855 alert("Please select only one user.");
859 var ok
= confirm("Reset password of selected user?");
862 notify("Resetting password for selected user...");
866 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
867 param_escape(id
), true);
868 xmlhttp
.onreadystatechange
=userlist_callback
;
873 function selectedUserDetails() {
875 if (!xmlhttp_ready(xmlhttp
)) {
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.");
896 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
897 xmlhttp
.onreadystatechange
=infobox_callback
;
902 function selectedFeedDetails() {
904 if (!xmlhttp_ready(xmlhttp
)) {
909 var rows
= getSelectedFeeds();
911 if (rows
.length
== 0) {
912 alert("No feeds are selected.");
916 if (rows
.length
> 1) {
917 notify("Please select only one feed.");
925 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
926 param_escape(rows
.toString()), true);
927 xmlhttp
.onreadystatechange
=infobox_callback
;
932 function editSelectedFilter() {
933 var rows
= getSelectedFilters();
935 if (rows
.length
== 0) {
936 alert("No filters are selected.");
940 if (rows
.length
> 1) {
941 alert("Please select only one filter.");
952 function editSelectedFeed() {
953 var rows
= getSelectedFeeds();
955 if (rows
.length
== 0) {
956 notify("No feeds are selected.");
960 if (rows
.length
> 1) {
961 notify("Please select one feed.");
971 function editSelectedFeedCat() {
972 var rows
= getSelectedFeedCats();
974 if (rows
.length
== 0) {
975 alert("No categories are selected.");
979 if (rows
.length
> 1) {
980 alert("Please select only one category.");
986 editFeedCat(rows
[0]);
990 function piggie_callback() {
991 var piggie
= document
.getElementById("piggie");
993 piggie
.style
.top
= piggie_top
;
994 piggie
.style
.backgroundColor
= "white";
995 piggie
.style
.borderWidth
= "1px";
997 if (piggie_fwd
&& piggie_top
< 0) {
998 setTimeout("piggie_callback()", 50);
999 piggie_top
= piggie_top
+ 10;
1000 } else if (piggie_fwd
&& piggie_top
>= 0) {
1002 setTimeout("piggie_callback()", 50);
1003 } else if (!piggie_fwd
&& piggie_top
> -400) {
1004 setTimeout("piggie_callback()", 50);
1005 piggie_top
= piggie_top
- 10;
1006 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1007 piggie
.style
.display
= "none";
1012 var piggie_opacity
= 0;
1014 function piggie2_callback() {
1015 var piggie
= document
.getElementById("piggie");
1016 piggie
.style
.top
= 0;
1017 piggie
.style
.opacity
= piggie_opacity
;
1018 piggie
.style
.backgroundColor
= "transparent";
1019 piggie
.style
.borderWidth
= "0px";
1021 if (piggie_fwd
&& piggie_opacity
< 1) {
1022 setTimeout("piggie2_callback()", 50);
1023 piggie_opacity
= piggie_opacity
+ 0.03;
1024 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1026 setTimeout("piggie2_callback()", 50);
1027 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1028 setTimeout("piggie2_callback()", 50);
1029 piggie_opacity
= piggie_opacity
- 0.03;
1030 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1031 piggie
.style
.display
= "none";
1036 function localPiggieFunction(enable
) {
1038 debug("I LOVEDED IT!");
1039 var piggie
= document
.getElementById("piggie");
1040 piggie
.style
.display
= "block";
1042 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1050 function validateOpmlImport() {
1052 var opml_file
= document
.getElementById("opml_file");
1054 if (opml_file
.value
.length
== 0) {
1055 alert("No OPML file to upload.");
1062 function updateFilterList(sort_key
) {
1064 if (!xmlhttp_ready(xmlhttp
)) {
1065 printLockingError();
1069 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1071 // p_notify("Loading, please wait...");
1073 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1074 param_escape(sort_key
), true);
1075 xmlhttp
.onreadystatechange
=filterlist_callback
;
1080 function updateLabelList(sort_key
) {
1082 if (!xmlhttp_ready(xmlhttp
)) {
1083 printLockingError();
1087 // p_notify("Loading, please wait...");
1089 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1091 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1092 param_escape(sort_key
), true);
1093 xmlhttp
.onreadystatechange
=labellist_callback
;
1097 function updatePrefsList() {
1099 if (!xmlhttp_ready(xmlhttp
)) {
1100 printLockingError();
1104 // p_notify("Loading, please wait...");
1106 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1107 xmlhttp
.onreadystatechange
=prefslist_callback
;
1112 function selectTab(id
, noupdate
) {
1116 if (!id
) id
= active_tab
;
1120 if (!xmlhttp_ready(xmlhttp
)) {
1121 printLockingError();
1126 var c
= document
.getElementById('prefContent');
1132 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1134 // notify("Loading, please wait...", true);
1136 // close active infobox if needed
1139 // clean up all current selections, just in case
1140 active_feed_cat
= false;
1141 active_label
= false;
1143 if (id
== "feedConfig") {
1145 } else if (id
== "filterConfig") {
1147 } else if (id
== "labelConfig") {
1149 } else if (id
== "genConfig") {
1151 } else if (id
== "userConfig") {
1153 } else if (id
== "feedBrowser") {
1154 updateBigFeedBrowser();
1158 var tab
= document
.getElementById(active_tab
+ "Tab");
1161 if (tab
.className
.match("Selected")) {
1162 tab
.className
= "prefsTab";
1166 tab
= document
.getElementById(id
+ "Tab");
1169 if (!tab
.className
.match("Selected")) {
1170 tab
.className
= tab
.className
+ "Selected";
1174 if (active_tab
!= id
) {
1175 storeInitParam("prefs_active_tab", id
);
1181 exception_error("selectTab", e
);
1185 function backend_sanity_check_callback() {
1187 if (xmlhttp
.readyState
== 4) {
1191 if (!xmlhttp
.responseXML
) {
1192 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1196 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1199 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1203 var error_code
= reply
.getAttribute("error-code");
1205 if (error_code
&& error_code
!= 0) {
1206 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1209 debug("sanity check ok");
1211 var params
= reply
.nextSibling
;
1214 debug('reading init-params...');
1215 var param
= params
.firstChild
;
1218 var k
= param
.getAttribute("key");
1219 var v
= param
.getAttribute("value");
1220 debug(k
+ " => " + v
);
1222 param
= param
.nextSibling
;
1226 init_second_stage();
1229 exception_error("backend_sanity_check_callback", e
);
1234 function init_second_stage() {
1237 active_tab
= getInitParam("prefs_active_tab");
1238 if (!active_tab
) active_tab
= "genConfig";
1240 document
.onkeydown
= pref_hotkey_handler
;
1242 if (navigator
.userAgent
.match("Opera")) {
1243 setTimeout("selectTab()", 500);
1245 selectTab(active_tab
);
1249 exception_error("init_second_stage", e
);
1257 if (arguments
.callee
.done
) return;
1258 arguments
.callee
.done
= true;
1260 if (getURLParam('debug')) {
1261 document
.getElementById('debug_output').style
.display
= 'block';
1262 debug('debug mode activated');
1267 document
.getElementById("prefContent").innerHTML
=
1268 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1269 "to function properly. Your browser doesn't seem to support it.";
1273 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1274 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1278 exception_error("init", e
);
1282 function categorizeSelectedFeeds() {
1284 if (!xmlhttp_ready(xmlhttp
)) {
1285 printLockingError();
1289 var sel_rows
= getSelectedFeeds();
1291 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1292 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1294 if (sel_rows
.length
> 0) {
1296 notify("Changing category of selected feeds...");
1298 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1299 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1300 xmlhttp
.onreadystatechange
=feedlist_callback
;
1305 alert("No feeds are selected.");
1311 function validatePrefsReset() {
1312 return confirm("Reset to defaults?");
1315 function browseFeeds(limit
) {
1317 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1318 xmlhttp
.onreadystatechange
=infobox_callback
;
1323 function feedBrowserSubscribe() {
1326 var selected
= getSelectedFeedsFromBrowser();
1328 if (selected
.length
> 0) {
1330 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1331 param_escape(selected
.toString()), true);
1332 xmlhttp
.onreadystatechange
=feedlist_callback
;
1335 alert("No feeds are selected.");
1339 exception_error("feedBrowserSubscribe", e
);
1343 function updateBigFeedBrowser(limit
) {
1345 if (!xmlhttp_ready(xmlhttp
)) {
1346 printLockingError();
1350 // p_notify("Loading, please wait...");
1352 var query
= "backend.php?op=pref-feed-browser";
1354 var limit_sel
= document
.getElementById("feedBrowserLimit");
1357 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1358 query
= query
+ "&limit=" + param_escape(limit
);
1361 xmlhttp
.open("GET", query
, true);
1362 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1366 function browserToggleExpand(id
) {
1368 /* if (feed_to_expand && feed_to_expand != id) {
1369 var d = document.getElementById("BRDET-" + feed_to_expand);
1370 d.style.display = "none";
1373 if (!xmlhttp_ready(xmlhttp
)) {
1374 printLockingError();
1378 var d
= document
.getElementById("BRDET-" + id
);
1380 if (d
.style
.display
== "block") {
1381 d
.style
.display
= "none";
1385 feed_to_expand
= id
;
1387 d
.style
.display
= "block";
1388 d
.innerHTML
= "Loading, please wait...";
1390 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1391 + param_escape(id
), true);
1392 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1397 exception_error("browserExpand", e
);
1401 function validateNewPassword(form
) {
1402 if (form
.OLD_PASSWORD
.value
== "") {
1403 alert("Old password cannot be blank");
1406 if (form
.NEW_PASSWORD
.value
== "") {
1407 alert("New password cannot be blank");
1413 function selectPrefRows(kind
, select
) {
1416 var opbarid
= false;
1421 if (kind
== "feed") {
1422 opbarid
= "feedOpToolbar";
1425 lname
= "prefFeedList";
1426 } else if (kind
== "fcat") {
1427 opbarid
= "catOpToolbar";
1430 lname
= "prefFeedCatList";
1431 } else if (kind
== "filter") {
1432 opbarid
= "filterOpToolbar";
1435 lname
= "prefFilterList";
1436 } else if (kind
== "label") {
1437 opbarid
= "labelOpToolbar";
1440 lname
= "prefLabelList";
1441 } else if (kind
== "user") {
1442 opbarid
= "userOpToolbar";
1445 lname
= "prefUserList";
1449 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1450 disableContainerChildren(opbarid
, !select
);
1457 function toggleSelectPrefRow(sender
, kind
) {
1459 toggleSelectRow(sender
);
1462 var opbarid
= false;
1465 if (kind
== "feed") {
1466 opbarid
= "feedOpToolbar";
1467 nsel
= getSelectedFeeds();
1468 } else if (kind
== "fcat") {
1469 opbarid
= "catOpToolbar";
1470 nsel
= getSelectedFeedCats();
1471 } else if (kind
== "filter") {
1472 opbarid
= "filterOpToolbar";
1473 nsel
= getSelectedFilters();
1474 } else if (kind
== "label") {
1475 opbarid
= "labelOpToolbar";
1476 nsel
= getSelectedLabels();
1477 } else if (kind
== "user") {
1478 opbarid
= "userOpToolbar";
1479 nsel
= getSelectedUsers();
1482 if (opbarid
&& nsel
!= -1) {
1483 disableContainerChildren(opbarid
, nsel
== false);
1489 function toggleSelectFBListRow(sender
) {
1490 toggleSelectListRow(sender
);
1491 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1496 function pref_hotkey_handler(e
) {
1501 if (!hotkeys_enabled
) return;
1504 keycode
= window
.event
.keyCode
;
1509 if (keycode
== 13 || keycode
== 27) {
1512 seq
= seq
+ "" + keycode
;
1516 if (document
.getElementById("piggie")) {
1518 if (seq
.match("807371717369")) {
1520 localPiggieFunction(true);
1522 localPiggieFunction(false);
1527 exception_error("pref_hotkey_handler", e
);
1531 function userSwitch() {
1532 var chooser
= document
.getElementById("userSwitch");
1533 var user
= chooser
[chooser
.selectedIndex
].value
;
1534 window
.location
= "prefs.php?swu=" + user
;
1537 function editFeedCats() {
1538 if (!xmlhttp_ready(xmlhttp
)) {
1539 printLockingError();
1543 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1544 xmlhttp
.onreadystatechange
=infobox_callback
;
1548 function showFeedsWithErrors() {
1549 displayDlg('feedUpdateErrors');
1552 function filterDlgCheckAction(sender
) {
1556 var action
= sender
[sender
.selectedIndex
].value
;
1558 var form
= document
.forms
["filter_add_form"];
1561 form
= document
.forms
["filter_edit_form"];
1565 debug("filterDlgCheckAction: can't find form!");
1569 var action_param
= form
.action_param
;
1571 if (!action_param
) {
1572 debug("filterDlgCheckAction: can't find action param!");
1576 // if selected action supports parameters, enable params field
1578 action_param
.disabled
= false;
1580 action_param
.disabled
= true;
1584 exception_error(e
, "filterDlgCheckAction");