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 var slat
= document
.getElementById("show_last_article_times");
210 var slat_checked
= false;
212 slat_checked
= slat
.checked
;
215 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
216 "&sort=" + param_escape(sort_key
) +
217 "&slat=" + param_escape(slat_checked
) +
218 "&search=" + param_escape(search
), true);
219 xmlhttp
.onreadystatechange
=feedlist_callback
;
224 function updateUsersList(sort_key
) {
226 if (!xmlhttp_ready(xmlhttp
)) {
231 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
233 // p_notify("Loading, please wait...");
235 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
236 + param_escape(sort_key
), true);
237 xmlhttp
.onreadystatechange
=userlist_callback
;
242 function addLabel() {
244 if (!xmlhttp_ready(xmlhttp
)) {
249 var form
= document
.forms
['label_edit_form'];
251 var sql_exp
= form
.sql_exp
.value
;
252 var description
= form
.description
.value
;
255 alert("Can't create label: missing SQL expression.");
259 if (description
== "") {
260 alert("Can't create label: missing caption.");
264 var query
= Form
.serialize("label_edit_form");
266 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
267 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
273 if (!xmlhttp_ready(xmlhttp
)) {
278 var link
= document
.getElementById("fadd_link");
280 if (link
.value
.length
== 0) {
281 alert(__("Error: No feed URL given."));
282 } else if (!isValidURL(link
.value
)) {
283 alert(__("Error: Invalid feed URL."));
285 notify_progress("Adding feed...");
287 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
288 param_escape(link
.value
), true);
289 xmlhttp
.onreadystatechange
=feedlist_callback
;
298 function addFeedCat() {
300 if (!xmlhttp_ready(xmlhttp
)) {
305 var cat
= document
.getElementById("fadd_cat");
307 if (cat
.value
.length
== 0) {
308 alert(__("Can't add category: no name specified."));
310 notify_progress("Adding feed category...");
312 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
313 param_escape(cat
.value
), true);
314 xmlhttp
.onreadystatechange
=infobox_callback
;
324 if (!xmlhttp_ready(xmlhttp
)) {
329 var sqlexp
= document
.getElementById("uadd_box");
331 if (sqlexp
.value
.length
== 0) {
332 alert("Can't add user: no login specified.");
334 notify_progress("Adding user...");
336 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
337 param_escape(sqlexp
.value
), true);
339 xmlhttp
.onreadystatechange
=userlist_callback
;
347 function editLabel(id
) {
349 if (!xmlhttp_ready(xmlhttp
)) {
354 notify_progress("Loading, please wait...");
356 document
.getElementById("label_create_btn").disabled
= true;
360 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
361 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
363 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
364 param_escape(id
), true);
365 xmlhttp
.onreadystatechange
=infobox_callback
;
370 function editUser(id
) {
372 if (!xmlhttp_ready(xmlhttp
)) {
377 notify_progress("Loading, please wait...");
379 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
380 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
382 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
383 param_escape(id
), true);
384 xmlhttp
.onreadystatechange
=infobox_callback
;
389 function editFilter(id
) {
391 if (!xmlhttp_ready(xmlhttp
)) {
396 notify_progress("Loading, please wait...");
398 document
.getElementById("create_filter_btn").disabled
= true;
400 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
401 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
403 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
404 xmlhttp
.onreadystatechange
=infobox_callback
;
408 function editFeed(feed
) {
410 // notify("Editing feed...");
412 if (!xmlhttp_ready(xmlhttp
)) {
417 notify_progress("Loading, please wait...");
419 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
422 document
.getElementById("top25_feeds_btn").disabled
= true;
424 // this button is not always available, no-op if not found
427 // clean selection from all rows & select row being edited
428 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
429 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
431 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
432 param_escape(feed
), true);
434 xmlhttp
.onreadystatechange
=infobox_callback
;
439 function editFeedCat(cat
) {
441 if (!xmlhttp_ready(xmlhttp
)) {
446 notify_progress("Loading, please wait...");
448 active_feed_cat
= cat
;
450 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
451 param_escape(cat
), true);
452 xmlhttp
.onreadystatechange
=infobox_callback
;
457 function getSelectedLabels() {
458 return getSelectedTableRowIds("prefLabelList", "LILRR");
461 function getSelectedUsers() {
462 return getSelectedTableRowIds("prefUserList", "UMRR");
465 function getSelectedFeeds() {
466 return getSelectedTableRowIds("prefFeedList", "FEEDR");
469 function getSelectedFilters() {
470 return getSelectedTableRowIds("prefFilterList", "FILRR");
473 function getSelectedFeedCats() {
474 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
477 function getSelectedFeedsFromBrowser() {
479 var list
= document
.getElementById("browseFeedList");
480 if (!list
) list
= document
.getElementById("browseBigFeedList");
482 var selected
= new Array();
484 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
485 var child
= list
.childNodes
[i
];
486 if (child
.id
&& child
.id
.match("FBROW-")) {
487 var id
= child
.id
.replace("FBROW-", "");
489 var cb
= document
.getElementById("FBCHK-" + id
);
500 function removeSelectedLabels() {
502 if (!xmlhttp_ready(xmlhttp
)) {
507 var sel_rows
= getSelectedLabels();
509 if (sel_rows
.length
> 0) {
511 var ok
= confirm("Remove selected labels?");
514 notify_progress("Removing selected labels...");
516 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
517 param_escape(sel_rows
.toString()), true);
518 xmlhttp
.onreadystatechange
=labellist_callback
;
522 alert("No labels are selected.");
528 function removeSelectedUsers() {
530 if (!xmlhttp_ready(xmlhttp
)) {
535 var sel_rows
= getSelectedUsers();
537 if (sel_rows
.length
> 0) {
539 var ok
= confirm("Remove selected users?");
542 notify_progress("Removing selected users...");
544 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
545 param_escape(sel_rows
.toString()), true);
546 xmlhttp
.onreadystatechange
=userlist_callback
;
551 alert("No users are selected.");
557 function removeSelectedFilters() {
559 if (!xmlhttp_ready(xmlhttp
)) {
564 var sel_rows
= getSelectedFilters();
566 if (sel_rows
.length
> 0) {
568 var ok
= confirm("Remove selected filters?");
571 notify_progress("Removing selected filters...");
573 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
574 param_escape(sel_rows
.toString()), true);
575 xmlhttp
.onreadystatechange
=filterlist_callback
;
579 alert("No filters are selected.");
586 function removeSelectedFeeds() {
588 if (!xmlhttp_ready(xmlhttp
)) {
593 var sel_rows
= getSelectedFeeds();
595 if (sel_rows
.length
> 0) {
597 var ok
= confirm("Unsubscribe from selected feeds?");
601 notify_progress("Unsubscribing from selected feeds...");
603 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
604 param_escape(sel_rows
.toString()), true);
605 xmlhttp
.onreadystatechange
=feedlist_callback
;
611 alert("No feeds are selected.");
618 function removeSelectedFeedCats() {
620 if (!xmlhttp_ready(xmlhttp
)) {
625 var sel_rows
= getSelectedFeedCats();
627 if (sel_rows
.length
> 0) {
629 var ok
= confirm("Remove selected categories?");
632 notify_progress("Removing selected categories...");
634 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
635 param_escape(sel_rows
.toString()), true);
636 xmlhttp
.onreadystatechange
=infobox_callback
;
642 alert("No categories are selected.");
649 function feedEditCancel() {
651 if (!xmlhttp_ready(xmlhttp
)) {
656 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
659 document
.getElementById("top25_feeds_btn").disabled
= false;
661 // this button is not always available, no-op if not found
666 selectPrefRows('feed', false); // cleanup feed selection
671 function feedCatEditCancel() {
673 if (!xmlhttp_ready(xmlhttp
)) {
678 active_feed_cat
= false;
680 // notify("Operation cancelled.");
682 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
683 xmlhttp
.onreadystatechange
=infobox_callback
;
689 function feedEditSave() {
693 if (!xmlhttp_ready(xmlhttp
)) {
698 // FIXME: add parameter validation
700 var query
= Form
.serialize("edit_feed_form");
702 notify_progress("Saving feed...");
704 xmlhttp
.open("POST", "backend.php", true);
705 xmlhttp
.onreadystatechange
=feedlist_callback
;
706 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
714 exception_error("feedEditSave", e
);
718 function feedCatEditSave() {
720 if (!xmlhttp_ready(xmlhttp
)) {
725 notify_progress("Saving category...");
727 var query
= Form
.serialize("feed_cat_edit_form");
729 xmlhttp
.open("GET", "backend.php?" + query
, true);
730 xmlhttp
.onreadystatechange
=infobox_callback
;
733 active_feed_cat
= false;
739 function labelTest() {
741 var container
= document
.getElementById('label_test_result');
742 container
.style
.display
= "block";
743 container
.innerHTML
= "<p>Loading, please wait...</p>";
745 var form
= document
.forms
['label_edit_form'];
747 var sql_exp
= form
.sql_exp
.value
;
748 var description
= form
.description
.value
;
750 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
751 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
753 xmlhttp
.onreadystatechange
=labeltest_callback
;
759 function displayHelpInfobox(topic_id
) {
761 /* if (!xmlhttp_ready(xmlhttp)) {
766 notify_progress("Loading help...");
768 xmlhttp.open("GET", "backend.php?op=help&tid=" +
769 param_escape(topic_id), true);
771 xmlhttp.onreadystatechange=helpbox_callback;
772 xmlhttp.send(null); */
774 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
776 var w
= window
.open(url
, "ttrss_help",
777 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
781 function labelEditCancel() {
783 if (!xmlhttp_ready(xmlhttp
)) {
788 document
.getElementById("label_create_btn").disabled
= false;
790 active_label
= false;
792 selectPrefRows('label', false); // cleanup feed selection
798 function userEditCancel() {
800 if (!xmlhttp_ready(xmlhttp
)) {
805 selectPrefRows('user', false); // cleanup feed selection
811 function filterEditCancel() {
813 if (!xmlhttp_ready(xmlhttp
)) {
818 document
.getElementById("create_filter_btn").disabled
= false;
820 selectPrefRows('filter', false); // cleanup feed selection
826 function labelEditSave() {
828 var label
= active_label
;
830 if (!xmlhttp_ready(xmlhttp
)) {
835 /* if (!is_opera()) {
837 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
838 var description = document.forms["label_edit_form"].description.value;
840 if (sql_exp.length == 0) {
841 alert("SQL Expression cannot be blank.");
845 if (description.length == 0) {
846 alert("Caption field cannot be blank.");
853 notify_progress("Saving label...");
855 active_label
= false;
857 query
= Form
.serialize("label_edit_form");
859 xmlhttp
.open("GET", "backend.php?" + query
, true);
860 xmlhttp
.onreadystatechange
=labellist_callback
;
866 function userEditSave() {
868 if (!xmlhttp_ready(xmlhttp
)) {
873 var login
= document
.forms
["user_edit_form"].login
.value
;
875 if (login
.length
== 0) {
876 alert("Login field cannot be blank.");
880 notify_progress("Saving user...");
884 var query
= Form
.serialize("user_edit_form");
886 xmlhttp
.open("GET", "backend.php?" + query
, true);
887 xmlhttp
.onreadystatechange
=userlist_callback
;
894 function filterEditSave() {
896 if (!xmlhttp_ready(xmlhttp
)) {
901 /* if (!is_opera()) {
902 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
904 if (reg_exp.length == 0) {
905 alert("Filter expression field cannot be blank.");
910 notify_progress("Saving filter...");
912 var query
= Form
.serialize("filter_edit_form");
916 document
.getElementById("create_filter_btn").disabled
= false;
918 xmlhttp
.open("GET", "backend.php?" + query
, true);
919 xmlhttp
.onreadystatechange
=filterlist_callback
;
925 function editSelectedLabel() {
926 var rows
= getSelectedLabels();
928 if (rows
.length
== 0) {
929 alert(__("No labels are selected."));
933 if (rows
.length
> 1) {
934 alert(__("Please select only one label."));
944 function editSelectedUser() {
945 var rows
= getSelectedUsers();
947 if (rows
.length
== 0) {
948 alert(__("No users are selected."));
952 if (rows
.length
> 1) {
953 alert(__("Please select only one user."));
962 function resetSelectedUserPass() {
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."));
975 var ok
= confirm(__("Reset password of selected user?"));
978 notify_progress("Resetting password for selected user...");
982 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
983 param_escape(id
), true);
984 xmlhttp
.onreadystatechange
=userlist_callback
;
989 function selectedUserDetails() {
991 if (!xmlhttp_ready(xmlhttp
)) {
996 var rows
= getSelectedUsers();
998 if (rows
.length
== 0) {
999 alert(__("No users are selected."));
1003 if (rows
.length
> 1) {
1004 alert(__("Please select only one user."));
1008 notify_progress("Loading, please wait...");
1012 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1013 xmlhttp
.onreadystatechange
=infobox_callback
;
1018 function selectedFeedDetails() {
1020 if (!xmlhttp_ready(xmlhttp
)) {
1021 printLockingError();
1025 var rows
= getSelectedFeeds();
1027 if (rows
.length
== 0) {
1028 alert(__("No feeds are selected."));
1032 if (rows
.length
> 1) {
1033 alert(__("Please select only one feed."));
1037 // var id = rows[0];
1041 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1042 param_escape(rows
.toString()), true);
1043 xmlhttp
.onreadystatechange
=infobox_callback
;
1048 function editSelectedFilter() {
1049 var rows
= getSelectedFilters();
1051 if (rows
.length
== 0) {
1052 alert(__("No filters are selected."));
1056 if (rows
.length
> 1) {
1057 alert(__("Please select only one filter."));
1063 editFilter(rows
[0]);
1068 function editSelectedFeed() {
1069 var rows
= getSelectedFeeds();
1071 if (rows
.length
== 0) {
1072 alert(__("No feeds are selected."));
1076 if (rows
.length
> 1) {
1077 alert(__("Please select one feed."));
1087 function editSelectedFeedCat() {
1088 var rows
= getSelectedFeedCats();
1090 if (rows
.length
== 0) {
1091 alert(__("No categories are selected."));
1095 if (rows
.length
> 1) {
1096 alert(__("Please select only one category."));
1102 editFeedCat(rows
[0]);
1106 function piggie_callback() {
1107 var piggie
= document
.getElementById("piggie");
1109 piggie
.style
.top
= piggie_top
;
1110 piggie
.style
.backgroundColor
= "white";
1111 piggie
.style
.borderWidth
= "1px";
1113 if (piggie_fwd
&& piggie_top
< 0) {
1114 setTimeout("piggie_callback()", 50);
1115 piggie_top
= piggie_top
+ 10;
1116 } else if (piggie_fwd
&& piggie_top
>= 0) {
1118 setTimeout("piggie_callback()", 50);
1119 } else if (!piggie_fwd
&& piggie_top
> -400) {
1120 setTimeout("piggie_callback()", 50);
1121 piggie_top
= piggie_top
- 10;
1122 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1123 piggie
.style
.display
= "none";
1128 var piggie_opacity
= 0;
1130 function piggie2_callback() {
1131 var piggie
= document
.getElementById("piggie");
1132 piggie
.style
.top
= 0;
1133 piggie
.style
.opacity
= piggie_opacity
;
1134 piggie
.style
.backgroundColor
= "transparent";
1135 piggie
.style
.borderWidth
= "0px";
1137 if (piggie_fwd
&& piggie_opacity
< 1) {
1138 setTimeout("piggie2_callback()", 50);
1139 piggie_opacity
= piggie_opacity
+ 0.03;
1140 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1142 setTimeout("piggie2_callback()", 50);
1143 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1144 setTimeout("piggie2_callback()", 50);
1145 piggie_opacity
= piggie_opacity
- 0.03;
1146 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1147 piggie
.style
.display
= "none";
1152 function localPiggieFunction(enable
) {
1154 debug("I LOVEDED IT!");
1155 var piggie
= document
.getElementById("piggie");
1156 piggie
.style
.display
= "block";
1158 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1166 function validateOpmlImport() {
1168 var opml_file
= document
.getElementById("opml_file");
1170 if (opml_file
.value
.length
== 0) {
1171 alert(__("No OPML file to upload."));
1178 function updateFilterList(sort_key
) {
1180 if (!xmlhttp_ready(xmlhttp
)) {
1181 printLockingError();
1185 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1187 // p_notify("Loading, please wait...");
1189 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1190 param_escape(sort_key
), true);
1191 xmlhttp
.onreadystatechange
=filterlist_callback
;
1196 function updateLabelList(sort_key
) {
1198 if (!xmlhttp_ready(xmlhttp
)) {
1199 printLockingError();
1203 // p_notify("Loading, please wait...");
1205 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1207 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1208 param_escape(sort_key
), true);
1209 xmlhttp
.onreadystatechange
=labellist_callback
;
1213 function updatePrefsList() {
1215 if (!xmlhttp_ready(xmlhttp
)) {
1216 printLockingError();
1220 // p_notify("Loading, please wait...");
1222 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1223 xmlhttp
.onreadystatechange
=prefslist_callback
;
1228 function selectTab(id
, noupdate
, subop
) {
1232 if (!id
) id
= active_tab
;
1236 if (!xmlhttp_ready(xmlhttp
)) {
1237 printLockingError();
1242 var c
= document
.getElementById('prefContent');
1248 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1250 notify_progress("Loading, please wait...");
1252 // close active infobox if needed
1255 // clean up all current selections, just in case
1256 active_feed_cat
= false;
1257 active_label
= false;
1259 if (id
== "feedConfig") {
1261 } else if (id
== "filterConfig") {
1263 } else if (id
== "labelConfig") {
1265 } else if (id
== "genConfig") {
1267 } else if (id
== "userConfig") {
1269 } else if (id
== "feedBrowser") {
1270 updateBigFeedBrowser();
1274 var tab
= document
.getElementById(active_tab
+ "Tab");
1277 if (tab
.className
.match("Selected")) {
1278 tab
.className
= "prefsTab";
1282 tab
= document
.getElementById(id
+ "Tab");
1285 if (!tab
.className
.match("Selected")) {
1286 tab
.className
= tab
.className
+ "Selected";
1293 exception_error("selectTab", e
);
1297 function backend_sanity_check_callback() {
1299 if (xmlhttp
.readyState
== 4) {
1303 if (sanity_check_done
) {
1304 fatalError(11, "Sanity check request received twice. This can indicate "+
1305 "presence of Firebug or some other disrupting extension. "+
1306 "Please disable it and try again.");
1310 if (!xmlhttp
.responseXML
) {
1311 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1315 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1318 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1322 var error_code
= reply
.getAttribute("error-code");
1324 if (error_code
&& error_code
!= 0) {
1325 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1328 debug("sanity check ok");
1330 var params
= reply
.nextSibling
;
1333 debug('reading init-params...');
1334 var param
= params
.firstChild
;
1337 var k
= param
.getAttribute("key");
1338 var v
= param
.getAttribute("value");
1339 debug(k
+ " => " + v
);
1341 param
= param
.nextSibling
;
1345 sanity_check_done
= true;
1347 init_second_stage();
1350 exception_error("backend_sanity_check_callback", e
);
1355 function init_second_stage() {
1358 active_tab
= getInitParam("prefs_active_tab");
1359 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1361 document
.onkeydown
= pref_hotkey_handler
;
1363 var tab
= getURLParam('tab');
1365 caller_subop
= getURLParam('subop');
1371 if (navigator
.userAgent
.match("Opera")) {
1372 setTimeout("selectTab()", 500);
1374 selectTab(active_tab
);
1378 exception_error("init_second_stage", e
);
1386 if (arguments
.callee
.done
) return;
1387 arguments
.callee
.done
= true;
1389 if (getURLParam('debug')) {
1390 document
.getElementById('debug_output').style
.display
= 'block';
1391 debug('debug mode activated');
1396 document
.getElementById("prefContent").innerHTML
=
1397 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1398 "to function properly. Your browser doesn't seem to support it.";
1402 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1403 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1407 exception_error("init", e
);
1411 function categorizeSelectedFeeds() {
1413 if (!xmlhttp_ready(xmlhttp
)) {
1414 printLockingError();
1418 var sel_rows
= getSelectedFeeds();
1420 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1421 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1423 if (sel_rows
.length
> 0) {
1425 notify_progress("Changing category of selected feeds...");
1427 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1428 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1429 xmlhttp
.onreadystatechange
=feedlist_callback
;
1434 alert(__("No feeds are selected."));
1440 function validatePrefsReset() {
1441 return confirm(__("Reset to defaults?"));
1444 function browseFeeds(limit
) {
1446 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1447 xmlhttp
.onreadystatechange
=infobox_callback
;
1452 function feedBrowserSubscribe() {
1455 var selected
= getSelectedFeedsFromBrowser();
1457 if (selected
.length
> 0) {
1459 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1460 param_escape(selected
.toString()), true);
1461 xmlhttp
.onreadystatechange
=feedlist_callback
;
1464 alert("No feeds are selected.");
1468 exception_error("feedBrowserSubscribe", e
);
1472 function updateBigFeedBrowser(limit
) {
1474 if (!xmlhttp_ready(xmlhttp
)) {
1475 printLockingError();
1479 // p_notify("Loading, please wait...");
1481 var query
= "backend.php?op=pref-feed-browser";
1483 var limit_sel
= document
.getElementById("feedBrowserLimit");
1486 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1487 query
= query
+ "&limit=" + param_escape(limit
);
1490 xmlhttp
.open("GET", query
, true);
1491 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1495 function browserToggleExpand(id
) {
1497 /* if (feed_to_expand && feed_to_expand != id) {
1498 var d = document.getElementById("BRDET-" + feed_to_expand);
1499 d.style.display = "none";
1502 if (!xmlhttp_ready(xmlhttp
)) {
1503 printLockingError();
1507 var d
= document
.getElementById("BRDET-" + id
);
1509 if (d
.style
.display
== "block") {
1510 d
.style
.display
= "none";
1514 feed_to_expand
= id
;
1516 d
.style
.display
= "block";
1517 d
.innerHTML
= "Loading, please wait...";
1519 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1520 + param_escape(id
), true);
1521 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1526 exception_error("browserExpand", e
);
1530 function selectPrefRows(kind
, select
) {
1533 var opbarid
= false;
1538 if (kind
== "feed") {
1539 opbarid
= "feedOpToolbar";
1542 lname
= "prefFeedList";
1543 } else if (kind
== "fcat") {
1544 opbarid
= "catOpToolbar";
1547 lname
= "prefFeedCatList";
1548 } else if (kind
== "filter") {
1549 opbarid
= "filterOpToolbar";
1552 lname
= "prefFilterList";
1553 } else if (kind
== "label") {
1554 opbarid
= "labelOpToolbar";
1557 lname
= "prefLabelList";
1558 } else if (kind
== "user") {
1559 opbarid
= "userOpToolbar";
1562 lname
= "prefUserList";
1566 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1567 disableContainerChildren(opbarid
, !select
);
1574 function toggleSelectPrefRow(sender
, kind
) {
1576 toggleSelectRow(sender
);
1579 var opbarid
= false;
1582 if (kind
== "feed") {
1583 opbarid
= "feedOpToolbar";
1584 nsel
= getSelectedFeeds();
1585 } else if (kind
== "fcat") {
1586 opbarid
= "catOpToolbar";
1587 nsel
= getSelectedFeedCats();
1588 } else if (kind
== "filter") {
1589 opbarid
= "filterOpToolbar";
1590 nsel
= getSelectedFilters();
1591 } else if (kind
== "label") {
1592 opbarid
= "labelOpToolbar";
1593 nsel
= getSelectedLabels();
1594 } else if (kind
== "user") {
1595 opbarid
= "userOpToolbar";
1596 nsel
= getSelectedUsers();
1599 if (opbarid
&& nsel
!= -1) {
1600 disableContainerChildren(opbarid
, nsel
== false);
1606 function toggleSelectFBListRow(sender
) {
1607 toggleSelectListRow(sender
);
1608 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1613 function pref_hotkey_handler(e
) {
1618 if (!hotkeys_enabled
) return;
1621 keycode
= window
.event
.keyCode
;
1626 if (keycode
== 13 || keycode
== 27) {
1629 seq
= seq
+ "" + keycode
;
1633 if (document
.getElementById("piggie")) {
1635 if (seq
.match("807371717369")) {
1637 localPiggieFunction(true);
1639 localPiggieFunction(false);
1644 exception_error("pref_hotkey_handler", e
);
1648 function userSwitch() {
1649 var chooser
= document
.getElementById("userSwitch");
1650 var user
= chooser
[chooser
.selectedIndex
].value
;
1651 window
.location
= "prefs.php?swu=" + user
;
1654 function editFeedCats() {
1655 if (!xmlhttp_ready(xmlhttp
)) {
1656 printLockingError();
1660 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1663 document
.getElementById("top25_feeds_btn").disabled
= true;
1665 // this button is not always available, no-op if not found
1668 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1669 xmlhttp
.onreadystatechange
=infobox_callback
;
1673 function showFeedsWithErrors() {
1674 displayDlg('feedUpdateErrors');
1677 function changeUserPassword() {
1681 if (!xmlhttp_ready(xmlhttp
)) {
1682 printLockingError();
1686 var query
= Form
.serialize("change_pass_form");
1688 notify_progress("Trying to change password...");
1690 xmlhttp
.open("POST", "backend.php", true);
1691 xmlhttp
.onreadystatechange
=changepass_callback
;
1692 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1693 xmlhttp
.send(query
);
1696 exception_error("changeUserPassword", e
);
1702 function changeUserEmail() {
1706 if (!xmlhttp_ready(xmlhttp
)) {
1707 printLockingError();
1711 var query
= Form
.serialize("change_email_form");
1713 notify_progress("Trying to change e-mail...");
1715 xmlhttp
.open("POST", "backend.php", true);
1716 xmlhttp
.onreadystatechange
=notify_callback
;
1717 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1718 xmlhttp
.send(query
);
1721 exception_error("changeUserPassword", e
);
1728 function feedlistToggleSLAT() {
1729 notify_progress("Loading, please wait...");