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 // clean selection from all rows & select row being edited
412 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
413 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
415 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
416 param_escape(feed
), true);
418 xmlhttp
.onreadystatechange
=infobox_callback
;
423 function editFeedCat(cat
) {
425 if (!xmlhttp_ready(xmlhttp
)) {
430 notify_progress("Loading, please wait...");
432 active_feed_cat
= cat
;
434 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
435 param_escape(cat
), true);
436 xmlhttp
.onreadystatechange
=infobox_callback
;
441 function getSelectedLabels() {
442 return getSelectedTableRowIds("prefLabelList", "LILRR");
445 function getSelectedUsers() {
446 return getSelectedTableRowIds("prefUserList", "UMRR");
449 function getSelectedFeeds() {
450 return getSelectedTableRowIds("prefFeedList", "FEEDR");
453 function getSelectedFilters() {
454 return getSelectedTableRowIds("prefFilterList", "FILRR");
457 function getSelectedFeedCats() {
458 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
461 function getSelectedFeedsFromBrowser() {
463 var list
= document
.getElementById("browseFeedList");
464 if (!list
) list
= document
.getElementById("browseBigFeedList");
466 var selected
= new Array();
468 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
469 var child
= list
.childNodes
[i
];
470 if (child
.id
&& child
.id
.match("FBROW-")) {
471 var id
= child
.id
.replace("FBROW-", "");
473 var cb
= document
.getElementById("FBCHK-" + id
);
484 function removeSelectedLabels() {
486 if (!xmlhttp_ready(xmlhttp
)) {
491 var sel_rows
= getSelectedLabels();
493 if (sel_rows
.length
> 0) {
495 var ok
= confirm("Remove selected labels?");
498 notify_progress("Removing selected labels...");
500 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
501 param_escape(sel_rows
.toString()), true);
502 xmlhttp
.onreadystatechange
=labellist_callback
;
506 alert("No labels are selected.");
512 function removeSelectedUsers() {
514 if (!xmlhttp_ready(xmlhttp
)) {
519 var sel_rows
= getSelectedUsers();
521 if (sel_rows
.length
> 0) {
523 var ok
= confirm("Remove selected users?");
526 notify_progress("Removing selected users...");
528 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
529 param_escape(sel_rows
.toString()), true);
530 xmlhttp
.onreadystatechange
=userlist_callback
;
535 alert("No users are selected.");
541 function removeSelectedFilters() {
543 if (!xmlhttp_ready(xmlhttp
)) {
548 var sel_rows
= getSelectedFilters();
550 if (sel_rows
.length
> 0) {
552 var ok
= confirm("Remove selected filters?");
555 notify_progress("Removing selected filters...");
557 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
558 param_escape(sel_rows
.toString()), true);
559 xmlhttp
.onreadystatechange
=filterlist_callback
;
563 alert("No filters are selected.");
570 function removeSelectedFeeds() {
572 if (!xmlhttp_ready(xmlhttp
)) {
577 var sel_rows
= getSelectedFeeds();
579 if (sel_rows
.length
> 0) {
581 var ok
= confirm("Unsubscribe from selected feeds?");
585 notify_progress("Unsubscribing from selected feeds...");
587 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
588 param_escape(sel_rows
.toString()), true);
589 xmlhttp
.onreadystatechange
=feedlist_callback
;
595 alert("No feeds are selected.");
602 function removeSelectedFeedCats() {
604 if (!xmlhttp_ready(xmlhttp
)) {
609 var sel_rows
= getSelectedFeedCats();
611 if (sel_rows
.length
> 0) {
613 var ok
= confirm("Remove selected categories?");
616 notify_progress("Removing selected categories...");
618 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
619 param_escape(sel_rows
.toString()), true);
620 xmlhttp
.onreadystatechange
=infobox_callback
;
626 alert("No categories are selected.");
633 function feedEditCancel() {
635 if (!xmlhttp_ready(xmlhttp
)) {
642 selectPrefRows('feed', false); // cleanup feed selection
647 function feedCatEditCancel() {
649 if (!xmlhttp_ready(xmlhttp
)) {
654 active_feed_cat
= false;
656 // notify("Operation cancelled.");
658 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
659 xmlhttp
.onreadystatechange
=infobox_callback
;
665 function feedEditSave() {
669 if (!xmlhttp_ready(xmlhttp
)) {
674 // FIXME: add parameter validation
676 var query
= Form
.serialize("edit_feed_form");
678 notify_progress("Saving feed...");
680 xmlhttp
.open("POST", "backend.php", true);
681 xmlhttp
.onreadystatechange
=feedlist_callback
;
682 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
690 exception_error("feedEditSave", e
);
694 function feedCatEditSave() {
696 if (!xmlhttp_ready(xmlhttp
)) {
701 notify_progress("Saving category...");
703 var query
= Form
.serialize("feed_cat_edit_form");
705 xmlhttp
.open("GET", "backend.php?" + query
, true);
706 xmlhttp
.onreadystatechange
=infobox_callback
;
709 active_feed_cat
= false;
715 function labelTest() {
717 var container
= document
.getElementById('label_test_result');
718 container
.style
.display
= "block";
719 container
.innerHTML
= "<p>Loading, please wait...</p>";
721 var form
= document
.forms
['label_edit_form'];
723 var sql_exp
= form
.sql_exp
.value
;
724 var description
= form
.description
.value
;
726 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
727 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
729 xmlhttp
.onreadystatechange
=labeltest_callback
;
735 function displayHelpInfobox(topic_id
) {
737 /* if (!xmlhttp_ready(xmlhttp)) {
742 notify_progress("Loading help...");
744 xmlhttp.open("GET", "backend.php?op=help&tid=" +
745 param_escape(topic_id), true);
747 xmlhttp.onreadystatechange=helpbox_callback;
748 xmlhttp.send(null); */
750 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
752 var w
= window
.open(url
, "ttrss_help",
753 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
757 function labelEditCancel() {
759 if (!xmlhttp_ready(xmlhttp
)) {
764 document
.getElementById("label_create_btn").disabled
= false;
766 active_label
= false;
768 selectPrefRows('label', false); // cleanup feed selection
774 function userEditCancel() {
776 if (!xmlhttp_ready(xmlhttp
)) {
781 selectPrefRows('user', false); // cleanup feed selection
787 function filterEditCancel() {
789 if (!xmlhttp_ready(xmlhttp
)) {
794 document
.getElementById("create_filter_btn").disabled
= false;
796 selectPrefRows('filter', false); // cleanup feed selection
802 function labelEditSave() {
804 var label
= active_label
;
806 if (!xmlhttp_ready(xmlhttp
)) {
811 /* if (!is_opera()) {
813 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
814 var description = document.forms["label_edit_form"].description.value;
816 if (sql_exp.length == 0) {
817 alert("SQL Expression cannot be blank.");
821 if (description.length == 0) {
822 alert("Caption field cannot be blank.");
829 notify_progress("Saving label...");
831 active_label
= false;
833 query
= Form
.serialize("label_edit_form");
835 xmlhttp
.open("GET", "backend.php?" + query
, true);
836 xmlhttp
.onreadystatechange
=labellist_callback
;
842 function userEditSave() {
844 if (!xmlhttp_ready(xmlhttp
)) {
849 var login
= document
.forms
["user_edit_form"].login
.value
;
851 if (login
.length
== 0) {
852 alert("Login field cannot be blank.");
856 notify_progress("Saving user...");
860 var query
= Form
.serialize("user_edit_form");
862 xmlhttp
.open("GET", "backend.php?" + query
, true);
863 xmlhttp
.onreadystatechange
=userlist_callback
;
870 function filterEditSave() {
872 if (!xmlhttp_ready(xmlhttp
)) {
877 /* if (!is_opera()) {
878 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
880 if (reg_exp.length == 0) {
881 alert("Filter expression field cannot be blank.");
886 notify_progress("Saving filter...");
888 var query
= Form
.serialize("filter_edit_form");
892 document
.getElementById("create_filter_btn").disabled
= false;
894 xmlhttp
.open("GET", "backend.php?" + query
, true);
895 xmlhttp
.onreadystatechange
=filterlist_callback
;
901 function editSelectedLabel() {
902 var rows
= getSelectedLabels();
904 if (rows
.length
== 0) {
905 alert(__("No labels are selected."));
909 if (rows
.length
> 1) {
910 alert(__("Please select only one label."));
920 function editSelectedUser() {
921 var rows
= getSelectedUsers();
923 if (rows
.length
== 0) {
924 alert(__("No users are selected."));
928 if (rows
.length
> 1) {
929 alert(__("Please select only one user."));
938 function resetSelectedUserPass() {
939 var rows
= getSelectedUsers();
941 if (rows
.length
== 0) {
942 alert(__("No users are selected."));
946 if (rows
.length
> 1) {
947 alert(__("Please select only one user."));
951 var ok
= confirm(__("Reset password of selected user?"));
954 notify_progress("Resetting password for selected user...");
958 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
959 param_escape(id
), true);
960 xmlhttp
.onreadystatechange
=userlist_callback
;
965 function selectedUserDetails() {
967 if (!xmlhttp_ready(xmlhttp
)) {
972 var rows
= getSelectedUsers();
974 if (rows
.length
== 0) {
975 alert(__("No users are selected."));
979 if (rows
.length
> 1) {
980 alert(__("Please select only one user."));
984 notify_progress("Loading, please wait...");
988 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
989 xmlhttp
.onreadystatechange
=infobox_callback
;
994 function selectedFeedDetails() {
996 if (!xmlhttp_ready(xmlhttp
)) {
1001 var rows
= getSelectedFeeds();
1003 if (rows
.length
== 0) {
1004 alert(__("No feeds are selected."));
1008 if (rows
.length
> 1) {
1009 alert(__("Please select only one feed."));
1013 // var id = rows[0];
1017 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1018 param_escape(rows
.toString()), true);
1019 xmlhttp
.onreadystatechange
=infobox_callback
;
1024 function editSelectedFilter() {
1025 var rows
= getSelectedFilters();
1027 if (rows
.length
== 0) {
1028 alert(__("No filters are selected."));
1032 if (rows
.length
> 1) {
1033 alert(__("Please select only one filter."));
1039 editFilter(rows
[0]);
1044 function editSelectedFeed() {
1045 var rows
= getSelectedFeeds();
1047 if (rows
.length
== 0) {
1048 alert(__("No feeds are selected."));
1052 if (rows
.length
> 1) {
1053 alert(__("Please select one feed."));
1063 function editSelectedFeedCat() {
1064 var rows
= getSelectedFeedCats();
1066 if (rows
.length
== 0) {
1067 alert(__("No categories are selected."));
1071 if (rows
.length
> 1) {
1072 alert(__("Please select only one category."));
1078 editFeedCat(rows
[0]);
1082 function piggie_callback() {
1083 var piggie
= document
.getElementById("piggie");
1085 piggie
.style
.top
= piggie_top
;
1086 piggie
.style
.backgroundColor
= "white";
1087 piggie
.style
.borderWidth
= "1px";
1089 if (piggie_fwd
&& piggie_top
< 0) {
1090 setTimeout("piggie_callback()", 50);
1091 piggie_top
= piggie_top
+ 10;
1092 } else if (piggie_fwd
&& piggie_top
>= 0) {
1094 setTimeout("piggie_callback()", 50);
1095 } else if (!piggie_fwd
&& piggie_top
> -400) {
1096 setTimeout("piggie_callback()", 50);
1097 piggie_top
= piggie_top
- 10;
1098 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1099 piggie
.style
.display
= "none";
1104 var piggie_opacity
= 0;
1106 function piggie2_callback() {
1107 var piggie
= document
.getElementById("piggie");
1108 piggie
.style
.top
= 0;
1109 piggie
.style
.opacity
= piggie_opacity
;
1110 piggie
.style
.backgroundColor
= "transparent";
1111 piggie
.style
.borderWidth
= "0px";
1113 if (piggie_fwd
&& piggie_opacity
< 1) {
1114 setTimeout("piggie2_callback()", 50);
1115 piggie_opacity
= piggie_opacity
+ 0.03;
1116 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1118 setTimeout("piggie2_callback()", 50);
1119 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1120 setTimeout("piggie2_callback()", 50);
1121 piggie_opacity
= piggie_opacity
- 0.03;
1122 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1123 piggie
.style
.display
= "none";
1128 function localPiggieFunction(enable
) {
1130 debug("I LOVEDED IT!");
1131 var piggie
= document
.getElementById("piggie");
1132 piggie
.style
.display
= "block";
1134 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1142 function validateOpmlImport() {
1144 var opml_file
= document
.getElementById("opml_file");
1146 if (opml_file
.value
.length
== 0) {
1147 alert(__("No OPML file to upload."));
1154 function updateFilterList(sort_key
) {
1156 if (!xmlhttp_ready(xmlhttp
)) {
1157 printLockingError();
1161 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1163 // p_notify("Loading, please wait...");
1165 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1166 param_escape(sort_key
), true);
1167 xmlhttp
.onreadystatechange
=filterlist_callback
;
1172 function updateLabelList(sort_key
) {
1174 if (!xmlhttp_ready(xmlhttp
)) {
1175 printLockingError();
1179 // p_notify("Loading, please wait...");
1181 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1183 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1184 param_escape(sort_key
), true);
1185 xmlhttp
.onreadystatechange
=labellist_callback
;
1189 function updatePrefsList() {
1191 if (!xmlhttp_ready(xmlhttp
)) {
1192 printLockingError();
1196 // p_notify("Loading, please wait...");
1198 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1199 xmlhttp
.onreadystatechange
=prefslist_callback
;
1204 function selectTab(id
, noupdate
, subop
) {
1208 if (!id
) id
= active_tab
;
1212 if (!xmlhttp_ready(xmlhttp
)) {
1213 printLockingError();
1218 var c
= document
.getElementById('prefContent');
1224 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1226 notify_progress("Loading, please wait...");
1228 // close active infobox if needed
1231 // clean up all current selections, just in case
1232 active_feed_cat
= false;
1233 active_label
= false;
1235 if (id
== "feedConfig") {
1237 } else if (id
== "filterConfig") {
1239 } else if (id
== "labelConfig") {
1241 } else if (id
== "genConfig") {
1243 } else if (id
== "userConfig") {
1245 } else if (id
== "feedBrowser") {
1246 updateBigFeedBrowser();
1250 var tab
= document
.getElementById(active_tab
+ "Tab");
1253 if (tab
.className
.match("Selected")) {
1254 tab
.className
= "prefsTab";
1258 tab
= document
.getElementById(id
+ "Tab");
1261 if (!tab
.className
.match("Selected")) {
1262 tab
.className
= tab
.className
+ "Selected";
1269 exception_error("selectTab", e
);
1273 function backend_sanity_check_callback() {
1275 if (xmlhttp
.readyState
== 4) {
1279 if (sanity_check_done
) {
1280 fatalError(11, "Sanity check request received twice. This can indicate "+
1281 "presence of Firebug or some other disrupting extension. "+
1282 "Please disable it and try again.");
1286 if (!xmlhttp
.responseXML
) {
1287 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1291 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1294 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1298 var error_code
= reply
.getAttribute("error-code");
1300 if (error_code
&& error_code
!= 0) {
1301 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1304 debug("sanity check ok");
1306 var params
= reply
.nextSibling
;
1309 debug('reading init-params...');
1310 var param
= params
.firstChild
;
1313 var k
= param
.getAttribute("key");
1314 var v
= param
.getAttribute("value");
1315 debug(k
+ " => " + v
);
1317 param
= param
.nextSibling
;
1321 sanity_check_done
= true;
1323 init_second_stage();
1326 exception_error("backend_sanity_check_callback", e
);
1331 function init_second_stage() {
1334 active_tab
= getInitParam("prefs_active_tab");
1335 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1337 document
.onkeydown
= pref_hotkey_handler
;
1339 var tab
= getURLParam('tab');
1341 caller_subop
= getURLParam('subop');
1347 if (navigator
.userAgent
.match("Opera")) {
1348 setTimeout("selectTab()", 500);
1350 selectTab(active_tab
);
1354 exception_error("init_second_stage", e
);
1362 if (arguments
.callee
.done
) return;
1363 arguments
.callee
.done
= true;
1365 if (getURLParam('debug')) {
1366 document
.getElementById('debug_output').style
.display
= 'block';
1367 debug('debug mode activated');
1372 document
.getElementById("prefContent").innerHTML
=
1373 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1374 "to function properly. Your browser doesn't seem to support it.";
1378 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1379 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1383 exception_error("init", e
);
1387 function categorizeSelectedFeeds() {
1389 if (!xmlhttp_ready(xmlhttp
)) {
1390 printLockingError();
1394 var sel_rows
= getSelectedFeeds();
1396 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1397 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1399 if (sel_rows
.length
> 0) {
1401 notify_progress("Changing category of selected feeds...");
1403 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1404 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1405 xmlhttp
.onreadystatechange
=feedlist_callback
;
1410 alert(__("No feeds are selected."));
1416 function validatePrefsReset() {
1417 return confirm(__("Reset to defaults?"));
1420 function browseFeeds(limit
) {
1422 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1423 xmlhttp
.onreadystatechange
=infobox_callback
;
1428 function feedBrowserSubscribe() {
1431 var selected
= getSelectedFeedsFromBrowser();
1433 if (selected
.length
> 0) {
1435 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1436 param_escape(selected
.toString()), true);
1437 xmlhttp
.onreadystatechange
=feedlist_callback
;
1440 alert("No feeds are selected.");
1444 exception_error("feedBrowserSubscribe", e
);
1448 function updateBigFeedBrowser(limit
) {
1450 if (!xmlhttp_ready(xmlhttp
)) {
1451 printLockingError();
1455 // p_notify("Loading, please wait...");
1457 var query
= "backend.php?op=pref-feed-browser";
1459 var limit_sel
= document
.getElementById("feedBrowserLimit");
1462 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1463 query
= query
+ "&limit=" + param_escape(limit
);
1466 xmlhttp
.open("GET", query
, true);
1467 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1471 function browserToggleExpand(id
) {
1473 /* if (feed_to_expand && feed_to_expand != id) {
1474 var d = document.getElementById("BRDET-" + feed_to_expand);
1475 d.style.display = "none";
1478 if (!xmlhttp_ready(xmlhttp
)) {
1479 printLockingError();
1483 var d
= document
.getElementById("BRDET-" + id
);
1485 if (d
.style
.display
== "block") {
1486 d
.style
.display
= "none";
1490 feed_to_expand
= id
;
1492 d
.style
.display
= "block";
1493 d
.innerHTML
= "Loading, please wait...";
1495 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1496 + param_escape(id
), true);
1497 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1502 exception_error("browserExpand", e
);
1506 function selectPrefRows(kind
, select
) {
1509 var opbarid
= false;
1514 if (kind
== "feed") {
1515 opbarid
= "feedOpToolbar";
1518 lname
= "prefFeedList";
1519 } else if (kind
== "fcat") {
1520 opbarid
= "catOpToolbar";
1523 lname
= "prefFeedCatList";
1524 } else if (kind
== "filter") {
1525 opbarid
= "filterOpToolbar";
1528 lname
= "prefFilterList";
1529 } else if (kind
== "label") {
1530 opbarid
= "labelOpToolbar";
1533 lname
= "prefLabelList";
1534 } else if (kind
== "user") {
1535 opbarid
= "userOpToolbar";
1538 lname
= "prefUserList";
1542 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1543 disableContainerChildren(opbarid
, !select
);
1550 function toggleSelectPrefRow(sender
, kind
) {
1552 toggleSelectRow(sender
);
1555 var opbarid
= false;
1558 if (kind
== "feed") {
1559 opbarid
= "feedOpToolbar";
1560 nsel
= getSelectedFeeds();
1561 } else if (kind
== "fcat") {
1562 opbarid
= "catOpToolbar";
1563 nsel
= getSelectedFeedCats();
1564 } else if (kind
== "filter") {
1565 opbarid
= "filterOpToolbar";
1566 nsel
= getSelectedFilters();
1567 } else if (kind
== "label") {
1568 opbarid
= "labelOpToolbar";
1569 nsel
= getSelectedLabels();
1570 } else if (kind
== "user") {
1571 opbarid
= "userOpToolbar";
1572 nsel
= getSelectedUsers();
1575 if (opbarid
&& nsel
!= -1) {
1576 disableContainerChildren(opbarid
, nsel
== false);
1582 function toggleSelectFBListRow(sender
) {
1583 toggleSelectListRow(sender
);
1584 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1589 function pref_hotkey_handler(e
) {
1594 if (!hotkeys_enabled
) return;
1597 keycode
= window
.event
.keyCode
;
1602 if (keycode
== 13 || keycode
== 27) {
1605 seq
= seq
+ "" + keycode
;
1609 if (document
.getElementById("piggie")) {
1611 if (seq
.match("807371717369")) {
1613 localPiggieFunction(true);
1615 localPiggieFunction(false);
1620 exception_error("pref_hotkey_handler", e
);
1624 function userSwitch() {
1625 var chooser
= document
.getElementById("userSwitch");
1626 var user
= chooser
[chooser
.selectedIndex
].value
;
1627 window
.location
= "prefs.php?swu=" + user
;
1630 function editFeedCats() {
1631 if (!xmlhttp_ready(xmlhttp
)) {
1632 printLockingError();
1636 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1637 xmlhttp
.onreadystatechange
=infobox_callback
;
1641 function showFeedsWithErrors() {
1642 displayDlg('feedUpdateErrors');
1645 function changeUserPassword() {
1649 if (!xmlhttp_ready(xmlhttp
)) {
1650 printLockingError();
1654 var query
= Form
.serialize("change_pass_form");
1656 notify_progress("Trying to change password...");
1658 xmlhttp
.open("POST", "backend.php", true);
1659 xmlhttp
.onreadystatechange
=changepass_callback
;
1660 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1661 xmlhttp
.send(query
);
1664 exception_error("changeUserPassword", e
);
1670 function changeUserEmail() {
1674 if (!xmlhttp_ready(xmlhttp
)) {
1675 printLockingError();
1679 var query
= Form
.serialize("change_email_form");
1681 notify_progress("Trying to change e-mail...");
1683 xmlhttp
.open("POST", "backend.php", true);
1684 xmlhttp
.onreadystatechange
=notify_callback
;
1685 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1686 xmlhttp
.send(query
);
1689 exception_error("changeUserPassword", e
);