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 function expand_feed_callback() {
18 if (xmlhttp
.readyState
== 4) {
20 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
21 container
.innerHTML
=xmlhttp
.responseText
;
22 container
.style
.display
= "block";
25 exception_error("expand_feed_callback", e
);
30 function feedlist_callback() {
31 if (xmlhttp
.readyState
== 4) {
33 var container
= document
.getElementById('prefContent');
34 container
.innerHTML
=xmlhttp
.responseText
;
35 selectTab("feedConfig", true);
38 var tuple
= caller_subop
.split(":");
39 if (tuple
[0] == 'editFeed') {
40 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
48 exception_error("feedlist_callback", e
);
53 function filterlist_callback() {
54 var container
= document
.getElementById('prefContent');
55 if (xmlhttp
.readyState
== 4) {
56 container
.innerHTML
=xmlhttp
.responseText
;
61 function labellist_callback() {
62 var container
= document
.getElementById('prefContent');
63 if (xmlhttp
.readyState
== 4) {
65 container
.innerHTML
=xmlhttp
.responseText
;
67 var row
= document
.getElementById("LILRR-" + active_label
);
69 if (!row
.className
.match("Selected")) {
70 row
.className
= row
.className
+ "Selected";
73 var checkbox
= document
.getElementById("LICHK-" + active_label
);
76 checkbox
.checked
= true;
83 function labeltest_callback() {
84 var container
= document
.getElementById('label_test_result');
85 if (xmlhttp
.readyState
== 4) {
86 container
.innerHTML
=xmlhttp
.responseText
;
91 function feed_browser_callback() {
92 var container
= document
.getElementById('prefContent');
93 if (xmlhttp
.readyState
== 4) {
94 container
.innerHTML
=xmlhttp
.responseText
;
99 function userlist_callback() {
100 var container
= document
.getElementById('prefContent');
101 if (xmlhttp
.readyState
== 4) {
102 container
.innerHTML
=xmlhttp
.responseText
;
107 function prefslist_callback() {
108 var container
= document
.getElementById('prefContent');
109 if (xmlhttp
.readyState
== 4) {
111 container
.innerHTML
=xmlhttp
.responseText
;
117 function gethelp_callback() {
118 var container
= document
.getElementById('prefHelpBox');
119 if (xmlhttp
.readyState
== 4) {
121 container
.innerHTML
= xmlhttp
.responseText
;
122 container
.style
.display
= "block";
127 function notify_callback() {
128 if (xmlhttp
.readyState
== 4) {
129 notify_info(xmlhttp
.responseText
);
134 function changepass_callback() {
136 if (xmlhttp
.readyState
== 4) {
138 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
139 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
141 notify_info(xmlhttp
.responseText
);
142 var warn
= document
.getElementById("default_pass_warning");
143 if (warn
) warn
.style
.display
= "none";
146 document
.forms
['change_pass_form'].reset();
150 exception_error("changepass_callback", e
);
154 function updateFeedList(sort_key
) {
156 if (!xmlhttp_ready(xmlhttp
)) {
161 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
163 // p_notify("Loading, please wait...");
165 var feed_search
= document
.getElementById("feed_search");
167 if (feed_search
) { search
= feed_search
.value
; }
169 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
170 "&sort=" + param_escape(sort_key
) +
171 "&search=" + param_escape(search
), true);
172 xmlhttp
.onreadystatechange
=feedlist_callback
;
177 function updateUsersList(sort_key
) {
179 if (!xmlhttp_ready(xmlhttp
)) {
184 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
186 // p_notify("Loading, please wait...");
188 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
189 + param_escape(sort_key
), true);
190 xmlhttp
.onreadystatechange
=userlist_callback
;
195 function addLabel() {
197 if (!xmlhttp_ready(xmlhttp
)) {
202 var form
= document
.forms
['label_edit_form'];
204 var sql_exp
= form
.sql_exp
.value
;
205 var description
= form
.description
.value
;
208 alert("Can't create label: missing SQL expression.");
212 if (description
== "") {
213 alert("Can't create label: missing caption.");
217 var query
= Form
.serialize("label_edit_form");
219 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
220 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
226 if (!xmlhttp_ready(xmlhttp
)) {
231 var link
= document
.getElementById("fadd_link");
233 if (link
.value
.length
== 0) {
234 alert(__("Error: No feed URL given."));
235 } else if (!isValidURL(link
.value
)) {
236 alert(__("Error: Invalid feed URL."));
238 notify_progress("Adding feed...");
240 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
241 param_escape(link
.value
), true);
242 xmlhttp
.onreadystatechange
=feedlist_callback
;
251 function addFeedCat() {
253 if (!xmlhttp_ready(xmlhttp
)) {
258 var cat
= document
.getElementById("fadd_cat");
260 if (cat
.value
.length
== 0) {
261 alert(__("Can't add category: no name specified."));
263 notify_progress("Adding feed category...");
265 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
266 param_escape(cat
.value
), true);
267 xmlhttp
.onreadystatechange
=infobox_callback
;
277 if (!xmlhttp_ready(xmlhttp
)) {
282 var sqlexp
= document
.getElementById("uadd_box");
284 if (sqlexp
.value
.length
== 0) {
285 alert("Can't add user: no login specified.");
287 notify_progress("Adding user...");
289 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
290 param_escape(sqlexp
.value
), true);
292 xmlhttp
.onreadystatechange
=userlist_callback
;
300 function editLabel(id
) {
302 if (!xmlhttp_ready(xmlhttp
)) {
307 notify_progress("Loading, please wait...");
309 document
.getElementById("label_create_btn").disabled
= true;
313 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
314 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
316 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
317 param_escape(id
), true);
318 xmlhttp
.onreadystatechange
=infobox_callback
;
323 function editUser(id
) {
325 if (!xmlhttp_ready(xmlhttp
)) {
330 notify_progress("Loading, please wait...");
332 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
333 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
335 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
336 param_escape(id
), true);
337 xmlhttp
.onreadystatechange
=infobox_callback
;
342 function editFilter(id
) {
344 if (!xmlhttp_ready(xmlhttp
)) {
349 notify_progress("Loading, please wait...");
351 document
.getElementById("create_filter_btn").disabled
= true;
353 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
354 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
356 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
357 xmlhttp
.onreadystatechange
=infobox_callback
;
361 function editFeed(feed
) {
363 // notify("Editing feed...");
365 if (!xmlhttp_ready(xmlhttp
)) {
370 notify_progress("Loading, please wait...");
372 // clean selection from all rows & select row being edited
373 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
374 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
376 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
377 param_escape(feed
), true);
379 xmlhttp
.onreadystatechange
=infobox_callback
;
384 function editFeedCat(cat
) {
386 if (!xmlhttp_ready(xmlhttp
)) {
391 notify_progress("Loading, please wait...");
393 active_feed_cat
= cat
;
395 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
396 param_escape(cat
), true);
397 xmlhttp
.onreadystatechange
=infobox_callback
;
402 function getSelectedLabels() {
403 return getSelectedTableRowIds("prefLabelList", "LILRR");
406 function getSelectedUsers() {
407 return getSelectedTableRowIds("prefUserList", "UMRR");
410 function getSelectedFeeds() {
411 return getSelectedTableRowIds("prefFeedList", "FEEDR");
414 function getSelectedFilters() {
415 return getSelectedTableRowIds("prefFilterList", "FILRR");
418 function getSelectedFeedCats() {
419 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
422 function getSelectedFeedsFromBrowser() {
424 var list
= document
.getElementById("browseFeedList");
425 if (!list
) list
= document
.getElementById("browseBigFeedList");
427 var selected
= new Array();
429 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
430 var child
= list
.childNodes
[i
];
431 if (child
.id
&& child
.id
.match("FBROW-")) {
432 var id
= child
.id
.replace("FBROW-", "");
434 var cb
= document
.getElementById("FBCHK-" + id
);
445 function removeSelectedLabels() {
447 if (!xmlhttp_ready(xmlhttp
)) {
452 var sel_rows
= getSelectedLabels();
454 if (sel_rows
.length
> 0) {
456 var ok
= confirm("Remove selected labels?");
459 notify_progress("Removing selected labels...");
461 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
462 param_escape(sel_rows
.toString()), true);
463 xmlhttp
.onreadystatechange
=labellist_callback
;
467 alert("No labels are selected.");
473 function removeSelectedUsers() {
475 if (!xmlhttp_ready(xmlhttp
)) {
480 var sel_rows
= getSelectedUsers();
482 if (sel_rows
.length
> 0) {
484 var ok
= confirm("Remove selected users?");
487 notify_progress("Removing selected users...");
489 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
490 param_escape(sel_rows
.toString()), true);
491 xmlhttp
.onreadystatechange
=userlist_callback
;
496 alert("No users are selected.");
502 function removeSelectedFilters() {
504 if (!xmlhttp_ready(xmlhttp
)) {
509 var sel_rows
= getSelectedFilters();
511 if (sel_rows
.length
> 0) {
513 var ok
= confirm("Remove selected filters?");
516 notify_progress("Removing selected filters...");
518 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
519 param_escape(sel_rows
.toString()), true);
520 xmlhttp
.onreadystatechange
=filterlist_callback
;
524 alert("No filters are selected.");
531 function removeSelectedFeeds() {
533 if (!xmlhttp_ready(xmlhttp
)) {
538 var sel_rows
= getSelectedFeeds();
540 if (sel_rows
.length
> 0) {
542 var ok
= confirm("Unsubscribe from selected feeds?");
546 notify_progress("Unsubscribing from selected feeds...");
548 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
549 param_escape(sel_rows
.toString()), true);
550 xmlhttp
.onreadystatechange
=feedlist_callback
;
556 alert("No feeds are selected.");
563 function removeSelectedFeedCats() {
565 if (!xmlhttp_ready(xmlhttp
)) {
570 var sel_rows
= getSelectedFeedCats();
572 if (sel_rows
.length
> 0) {
574 var ok
= confirm("Remove selected categories?");
577 notify_progress("Removing selected categories...");
579 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
580 param_escape(sel_rows
.toString()), true);
581 xmlhttp
.onreadystatechange
=infobox_callback
;
587 alert("No categories are selected.");
594 function feedEditCancel() {
596 if (!xmlhttp_ready(xmlhttp
)) {
603 selectPrefRows('feed', false); // cleanup feed selection
608 function feedCatEditCancel() {
610 if (!xmlhttp_ready(xmlhttp
)) {
615 active_feed_cat
= false;
617 // notify("Operation cancelled.");
619 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
620 xmlhttp
.onreadystatechange
=infobox_callback
;
626 function feedEditSave() {
630 if (!xmlhttp_ready(xmlhttp
)) {
635 // FIXME: add parameter validation
637 var query
= Form
.serialize("edit_feed_form");
639 notify_progress("Saving feed...");
641 xmlhttp
.open("POST", "backend.php", true);
642 xmlhttp
.onreadystatechange
=feedlist_callback
;
643 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
651 exception_error("feedEditSave", e
);
655 function feedCatEditSave() {
657 if (!xmlhttp_ready(xmlhttp
)) {
662 notify_progress("Saving category...");
664 var query
= Form
.serialize("feed_cat_edit_form");
666 xmlhttp
.open("GET", "backend.php?" + query
, true);
667 xmlhttp
.onreadystatechange
=infobox_callback
;
670 active_feed_cat
= false;
676 function labelTest() {
678 var container
= document
.getElementById('label_test_result');
679 container
.style
.display
= "block";
680 container
.innerHTML
= "<p>Loading, please wait...</p>";
682 var form
= document
.forms
['label_edit_form'];
684 var sql_exp
= form
.sql_exp
.value
;
685 var description
= form
.description
.value
;
687 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
688 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
690 xmlhttp
.onreadystatechange
=labeltest_callback
;
696 function displayHelpInfobox(topic_id
) {
698 if (!xmlhttp_ready(xmlhttp
)) {
703 notify_progress("Loading help...");
705 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
706 param_escape(topic_id
) + "&noheaders=1", true);
708 xmlhttp
.onreadystatechange
=infobox_callback
;
713 function labelEditCancel() {
715 if (!xmlhttp_ready(xmlhttp
)) {
720 document
.getElementById("label_create_btn").disabled
= false;
722 active_label
= false;
724 selectPrefRows('label', false); // cleanup feed selection
730 function userEditCancel() {
732 if (!xmlhttp_ready(xmlhttp
)) {
737 selectPrefRows('user', false); // cleanup feed selection
743 function filterEditCancel() {
745 if (!xmlhttp_ready(xmlhttp
)) {
750 document
.getElementById("create_filter_btn").disabled
= false;
752 selectPrefRows('filter', false); // cleanup feed selection
758 function labelEditSave() {
760 var label
= active_label
;
762 if (!xmlhttp_ready(xmlhttp
)) {
767 /* if (!is_opera()) {
769 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
770 var description = document.forms["label_edit_form"].description.value;
772 if (sql_exp.length == 0) {
773 alert("SQL Expression cannot be blank.");
777 if (description.length == 0) {
778 alert("Caption field cannot be blank.");
785 notify_progress("Saving label...");
787 active_label
= false;
789 query
= Form
.serialize("label_edit_form");
791 xmlhttp
.open("GET", "backend.php?" + query
, true);
792 xmlhttp
.onreadystatechange
=labellist_callback
;
798 function userEditSave() {
800 if (!xmlhttp_ready(xmlhttp
)) {
805 var login
= document
.forms
["user_edit_form"].login
.value
;
807 if (login
.length
== 0) {
808 alert("Login field cannot be blank.");
812 notify_progress("Saving user...");
816 var query
= Form
.serialize("user_edit_form");
818 xmlhttp
.open("GET", "backend.php?" + query
, true);
819 xmlhttp
.onreadystatechange
=userlist_callback
;
826 function filterEditSave() {
828 if (!xmlhttp_ready(xmlhttp
)) {
833 /* if (!is_opera()) {
834 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
836 if (reg_exp.length == 0) {
837 alert("Filter expression field cannot be blank.");
842 notify_progress("Saving filter...");
844 var query
= Form
.serialize("filter_edit_form");
848 document
.getElementById("create_filter_btn").disabled
= false;
850 xmlhttp
.open("GET", "backend.php?" + query
, true);
851 xmlhttp
.onreadystatechange
=filterlist_callback
;
857 function editSelectedLabel() {
858 var rows
= getSelectedLabels();
860 if (rows
.length
== 0) {
861 alert(__("No labels are selected."));
865 if (rows
.length
> 1) {
866 alert(__("Please select only one label."));
876 function editSelectedUser() {
877 var rows
= getSelectedUsers();
879 if (rows
.length
== 0) {
880 alert(__("No users are selected."));
884 if (rows
.length
> 1) {
885 alert(__("Please select only one user."));
894 function resetSelectedUserPass() {
895 var rows
= getSelectedUsers();
897 if (rows
.length
== 0) {
898 alert(__("No users are selected."));
902 if (rows
.length
> 1) {
903 alert(__("Please select only one user."));
907 var ok
= confirm(__("Reset password of selected user?"));
910 notify_progress("Resetting password for selected user...");
914 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
915 param_escape(id
), true);
916 xmlhttp
.onreadystatechange
=userlist_callback
;
921 function selectedUserDetails() {
923 if (!xmlhttp_ready(xmlhttp
)) {
928 var rows
= getSelectedUsers();
930 if (rows
.length
== 0) {
931 alert(__("No users are selected."));
935 if (rows
.length
> 1) {
936 alert(__("Please select only one user."));
940 notify_progress("Loading, please wait...");
944 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
945 xmlhttp
.onreadystatechange
=infobox_callback
;
950 function selectedFeedDetails() {
952 if (!xmlhttp_ready(xmlhttp
)) {
957 var rows
= getSelectedFeeds();
959 if (rows
.length
== 0) {
960 alert(__("No feeds are selected."));
964 if (rows
.length
> 1) {
965 alert(__("Please select only one feed."));
973 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
974 param_escape(rows
.toString()), true);
975 xmlhttp
.onreadystatechange
=infobox_callback
;
980 function editSelectedFilter() {
981 var rows
= getSelectedFilters();
983 if (rows
.length
== 0) {
984 alert(__("No filters are selected."));
988 if (rows
.length
> 1) {
989 alert(__("Please select only one filter."));
1000 function editSelectedFeed() {
1001 var rows
= getSelectedFeeds();
1003 if (rows
.length
== 0) {
1004 alert(__("No feeds are selected."));
1008 if (rows
.length
> 1) {
1009 alert(__("Please select one feed."));
1019 function editSelectedFeedCat() {
1020 var rows
= getSelectedFeedCats();
1022 if (rows
.length
== 0) {
1023 alert(__("No categories are selected."));
1027 if (rows
.length
> 1) {
1028 alert(__("Please select only one category."));
1034 editFeedCat(rows
[0]);
1038 function piggie_callback() {
1039 var piggie
= document
.getElementById("piggie");
1041 piggie
.style
.top
= piggie_top
;
1042 piggie
.style
.backgroundColor
= "white";
1043 piggie
.style
.borderWidth
= "1px";
1045 if (piggie_fwd
&& piggie_top
< 0) {
1046 setTimeout("piggie_callback()", 50);
1047 piggie_top
= piggie_top
+ 10;
1048 } else if (piggie_fwd
&& piggie_top
>= 0) {
1050 setTimeout("piggie_callback()", 50);
1051 } else if (!piggie_fwd
&& piggie_top
> -400) {
1052 setTimeout("piggie_callback()", 50);
1053 piggie_top
= piggie_top
- 10;
1054 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1055 piggie
.style
.display
= "none";
1060 var piggie_opacity
= 0;
1062 function piggie2_callback() {
1063 var piggie
= document
.getElementById("piggie");
1064 piggie
.style
.top
= 0;
1065 piggie
.style
.opacity
= piggie_opacity
;
1066 piggie
.style
.backgroundColor
= "transparent";
1067 piggie
.style
.borderWidth
= "0px";
1069 if (piggie_fwd
&& piggie_opacity
< 1) {
1070 setTimeout("piggie2_callback()", 50);
1071 piggie_opacity
= piggie_opacity
+ 0.03;
1072 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1074 setTimeout("piggie2_callback()", 50);
1075 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1076 setTimeout("piggie2_callback()", 50);
1077 piggie_opacity
= piggie_opacity
- 0.03;
1078 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1079 piggie
.style
.display
= "none";
1084 function localPiggieFunction(enable
) {
1086 debug("I LOVEDED IT!");
1087 var piggie
= document
.getElementById("piggie");
1088 piggie
.style
.display
= "block";
1090 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1098 function validateOpmlImport() {
1100 var opml_file
= document
.getElementById("opml_file");
1102 if (opml_file
.value
.length
== 0) {
1103 alert(__("No OPML file to upload."));
1110 function updateFilterList(sort_key
) {
1112 if (!xmlhttp_ready(xmlhttp
)) {
1113 printLockingError();
1117 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1119 // p_notify("Loading, please wait...");
1121 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1122 param_escape(sort_key
), true);
1123 xmlhttp
.onreadystatechange
=filterlist_callback
;
1128 function updateLabelList(sort_key
) {
1130 if (!xmlhttp_ready(xmlhttp
)) {
1131 printLockingError();
1135 // p_notify("Loading, please wait...");
1137 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1139 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1140 param_escape(sort_key
), true);
1141 xmlhttp
.onreadystatechange
=labellist_callback
;
1145 function updatePrefsList() {
1147 if (!xmlhttp_ready(xmlhttp
)) {
1148 printLockingError();
1152 // p_notify("Loading, please wait...");
1154 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1155 xmlhttp
.onreadystatechange
=prefslist_callback
;
1160 function selectTab(id
, noupdate
, subop
) {
1164 if (!id
) id
= active_tab
;
1168 if (!xmlhttp_ready(xmlhttp
)) {
1169 printLockingError();
1174 var c
= document
.getElementById('prefContent');
1180 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1182 notify_progress("Loading, please wait...");
1184 // close active infobox if needed
1187 // clean up all current selections, just in case
1188 active_feed_cat
= false;
1189 active_label
= false;
1191 if (id
== "feedConfig") {
1193 } else if (id
== "filterConfig") {
1195 } else if (id
== "labelConfig") {
1197 } else if (id
== "genConfig") {
1199 } else if (id
== "userConfig") {
1201 } else if (id
== "feedBrowser") {
1202 updateBigFeedBrowser();
1206 var tab
= document
.getElementById(active_tab
+ "Tab");
1209 if (tab
.className
.match("Selected")) {
1210 tab
.className
= "prefsTab";
1214 tab
= document
.getElementById(id
+ "Tab");
1217 if (!tab
.className
.match("Selected")) {
1218 tab
.className
= tab
.className
+ "Selected";
1225 exception_error("selectTab", e
);
1229 function backend_sanity_check_callback() {
1231 if (xmlhttp
.readyState
== 4) {
1235 if (!xmlhttp
.responseXML
) {
1236 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1240 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1243 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1247 var error_code
= reply
.getAttribute("error-code");
1249 if (error_code
&& error_code
!= 0) {
1250 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1253 debug("sanity check ok");
1255 var params
= reply
.nextSibling
;
1258 debug('reading init-params...');
1259 var param
= params
.firstChild
;
1262 var k
= param
.getAttribute("key");
1263 var v
= param
.getAttribute("value");
1264 debug(k
+ " => " + v
);
1266 param
= param
.nextSibling
;
1270 init_second_stage();
1273 exception_error("backend_sanity_check_callback", e
);
1278 function init_second_stage() {
1281 active_tab
= getInitParam("prefs_active_tab");
1282 if (!active_tab
) active_tab
= "genConfig";
1284 document
.onkeydown
= pref_hotkey_handler
;
1286 var tab
= getURLParam('tab');
1288 caller_subop
= getURLParam('subop');
1294 if (navigator
.userAgent
.match("Opera")) {
1295 setTimeout("selectTab()", 500);
1297 selectTab(active_tab
);
1301 exception_error("init_second_stage", e
);
1309 if (arguments
.callee
.done
) return;
1310 arguments
.callee
.done
= true;
1312 if (getURLParam('debug')) {
1313 document
.getElementById('debug_output').style
.display
= 'block';
1314 debug('debug mode activated');
1319 document
.getElementById("prefContent").innerHTML
=
1320 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1321 "to function properly. Your browser doesn't seem to support it.";
1325 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1326 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1330 exception_error("init", e
);
1334 function categorizeSelectedFeeds() {
1336 if (!xmlhttp_ready(xmlhttp
)) {
1337 printLockingError();
1341 var sel_rows
= getSelectedFeeds();
1343 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1344 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1346 if (sel_rows
.length
> 0) {
1348 notify_progress("Changing category of selected feeds...");
1350 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1351 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1352 xmlhttp
.onreadystatechange
=feedlist_callback
;
1357 alert(__("No feeds are selected."));
1363 function validatePrefsReset() {
1364 return confirm(__("Reset to defaults?"));
1367 function browseFeeds(limit
) {
1369 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1370 xmlhttp
.onreadystatechange
=infobox_callback
;
1375 function feedBrowserSubscribe() {
1378 var selected
= getSelectedFeedsFromBrowser();
1380 if (selected
.length
> 0) {
1382 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1383 param_escape(selected
.toString()), true);
1384 xmlhttp
.onreadystatechange
=feedlist_callback
;
1387 alert("No feeds are selected.");
1391 exception_error("feedBrowserSubscribe", e
);
1395 function updateBigFeedBrowser(limit
) {
1397 if (!xmlhttp_ready(xmlhttp
)) {
1398 printLockingError();
1402 // p_notify("Loading, please wait...");
1404 var query
= "backend.php?op=pref-feed-browser";
1406 var limit_sel
= document
.getElementById("feedBrowserLimit");
1409 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1410 query
= query
+ "&limit=" + param_escape(limit
);
1413 xmlhttp
.open("GET", query
, true);
1414 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1418 function browserToggleExpand(id
) {
1420 /* if (feed_to_expand && feed_to_expand != id) {
1421 var d = document.getElementById("BRDET-" + feed_to_expand);
1422 d.style.display = "none";
1425 if (!xmlhttp_ready(xmlhttp
)) {
1426 printLockingError();
1430 var d
= document
.getElementById("BRDET-" + id
);
1432 if (d
.style
.display
== "block") {
1433 d
.style
.display
= "none";
1437 feed_to_expand
= id
;
1439 d
.style
.display
= "block";
1440 d
.innerHTML
= "Loading, please wait...";
1442 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1443 + param_escape(id
), true);
1444 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1449 exception_error("browserExpand", e
);
1453 function selectPrefRows(kind
, select
) {
1456 var opbarid
= false;
1461 if (kind
== "feed") {
1462 opbarid
= "feedOpToolbar";
1465 lname
= "prefFeedList";
1466 } else if (kind
== "fcat") {
1467 opbarid
= "catOpToolbar";
1470 lname
= "prefFeedCatList";
1471 } else if (kind
== "filter") {
1472 opbarid
= "filterOpToolbar";
1475 lname
= "prefFilterList";
1476 } else if (kind
== "label") {
1477 opbarid
= "labelOpToolbar";
1480 lname
= "prefLabelList";
1481 } else if (kind
== "user") {
1482 opbarid
= "userOpToolbar";
1485 lname
= "prefUserList";
1489 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1490 disableContainerChildren(opbarid
, !select
);
1497 function toggleSelectPrefRow(sender
, kind
) {
1499 toggleSelectRow(sender
);
1502 var opbarid
= false;
1505 if (kind
== "feed") {
1506 opbarid
= "feedOpToolbar";
1507 nsel
= getSelectedFeeds();
1508 } else if (kind
== "fcat") {
1509 opbarid
= "catOpToolbar";
1510 nsel
= getSelectedFeedCats();
1511 } else if (kind
== "filter") {
1512 opbarid
= "filterOpToolbar";
1513 nsel
= getSelectedFilters();
1514 } else if (kind
== "label") {
1515 opbarid
= "labelOpToolbar";
1516 nsel
= getSelectedLabels();
1517 } else if (kind
== "user") {
1518 opbarid
= "userOpToolbar";
1519 nsel
= getSelectedUsers();
1522 if (opbarid
&& nsel
!= -1) {
1523 disableContainerChildren(opbarid
, nsel
== false);
1529 function toggleSelectFBListRow(sender
) {
1530 toggleSelectListRow(sender
);
1531 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1536 function pref_hotkey_handler(e
) {
1541 if (!hotkeys_enabled
) return;
1544 keycode
= window
.event
.keyCode
;
1549 if (keycode
== 13 || keycode
== 27) {
1552 seq
= seq
+ "" + keycode
;
1556 if (document
.getElementById("piggie")) {
1558 if (seq
.match("807371717369")) {
1560 localPiggieFunction(true);
1562 localPiggieFunction(false);
1567 exception_error("pref_hotkey_handler", e
);
1571 function userSwitch() {
1572 var chooser
= document
.getElementById("userSwitch");
1573 var user
= chooser
[chooser
.selectedIndex
].value
;
1574 window
.location
= "prefs.php?swu=" + user
;
1577 function editFeedCats() {
1578 if (!xmlhttp_ready(xmlhttp
)) {
1579 printLockingError();
1583 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1584 xmlhttp
.onreadystatechange
=infobox_callback
;
1588 function showFeedsWithErrors() {
1589 displayDlg('feedUpdateErrors');
1592 function changeUserPassword() {
1596 if (!xmlhttp_ready(xmlhttp
)) {
1597 printLockingError();
1601 var query
= Form
.serialize("change_pass_form");
1603 notify_progress("Trying to change password...");
1605 xmlhttp
.open("POST", "backend.php", true);
1606 xmlhttp
.onreadystatechange
=changepass_callback
;
1607 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1608 xmlhttp
.send(query
);
1611 exception_error("changeUserPassword", e
);
1617 function changeUserEmail() {
1621 if (!xmlhttp_ready(xmlhttp
)) {
1622 printLockingError();
1626 var query
= Form
.serialize("change_email_form");
1628 notify_progress("Trying to change e-mail...");
1630 xmlhttp
.open("POST", "backend.php", true);
1631 xmlhttp
.onreadystatechange
=notify_callback
;
1632 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1633 xmlhttp
.send(query
);
1636 exception_error("changeUserPassword", e
);