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. This can indicate "+
1247 "presence of Firebug or some other disrupting extension. "+
1248 "Please disable it and try again.");
1252 if (!xmlhttp
.responseXML
) {
1253 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1257 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1260 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1264 var error_code
= reply
.getAttribute("error-code");
1266 if (error_code
&& error_code
!= 0) {
1267 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1270 debug("sanity check ok");
1272 var params
= reply
.nextSibling
;
1275 debug('reading init-params...');
1276 var param
= params
.firstChild
;
1279 var k
= param
.getAttribute("key");
1280 var v
= param
.getAttribute("value");
1281 debug(k
+ " => " + v
);
1283 param
= param
.nextSibling
;
1287 sanity_check_done
= true;
1289 init_second_stage();
1292 exception_error("backend_sanity_check_callback", e
);
1297 function init_second_stage() {
1300 active_tab
= getInitParam("prefs_active_tab");
1301 if (!active_tab
) active_tab
= "genConfig";
1303 document
.onkeydown
= pref_hotkey_handler
;
1305 var tab
= getURLParam('tab');
1307 caller_subop
= getURLParam('subop');
1313 if (navigator
.userAgent
.match("Opera")) {
1314 setTimeout("selectTab()", 500);
1316 selectTab(active_tab
);
1320 exception_error("init_second_stage", e
);
1328 if (arguments
.callee
.done
) return;
1329 arguments
.callee
.done
= true;
1331 if (getURLParam('debug')) {
1332 document
.getElementById('debug_output').style
.display
= 'block';
1333 debug('debug mode activated');
1338 document
.getElementById("prefContent").innerHTML
=
1339 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1340 "to function properly. Your browser doesn't seem to support it.";
1344 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1345 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1349 exception_error("init", e
);
1353 function categorizeSelectedFeeds() {
1355 if (!xmlhttp_ready(xmlhttp
)) {
1356 printLockingError();
1360 var sel_rows
= getSelectedFeeds();
1362 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1363 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1365 if (sel_rows
.length
> 0) {
1367 notify_progress("Changing category of selected feeds...");
1369 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1370 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1371 xmlhttp
.onreadystatechange
=feedlist_callback
;
1376 alert(__("No feeds are selected."));
1382 function validatePrefsReset() {
1383 return confirm(__("Reset to defaults?"));
1386 function browseFeeds(limit
) {
1388 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1389 xmlhttp
.onreadystatechange
=infobox_callback
;
1394 function feedBrowserSubscribe() {
1397 var selected
= getSelectedFeedsFromBrowser();
1399 if (selected
.length
> 0) {
1401 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1402 param_escape(selected
.toString()), true);
1403 xmlhttp
.onreadystatechange
=feedlist_callback
;
1406 alert("No feeds are selected.");
1410 exception_error("feedBrowserSubscribe", e
);
1414 function updateBigFeedBrowser(limit
) {
1416 if (!xmlhttp_ready(xmlhttp
)) {
1417 printLockingError();
1421 // p_notify("Loading, please wait...");
1423 var query
= "backend.php?op=pref-feed-browser";
1425 var limit_sel
= document
.getElementById("feedBrowserLimit");
1428 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1429 query
= query
+ "&limit=" + param_escape(limit
);
1432 xmlhttp
.open("GET", query
, true);
1433 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1437 function browserToggleExpand(id
) {
1439 /* if (feed_to_expand && feed_to_expand != id) {
1440 var d = document.getElementById("BRDET-" + feed_to_expand);
1441 d.style.display = "none";
1444 if (!xmlhttp_ready(xmlhttp
)) {
1445 printLockingError();
1449 var d
= document
.getElementById("BRDET-" + id
);
1451 if (d
.style
.display
== "block") {
1452 d
.style
.display
= "none";
1456 feed_to_expand
= id
;
1458 d
.style
.display
= "block";
1459 d
.innerHTML
= "Loading, please wait...";
1461 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1462 + param_escape(id
), true);
1463 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1468 exception_error("browserExpand", e
);
1472 function selectPrefRows(kind
, select
) {
1475 var opbarid
= false;
1480 if (kind
== "feed") {
1481 opbarid
= "feedOpToolbar";
1484 lname
= "prefFeedList";
1485 } else if (kind
== "fcat") {
1486 opbarid
= "catOpToolbar";
1489 lname
= "prefFeedCatList";
1490 } else if (kind
== "filter") {
1491 opbarid
= "filterOpToolbar";
1494 lname
= "prefFilterList";
1495 } else if (kind
== "label") {
1496 opbarid
= "labelOpToolbar";
1499 lname
= "prefLabelList";
1500 } else if (kind
== "user") {
1501 opbarid
= "userOpToolbar";
1504 lname
= "prefUserList";
1508 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1509 disableContainerChildren(opbarid
, !select
);
1516 function toggleSelectPrefRow(sender
, kind
) {
1518 toggleSelectRow(sender
);
1521 var opbarid
= false;
1524 if (kind
== "feed") {
1525 opbarid
= "feedOpToolbar";
1526 nsel
= getSelectedFeeds();
1527 } else if (kind
== "fcat") {
1528 opbarid
= "catOpToolbar";
1529 nsel
= getSelectedFeedCats();
1530 } else if (kind
== "filter") {
1531 opbarid
= "filterOpToolbar";
1532 nsel
= getSelectedFilters();
1533 } else if (kind
== "label") {
1534 opbarid
= "labelOpToolbar";
1535 nsel
= getSelectedLabels();
1536 } else if (kind
== "user") {
1537 opbarid
= "userOpToolbar";
1538 nsel
= getSelectedUsers();
1541 if (opbarid
&& nsel
!= -1) {
1542 disableContainerChildren(opbarid
, nsel
== false);
1548 function toggleSelectFBListRow(sender
) {
1549 toggleSelectListRow(sender
);
1550 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1555 function pref_hotkey_handler(e
) {
1560 if (!hotkeys_enabled
) return;
1563 keycode
= window
.event
.keyCode
;
1568 if (keycode
== 13 || keycode
== 27) {
1571 seq
= seq
+ "" + keycode
;
1575 if (document
.getElementById("piggie")) {
1577 if (seq
.match("807371717369")) {
1579 localPiggieFunction(true);
1581 localPiggieFunction(false);
1586 exception_error("pref_hotkey_handler", e
);
1590 function userSwitch() {
1591 var chooser
= document
.getElementById("userSwitch");
1592 var user
= chooser
[chooser
.selectedIndex
].value
;
1593 window
.location
= "prefs.php?swu=" + user
;
1596 function editFeedCats() {
1597 if (!xmlhttp_ready(xmlhttp
)) {
1598 printLockingError();
1602 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1603 xmlhttp
.onreadystatechange
=infobox_callback
;
1607 function showFeedsWithErrors() {
1608 displayDlg('feedUpdateErrors');
1611 function changeUserPassword() {
1615 if (!xmlhttp_ready(xmlhttp
)) {
1616 printLockingError();
1620 var query
= Form
.serialize("change_pass_form");
1622 notify_progress("Trying to change password...");
1624 xmlhttp
.open("POST", "backend.php", true);
1625 xmlhttp
.onreadystatechange
=changepass_callback
;
1626 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1627 xmlhttp
.send(query
);
1630 exception_error("changeUserPassword", e
);
1636 function changeUserEmail() {
1640 if (!xmlhttp_ready(xmlhttp
)) {
1641 printLockingError();
1645 var query
= Form
.serialize("change_email_form");
1647 notify_progress("Trying to change e-mail...");
1649 xmlhttp
.open("POST", "backend.php", true);
1650 xmlhttp
.onreadystatechange
=notify_callback
;
1651 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1652 xmlhttp
.send(query
);
1655 exception_error("changeUserPassword", e
);