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 /* stub for subscription dialog */
59 function dlg_frefresh_callback() {
60 if (xmlhttp
.readyState
== 4) {
61 // setTimeout("updateFeedList()", 500);
64 var container
= document
.getElementById('prefContent');
65 container
.innerHTML
=xmlhttp
.responseText
;
66 selectTab("feedConfig", true);
69 var tuple
= caller_subop
.split(":");
70 if (tuple
[0] == 'editFeed') {
71 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
76 if (typeof correctPNG
!= 'undefined') {
81 exception_error("feedlist_callback", e
);
86 function filterlist_callback() {
87 var container
= document
.getElementById('prefContent');
88 if (xmlhttp
.readyState
== 4) {
89 container
.innerHTML
=xmlhttp
.responseText
;
90 if (typeof correctPNG
!= 'undefined') {
97 function labellist_callback() {
98 var container
= document
.getElementById('prefContent');
99 if (xmlhttp
.readyState
== 4) {
101 container
.innerHTML
=xmlhttp
.responseText
;
103 var row
= document
.getElementById("LILRR-" + active_label
);
105 if (!row
.className
.match("Selected")) {
106 row
.className
= row
.className
+ "Selected";
109 var checkbox
= document
.getElementById("LICHK-" + active_label
);
112 checkbox
.checked
= true;
115 if (typeof correctPNG
!= 'undefined') {
122 function labeltest_callback() {
123 var container
= document
.getElementById('label_test_result');
124 if (xmlhttp
.readyState
== 4) {
125 container
.innerHTML
=xmlhttp
.responseText
;
130 function feed_browser_callback() {
131 var container
= document
.getElementById('prefContent');
132 if (xmlhttp
.readyState
== 4) {
133 container
.innerHTML
=xmlhttp
.responseText
;
138 function userlist_callback() {
139 var container
= document
.getElementById('prefContent');
140 if (xmlhttp
.readyState
== 4) {
141 container
.innerHTML
=xmlhttp
.responseText
;
146 function prefslist_callback() {
147 var container
= document
.getElementById('prefContent');
148 if (xmlhttp
.readyState
== 4) {
150 container
.innerHTML
=xmlhttp
.responseText
;
156 function gethelp_callback() {
157 var container
= document
.getElementById('prefHelpBox');
158 if (xmlhttp
.readyState
== 4) {
160 container
.innerHTML
= xmlhttp
.responseText
;
161 container
.style
.display
= "block";
166 function notify_callback() {
167 if (xmlhttp
.readyState
== 4) {
168 notify_info(xmlhttp
.responseText
);
173 function changepass_callback() {
175 if (xmlhttp
.readyState
== 4) {
177 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
178 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
180 notify_info(xmlhttp
.responseText
);
181 var warn
= document
.getElementById("default_pass_warning");
182 if (warn
) warn
.style
.display
= "none";
185 document
.forms
['change_pass_form'].reset();
189 exception_error("changepass_callback", e
);
193 function updateFeedList(sort_key
) {
195 if (!xmlhttp_ready(xmlhttp
)) {
200 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
202 // p_notify("Loading, please wait...");
204 var feed_search
= document
.getElementById("feed_search");
206 if (feed_search
) { search
= feed_search
.value
; }
208 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
209 "&sort=" + param_escape(sort_key
) +
210 "&search=" + param_escape(search
), true);
211 xmlhttp
.onreadystatechange
=feedlist_callback
;
216 function updateUsersList(sort_key
) {
218 if (!xmlhttp_ready(xmlhttp
)) {
223 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
225 // p_notify("Loading, please wait...");
227 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
228 + param_escape(sort_key
), true);
229 xmlhttp
.onreadystatechange
=userlist_callback
;
234 function addLabel() {
236 if (!xmlhttp_ready(xmlhttp
)) {
241 var form
= document
.forms
['label_edit_form'];
243 var sql_exp
= form
.sql_exp
.value
;
244 var description
= form
.description
.value
;
247 alert("Can't create label: missing SQL expression.");
251 if (description
== "") {
252 alert("Can't create label: missing caption.");
256 var query
= Form
.serialize("label_edit_form");
258 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
259 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
265 if (!xmlhttp_ready(xmlhttp
)) {
270 var link
= document
.getElementById("fadd_link");
272 if (link
.value
.length
== 0) {
273 alert(__("Error: No feed URL given."));
274 } else if (!isValidURL(link
.value
)) {
275 alert(__("Error: Invalid feed URL."));
277 notify_progress("Adding feed...");
279 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
280 param_escape(link
.value
), true);
281 xmlhttp
.onreadystatechange
=feedlist_callback
;
290 function addFeedCat() {
292 if (!xmlhttp_ready(xmlhttp
)) {
297 var cat
= document
.getElementById("fadd_cat");
299 if (cat
.value
.length
== 0) {
300 alert(__("Can't add category: no name specified."));
302 notify_progress("Adding feed category...");
304 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
305 param_escape(cat
.value
), true);
306 xmlhttp
.onreadystatechange
=infobox_callback
;
316 if (!xmlhttp_ready(xmlhttp
)) {
321 var sqlexp
= document
.getElementById("uadd_box");
323 if (sqlexp
.value
.length
== 0) {
324 alert("Can't add user: no login specified.");
326 notify_progress("Adding user...");
328 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
329 param_escape(sqlexp
.value
), true);
331 xmlhttp
.onreadystatechange
=userlist_callback
;
339 function editLabel(id
) {
341 if (!xmlhttp_ready(xmlhttp
)) {
346 notify_progress("Loading, please wait...");
348 document
.getElementById("label_create_btn").disabled
= true;
352 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
353 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
355 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
356 param_escape(id
), true);
357 xmlhttp
.onreadystatechange
=infobox_callback
;
362 function editUser(id
) {
364 if (!xmlhttp_ready(xmlhttp
)) {
369 notify_progress("Loading, please wait...");
371 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
372 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
374 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
375 param_escape(id
), true);
376 xmlhttp
.onreadystatechange
=infobox_callback
;
381 function editFilter(id
) {
383 if (!xmlhttp_ready(xmlhttp
)) {
388 notify_progress("Loading, please wait...");
390 document
.getElementById("create_filter_btn").disabled
= true;
392 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
393 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
395 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
396 xmlhttp
.onreadystatechange
=infobox_callback
;
400 function editFeed(feed
) {
402 // notify("Editing feed...");
404 if (!xmlhttp_ready(xmlhttp
)) {
409 notify_progress("Loading, please wait...");
411 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
414 document
.getElementById("top25_feeds_btn").disabled
= true;
416 // this button is not always available, no-op if not found
419 // clean selection from all rows & select row being edited
420 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
421 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
423 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
424 param_escape(feed
), true);
426 xmlhttp
.onreadystatechange
=infobox_callback
;
431 function editFeedCat(cat
) {
433 if (!xmlhttp_ready(xmlhttp
)) {
438 notify_progress("Loading, please wait...");
440 active_feed_cat
= cat
;
442 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
443 param_escape(cat
), true);
444 xmlhttp
.onreadystatechange
=infobox_callback
;
449 function getSelectedLabels() {
450 return getSelectedTableRowIds("prefLabelList", "LILRR");
453 function getSelectedUsers() {
454 return getSelectedTableRowIds("prefUserList", "UMRR");
457 function getSelectedFeeds() {
458 return getSelectedTableRowIds("prefFeedList", "FEEDR");
461 function getSelectedFilters() {
462 return getSelectedTableRowIds("prefFilterList", "FILRR");
465 function getSelectedFeedCats() {
466 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
469 function getSelectedFeedsFromBrowser() {
471 var list
= document
.getElementById("browseFeedList");
472 if (!list
) list
= document
.getElementById("browseBigFeedList");
474 var selected
= new Array();
476 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
477 var child
= list
.childNodes
[i
];
478 if (child
.id
&& child
.id
.match("FBROW-")) {
479 var id
= child
.id
.replace("FBROW-", "");
481 var cb
= document
.getElementById("FBCHK-" + id
);
492 function removeSelectedLabels() {
494 if (!xmlhttp_ready(xmlhttp
)) {
499 var sel_rows
= getSelectedLabels();
501 if (sel_rows
.length
> 0) {
503 var ok
= confirm("Remove selected labels?");
506 notify_progress("Removing selected labels...");
508 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
509 param_escape(sel_rows
.toString()), true);
510 xmlhttp
.onreadystatechange
=labellist_callback
;
514 alert("No labels are selected.");
520 function removeSelectedUsers() {
522 if (!xmlhttp_ready(xmlhttp
)) {
527 var sel_rows
= getSelectedUsers();
529 if (sel_rows
.length
> 0) {
531 var ok
= confirm("Remove selected users?");
534 notify_progress("Removing selected users...");
536 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
537 param_escape(sel_rows
.toString()), true);
538 xmlhttp
.onreadystatechange
=userlist_callback
;
543 alert("No users are selected.");
549 function removeSelectedFilters() {
551 if (!xmlhttp_ready(xmlhttp
)) {
556 var sel_rows
= getSelectedFilters();
558 if (sel_rows
.length
> 0) {
560 var ok
= confirm("Remove selected filters?");
563 notify_progress("Removing selected filters...");
565 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
566 param_escape(sel_rows
.toString()), true);
567 xmlhttp
.onreadystatechange
=filterlist_callback
;
571 alert("No filters are selected.");
578 function removeSelectedFeeds() {
580 if (!xmlhttp_ready(xmlhttp
)) {
585 var sel_rows
= getSelectedFeeds();
587 if (sel_rows
.length
> 0) {
589 var ok
= confirm("Unsubscribe from selected feeds?");
593 notify_progress("Unsubscribing from selected feeds...");
595 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
596 param_escape(sel_rows
.toString()), true);
597 xmlhttp
.onreadystatechange
=feedlist_callback
;
603 alert("No feeds are selected.");
610 function removeSelectedFeedCats() {
612 if (!xmlhttp_ready(xmlhttp
)) {
617 var sel_rows
= getSelectedFeedCats();
619 if (sel_rows
.length
> 0) {
621 var ok
= confirm("Remove selected categories?");
624 notify_progress("Removing selected categories...");
626 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
627 param_escape(sel_rows
.toString()), true);
628 xmlhttp
.onreadystatechange
=infobox_callback
;
634 alert("No categories are selected.");
641 function feedEditCancel() {
643 if (!xmlhttp_ready(xmlhttp
)) {
648 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
651 document
.getElementById("top25_feeds_btn").disabled
= false;
653 // this button is not always available, no-op if not found
658 selectPrefRows('feed', false); // cleanup feed selection
663 function feedCatEditCancel() {
665 if (!xmlhttp_ready(xmlhttp
)) {
670 active_feed_cat
= false;
672 // notify("Operation cancelled.");
674 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
675 xmlhttp
.onreadystatechange
=infobox_callback
;
681 function feedEditSave() {
685 if (!xmlhttp_ready(xmlhttp
)) {
690 // FIXME: add parameter validation
692 var query
= Form
.serialize("edit_feed_form");
694 notify_progress("Saving feed...");
696 xmlhttp
.open("POST", "backend.php", true);
697 xmlhttp
.onreadystatechange
=feedlist_callback
;
698 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
706 exception_error("feedEditSave", e
);
710 function feedCatEditSave() {
712 if (!xmlhttp_ready(xmlhttp
)) {
717 notify_progress("Saving category...");
719 var query
= Form
.serialize("feed_cat_edit_form");
721 xmlhttp
.open("GET", "backend.php?" + query
, true);
722 xmlhttp
.onreadystatechange
=infobox_callback
;
725 active_feed_cat
= false;
731 function labelTest() {
733 var container
= document
.getElementById('label_test_result');
734 container
.style
.display
= "block";
735 container
.innerHTML
= "<p>Loading, please wait...</p>";
737 var form
= document
.forms
['label_edit_form'];
739 var sql_exp
= form
.sql_exp
.value
;
740 var description
= form
.description
.value
;
742 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
743 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
745 xmlhttp
.onreadystatechange
=labeltest_callback
;
751 function displayHelpInfobox(topic_id
) {
753 /* if (!xmlhttp_ready(xmlhttp)) {
758 notify_progress("Loading help...");
760 xmlhttp.open("GET", "backend.php?op=help&tid=" +
761 param_escape(topic_id), true);
763 xmlhttp.onreadystatechange=helpbox_callback;
764 xmlhttp.send(null); */
766 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
768 var w
= window
.open(url
, "ttrss_help",
769 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
773 function labelEditCancel() {
775 if (!xmlhttp_ready(xmlhttp
)) {
780 document
.getElementById("label_create_btn").disabled
= false;
782 active_label
= false;
784 selectPrefRows('label', false); // cleanup feed selection
790 function userEditCancel() {
792 if (!xmlhttp_ready(xmlhttp
)) {
797 selectPrefRows('user', false); // cleanup feed selection
803 function filterEditCancel() {
805 if (!xmlhttp_ready(xmlhttp
)) {
810 document
.getElementById("create_filter_btn").disabled
= false;
812 selectPrefRows('filter', false); // cleanup feed selection
818 function labelEditSave() {
820 var label
= active_label
;
822 if (!xmlhttp_ready(xmlhttp
)) {
827 /* if (!is_opera()) {
829 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
830 var description = document.forms["label_edit_form"].description.value;
832 if (sql_exp.length == 0) {
833 alert("SQL Expression cannot be blank.");
837 if (description.length == 0) {
838 alert("Caption field cannot be blank.");
845 notify_progress("Saving label...");
847 active_label
= false;
849 query
= Form
.serialize("label_edit_form");
851 xmlhttp
.open("GET", "backend.php?" + query
, true);
852 xmlhttp
.onreadystatechange
=labellist_callback
;
858 function userEditSave() {
860 if (!xmlhttp_ready(xmlhttp
)) {
865 var login
= document
.forms
["user_edit_form"].login
.value
;
867 if (login
.length
== 0) {
868 alert("Login field cannot be blank.");
872 notify_progress("Saving user...");
876 var query
= Form
.serialize("user_edit_form");
878 xmlhttp
.open("GET", "backend.php?" + query
, true);
879 xmlhttp
.onreadystatechange
=userlist_callback
;
886 function filterEditSave() {
888 if (!xmlhttp_ready(xmlhttp
)) {
893 /* if (!is_opera()) {
894 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
896 if (reg_exp.length == 0) {
897 alert("Filter expression field cannot be blank.");
902 notify_progress("Saving filter...");
904 var query
= Form
.serialize("filter_edit_form");
908 document
.getElementById("create_filter_btn").disabled
= false;
910 xmlhttp
.open("GET", "backend.php?" + query
, true);
911 xmlhttp
.onreadystatechange
=filterlist_callback
;
917 function editSelectedLabel() {
918 var rows
= getSelectedLabels();
920 if (rows
.length
== 0) {
921 alert(__("No labels are selected."));
925 if (rows
.length
> 1) {
926 alert(__("Please select only one label."));
936 function editSelectedUser() {
937 var rows
= getSelectedUsers();
939 if (rows
.length
== 0) {
940 alert(__("No users are selected."));
944 if (rows
.length
> 1) {
945 alert(__("Please select only one user."));
954 function resetSelectedUserPass() {
955 var rows
= getSelectedUsers();
957 if (rows
.length
== 0) {
958 alert(__("No users are selected."));
962 if (rows
.length
> 1) {
963 alert(__("Please select only one user."));
967 var ok
= confirm(__("Reset password of selected user?"));
970 notify_progress("Resetting password for selected user...");
974 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
975 param_escape(id
), true);
976 xmlhttp
.onreadystatechange
=userlist_callback
;
981 function selectedUserDetails() {
983 if (!xmlhttp_ready(xmlhttp
)) {
988 var rows
= getSelectedUsers();
990 if (rows
.length
== 0) {
991 alert(__("No users are selected."));
995 if (rows
.length
> 1) {
996 alert(__("Please select only one user."));
1000 notify_progress("Loading, please wait...");
1004 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1005 xmlhttp
.onreadystatechange
=infobox_callback
;
1010 function selectedFeedDetails() {
1012 if (!xmlhttp_ready(xmlhttp
)) {
1013 printLockingError();
1017 var rows
= getSelectedFeeds();
1019 if (rows
.length
== 0) {
1020 alert(__("No feeds are selected."));
1024 if (rows
.length
> 1) {
1025 alert(__("Please select only one feed."));
1029 // var id = rows[0];
1033 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1034 param_escape(rows
.toString()), true);
1035 xmlhttp
.onreadystatechange
=infobox_callback
;
1040 function editSelectedFilter() {
1041 var rows
= getSelectedFilters();
1043 if (rows
.length
== 0) {
1044 alert(__("No filters are selected."));
1048 if (rows
.length
> 1) {
1049 alert(__("Please select only one filter."));
1055 editFilter(rows
[0]);
1060 function editSelectedFeed() {
1061 var rows
= getSelectedFeeds();
1063 if (rows
.length
== 0) {
1064 alert(__("No feeds are selected."));
1068 if (rows
.length
> 1) {
1069 alert(__("Please select one feed."));
1079 function editSelectedFeedCat() {
1080 var rows
= getSelectedFeedCats();
1082 if (rows
.length
== 0) {
1083 alert(__("No categories are selected."));
1087 if (rows
.length
> 1) {
1088 alert(__("Please select only one category."));
1094 editFeedCat(rows
[0]);
1098 function piggie_callback() {
1099 var piggie
= document
.getElementById("piggie");
1101 piggie
.style
.top
= piggie_top
;
1102 piggie
.style
.backgroundColor
= "white";
1103 piggie
.style
.borderWidth
= "1px";
1105 if (piggie_fwd
&& piggie_top
< 0) {
1106 setTimeout("piggie_callback()", 50);
1107 piggie_top
= piggie_top
+ 10;
1108 } else if (piggie_fwd
&& piggie_top
>= 0) {
1110 setTimeout("piggie_callback()", 50);
1111 } else if (!piggie_fwd
&& piggie_top
> -400) {
1112 setTimeout("piggie_callback()", 50);
1113 piggie_top
= piggie_top
- 10;
1114 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1115 piggie
.style
.display
= "none";
1120 var piggie_opacity
= 0;
1122 function piggie2_callback() {
1123 var piggie
= document
.getElementById("piggie");
1124 piggie
.style
.top
= 0;
1125 piggie
.style
.opacity
= piggie_opacity
;
1126 piggie
.style
.backgroundColor
= "transparent";
1127 piggie
.style
.borderWidth
= "0px";
1129 if (piggie_fwd
&& piggie_opacity
< 1) {
1130 setTimeout("piggie2_callback()", 50);
1131 piggie_opacity
= piggie_opacity
+ 0.03;
1132 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1134 setTimeout("piggie2_callback()", 50);
1135 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1136 setTimeout("piggie2_callback()", 50);
1137 piggie_opacity
= piggie_opacity
- 0.03;
1138 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1139 piggie
.style
.display
= "none";
1144 function localPiggieFunction(enable
) {
1146 debug("I LOVEDED IT!");
1147 var piggie
= document
.getElementById("piggie");
1148 piggie
.style
.display
= "block";
1150 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1158 function validateOpmlImport() {
1160 var opml_file
= document
.getElementById("opml_file");
1162 if (opml_file
.value
.length
== 0) {
1163 alert(__("No OPML file to upload."));
1170 function updateFilterList(sort_key
) {
1172 if (!xmlhttp_ready(xmlhttp
)) {
1173 printLockingError();
1177 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1179 // p_notify("Loading, please wait...");
1181 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1182 param_escape(sort_key
), true);
1183 xmlhttp
.onreadystatechange
=filterlist_callback
;
1188 function updateLabelList(sort_key
) {
1190 if (!xmlhttp_ready(xmlhttp
)) {
1191 printLockingError();
1195 // p_notify("Loading, please wait...");
1197 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1199 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1200 param_escape(sort_key
), true);
1201 xmlhttp
.onreadystatechange
=labellist_callback
;
1205 function updatePrefsList() {
1207 if (!xmlhttp_ready(xmlhttp
)) {
1208 printLockingError();
1212 // p_notify("Loading, please wait...");
1214 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1215 xmlhttp
.onreadystatechange
=prefslist_callback
;
1220 function selectTab(id
, noupdate
, subop
) {
1224 if (!id
) id
= active_tab
;
1228 if (!xmlhttp_ready(xmlhttp
)) {
1229 printLockingError();
1234 var c
= document
.getElementById('prefContent');
1240 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1242 notify_progress("Loading, please wait...");
1244 // close active infobox if needed
1247 // clean up all current selections, just in case
1248 active_feed_cat
= false;
1249 active_label
= false;
1251 if (id
== "feedConfig") {
1253 } else if (id
== "filterConfig") {
1255 } else if (id
== "labelConfig") {
1257 } else if (id
== "genConfig") {
1259 } else if (id
== "userConfig") {
1261 } else if (id
== "feedBrowser") {
1262 updateBigFeedBrowser();
1266 var tab
= document
.getElementById(active_tab
+ "Tab");
1269 if (tab
.className
.match("Selected")) {
1270 tab
.className
= "prefsTab";
1274 tab
= document
.getElementById(id
+ "Tab");
1277 if (!tab
.className
.match("Selected")) {
1278 tab
.className
= tab
.className
+ "Selected";
1285 exception_error("selectTab", e
);
1289 function backend_sanity_check_callback() {
1291 if (xmlhttp
.readyState
== 4) {
1295 if (sanity_check_done
) {
1296 fatalError(11, "Sanity check request received twice. This can indicate "+
1297 "presence of Firebug or some other disrupting extension. "+
1298 "Please disable it and try again.");
1302 if (!xmlhttp
.responseXML
) {
1303 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1307 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1310 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1314 var error_code
= reply
.getAttribute("error-code");
1316 if (error_code
&& error_code
!= 0) {
1317 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1320 debug("sanity check ok");
1322 var params
= reply
.nextSibling
;
1325 debug('reading init-params...');
1326 var param
= params
.firstChild
;
1329 var k
= param
.getAttribute("key");
1330 var v
= param
.getAttribute("value");
1331 debug(k
+ " => " + v
);
1333 param
= param
.nextSibling
;
1337 sanity_check_done
= true;
1339 init_second_stage();
1342 exception_error("backend_sanity_check_callback", e
);
1347 function init_second_stage() {
1350 active_tab
= getInitParam("prefs_active_tab");
1351 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1353 document
.onkeydown
= pref_hotkey_handler
;
1355 var tab
= getURLParam('tab');
1357 caller_subop
= getURLParam('subop');
1363 if (navigator
.userAgent
.match("Opera")) {
1364 setTimeout("selectTab()", 500);
1366 selectTab(active_tab
);
1370 exception_error("init_second_stage", e
);
1378 if (arguments
.callee
.done
) return;
1379 arguments
.callee
.done
= true;
1381 if (getURLParam('debug')) {
1382 document
.getElementById('debug_output').style
.display
= 'block';
1383 debug('debug mode activated');
1388 document
.getElementById("prefContent").innerHTML
=
1389 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1390 "to function properly. Your browser doesn't seem to support it.";
1394 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1395 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1399 exception_error("init", e
);
1403 function categorizeSelectedFeeds() {
1405 if (!xmlhttp_ready(xmlhttp
)) {
1406 printLockingError();
1410 var sel_rows
= getSelectedFeeds();
1412 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1413 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1415 if (sel_rows
.length
> 0) {
1417 notify_progress("Changing category of selected feeds...");
1419 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1420 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1421 xmlhttp
.onreadystatechange
=feedlist_callback
;
1426 alert(__("No feeds are selected."));
1432 function validatePrefsReset() {
1433 return confirm(__("Reset to defaults?"));
1436 function browseFeeds(limit
) {
1438 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1439 xmlhttp
.onreadystatechange
=infobox_callback
;
1444 function feedBrowserSubscribe() {
1447 var selected
= getSelectedFeedsFromBrowser();
1449 if (selected
.length
> 0) {
1451 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1452 param_escape(selected
.toString()), true);
1453 xmlhttp
.onreadystatechange
=feedlist_callback
;
1456 alert("No feeds are selected.");
1460 exception_error("feedBrowserSubscribe", e
);
1464 function updateBigFeedBrowser(limit
) {
1466 if (!xmlhttp_ready(xmlhttp
)) {
1467 printLockingError();
1471 // p_notify("Loading, please wait...");
1473 var query
= "backend.php?op=pref-feed-browser";
1475 var limit_sel
= document
.getElementById("feedBrowserLimit");
1478 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1479 query
= query
+ "&limit=" + param_escape(limit
);
1482 xmlhttp
.open("GET", query
, true);
1483 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1487 function browserToggleExpand(id
) {
1489 /* if (feed_to_expand && feed_to_expand != id) {
1490 var d = document.getElementById("BRDET-" + feed_to_expand);
1491 d.style.display = "none";
1494 if (!xmlhttp_ready(xmlhttp
)) {
1495 printLockingError();
1499 var d
= document
.getElementById("BRDET-" + id
);
1501 if (d
.style
.display
== "block") {
1502 d
.style
.display
= "none";
1506 feed_to_expand
= id
;
1508 d
.style
.display
= "block";
1509 d
.innerHTML
= "Loading, please wait...";
1511 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1512 + param_escape(id
), true);
1513 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1518 exception_error("browserExpand", e
);
1522 function selectPrefRows(kind
, select
) {
1525 var opbarid
= false;
1530 if (kind
== "feed") {
1531 opbarid
= "feedOpToolbar";
1534 lname
= "prefFeedList";
1535 } else if (kind
== "fcat") {
1536 opbarid
= "catOpToolbar";
1539 lname
= "prefFeedCatList";
1540 } else if (kind
== "filter") {
1541 opbarid
= "filterOpToolbar";
1544 lname
= "prefFilterList";
1545 } else if (kind
== "label") {
1546 opbarid
= "labelOpToolbar";
1549 lname
= "prefLabelList";
1550 } else if (kind
== "user") {
1551 opbarid
= "userOpToolbar";
1554 lname
= "prefUserList";
1558 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1559 disableContainerChildren(opbarid
, !select
);
1566 function toggleSelectPrefRow(sender
, kind
) {
1568 toggleSelectRow(sender
);
1571 var opbarid
= false;
1574 if (kind
== "feed") {
1575 opbarid
= "feedOpToolbar";
1576 nsel
= getSelectedFeeds();
1577 } else if (kind
== "fcat") {
1578 opbarid
= "catOpToolbar";
1579 nsel
= getSelectedFeedCats();
1580 } else if (kind
== "filter") {
1581 opbarid
= "filterOpToolbar";
1582 nsel
= getSelectedFilters();
1583 } else if (kind
== "label") {
1584 opbarid
= "labelOpToolbar";
1585 nsel
= getSelectedLabels();
1586 } else if (kind
== "user") {
1587 opbarid
= "userOpToolbar";
1588 nsel
= getSelectedUsers();
1591 if (opbarid
&& nsel
!= -1) {
1592 disableContainerChildren(opbarid
, nsel
== false);
1598 function toggleSelectFBListRow(sender
) {
1599 toggleSelectListRow(sender
);
1600 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1605 function pref_hotkey_handler(e
) {
1610 if (!hotkeys_enabled
) return;
1613 keycode
= window
.event
.keyCode
;
1618 if (keycode
== 13 || keycode
== 27) {
1621 seq
= seq
+ "" + keycode
;
1625 if (document
.getElementById("piggie")) {
1627 if (seq
.match("807371717369")) {
1629 localPiggieFunction(true);
1631 localPiggieFunction(false);
1636 exception_error("pref_hotkey_handler", e
);
1640 function userSwitch() {
1641 var chooser
= document
.getElementById("userSwitch");
1642 var user
= chooser
[chooser
.selectedIndex
].value
;
1643 window
.location
= "prefs.php?swu=" + user
;
1646 function editFeedCats() {
1647 if (!xmlhttp_ready(xmlhttp
)) {
1648 printLockingError();
1652 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1655 document
.getElementById("top25_feeds_btn").disabled
= true;
1657 // this button is not always available, no-op if not found
1660 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1661 xmlhttp
.onreadystatechange
=infobox_callback
;
1665 function showFeedsWithErrors() {
1666 displayDlg('feedUpdateErrors');
1669 function changeUserPassword() {
1673 if (!xmlhttp_ready(xmlhttp
)) {
1674 printLockingError();
1678 var query
= Form
.serialize("change_pass_form");
1680 notify_progress("Trying to change password...");
1682 xmlhttp
.open("POST", "backend.php", true);
1683 xmlhttp
.onreadystatechange
=changepass_callback
;
1684 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1685 xmlhttp
.send(query
);
1688 exception_error("changeUserPassword", e
);
1694 function changeUserEmail() {
1698 if (!xmlhttp_ready(xmlhttp
)) {
1699 printLockingError();
1703 var query
= Form
.serialize("change_email_form");
1705 notify_progress("Trying to change e-mail...");
1707 xmlhttp
.open("POST", "backend.php", true);
1708 xmlhttp
.onreadystatechange
=notify_callback
;
1709 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1710 xmlhttp
.send(query
);
1713 exception_error("changeUserPassword", e
);