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 var caller_subop
= false;
17 var sanity_check_done
= false;
19 function expand_feed_callback() {
20 if (xmlhttp
.readyState
== 4) {
22 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
23 container
.innerHTML
=xmlhttp
.responseText
;
24 container
.style
.display
= "block";
27 exception_error("expand_feed_callback", e
);
32 function feedlist_callback() {
33 if (xmlhttp
.readyState
== 4) {
35 var container
= document
.getElementById('prefContent');
36 container
.innerHTML
=xmlhttp
.responseText
;
37 selectTab("feedConfig", true);
40 var tuple
= caller_subop
.split(":");
41 if (tuple
[0] == 'editFeed') {
42 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
47 if (typeof correctPNG
!= 'undefined') {
52 exception_error("feedlist_callback", e
);
57 function filterlist_callback() {
58 var container
= document
.getElementById('prefContent');
59 if (xmlhttp
.readyState
== 4) {
60 container
.innerHTML
=xmlhttp
.responseText
;
61 if (typeof correctPNG
!= 'undefined') {
68 function labellist_callback() {
69 var container
= document
.getElementById('prefContent');
70 if (xmlhttp
.readyState
== 4) {
72 container
.innerHTML
=xmlhttp
.responseText
;
74 var row
= document
.getElementById("LILRR-" + active_label
);
76 if (!row
.className
.match("Selected")) {
77 row
.className
= row
.className
+ "Selected";
80 var checkbox
= document
.getElementById("LICHK-" + active_label
);
83 checkbox
.checked
= true;
86 if (typeof correctPNG
!= 'undefined') {
93 function labeltest_callback() {
94 var container
= document
.getElementById('label_test_result');
95 if (xmlhttp
.readyState
== 4) {
96 container
.innerHTML
=xmlhttp
.responseText
;
101 function feed_browser_callback() {
102 var container
= document
.getElementById('prefContent');
103 if (xmlhttp
.readyState
== 4) {
104 container
.innerHTML
=xmlhttp
.responseText
;
109 function userlist_callback() {
110 var container
= document
.getElementById('prefContent');
111 if (xmlhttp
.readyState
== 4) {
112 container
.innerHTML
=xmlhttp
.responseText
;
117 function prefslist_callback() {
118 var container
= document
.getElementById('prefContent');
119 if (xmlhttp
.readyState
== 4) {
121 container
.innerHTML
=xmlhttp
.responseText
;
127 function gethelp_callback() {
128 var container
= document
.getElementById('prefHelpBox');
129 if (xmlhttp
.readyState
== 4) {
131 container
.innerHTML
= xmlhttp
.responseText
;
132 container
.style
.display
= "block";
137 function notify_callback() {
138 if (xmlhttp
.readyState
== 4) {
139 notify_info(xmlhttp
.responseText
);
144 function changepass_callback() {
146 if (xmlhttp
.readyState
== 4) {
148 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
149 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
151 notify_info(xmlhttp
.responseText
);
152 var warn
= document
.getElementById("default_pass_warning");
153 if (warn
) warn
.style
.display
= "none";
156 document
.forms
['change_pass_form'].reset();
160 exception_error("changepass_callback", e
);
164 function updateFeedList(sort_key
) {
166 if (!xmlhttp_ready(xmlhttp
)) {
171 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
173 // p_notify("Loading, please wait...");
175 var feed_search
= document
.getElementById("feed_search");
177 if (feed_search
) { search
= feed_search
.value
; }
179 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
180 "&sort=" + param_escape(sort_key
) +
181 "&search=" + param_escape(search
), true);
182 xmlhttp
.onreadystatechange
=feedlist_callback
;
187 function updateUsersList(sort_key
) {
189 if (!xmlhttp_ready(xmlhttp
)) {
194 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
196 // p_notify("Loading, please wait...");
198 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
199 + param_escape(sort_key
), true);
200 xmlhttp
.onreadystatechange
=userlist_callback
;
205 function addLabel() {
207 if (!xmlhttp_ready(xmlhttp
)) {
212 var form
= document
.forms
['label_edit_form'];
214 var sql_exp
= form
.sql_exp
.value
;
215 var description
= form
.description
.value
;
218 alert("Can't create label: missing SQL expression.");
222 if (description
== "") {
223 alert("Can't create label: missing caption.");
227 var query
= Form
.serialize("label_edit_form");
229 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
230 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
236 if (!xmlhttp_ready(xmlhttp
)) {
241 var link
= document
.getElementById("fadd_link");
243 if (link
.value
.length
== 0) {
244 alert(__("Error: No feed URL given."));
245 } else if (!isValidURL(link
.value
)) {
246 alert(__("Error: Invalid feed URL."));
248 notify_progress("Adding feed...");
250 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
251 param_escape(link
.value
), true);
252 xmlhttp
.onreadystatechange
=feedlist_callback
;
261 function addFeedCat() {
263 if (!xmlhttp_ready(xmlhttp
)) {
268 var cat
= document
.getElementById("fadd_cat");
270 if (cat
.value
.length
== 0) {
271 alert(__("Can't add category: no name specified."));
273 notify_progress("Adding feed category...");
275 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
276 param_escape(cat
.value
), true);
277 xmlhttp
.onreadystatechange
=infobox_callback
;
287 if (!xmlhttp_ready(xmlhttp
)) {
292 var sqlexp
= document
.getElementById("uadd_box");
294 if (sqlexp
.value
.length
== 0) {
295 alert("Can't add user: no login specified.");
297 notify_progress("Adding user...");
299 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
300 param_escape(sqlexp
.value
), true);
302 xmlhttp
.onreadystatechange
=userlist_callback
;
310 function editLabel(id
) {
312 if (!xmlhttp_ready(xmlhttp
)) {
317 notify_progress("Loading, please wait...");
319 document
.getElementById("label_create_btn").disabled
= true;
323 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
324 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
326 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
327 param_escape(id
), true);
328 xmlhttp
.onreadystatechange
=infobox_callback
;
333 function editUser(id
) {
335 if (!xmlhttp_ready(xmlhttp
)) {
340 notify_progress("Loading, please wait...");
342 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
343 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
345 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
346 param_escape(id
), true);
347 xmlhttp
.onreadystatechange
=infobox_callback
;
352 function editFilter(id
) {
354 if (!xmlhttp_ready(xmlhttp
)) {
359 notify_progress("Loading, please wait...");
361 document
.getElementById("create_filter_btn").disabled
= true;
363 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
364 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
366 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
367 xmlhttp
.onreadystatechange
=infobox_callback
;
371 function editFeed(feed
) {
373 // notify("Editing feed...");
375 if (!xmlhttp_ready(xmlhttp
)) {
380 notify_progress("Loading, please wait...");
382 // clean selection from all rows & select row being edited
383 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
384 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
386 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
387 param_escape(feed
), true);
389 xmlhttp
.onreadystatechange
=infobox_callback
;
394 function editFeedCat(cat
) {
396 if (!xmlhttp_ready(xmlhttp
)) {
401 notify_progress("Loading, please wait...");
403 active_feed_cat
= cat
;
405 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
406 param_escape(cat
), true);
407 xmlhttp
.onreadystatechange
=infobox_callback
;
412 function getSelectedLabels() {
413 return getSelectedTableRowIds("prefLabelList", "LILRR");
416 function getSelectedUsers() {
417 return getSelectedTableRowIds("prefUserList", "UMRR");
420 function getSelectedFeeds() {
421 return getSelectedTableRowIds("prefFeedList", "FEEDR");
424 function getSelectedFilters() {
425 return getSelectedTableRowIds("prefFilterList", "FILRR");
428 function getSelectedFeedCats() {
429 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
432 function getSelectedFeedsFromBrowser() {
434 var list
= document
.getElementById("browseFeedList");
435 if (!list
) list
= document
.getElementById("browseBigFeedList");
437 var selected
= new Array();
439 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
440 var child
= list
.childNodes
[i
];
441 if (child
.id
&& child
.id
.match("FBROW-")) {
442 var id
= child
.id
.replace("FBROW-", "");
444 var cb
= document
.getElementById("FBCHK-" + id
);
455 function removeSelectedLabels() {
457 if (!xmlhttp_ready(xmlhttp
)) {
462 var sel_rows
= getSelectedLabels();
464 if (sel_rows
.length
> 0) {
466 var ok
= confirm("Remove selected labels?");
469 notify_progress("Removing selected labels...");
471 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
472 param_escape(sel_rows
.toString()), true);
473 xmlhttp
.onreadystatechange
=labellist_callback
;
477 alert("No labels are selected.");
483 function removeSelectedUsers() {
485 if (!xmlhttp_ready(xmlhttp
)) {
490 var sel_rows
= getSelectedUsers();
492 if (sel_rows
.length
> 0) {
494 var ok
= confirm("Remove selected users?");
497 notify_progress("Removing selected users...");
499 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
500 param_escape(sel_rows
.toString()), true);
501 xmlhttp
.onreadystatechange
=userlist_callback
;
506 alert("No users are selected.");
512 function removeSelectedFilters() {
514 if (!xmlhttp_ready(xmlhttp
)) {
519 var sel_rows
= getSelectedFilters();
521 if (sel_rows
.length
> 0) {
523 var ok
= confirm("Remove selected filters?");
526 notify_progress("Removing selected filters...");
528 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
529 param_escape(sel_rows
.toString()), true);
530 xmlhttp
.onreadystatechange
=filterlist_callback
;
534 alert("No filters are selected.");
541 function removeSelectedFeeds() {
543 if (!xmlhttp_ready(xmlhttp
)) {
548 var sel_rows
= getSelectedFeeds();
550 if (sel_rows
.length
> 0) {
552 var ok
= confirm("Unsubscribe from selected feeds?");
556 notify_progress("Unsubscribing from selected feeds...");
558 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
559 param_escape(sel_rows
.toString()), true);
560 xmlhttp
.onreadystatechange
=feedlist_callback
;
566 alert("No feeds are selected.");
573 function removeSelectedFeedCats() {
575 if (!xmlhttp_ready(xmlhttp
)) {
580 var sel_rows
= getSelectedFeedCats();
582 if (sel_rows
.length
> 0) {
584 var ok
= confirm("Remove selected categories?");
587 notify_progress("Removing selected categories...");
589 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
590 param_escape(sel_rows
.toString()), true);
591 xmlhttp
.onreadystatechange
=infobox_callback
;
597 alert("No categories are selected.");
604 function feedEditCancel() {
606 if (!xmlhttp_ready(xmlhttp
)) {
613 selectPrefRows('feed', false); // cleanup feed selection
618 function feedCatEditCancel() {
620 if (!xmlhttp_ready(xmlhttp
)) {
625 active_feed_cat
= false;
627 // notify("Operation cancelled.");
629 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
630 xmlhttp
.onreadystatechange
=infobox_callback
;
636 function feedEditSave() {
640 if (!xmlhttp_ready(xmlhttp
)) {
645 // FIXME: add parameter validation
647 var query
= Form
.serialize("edit_feed_form");
649 notify_progress("Saving feed...");
651 xmlhttp
.open("POST", "backend.php", true);
652 xmlhttp
.onreadystatechange
=feedlist_callback
;
653 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
661 exception_error("feedEditSave", e
);
665 function feedCatEditSave() {
667 if (!xmlhttp_ready(xmlhttp
)) {
672 notify_progress("Saving category...");
674 var query
= Form
.serialize("feed_cat_edit_form");
676 xmlhttp
.open("GET", "backend.php?" + query
, true);
677 xmlhttp
.onreadystatechange
=infobox_callback
;
680 active_feed_cat
= false;
686 function labelTest() {
688 var container
= document
.getElementById('label_test_result');
689 container
.style
.display
= "block";
690 container
.innerHTML
= "<p>Loading, please wait...</p>";
692 var form
= document
.forms
['label_edit_form'];
694 var sql_exp
= form
.sql_exp
.value
;
695 var description
= form
.description
.value
;
697 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
698 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
700 xmlhttp
.onreadystatechange
=labeltest_callback
;
706 function displayHelpInfobox(topic_id
) {
708 if (!xmlhttp_ready(xmlhttp
)) {
713 notify_progress("Loading help...");
715 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
716 param_escape(topic_id
) + "&noheaders=1", true);
718 xmlhttp
.onreadystatechange
=infobox_callback
;
723 function labelEditCancel() {
725 if (!xmlhttp_ready(xmlhttp
)) {
730 document
.getElementById("label_create_btn").disabled
= false;
732 active_label
= false;
734 selectPrefRows('label', false); // cleanup feed selection
740 function userEditCancel() {
742 if (!xmlhttp_ready(xmlhttp
)) {
747 selectPrefRows('user', false); // cleanup feed selection
753 function filterEditCancel() {
755 if (!xmlhttp_ready(xmlhttp
)) {
760 document
.getElementById("create_filter_btn").disabled
= false;
762 selectPrefRows('filter', false); // cleanup feed selection
768 function labelEditSave() {
770 var label
= active_label
;
772 if (!xmlhttp_ready(xmlhttp
)) {
777 /* if (!is_opera()) {
779 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
780 var description = document.forms["label_edit_form"].description.value;
782 if (sql_exp.length == 0) {
783 alert("SQL Expression cannot be blank.");
787 if (description.length == 0) {
788 alert("Caption field cannot be blank.");
795 notify_progress("Saving label...");
797 active_label
= false;
799 query
= Form
.serialize("label_edit_form");
801 xmlhttp
.open("GET", "backend.php?" + query
, true);
802 xmlhttp
.onreadystatechange
=labellist_callback
;
808 function userEditSave() {
810 if (!xmlhttp_ready(xmlhttp
)) {
815 var login
= document
.forms
["user_edit_form"].login
.value
;
817 if (login
.length
== 0) {
818 alert("Login field cannot be blank.");
822 notify_progress("Saving user...");
826 var query
= Form
.serialize("user_edit_form");
828 xmlhttp
.open("GET", "backend.php?" + query
, true);
829 xmlhttp
.onreadystatechange
=userlist_callback
;
836 function filterEditSave() {
838 if (!xmlhttp_ready(xmlhttp
)) {
843 /* if (!is_opera()) {
844 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
846 if (reg_exp.length == 0) {
847 alert("Filter expression field cannot be blank.");
852 notify_progress("Saving filter...");
854 var query
= Form
.serialize("filter_edit_form");
858 document
.getElementById("create_filter_btn").disabled
= false;
860 xmlhttp
.open("GET", "backend.php?" + query
, true);
861 xmlhttp
.onreadystatechange
=filterlist_callback
;
867 function editSelectedLabel() {
868 var rows
= getSelectedLabels();
870 if (rows
.length
== 0) {
871 alert(__("No labels are selected."));
875 if (rows
.length
> 1) {
876 alert(__("Please select only one label."));
886 function editSelectedUser() {
887 var rows
= getSelectedUsers();
889 if (rows
.length
== 0) {
890 alert(__("No users are selected."));
894 if (rows
.length
> 1) {
895 alert(__("Please select only one user."));
904 function resetSelectedUserPass() {
905 var rows
= getSelectedUsers();
907 if (rows
.length
== 0) {
908 alert(__("No users are selected."));
912 if (rows
.length
> 1) {
913 alert(__("Please select only one user."));
917 var ok
= confirm(__("Reset password of selected user?"));
920 notify_progress("Resetting password for selected user...");
924 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
925 param_escape(id
), true);
926 xmlhttp
.onreadystatechange
=userlist_callback
;
931 function selectedUserDetails() {
933 if (!xmlhttp_ready(xmlhttp
)) {
938 var rows
= getSelectedUsers();
940 if (rows
.length
== 0) {
941 alert(__("No users are selected."));
945 if (rows
.length
> 1) {
946 alert(__("Please select only one user."));
950 notify_progress("Loading, please wait...");
954 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
955 xmlhttp
.onreadystatechange
=infobox_callback
;
960 function selectedFeedDetails() {
962 if (!xmlhttp_ready(xmlhttp
)) {
967 var rows
= getSelectedFeeds();
969 if (rows
.length
== 0) {
970 alert(__("No feeds are selected."));
974 if (rows
.length
> 1) {
975 alert(__("Please select only one feed."));
983 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
984 param_escape(rows
.toString()), true);
985 xmlhttp
.onreadystatechange
=infobox_callback
;
990 function editSelectedFilter() {
991 var rows
= getSelectedFilters();
993 if (rows
.length
== 0) {
994 alert(__("No filters are selected."));
998 if (rows
.length
> 1) {
999 alert(__("Please select only one filter."));
1005 editFilter(rows
[0]);
1010 function editSelectedFeed() {
1011 var rows
= getSelectedFeeds();
1013 if (rows
.length
== 0) {
1014 alert(__("No feeds are selected."));
1018 if (rows
.length
> 1) {
1019 alert(__("Please select one feed."));
1029 function editSelectedFeedCat() {
1030 var rows
= getSelectedFeedCats();
1032 if (rows
.length
== 0) {
1033 alert(__("No categories are selected."));
1037 if (rows
.length
> 1) {
1038 alert(__("Please select only one category."));
1044 editFeedCat(rows
[0]);
1048 function piggie_callback() {
1049 var piggie
= document
.getElementById("piggie");
1051 piggie
.style
.top
= piggie_top
;
1052 piggie
.style
.backgroundColor
= "white";
1053 piggie
.style
.borderWidth
= "1px";
1055 if (piggie_fwd
&& piggie_top
< 0) {
1056 setTimeout("piggie_callback()", 50);
1057 piggie_top
= piggie_top
+ 10;
1058 } else if (piggie_fwd
&& piggie_top
>= 0) {
1060 setTimeout("piggie_callback()", 50);
1061 } else if (!piggie_fwd
&& piggie_top
> -400) {
1062 setTimeout("piggie_callback()", 50);
1063 piggie_top
= piggie_top
- 10;
1064 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1065 piggie
.style
.display
= "none";
1070 var piggie_opacity
= 0;
1072 function piggie2_callback() {
1073 var piggie
= document
.getElementById("piggie");
1074 piggie
.style
.top
= 0;
1075 piggie
.style
.opacity
= piggie_opacity
;
1076 piggie
.style
.backgroundColor
= "transparent";
1077 piggie
.style
.borderWidth
= "0px";
1079 if (piggie_fwd
&& piggie_opacity
< 1) {
1080 setTimeout("piggie2_callback()", 50);
1081 piggie_opacity
= piggie_opacity
+ 0.03;
1082 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1084 setTimeout("piggie2_callback()", 50);
1085 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1086 setTimeout("piggie2_callback()", 50);
1087 piggie_opacity
= piggie_opacity
- 0.03;
1088 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1089 piggie
.style
.display
= "none";
1094 function localPiggieFunction(enable
) {
1096 debug("I LOVEDED IT!");
1097 var piggie
= document
.getElementById("piggie");
1098 piggie
.style
.display
= "block";
1100 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1108 function validateOpmlImport() {
1110 var opml_file
= document
.getElementById("opml_file");
1112 if (opml_file
.value
.length
== 0) {
1113 alert(__("No OPML file to upload."));
1120 function updateFilterList(sort_key
) {
1122 if (!xmlhttp_ready(xmlhttp
)) {
1123 printLockingError();
1127 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1129 // p_notify("Loading, please wait...");
1131 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1132 param_escape(sort_key
), true);
1133 xmlhttp
.onreadystatechange
=filterlist_callback
;
1138 function updateLabelList(sort_key
) {
1140 if (!xmlhttp_ready(xmlhttp
)) {
1141 printLockingError();
1145 // p_notify("Loading, please wait...");
1147 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1149 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1150 param_escape(sort_key
), true);
1151 xmlhttp
.onreadystatechange
=labellist_callback
;
1155 function updatePrefsList() {
1157 if (!xmlhttp_ready(xmlhttp
)) {
1158 printLockingError();
1162 // p_notify("Loading, please wait...");
1164 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1165 xmlhttp
.onreadystatechange
=prefslist_callback
;
1170 function selectTab(id
, noupdate
, subop
) {
1174 if (!id
) id
= active_tab
;
1178 if (!xmlhttp_ready(xmlhttp
)) {
1179 printLockingError();
1184 var c
= document
.getElementById('prefContent');
1190 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1192 notify_progress("Loading, please wait...");
1194 // close active infobox if needed
1197 // clean up all current selections, just in case
1198 active_feed_cat
= false;
1199 active_label
= false;
1201 if (id
== "feedConfig") {
1203 } else if (id
== "filterConfig") {
1205 } else if (id
== "labelConfig") {
1207 } else if (id
== "genConfig") {
1209 } else if (id
== "userConfig") {
1211 } else if (id
== "feedBrowser") {
1212 updateBigFeedBrowser();
1216 var tab
= document
.getElementById(active_tab
+ "Tab");
1219 if (tab
.className
.match("Selected")) {
1220 tab
.className
= "prefsTab";
1224 tab
= document
.getElementById(id
+ "Tab");
1227 if (!tab
.className
.match("Selected")) {
1228 tab
.className
= tab
.className
+ "Selected";
1235 exception_error("selectTab", e
);
1239 function backend_sanity_check_callback() {
1241 if (xmlhttp
.readyState
== 4) {
1245 if (sanity_check_done
) {
1246 fatalError(11, "Sanity check request received twice. You could be running"+
1247 " Firebug or some other disrupting extension. Please turn it off.");
1251 if (!xmlhttp
.responseXML
) {
1252 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1256 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1259 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1263 var error_code
= reply
.getAttribute("error-code");
1265 if (error_code
&& error_code
!= 0) {
1266 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1269 debug("sanity check ok");
1271 var params
= reply
.nextSibling
;
1274 debug('reading init-params...');
1275 var param
= params
.firstChild
;
1278 var k
= param
.getAttribute("key");
1279 var v
= param
.getAttribute("value");
1280 debug(k
+ " => " + v
);
1282 param
= param
.nextSibling
;
1286 sanity_check_done
= true;
1288 init_second_stage();
1291 exception_error("backend_sanity_check_callback", e
);
1296 function init_second_stage() {
1299 active_tab
= getInitParam("prefs_active_tab");
1300 if (!active_tab
) active_tab
= "genConfig";
1302 document
.onkeydown
= pref_hotkey_handler
;
1304 var tab
= getURLParam('tab');
1306 caller_subop
= getURLParam('subop');
1312 if (navigator
.userAgent
.match("Opera")) {
1313 setTimeout("selectTab()", 500);
1315 selectTab(active_tab
);
1319 exception_error("init_second_stage", e
);
1327 if (arguments
.callee
.done
) return;
1328 arguments
.callee
.done
= true;
1330 if (getURLParam('debug')) {
1331 document
.getElementById('debug_output').style
.display
= 'block';
1332 debug('debug mode activated');
1337 document
.getElementById("prefContent").innerHTML
=
1338 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1339 "to function properly. Your browser doesn't seem to support it.";
1343 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1344 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1348 exception_error("init", e
);
1352 function categorizeSelectedFeeds() {
1354 if (!xmlhttp_ready(xmlhttp
)) {
1355 printLockingError();
1359 var sel_rows
= getSelectedFeeds();
1361 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1362 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1364 if (sel_rows
.length
> 0) {
1366 notify_progress("Changing category of selected feeds...");
1368 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1369 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1370 xmlhttp
.onreadystatechange
=feedlist_callback
;
1375 alert(__("No feeds are selected."));
1381 function validatePrefsReset() {
1382 return confirm(__("Reset to defaults?"));
1385 function browseFeeds(limit
) {
1387 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1388 xmlhttp
.onreadystatechange
=infobox_callback
;
1393 function feedBrowserSubscribe() {
1396 var selected
= getSelectedFeedsFromBrowser();
1398 if (selected
.length
> 0) {
1400 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1401 param_escape(selected
.toString()), true);
1402 xmlhttp
.onreadystatechange
=feedlist_callback
;
1405 alert("No feeds are selected.");
1409 exception_error("feedBrowserSubscribe", e
);
1413 function updateBigFeedBrowser(limit
) {
1415 if (!xmlhttp_ready(xmlhttp
)) {
1416 printLockingError();
1420 // p_notify("Loading, please wait...");
1422 var query
= "backend.php?op=pref-feed-browser";
1424 var limit_sel
= document
.getElementById("feedBrowserLimit");
1427 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1428 query
= query
+ "&limit=" + param_escape(limit
);
1431 xmlhttp
.open("GET", query
, true);
1432 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1436 function browserToggleExpand(id
) {
1438 /* if (feed_to_expand && feed_to_expand != id) {
1439 var d = document.getElementById("BRDET-" + feed_to_expand);
1440 d.style.display = "none";
1443 if (!xmlhttp_ready(xmlhttp
)) {
1444 printLockingError();
1448 var d
= document
.getElementById("BRDET-" + id
);
1450 if (d
.style
.display
== "block") {
1451 d
.style
.display
= "none";
1455 feed_to_expand
= id
;
1457 d
.style
.display
= "block";
1458 d
.innerHTML
= "Loading, please wait...";
1460 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1461 + param_escape(id
), true);
1462 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1467 exception_error("browserExpand", e
);
1471 function selectPrefRows(kind
, select
) {
1474 var opbarid
= false;
1479 if (kind
== "feed") {
1480 opbarid
= "feedOpToolbar";
1483 lname
= "prefFeedList";
1484 } else if (kind
== "fcat") {
1485 opbarid
= "catOpToolbar";
1488 lname
= "prefFeedCatList";
1489 } else if (kind
== "filter") {
1490 opbarid
= "filterOpToolbar";
1493 lname
= "prefFilterList";
1494 } else if (kind
== "label") {
1495 opbarid
= "labelOpToolbar";
1498 lname
= "prefLabelList";
1499 } else if (kind
== "user") {
1500 opbarid
= "userOpToolbar";
1503 lname
= "prefUserList";
1507 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1508 disableContainerChildren(opbarid
, !select
);
1515 function toggleSelectPrefRow(sender
, kind
) {
1517 toggleSelectRow(sender
);
1520 var opbarid
= false;
1523 if (kind
== "feed") {
1524 opbarid
= "feedOpToolbar";
1525 nsel
= getSelectedFeeds();
1526 } else if (kind
== "fcat") {
1527 opbarid
= "catOpToolbar";
1528 nsel
= getSelectedFeedCats();
1529 } else if (kind
== "filter") {
1530 opbarid
= "filterOpToolbar";
1531 nsel
= getSelectedFilters();
1532 } else if (kind
== "label") {
1533 opbarid
= "labelOpToolbar";
1534 nsel
= getSelectedLabels();
1535 } else if (kind
== "user") {
1536 opbarid
= "userOpToolbar";
1537 nsel
= getSelectedUsers();
1540 if (opbarid
&& nsel
!= -1) {
1541 disableContainerChildren(opbarid
, nsel
== false);
1547 function toggleSelectFBListRow(sender
) {
1548 toggleSelectListRow(sender
);
1549 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1554 function pref_hotkey_handler(e
) {
1559 if (!hotkeys_enabled
) return;
1562 keycode
= window
.event
.keyCode
;
1567 if (keycode
== 13 || keycode
== 27) {
1570 seq
= seq
+ "" + keycode
;
1574 if (document
.getElementById("piggie")) {
1576 if (seq
.match("807371717369")) {
1578 localPiggieFunction(true);
1580 localPiggieFunction(false);
1585 exception_error("pref_hotkey_handler", e
);
1589 function userSwitch() {
1590 var chooser
= document
.getElementById("userSwitch");
1591 var user
= chooser
[chooser
.selectedIndex
].value
;
1592 window
.location
= "prefs.php?swu=" + user
;
1595 function editFeedCats() {
1596 if (!xmlhttp_ready(xmlhttp
)) {
1597 printLockingError();
1601 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1602 xmlhttp
.onreadystatechange
=infobox_callback
;
1606 function showFeedsWithErrors() {
1607 displayDlg('feedUpdateErrors');
1610 function changeUserPassword() {
1614 if (!xmlhttp_ready(xmlhttp
)) {
1615 printLockingError();
1619 var query
= Form
.serialize("change_pass_form");
1621 notify_progress("Trying to change password...");
1623 xmlhttp
.open("POST", "backend.php", true);
1624 xmlhttp
.onreadystatechange
=changepass_callback
;
1625 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1626 xmlhttp
.send(query
);
1629 exception_error("changeUserPassword", e
);
1635 function changeUserEmail() {
1639 if (!xmlhttp_ready(xmlhttp
)) {
1640 printLockingError();
1644 var query
= Form
.serialize("change_email_form");
1646 notify_progress("Trying to change e-mail...");
1648 xmlhttp
.open("POST", "backend.php", true);
1649 xmlhttp
.onreadystatechange
=notify_callback
;
1650 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1651 xmlhttp
.send(query
);
1654 exception_error("changeUserPassword", e
);