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;
20 function replace_pubkey_callback() {
21 if (xmlhttp.readyState == 4) {
23 var link = document.getElementById("pubGenAddress");
25 if (xmlhttp.responseXML) {
29 notify_error("Error while changing adress");
32 exception_error("replace_pubkey_callback", e);
37 function expand_feed_callback() {
38 if (xmlhttp
.readyState
== 4) {
40 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
41 container
.innerHTML
=xmlhttp
.responseText
;
42 container
.style
.display
= "block";
45 exception_error("expand_feed_callback", e
);
50 function feedlist_callback() {
51 if (xmlhttp
.readyState
== 4) {
53 var container
= document
.getElementById('prefContent');
54 container
.innerHTML
=xmlhttp
.responseText
;
55 selectTab("feedConfig", true);
58 var tuple
= caller_subop
.split(":");
59 if (tuple
[0] == 'editFeed') {
60 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
65 if (typeof correctPNG
!= 'undefined') {
70 exception_error("feedlist_callback", e
);
75 /* stub for subscription dialog */
77 function dlg_frefresh_callback() {
78 if (xmlhttp
.readyState
== 4) {
79 // setTimeout("updateFeedList()", 500);
82 var container
= document
.getElementById('prefContent');
83 container
.innerHTML
=xmlhttp
.responseText
;
84 selectTab("feedConfig", true);
87 var tuple
= caller_subop
.split(":");
88 if (tuple
[0] == 'editFeed') {
89 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
94 if (typeof correctPNG
!= 'undefined') {
99 exception_error("feedlist_callback", e
);
104 function filterlist_callback() {
105 var container
= document
.getElementById('prefContent');
106 if (xmlhttp
.readyState
== 4) {
107 container
.innerHTML
=xmlhttp
.responseText
;
108 if (typeof correctPNG
!= 'undefined') {
115 function labellist_callback() {
116 var container
= document
.getElementById('prefContent');
117 if (xmlhttp
.readyState
== 4) {
119 container
.innerHTML
=xmlhttp
.responseText
;
121 var row
= document
.getElementById("LILRR-" + active_label
);
123 if (!row
.className
.match("Selected")) {
124 row
.className
= row
.className
+ "Selected";
127 var checkbox
= document
.getElementById("LICHK-" + active_label
);
130 checkbox
.checked
= true;
133 if (typeof correctPNG
!= 'undefined') {
140 function labeltest_callback() {
141 var container
= document
.getElementById('label_test_result');
142 if (xmlhttp
.readyState
== 4) {
143 container
.innerHTML
=xmlhttp
.responseText
;
148 function feed_browser_callback() {
149 var container
= document
.getElementById('prefContent');
150 if (xmlhttp
.readyState
== 4) {
151 container
.innerHTML
=xmlhttp
.responseText
;
156 function userlist_callback() {
157 var container
= document
.getElementById('prefContent');
158 if (xmlhttp
.readyState
== 4) {
159 container
.innerHTML
=xmlhttp
.responseText
;
164 function prefslist_callback() {
165 var container
= document
.getElementById('prefContent');
166 if (xmlhttp
.readyState
== 4) {
168 container
.innerHTML
=xmlhttp
.responseText
;
174 function gethelp_callback() {
175 var container
= document
.getElementById('prefHelpBox');
176 if (xmlhttp
.readyState
== 4) {
178 container
.innerHTML
= xmlhttp
.responseText
;
179 container
.style
.display
= "block";
184 function notify_callback() {
185 if (xmlhttp
.readyState
== 4) {
186 notify_info(xmlhttp
.responseText
);
191 function changepass_callback() {
193 if (xmlhttp
.readyState
== 4) {
195 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
196 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
198 notify_info(xmlhttp
.responseText
);
199 var warn
= document
.getElementById("default_pass_warning");
200 if (warn
) warn
.style
.display
= "none";
203 document
.forms
['change_pass_form'].reset();
207 exception_error("changepass_callback", e
);
211 function updateFeedList(sort_key
) {
213 if (!xmlhttp_ready(xmlhttp
)) {
218 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
220 // p_notify("Loading, please wait...");
222 var feed_search
= document
.getElementById("feed_search");
224 if (feed_search
) { search
= feed_search
.value
; }
226 var slat
= document
.getElementById("show_last_article_times");
228 var slat_checked
= false;
230 slat_checked
= slat
.checked
;
233 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
234 "&sort=" + param_escape(sort_key
) +
235 "&slat=" + param_escape(slat_checked
) +
236 "&search=" + param_escape(search
), true);
237 xmlhttp
.onreadystatechange
=feedlist_callback
;
242 function updateUsersList(sort_key
) {
244 if (!xmlhttp_ready(xmlhttp
)) {
249 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
251 // p_notify("Loading, please wait...");
253 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
254 + param_escape(sort_key
), true);
255 xmlhttp
.onreadystatechange
=userlist_callback
;
260 function addLabel() {
262 if (!xmlhttp_ready(xmlhttp
)) {
267 var form
= document
.forms
['label_edit_form'];
269 var sql_exp
= form
.sql_exp
.value
;
270 var description
= form
.description
.value
;
273 alert("Can't create label: missing SQL expression.");
277 if (description
== "") {
278 alert("Can't create label: missing caption.");
282 var query
= Form
.serialize("label_edit_form");
284 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
285 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
291 if (!xmlhttp_ready(xmlhttp
)) {
296 var link
= document
.getElementById("fadd_link");
298 if (link
.value
.length
== 0) {
299 alert(__("Error: No feed URL given."));
300 } else if (!isValidURL(link
.value
)) {
301 alert(__("Error: Invalid feed URL."));
303 notify_progress("Adding feed...");
305 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
306 param_escape(link
.value
), true);
307 xmlhttp
.onreadystatechange
=feedlist_callback
;
316 function addFeedCat() {
318 if (!xmlhttp_ready(xmlhttp
)) {
323 var cat
= document
.getElementById("fadd_cat");
325 if (cat
.value
.length
== 0) {
326 alert(__("Can't add category: no name specified."));
328 notify_progress("Adding feed category...");
330 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
331 param_escape(cat
.value
), true);
332 xmlhttp
.onreadystatechange
=infobox_callback
;
342 if (!xmlhttp_ready(xmlhttp
)) {
347 var sqlexp
= document
.getElementById("uadd_box");
349 if (sqlexp
.value
.length
== 0) {
350 alert("Can't add user: no login specified.");
352 notify_progress("Adding user...");
354 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
355 param_escape(sqlexp
.value
), true);
357 xmlhttp
.onreadystatechange
=userlist_callback
;
365 function editLabel(id
) {
367 if (!xmlhttp_ready(xmlhttp
)) {
372 notify_progress("Loading, please wait...");
374 document
.getElementById("label_create_btn").disabled
= true;
378 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
379 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
381 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
382 param_escape(id
), true);
383 xmlhttp
.onreadystatechange
=infobox_callback
;
388 function editUser(id
) {
390 if (!xmlhttp_ready(xmlhttp
)) {
395 notify_progress("Loading, please wait...");
397 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
398 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
400 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
401 param_escape(id
), true);
402 xmlhttp
.onreadystatechange
=infobox_callback
;
407 function editFilter(id
) {
409 if (!xmlhttp_ready(xmlhttp
)) {
414 notify_progress("Loading, please wait...");
416 document
.getElementById("create_filter_btn").disabled
= true;
418 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
419 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
421 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
422 xmlhttp
.onreadystatechange
=infobox_callback
;
426 function editFeed(feed
) {
428 // notify("Editing feed...");
430 if (!xmlhttp_ready(xmlhttp
)) {
435 notify_progress("Loading, please wait...");
437 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
440 document
.getElementById("top25_feeds_btn").disabled
= true;
442 // this button is not always available, no-op if not found
445 // clean selection from all rows & select row being edited
446 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
447 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
449 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
450 param_escape(feed
), true);
452 xmlhttp
.onreadystatechange
=infobox_callback
;
457 function editFeedCat(cat
) {
459 if (!xmlhttp_ready(xmlhttp
)) {
464 notify_progress("Loading, please wait...");
466 active_feed_cat
= cat
;
468 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
469 param_escape(cat
), true);
470 xmlhttp
.onreadystatechange
=infobox_callback
;
475 function getSelectedLabels() {
476 return getSelectedTableRowIds("prefLabelList", "LILRR");
479 function getSelectedUsers() {
480 return getSelectedTableRowIds("prefUserList", "UMRR");
483 function getSelectedFeeds() {
484 return getSelectedTableRowIds("prefFeedList", "FEEDR");
487 function getSelectedFilters() {
488 return getSelectedTableRowIds("prefFilterList", "FILRR");
491 function getSelectedFeedCats() {
492 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
495 function getSelectedFeedsFromBrowser() {
497 var list
= document
.getElementById("browseFeedList");
498 if (!list
) list
= document
.getElementById("browseBigFeedList");
500 var selected
= new Array();
502 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
503 var child
= list
.childNodes
[i
];
504 if (child
.id
&& child
.id
.match("FBROW-")) {
505 var id
= child
.id
.replace("FBROW-", "");
507 var cb
= document
.getElementById("FBCHK-" + id
);
518 function removeSelectedLabels() {
520 if (!xmlhttp_ready(xmlhttp
)) {
525 var sel_rows
= getSelectedLabels();
527 if (sel_rows
.length
> 0) {
529 var ok
= confirm("Remove selected labels?");
532 notify_progress("Removing selected labels...");
534 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
535 param_escape(sel_rows
.toString()), true);
536 xmlhttp
.onreadystatechange
=labellist_callback
;
540 alert("No labels are selected.");
546 function removeSelectedUsers() {
548 if (!xmlhttp_ready(xmlhttp
)) {
553 var sel_rows
= getSelectedUsers();
555 if (sel_rows
.length
> 0) {
557 var ok
= confirm("Remove selected users?");
560 notify_progress("Removing selected users...");
562 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
563 param_escape(sel_rows
.toString()), true);
564 xmlhttp
.onreadystatechange
=userlist_callback
;
569 alert("No users are selected.");
575 function removeSelectedFilters() {
577 if (!xmlhttp_ready(xmlhttp
)) {
582 var sel_rows
= getSelectedFilters();
584 if (sel_rows
.length
> 0) {
586 var ok
= confirm("Remove selected filters?");
589 notify_progress("Removing selected filters...");
591 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
592 param_escape(sel_rows
.toString()), true);
593 xmlhttp
.onreadystatechange
=filterlist_callback
;
597 alert("No filters are selected.");
604 function removeSelectedFeeds() {
606 if (!xmlhttp_ready(xmlhttp
)) {
611 var sel_rows
= getSelectedFeeds();
613 if (sel_rows
.length
> 0) {
615 var ok
= confirm("Unsubscribe from selected feeds?");
619 notify_progress("Unsubscribing from selected feeds...");
621 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
622 param_escape(sel_rows
.toString()), true);
623 xmlhttp
.onreadystatechange
=feedlist_callback
;
629 alert("No feeds are selected.");
636 function removeSelectedFeedCats() {
638 if (!xmlhttp_ready(xmlhttp
)) {
643 var sel_rows
= getSelectedFeedCats();
645 if (sel_rows
.length
> 0) {
647 var ok
= confirm("Remove selected categories?");
650 notify_progress("Removing selected categories...");
652 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
653 param_escape(sel_rows
.toString()), true);
654 xmlhttp
.onreadystatechange
=infobox_callback
;
660 alert("No categories are selected.");
667 function feedEditCancel() {
669 if (!xmlhttp_ready(xmlhttp
)) {
674 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
677 document
.getElementById("top25_feeds_btn").disabled
= false;
679 // this button is not always available, no-op if not found
684 selectPrefRows('feed', false); // cleanup feed selection
689 function feedCatEditCancel() {
691 if (!xmlhttp_ready(xmlhttp
)) {
696 active_feed_cat
= false;
698 // notify("Operation cancelled.");
700 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
701 xmlhttp
.onreadystatechange
=infobox_callback
;
707 function feedEditSave() {
711 if (!xmlhttp_ready(xmlhttp
)) {
716 // FIXME: add parameter validation
718 var query
= Form
.serialize("edit_feed_form");
720 notify_progress("Saving feed...");
722 xmlhttp
.open("POST", "backend.php", true);
723 xmlhttp
.onreadystatechange
=feedlist_callback
;
724 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
732 exception_error("feedEditSave", e
);
736 function feedCatEditSave() {
738 if (!xmlhttp_ready(xmlhttp
)) {
743 notify_progress("Saving category...");
745 var query
= Form
.serialize("feed_cat_edit_form");
747 xmlhttp
.open("GET", "backend.php?" + query
, true);
748 xmlhttp
.onreadystatechange
=infobox_callback
;
751 active_feed_cat
= false;
757 function labelTest() {
759 var container
= document
.getElementById('label_test_result');
760 container
.style
.display
= "block";
761 container
.innerHTML
= "<p>Loading, please wait...</p>";
763 var form
= document
.forms
['label_edit_form'];
765 var sql_exp
= form
.sql_exp
.value
;
766 var description
= form
.description
.value
;
768 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
769 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
771 xmlhttp
.onreadystatechange
=labeltest_callback
;
777 function displayHelpInfobox(topic_id
) {
779 /* if (!xmlhttp_ready(xmlhttp)) {
784 notify_progress("Loading help...");
786 xmlhttp.open("GET", "backend.php?op=help&tid=" +
787 param_escape(topic_id), true);
789 xmlhttp.onreadystatechange=helpbox_callback;
790 xmlhttp.send(null); */
792 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
794 var w
= window
.open(url
, "ttrss_help",
795 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
799 function labelEditCancel() {
801 if (!xmlhttp_ready(xmlhttp
)) {
806 document
.getElementById("label_create_btn").disabled
= false;
808 active_label
= false;
810 selectPrefRows('label', false); // cleanup feed selection
816 function userEditCancel() {
818 if (!xmlhttp_ready(xmlhttp
)) {
823 selectPrefRows('user', false); // cleanup feed selection
829 function filterEditCancel() {
831 if (!xmlhttp_ready(xmlhttp
)) {
836 document
.getElementById("create_filter_btn").disabled
= false;
838 selectPrefRows('filter', false); // cleanup feed selection
844 function labelEditSave() {
846 var label
= active_label
;
848 if (!xmlhttp_ready(xmlhttp
)) {
853 /* if (!is_opera()) {
855 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
856 var description = document.forms["label_edit_form"].description.value;
858 if (sql_exp.length == 0) {
859 alert("SQL Expression cannot be blank.");
863 if (description.length == 0) {
864 alert("Caption field cannot be blank.");
871 notify_progress("Saving label...");
873 active_label
= false;
875 query
= Form
.serialize("label_edit_form");
877 xmlhttp
.open("GET", "backend.php?" + query
, true);
878 xmlhttp
.onreadystatechange
=labellist_callback
;
884 function userEditSave() {
886 if (!xmlhttp_ready(xmlhttp
)) {
891 var login
= document
.forms
["user_edit_form"].login
.value
;
893 if (login
.length
== 0) {
894 alert("Login field cannot be blank.");
898 notify_progress("Saving user...");
902 var query
= Form
.serialize("user_edit_form");
904 xmlhttp
.open("GET", "backend.php?" + query
, true);
905 xmlhttp
.onreadystatechange
=userlist_callback
;
912 function filterEditSave() {
914 if (!xmlhttp_ready(xmlhttp
)) {
919 /* if (!is_opera()) {
920 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
922 if (reg_exp.length == 0) {
923 alert("Filter expression field cannot be blank.");
928 notify_progress("Saving filter...");
930 var query
= Form
.serialize("filter_edit_form");
934 document
.getElementById("create_filter_btn").disabled
= false;
936 xmlhttp
.open("GET", "backend.php?" + query
, true);
937 xmlhttp
.onreadystatechange
=filterlist_callback
;
943 function editSelectedLabel() {
944 var rows
= getSelectedLabels();
946 if (rows
.length
== 0) {
947 alert(__("No labels are selected."));
951 if (rows
.length
> 1) {
952 alert(__("Please select only one label."));
962 function editSelectedUser() {
963 var rows
= getSelectedUsers();
965 if (rows
.length
== 0) {
966 alert(__("No users are selected."));
970 if (rows
.length
> 1) {
971 alert(__("Please select only one user."));
980 function resetSelectedUserPass() {
981 var rows
= getSelectedUsers();
983 if (rows
.length
== 0) {
984 alert(__("No users are selected."));
988 if (rows
.length
> 1) {
989 alert(__("Please select only one user."));
993 var ok
= confirm(__("Reset password of selected user?"));
996 notify_progress("Resetting password for selected user...");
1000 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1001 param_escape(id
), true);
1002 xmlhttp
.onreadystatechange
=userlist_callback
;
1007 function selectedUserDetails() {
1009 if (!xmlhttp_ready(xmlhttp
)) {
1010 printLockingError();
1014 var rows
= getSelectedUsers();
1016 if (rows
.length
== 0) {
1017 alert(__("No users are selected."));
1021 if (rows
.length
> 1) {
1022 alert(__("Please select only one user."));
1026 notify_progress("Loading, please wait...");
1030 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1031 xmlhttp
.onreadystatechange
=infobox_callback
;
1036 function selectedFeedDetails() {
1038 if (!xmlhttp_ready(xmlhttp
)) {
1039 printLockingError();
1043 var rows
= getSelectedFeeds();
1045 if (rows
.length
== 0) {
1046 alert(__("No feeds are selected."));
1050 if (rows
.length
> 1) {
1051 alert(__("Please select only one feed."));
1055 // var id = rows[0];
1059 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1060 param_escape(rows
.toString()), true);
1061 xmlhttp
.onreadystatechange
=infobox_callback
;
1066 function editSelectedFilter() {
1067 var rows
= getSelectedFilters();
1069 if (rows
.length
== 0) {
1070 alert(__("No filters are selected."));
1074 if (rows
.length
> 1) {
1075 alert(__("Please select only one filter."));
1081 editFilter(rows
[0]);
1086 function editSelectedFeed() {
1087 var rows
= getSelectedFeeds();
1089 if (rows
.length
== 0) {
1090 alert(__("No feeds are selected."));
1094 if (rows
.length
> 1) {
1095 alert(__("Please select one feed."));
1105 function editSelectedFeedCat() {
1106 var rows
= getSelectedFeedCats();
1108 if (rows
.length
== 0) {
1109 alert(__("No categories are selected."));
1113 if (rows
.length
> 1) {
1114 alert(__("Please select only one category."));
1120 editFeedCat(rows
[0]);
1124 function piggie_callback() {
1125 var piggie
= document
.getElementById("piggie");
1127 piggie
.style
.top
= piggie_top
;
1128 piggie
.style
.backgroundColor
= "white";
1129 piggie
.style
.borderWidth
= "1px";
1131 if (piggie_fwd
&& piggie_top
< 0) {
1132 setTimeout("piggie_callback()", 50);
1133 piggie_top
= piggie_top
+ 10;
1134 } else if (piggie_fwd
&& piggie_top
>= 0) {
1136 setTimeout("piggie_callback()", 50);
1137 } else if (!piggie_fwd
&& piggie_top
> -400) {
1138 setTimeout("piggie_callback()", 50);
1139 piggie_top
= piggie_top
- 10;
1140 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1141 piggie
.style
.display
= "none";
1146 var piggie_opacity
= 0;
1148 function piggie2_callback() {
1149 var piggie
= document
.getElementById("piggie");
1150 piggie
.style
.top
= 0;
1151 piggie
.style
.opacity
= piggie_opacity
;
1152 piggie
.style
.backgroundColor
= "transparent";
1153 piggie
.style
.borderWidth
= "0px";
1155 if (piggie_fwd
&& piggie_opacity
< 1) {
1156 setTimeout("piggie2_callback()", 50);
1157 piggie_opacity
= piggie_opacity
+ 0.03;
1158 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1160 setTimeout("piggie2_callback()", 50);
1161 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1162 setTimeout("piggie2_callback()", 50);
1163 piggie_opacity
= piggie_opacity
- 0.03;
1164 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1165 piggie
.style
.display
= "none";
1170 function localPiggieFunction(enable
) {
1172 debug("I LOVEDED IT!");
1173 var piggie
= document
.getElementById("piggie");
1174 piggie
.style
.display
= "block";
1176 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1184 function validateOpmlImport() {
1186 var opml_file
= document
.getElementById("opml_file");
1188 if (opml_file
.value
.length
== 0) {
1189 alert(__("No OPML file to upload."));
1196 function updateFilterList(sort_key
) {
1198 if (!xmlhttp_ready(xmlhttp
)) {
1199 printLockingError();
1203 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1205 // p_notify("Loading, please wait...");
1207 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1208 param_escape(sort_key
), true);
1209 xmlhttp
.onreadystatechange
=filterlist_callback
;
1214 function updateLabelList(sort_key
) {
1216 if (!xmlhttp_ready(xmlhttp
)) {
1217 printLockingError();
1221 // p_notify("Loading, please wait...");
1223 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1225 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1226 param_escape(sort_key
), true);
1227 xmlhttp
.onreadystatechange
=labellist_callback
;
1231 function updatePrefsList() {
1233 if (!xmlhttp_ready(xmlhttp
)) {
1234 printLockingError();
1238 // p_notify("Loading, please wait...");
1240 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1241 xmlhttp
.onreadystatechange
=prefslist_callback
;
1246 function selectTab(id
, noupdate
, subop
) {
1250 if (!id
) id
= active_tab
;
1254 if (!xmlhttp_ready(xmlhttp
)) {
1255 printLockingError();
1260 var c
= document
.getElementById('prefContent');
1266 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1268 notify_progress("Loading, please wait...");
1270 // close active infobox if needed
1273 // clean up all current selections, just in case
1274 active_feed_cat
= false;
1275 active_label
= false;
1277 if (id
== "feedConfig") {
1279 } else if (id
== "filterConfig") {
1281 } else if (id
== "labelConfig") {
1283 } else if (id
== "genConfig") {
1285 } else if (id
== "userConfig") {
1287 } else if (id
== "feedBrowser") {
1288 updateBigFeedBrowser();
1292 var tab
= document
.getElementById(active_tab
+ "Tab");
1295 if (tab
.className
.match("Selected")) {
1296 tab
.className
= "prefsTab";
1300 tab
= document
.getElementById(id
+ "Tab");
1303 if (!tab
.className
.match("Selected")) {
1304 tab
.className
= tab
.className
+ "Selected";
1311 exception_error("selectTab", e
);
1315 function backend_sanity_check_callback() {
1317 if (xmlhttp
.readyState
== 4) {
1321 if (sanity_check_done
) {
1322 fatalError(11, "Sanity check request received twice. This can indicate "+
1323 "presence of Firebug or some other disrupting extension. "+
1324 "Please disable it and try again.");
1328 if (!xmlhttp
.responseXML
) {
1329 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1333 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1336 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1340 var error_code
= reply
.getAttribute("error-code");
1342 if (error_code
&& error_code
!= 0) {
1343 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1346 debug("sanity check ok");
1348 var params
= reply
.nextSibling
;
1351 debug('reading init-params...');
1352 var param
= params
.firstChild
;
1355 var k
= param
.getAttribute("key");
1356 var v
= param
.getAttribute("value");
1357 debug(k
+ " => " + v
);
1359 param
= param
.nextSibling
;
1363 sanity_check_done
= true;
1365 init_second_stage();
1368 exception_error("backend_sanity_check_callback", e
);
1373 function init_second_stage() {
1376 active_tab
= getInitParam("prefs_active_tab");
1377 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1379 document
.onkeydown
= pref_hotkey_handler
;
1381 var tab
= getURLParam('tab');
1383 caller_subop
= getURLParam('subop');
1389 if (navigator
.userAgent
.match("Opera")) {
1390 setTimeout("selectTab()", 500);
1392 selectTab(active_tab
);
1396 exception_error("init_second_stage", e
);
1404 if (arguments
.callee
.done
) return;
1405 arguments
.callee
.done
= true;
1407 if (getURLParam('debug')) {
1408 document
.getElementById('debug_output').style
.display
= 'block';
1409 debug('debug mode activated');
1414 document
.getElementById("prefContent").innerHTML
=
1415 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1416 "to function properly. Your browser doesn't seem to support it.";
1420 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1421 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1425 exception_error("init", e
);
1429 function categorizeSelectedFeeds() {
1431 if (!xmlhttp_ready(xmlhttp
)) {
1432 printLockingError();
1436 var sel_rows
= getSelectedFeeds();
1438 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1439 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1441 if (sel_rows
.length
> 0) {
1443 notify_progress("Changing category of selected feeds...");
1445 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1446 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1447 xmlhttp
.onreadystatechange
=feedlist_callback
;
1452 alert(__("No feeds are selected."));
1458 function validatePrefsReset() {
1459 return confirm(__("Reset to defaults?"));
1462 function browseFeeds(limit
) {
1464 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1465 xmlhttp
.onreadystatechange
=infobox_callback
;
1470 function feedBrowserSubscribe() {
1473 var selected
= getSelectedFeedsFromBrowser();
1475 if (selected
.length
> 0) {
1477 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1478 param_escape(selected
.toString()), true);
1479 xmlhttp
.onreadystatechange
=feedlist_callback
;
1482 alert("No feeds are selected.");
1486 exception_error("feedBrowserSubscribe", e
);
1490 function updateBigFeedBrowser(limit
) {
1492 if (!xmlhttp_ready(xmlhttp
)) {
1493 printLockingError();
1497 // p_notify("Loading, please wait...");
1499 var query
= "backend.php?op=pref-feed-browser";
1501 var limit_sel
= document
.getElementById("feedBrowserLimit");
1504 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1505 query
= query
+ "&limit=" + param_escape(limit
);
1508 xmlhttp
.open("GET", query
, true);
1509 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1513 function browserToggleExpand(id
) {
1515 /* if (feed_to_expand && feed_to_expand != id) {
1516 var d = document.getElementById("BRDET-" + feed_to_expand);
1517 d.style.display = "none";
1520 if (!xmlhttp_ready(xmlhttp
)) {
1521 printLockingError();
1525 var d
= document
.getElementById("BRDET-" + id
);
1527 if (d
.style
.display
== "block") {
1528 d
.style
.display
= "none";
1532 feed_to_expand
= id
;
1534 d
.style
.display
= "block";
1535 d
.innerHTML
= "Loading, please wait...";
1537 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1538 + param_escape(id
), true);
1539 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1544 exception_error("browserExpand", e
);
1548 function selectPrefRows(kind
, select
) {
1551 var opbarid
= false;
1556 if (kind
== "feed") {
1557 opbarid
= "feedOpToolbar";
1560 lname
= "prefFeedList";
1561 } else if (kind
== "fcat") {
1562 opbarid
= "catOpToolbar";
1565 lname
= "prefFeedCatList";
1566 } else if (kind
== "filter") {
1567 opbarid
= "filterOpToolbar";
1570 lname
= "prefFilterList";
1571 } else if (kind
== "label") {
1572 opbarid
= "labelOpToolbar";
1575 lname
= "prefLabelList";
1576 } else if (kind
== "user") {
1577 opbarid
= "userOpToolbar";
1580 lname
= "prefUserList";
1584 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1585 disableContainerChildren(opbarid
, !select
);
1592 function toggleSelectPrefRow(sender
, kind
) {
1594 toggleSelectRow(sender
);
1597 var opbarid
= false;
1600 if (kind
== "feed") {
1601 opbarid
= "feedOpToolbar";
1602 nsel
= getSelectedFeeds();
1603 } else if (kind
== "fcat") {
1604 opbarid
= "catOpToolbar";
1605 nsel
= getSelectedFeedCats();
1606 } else if (kind
== "filter") {
1607 opbarid
= "filterOpToolbar";
1608 nsel
= getSelectedFilters();
1609 } else if (kind
== "label") {
1610 opbarid
= "labelOpToolbar";
1611 nsel
= getSelectedLabels();
1612 } else if (kind
== "user") {
1613 opbarid
= "userOpToolbar";
1614 nsel
= getSelectedUsers();
1617 if (opbarid
&& nsel
!= -1) {
1618 disableContainerChildren(opbarid
, nsel
== false);
1624 function toggleSelectFBListRow(sender
) {
1625 toggleSelectListRow(sender
);
1626 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1631 function pref_hotkey_handler(e
) {
1636 if (!hotkeys_enabled
) return;
1639 keycode
= window
.event
.keyCode
;
1644 if (keycode
== 13 || keycode
== 27) {
1647 seq
= seq
+ "" + keycode
;
1651 if (document
.getElementById("piggie")) {
1653 if (seq
.match("807371717369")) {
1655 localPiggieFunction(true);
1657 localPiggieFunction(false);
1662 exception_error("pref_hotkey_handler", e
);
1666 function userSwitch() {
1667 var chooser
= document
.getElementById("userSwitch");
1668 var user
= chooser
[chooser
.selectedIndex
].value
;
1669 window
.location
= "prefs.php?swu=" + user
;
1672 function editFeedCats() {
1673 if (!xmlhttp_ready(xmlhttp
)) {
1674 printLockingError();
1678 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1681 document
.getElementById("top25_feeds_btn").disabled
= true;
1683 // this button is not always available, no-op if not found
1686 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1687 xmlhttp
.onreadystatechange
=infobox_callback
;
1691 function showFeedsWithErrors() {
1692 displayDlg('feedUpdateErrors');
1695 function changeUserPassword() {
1699 if (!xmlhttp_ready(xmlhttp
)) {
1700 printLockingError();
1704 var query
= Form
.serialize("change_pass_form");
1706 notify_progress("Trying to change password...");
1708 xmlhttp
.open("POST", "backend.php", true);
1709 xmlhttp
.onreadystatechange
=changepass_callback
;
1710 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1711 xmlhttp
.send(query
);
1714 exception_error("changeUserPassword", e
);
1720 function changeUserEmail() {
1724 if (!xmlhttp_ready(xmlhttp
)) {
1725 printLockingError();
1729 var query
= Form
.serialize("change_email_form");
1731 notify_progress("Trying to change e-mail...");
1733 xmlhttp
.open("POST", "backend.php", true);
1734 xmlhttp
.onreadystatechange
=notify_callback
;
1735 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1736 xmlhttp
.send(query
);
1739 exception_error("changeUserPassword", e
);
1746 function feedlistToggleSLAT() {
1747 notify_progress("Loading, please wait...");
1752 function pubRegenKey() {
1754 if (!xmlhttp_ready(xmlhttp)) {
1755 printLockingError();
1759 var ok = confirm("Replace current publishing address with a new one?");
1763 notify_progress("Trying to change address...");
1765 xmlhttp.open("GET", "backend.php?op=backend-rpc&subop=regen-pub-key");
1766 xmlhttp.onreadystatechange=replace_pubkey_callback;