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 replace_pubkey_callback() {
20 if (xmlhttp
.readyState
== 4) {
22 var link
= document
.getElementById("pubGenAddress");
24 if (xmlhttp
.responseXML
) {
26 var new_link
= xmlhttp
.responseXML
.getElementsByTagName("link")[0];
29 link
.href
= new_link
.firstChild
.nodeValue
;
30 link
.innerHTML
= new_link
.firstChild
.nodeValue
;
32 notify_info("Address changed.");
34 notify_error("Could not change address.");
38 notify_error("Could not change address.");
41 exception_error("replace_pubkey_callback", e
);
46 function expand_feed_callback() {
47 if (xmlhttp
.readyState
== 4) {
49 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
50 container
.innerHTML
=xmlhttp
.responseText
;
51 // container.style.display = "block";
53 Effect
.Appear(container
, {duration
: 0.5});
55 exception_error("expand_feed_callback", e
);
60 function feedlist_callback() {
61 if (xmlhttp
.readyState
== 4) {
63 var container
= document
.getElementById('prefContent');
64 container
.innerHTML
=xmlhttp
.responseText
;
65 selectTab("feedConfig", true);
68 var tuple
= caller_subop
.split(":");
69 if (tuple
[0] == 'editFeed') {
70 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
75 if (typeof correctPNG
!= 'undefined') {
80 exception_error("feedlist_callback", e
);
85 /* stub for subscription dialog */
87 function dlg_frefresh_callback() {
88 if (xmlhttp
.readyState
== 4) {
89 // setTimeout("updateFeedList()", 500);
92 var container
= document
.getElementById('prefContent');
93 container
.innerHTML
=xmlhttp
.responseText
;
94 selectTab("feedConfig", true);
97 var tuple
= caller_subop
.split(":");
98 if (tuple
[0] == 'editFeed') {
99 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
102 caller_subop
= false;
104 if (typeof correctPNG
!= 'undefined') {
109 exception_error("feedlist_callback", e
);
114 function filterlist_callback() {
115 var container
= document
.getElementById('prefContent');
116 if (xmlhttp
.readyState
== 4) {
117 container
.innerHTML
=xmlhttp
.responseText
;
118 if (typeof correctPNG
!= 'undefined') {
125 function labellist_callback() {
126 var container
= document
.getElementById('prefContent');
127 if (xmlhttp
.readyState
== 4) {
129 container
.innerHTML
=xmlhttp
.responseText
;
131 var row
= document
.getElementById("LILRR-" + active_label
);
133 if (!row
.className
.match("Selected")) {
134 row
.className
= row
.className
+ "Selected";
137 var checkbox
= document
.getElementById("LICHK-" + active_label
);
140 checkbox
.checked
= true;
143 if (typeof correctPNG
!= 'undefined') {
150 function labeltest_callback() {
151 var container
= document
.getElementById('label_test_result');
152 if (xmlhttp
.readyState
== 4) {
153 container
.innerHTML
=xmlhttp
.responseText
;
158 function feed_browser_callback() {
159 var container
= document
.getElementById('prefContent');
160 if (xmlhttp
.readyState
== 4) {
161 container
.innerHTML
=xmlhttp
.responseText
;
166 function userlist_callback() {
167 var container
= document
.getElementById('prefContent');
168 if (xmlhttp
.readyState
== 4) {
169 container
.innerHTML
=xmlhttp
.responseText
;
174 function prefslist_callback() {
175 var container
= document
.getElementById('prefContent');
176 if (xmlhttp
.readyState
== 4) {
178 container
.innerHTML
=xmlhttp
.responseText
;
184 function gethelp_callback() {
185 var container
= document
.getElementById('prefHelpBox');
186 if (xmlhttp
.readyState
== 4) {
188 container
.innerHTML
= xmlhttp
.responseText
;
189 container
.style
.display
= "block";
194 function notify_callback() {
195 if (xmlhttp
.readyState
== 4) {
196 notify_info(xmlhttp
.responseText
);
201 function changepass_callback() {
203 if (xmlhttp
.readyState
== 4) {
205 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
206 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
208 notify_info(xmlhttp
.responseText
);
209 var warn
= document
.getElementById("default_pass_warning");
210 if (warn
) warn
.style
.display
= "none";
213 document
.forms
['change_pass_form'].reset();
217 exception_error("changepass_callback", e
);
221 function updateFeedList(sort_key
) {
223 if (!xmlhttp_ready(xmlhttp
)) {
228 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
230 // p_notify("Loading, please wait...");
232 var feed_search
= document
.getElementById("feed_search");
234 if (feed_search
) { search
= feed_search
.value
; }
236 var slat
= document
.getElementById("show_last_article_times");
238 var slat_checked
= false;
240 slat_checked
= slat
.checked
;
243 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
244 "&sort=" + param_escape(sort_key
) +
245 "&slat=" + param_escape(slat_checked
) +
246 "&search=" + param_escape(search
), true);
247 xmlhttp
.onreadystatechange
=feedlist_callback
;
252 function updateUsersList(sort_key
) {
254 if (!xmlhttp_ready(xmlhttp
)) {
259 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
261 // p_notify("Loading, please wait...");
263 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
264 + param_escape(sort_key
), true);
265 xmlhttp
.onreadystatechange
=userlist_callback
;
270 function addLabel() {
272 if (!xmlhttp_ready(xmlhttp
)) {
277 var form
= document
.forms
['label_edit_form'];
279 var sql_exp
= form
.sql_exp
.value
;
280 var description
= form
.description
.value
;
283 alert(__("Can't create label: missing SQL expression."));
287 if (description
== "") {
288 alert(__("Can't create label: missing caption."));
292 var query
= Form
.serialize("label_edit_form");
294 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
295 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
301 if (!xmlhttp_ready(xmlhttp
)) {
306 var link
= document
.getElementById("fadd_link");
308 if (link
.value
.length
== 0) {
309 alert(__("Error: No feed URL given."));
310 } else if (!isValidURL(link
.value
)) {
311 alert(__("Error: Invalid feed URL."));
313 notify_progress("Adding feed...");
315 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
316 param_escape(link
.value
), true);
317 xmlhttp
.onreadystatechange
=feedlist_callback
;
326 function addFeedCat() {
328 if (!xmlhttp_ready(xmlhttp
)) {
333 var cat
= document
.getElementById("fadd_cat");
335 if (cat
.value
.length
== 0) {
336 alert(__("Can't add category: no name specified."));
338 notify_progress("Adding feed category...");
340 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
341 param_escape(cat
.value
), true);
342 xmlhttp
.onreadystatechange
=infobox_callback
;
352 if (!xmlhttp_ready(xmlhttp
)) {
357 var sqlexp
= document
.getElementById("uadd_box");
359 if (sqlexp
.value
.length
== 0) {
360 alert(__("Can't add user: no login specified."));
362 notify_progress("Adding user...");
364 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
365 param_escape(sqlexp
.value
), true);
367 xmlhttp
.onreadystatechange
=userlist_callback
;
375 function editLabel(id
) {
377 if (!xmlhttp_ready(xmlhttp
)) {
382 notify_progress("Loading, please wait...");
384 document
.getElementById("label_create_btn").disabled
= true;
388 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
389 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
391 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
392 param_escape(id
), true);
393 xmlhttp
.onreadystatechange
=infobox_callback
;
398 function editUser(id
) {
400 if (!xmlhttp_ready(xmlhttp
)) {
405 notify_progress("Loading, please wait...");
407 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
408 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
410 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
411 param_escape(id
), true);
412 xmlhttp
.onreadystatechange
=infobox_callback
;
417 function editFilter(id
) {
419 if (!xmlhttp_ready(xmlhttp
)) {
424 notify_progress("Loading, please wait...");
426 document
.getElementById("create_filter_btn").disabled
= true;
428 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
429 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
431 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
432 xmlhttp
.onreadystatechange
=infobox_callback
;
436 function editFeed(feed
) {
438 // notify("Editing feed...");
440 if (!xmlhttp_ready(xmlhttp
)) {
445 notify_progress("Loading, please wait...");
447 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
450 document
.getElementById("top25_feeds_btn").disabled
= true;
452 // this button is not always available, no-op if not found
455 // clean selection from all rows & select row being edited
456 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
457 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
459 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
460 param_escape(feed
), true);
462 xmlhttp
.onreadystatechange
=infobox_callback
;
467 function editFeedCat(cat
) {
469 if (!xmlhttp_ready(xmlhttp
)) {
474 notify_progress("Loading, please wait...");
476 active_feed_cat
= cat
;
478 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
479 param_escape(cat
), true);
480 xmlhttp
.onreadystatechange
=infobox_callback
;
485 function getSelectedLabels() {
486 return getSelectedTableRowIds("prefLabelList", "LILRR");
489 function getSelectedUsers() {
490 return getSelectedTableRowIds("prefUserList", "UMRR");
493 function getSelectedFeeds() {
494 return getSelectedTableRowIds("prefFeedList", "FEEDR");
497 function getSelectedFilters() {
498 return getSelectedTableRowIds("prefFilterList", "FILRR");
501 function getSelectedFeedCats() {
502 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
505 function getSelectedFeedsFromBrowser() {
507 var list
= document
.getElementById("browseFeedList");
508 if (!list
) list
= document
.getElementById("browseBigFeedList");
510 var selected
= new Array();
512 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
513 var child
= list
.childNodes
[i
];
514 if (child
.id
&& child
.id
.match("FBROW-")) {
515 var id
= child
.id
.replace("FBROW-", "");
517 var cb
= document
.getElementById("FBCHK-" + id
);
528 function removeSelectedLabels() {
530 if (!xmlhttp_ready(xmlhttp
)) {
535 var sel_rows
= getSelectedLabels();
537 if (sel_rows
.length
> 0) {
539 var ok
= confirm(__("Remove selected labels?"));
542 notify_progress("Removing selected labels...");
544 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
545 param_escape(sel_rows
.toString()), true);
546 xmlhttp
.onreadystatechange
=labellist_callback
;
550 alert(__("No labels are selected."));
556 function removeSelectedUsers() {
558 if (!xmlhttp_ready(xmlhttp
)) {
563 var sel_rows
= getSelectedUsers();
565 if (sel_rows
.length
> 0) {
567 var ok
= confirm(__("Remove selected users?"));
570 notify_progress("Removing selected users...");
572 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
573 param_escape(sel_rows
.toString()), true);
574 xmlhttp
.onreadystatechange
=userlist_callback
;
579 alert(__("No users are selected."));
585 function removeSelectedFilters() {
587 if (!xmlhttp_ready(xmlhttp
)) {
592 var sel_rows
= getSelectedFilters();
594 if (sel_rows
.length
> 0) {
596 var ok
= confirm(__("Remove selected filters?"));
599 notify_progress("Removing selected filters...");
601 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
602 param_escape(sel_rows
.toString()), true);
603 xmlhttp
.onreadystatechange
=filterlist_callback
;
607 alert(__("No filters are selected."));
614 function removeSelectedFeeds() {
616 if (!xmlhttp_ready(xmlhttp
)) {
621 var sel_rows
= getSelectedFeeds();
623 if (sel_rows
.length
> 0) {
625 var ok
= confirm(__("Unsubscribe from selected feeds?"));
629 notify_progress("Unsubscribing from selected feeds...");
631 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
632 param_escape(sel_rows
.toString()), true);
633 xmlhttp
.onreadystatechange
=feedlist_callback
;
639 alert(__("No feeds are selected."));
646 function removeSelectedFeedCats() {
648 if (!xmlhttp_ready(xmlhttp
)) {
653 var sel_rows
= getSelectedFeedCats();
655 if (sel_rows
.length
> 0) {
657 var ok
= confirm(__("Remove selected categories?"));
660 notify_progress("Removing selected categories...");
662 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
663 param_escape(sel_rows
.toString()), true);
664 xmlhttp
.onreadystatechange
=infobox_callback
;
670 alert(__("No categories are selected."));
677 function feedEditCancel() {
679 if (!xmlhttp_ready(xmlhttp
)) {
684 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
687 document
.getElementById("top25_feeds_btn").disabled
= false;
689 // this button is not always available, no-op if not found
694 selectPrefRows('feed', false); // cleanup feed selection
699 function feedCatEditCancel() {
701 if (!xmlhttp_ready(xmlhttp
)) {
706 active_feed_cat
= false;
708 // notify("Operation cancelled.");
710 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
711 xmlhttp
.onreadystatechange
=infobox_callback
;
717 function feedEditSave() {
721 if (!xmlhttp_ready(xmlhttp
)) {
726 // FIXME: add parameter validation
728 var query
= Form
.serialize("edit_feed_form");
730 notify_progress("Saving feed...");
732 xmlhttp
.open("POST", "backend.php", true);
733 xmlhttp
.onreadystatechange
=feedlist_callback
;
734 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
742 exception_error("feedEditSave", e
);
746 function feedCatEditSave() {
748 if (!xmlhttp_ready(xmlhttp
)) {
753 notify_progress("Saving category...");
755 var query
= Form
.serialize("feed_cat_edit_form");
757 xmlhttp
.open("GET", "backend.php?" + query
, true);
758 xmlhttp
.onreadystatechange
=infobox_callback
;
761 active_feed_cat
= false;
767 function labelTest() {
769 var container
= document
.getElementById('label_test_result');
770 container
.style
.display
= "block";
771 container
.innerHTML
= "<p>Loading, please wait...</p>";
773 var form
= document
.forms
['label_edit_form'];
775 var sql_exp
= form
.sql_exp
.value
;
776 var description
= form
.description
.value
;
778 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
779 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
781 xmlhttp
.onreadystatechange
=labeltest_callback
;
787 function displayHelpInfobox(topic_id
) {
789 /* if (!xmlhttp_ready(xmlhttp)) {
794 notify_progress("Loading help...");
796 xmlhttp.open("GET", "backend.php?op=help&tid=" +
797 param_escape(topic_id), true);
799 xmlhttp.onreadystatechange=helpbox_callback;
800 xmlhttp.send(null); */
802 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
804 var w
= window
.open(url
, "ttrss_help",
805 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
809 function labelEditCancel() {
811 if (!xmlhttp_ready(xmlhttp
)) {
816 document
.getElementById("label_create_btn").disabled
= false;
818 active_label
= false;
820 selectPrefRows('label', false); // cleanup feed selection
826 function userEditCancel() {
828 if (!xmlhttp_ready(xmlhttp
)) {
833 selectPrefRows('user', false); // cleanup feed selection
839 function filterEditCancel() {
841 if (!xmlhttp_ready(xmlhttp
)) {
846 document
.getElementById("create_filter_btn").disabled
= false;
848 selectPrefRows('filter', false); // cleanup feed selection
854 function labelEditSave() {
856 var label
= active_label
;
858 if (!xmlhttp_ready(xmlhttp
)) {
863 /* if (!is_opera()) {
865 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
866 var description = document.forms["label_edit_form"].description.value;
868 if (sql_exp.length == 0) {
869 alert("SQL Expression cannot be blank.");
873 if (description.length == 0) {
874 alert("Caption field cannot be blank.");
881 notify_progress("Saving label...");
883 active_label
= false;
885 query
= Form
.serialize("label_edit_form");
887 xmlhttp
.open("GET", "backend.php?" + query
, true);
888 xmlhttp
.onreadystatechange
=labellist_callback
;
894 function userEditSave() {
896 if (!xmlhttp_ready(xmlhttp
)) {
901 var login
= document
.forms
["user_edit_form"].login
.value
;
903 if (login
.length
== 0) {
904 alert(__("Login field cannot be blank."));
908 notify_progress("Saving user...");
912 var query
= Form
.serialize("user_edit_form");
914 xmlhttp
.open("GET", "backend.php?" + query
, true);
915 xmlhttp
.onreadystatechange
=userlist_callback
;
922 function filterEditSave() {
924 if (!xmlhttp_ready(xmlhttp
)) {
929 /* if (!is_opera()) {
930 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
932 if (reg_exp.length == 0) {
933 alert("Filter expression field cannot be blank.");
938 notify_progress("Saving filter...");
940 var query
= Form
.serialize("filter_edit_form");
944 document
.getElementById("create_filter_btn").disabled
= false;
946 xmlhttp
.open("GET", "backend.php?" + query
, true);
947 xmlhttp
.onreadystatechange
=filterlist_callback
;
953 function editSelectedLabel() {
954 var rows
= getSelectedLabels();
956 if (rows
.length
== 0) {
957 alert(__("No labels are selected."));
961 if (rows
.length
> 1) {
962 alert(__("Please select only one label."));
972 function editSelectedUser() {
973 var rows
= getSelectedUsers();
975 if (rows
.length
== 0) {
976 alert(__("No users are selected."));
980 if (rows
.length
> 1) {
981 alert(__("Please select only one user."));
990 function resetSelectedUserPass() {
991 var rows
= getSelectedUsers();
993 if (rows
.length
== 0) {
994 alert(__("No users are selected."));
998 if (rows
.length
> 1) {
999 alert(__("Please select only one user."));
1003 var ok
= confirm(__("Reset password of selected user?"));
1006 notify_progress("Resetting password for selected user...");
1010 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1011 param_escape(id
), true);
1012 xmlhttp
.onreadystatechange
=userlist_callback
;
1017 function selectedUserDetails() {
1019 if (!xmlhttp_ready(xmlhttp
)) {
1020 printLockingError();
1024 var rows
= getSelectedUsers();
1026 if (rows
.length
== 0) {
1027 alert(__("No users are selected."));
1031 if (rows
.length
> 1) {
1032 alert(__("Please select only one user."));
1036 notify_progress("Loading, please wait...");
1040 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1041 xmlhttp
.onreadystatechange
=infobox_callback
;
1046 function selectedFeedDetails() {
1048 if (!xmlhttp_ready(xmlhttp
)) {
1049 printLockingError();
1053 var rows
= getSelectedFeeds();
1055 if (rows
.length
== 0) {
1056 alert(__("No feeds are selected."));
1060 if (rows
.length
> 1) {
1061 alert(__("Please select only one feed."));
1065 // var id = rows[0];
1069 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1070 param_escape(rows
.toString()), true);
1071 xmlhttp
.onreadystatechange
=infobox_callback
;
1076 function editSelectedFilter() {
1077 var rows
= getSelectedFilters();
1079 if (rows
.length
== 0) {
1080 alert(__("No filters are selected."));
1084 if (rows
.length
> 1) {
1085 alert(__("Please select only one filter."));
1091 editFilter(rows
[0]);
1096 function editSelectedFeed() {
1097 var rows
= getSelectedFeeds();
1099 if (rows
.length
== 0) {
1100 alert(__("No feeds are selected."));
1104 if (rows
.length
> 1) {
1105 alert(__("Please select one feed."));
1115 function editSelectedFeedCat() {
1116 var rows
= getSelectedFeedCats();
1118 if (rows
.length
== 0) {
1119 alert(__("No categories are selected."));
1123 if (rows
.length
> 1) {
1124 alert(__("Please select only one category."));
1130 editFeedCat(rows
[0]);
1134 function piggie_callback() {
1135 var piggie
= document
.getElementById("piggie");
1137 piggie
.style
.top
= piggie_top
;
1138 piggie
.style
.backgroundColor
= "white";
1139 piggie
.style
.borderWidth
= "1px";
1141 if (piggie_fwd
&& piggie_top
< 0) {
1142 setTimeout("piggie_callback()", 50);
1143 piggie_top
= piggie_top
+ 10;
1144 } else if (piggie_fwd
&& piggie_top
>= 0) {
1146 setTimeout("piggie_callback()", 50);
1147 } else if (!piggie_fwd
&& piggie_top
> -400) {
1148 setTimeout("piggie_callback()", 50);
1149 piggie_top
= piggie_top
- 10;
1150 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1151 piggie
.style
.display
= "none";
1156 var piggie_opacity
= 0;
1158 function piggie2_callback() {
1159 var piggie
= document
.getElementById("piggie");
1160 piggie
.style
.top
= 0;
1161 piggie
.style
.opacity
= piggie_opacity
;
1162 piggie
.style
.backgroundColor
= "transparent";
1163 piggie
.style
.borderWidth
= "0px";
1165 if (piggie_fwd
&& piggie_opacity
< 1) {
1166 setTimeout("piggie2_callback()", 50);
1167 piggie_opacity
= piggie_opacity
+ 0.03;
1168 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1170 setTimeout("piggie2_callback()", 50);
1171 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1172 setTimeout("piggie2_callback()", 50);
1173 piggie_opacity
= piggie_opacity
- 0.03;
1174 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1175 piggie
.style
.display
= "none";
1180 function localPiggieFunction(enable
) {
1182 debug("I LOVEDED IT!");
1183 var piggie
= document
.getElementById("piggie");
1184 piggie
.style
.display
= "block";
1186 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1194 function validateOpmlImport() {
1196 var opml_file
= document
.getElementById("opml_file");
1198 if (opml_file
.value
.length
== 0) {
1199 alert(__("No OPML file to upload."));
1206 function updateFilterList(sort_key
) {
1208 if (!xmlhttp_ready(xmlhttp
)) {
1209 printLockingError();
1213 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1215 // p_notify("Loading, please wait...");
1217 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1218 param_escape(sort_key
), true);
1219 xmlhttp
.onreadystatechange
=filterlist_callback
;
1224 function updateLabelList(sort_key
) {
1226 if (!xmlhttp_ready(xmlhttp
)) {
1227 printLockingError();
1231 // p_notify("Loading, please wait...");
1233 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1235 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1236 param_escape(sort_key
), true);
1237 xmlhttp
.onreadystatechange
=labellist_callback
;
1241 function updatePrefsList() {
1243 if (!xmlhttp_ready(xmlhttp
)) {
1244 printLockingError();
1248 // p_notify("Loading, please wait...");
1250 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1251 xmlhttp
.onreadystatechange
=prefslist_callback
;
1256 function selectTab(id
, noupdate
, subop
) {
1260 if (!id
) id
= active_tab
;
1264 if (!xmlhttp_ready(xmlhttp
)) {
1265 printLockingError();
1270 var c
= document
.getElementById('prefContent');
1276 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1278 notify_progress("Loading, please wait...");
1280 // close active infobox if needed
1283 // clean up all current selections, just in case
1284 active_feed_cat
= false;
1285 active_label
= false;
1287 if (id
== "feedConfig") {
1289 } else if (id
== "filterConfig") {
1291 } else if (id
== "labelConfig") {
1293 } else if (id
== "genConfig") {
1295 } else if (id
== "userConfig") {
1297 } else if (id
== "feedBrowser") {
1298 updateBigFeedBrowser();
1302 var tab
= document
.getElementById(active_tab
+ "Tab");
1305 if (tab
.className
.match("Selected")) {
1306 tab
.className
= "prefsTab";
1310 tab
= document
.getElementById(id
+ "Tab");
1313 if (!tab
.className
.match("Selected")) {
1314 tab
.className
= tab
.className
+ "Selected";
1321 exception_error("selectTab", e
);
1325 function backend_sanity_check_callback() {
1327 if (xmlhttp
.readyState
== 4) {
1331 if (sanity_check_done
) {
1332 fatalError(11, "Sanity check request received twice. This can indicate "+
1333 "presence of Firebug or some other disrupting extension. "+
1334 "Please disable it and try again.");
1338 if (!xmlhttp
.responseXML
) {
1339 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1343 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1346 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1350 var error_code
= reply
.getAttribute("error-code");
1352 if (error_code
&& error_code
!= 0) {
1353 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1356 debug("sanity check ok");
1358 var params
= reply
.nextSibling
;
1361 debug('reading init-params...');
1362 var param
= params
.firstChild
;
1365 var k
= param
.getAttribute("key");
1366 var v
= param
.getAttribute("value");
1367 debug(k
+ " => " + v
);
1369 param
= param
.nextSibling
;
1373 sanity_check_done
= true;
1375 init_second_stage();
1378 exception_error("backend_sanity_check_callback", e
);
1383 function init_second_stage() {
1386 active_tab
= getInitParam("prefs_active_tab");
1387 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1389 document
.onkeydown
= pref_hotkey_handler
;
1391 var tab
= getURLParam('tab');
1393 caller_subop
= getURLParam('subop');
1399 if (navigator
.userAgent
.match("Opera")) {
1400 setTimeout("selectTab()", 500);
1402 selectTab(active_tab
);
1406 exception_error("init_second_stage", e
);
1414 if (arguments
.callee
.done
) return;
1415 arguments
.callee
.done
= true;
1417 if (getURLParam('debug')) {
1418 document
.getElementById('debug_output').style
.display
= 'block';
1419 debug('debug mode activated');
1424 document
.getElementById("prefContent").innerHTML
=
1425 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1426 "to function properly. Your browser doesn't seem to support it.";
1430 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1431 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1435 exception_error("init", e
);
1439 function categorizeSelectedFeeds() {
1441 if (!xmlhttp_ready(xmlhttp
)) {
1442 printLockingError();
1446 var sel_rows
= getSelectedFeeds();
1448 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1449 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1451 if (sel_rows
.length
> 0) {
1453 notify_progress("Changing category of selected feeds...");
1455 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1456 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1457 xmlhttp
.onreadystatechange
=feedlist_callback
;
1462 alert(__("No feeds are selected."));
1468 function validatePrefsReset() {
1469 return confirm(__("Reset to defaults?"));
1472 function browseFeeds(limit
) {
1474 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1475 xmlhttp
.onreadystatechange
=infobox_callback
;
1480 function feedBrowserSubscribe() {
1483 var selected
= getSelectedFeedsFromBrowser();
1485 if (selected
.length
> 0) {
1487 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1488 param_escape(selected
.toString()), true);
1489 xmlhttp
.onreadystatechange
=feedlist_callback
;
1492 alert(__("No feeds are selected."));
1496 exception_error("feedBrowserSubscribe", e
);
1500 function updateBigFeedBrowser(limit
) {
1502 if (!xmlhttp_ready(xmlhttp
)) {
1503 printLockingError();
1507 // p_notify("Loading, please wait...");
1509 var query
= "backend.php?op=pref-feed-browser";
1511 var limit_sel
= document
.getElementById("feedBrowserLimit");
1514 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1515 query
= query
+ "&limit=" + param_escape(limit
);
1518 xmlhttp
.open("GET", query
, true);
1519 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1523 function browserToggleExpand(id
) {
1525 /* if (feed_to_expand && feed_to_expand != id) {
1526 var d = document.getElementById("BRDET-" + feed_to_expand);
1527 d.style.display = "none";
1530 if (!xmlhttp_ready(xmlhttp
)) {
1531 printLockingError();
1535 /* if (feed_to_expand && id != feed_to_expand) {
1536 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1539 var d
= document
.getElementById("BRDET-" + id
);
1541 if (Element
.visible(d
)) {
1542 Effect
.Fade(d
, {duration
: 0.5});
1544 feed_to_expand
= id
;
1546 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1547 + param_escape(id
), true);
1548 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1553 exception_error("browserToggleExpand", e
);
1557 function selectPrefRows(kind
, select
) {
1560 var opbarid
= false;
1565 if (kind
== "feed") {
1566 opbarid
= "feedOpToolbar";
1569 lname
= "prefFeedList";
1570 } else if (kind
== "fcat") {
1571 opbarid
= "catOpToolbar";
1574 lname
= "prefFeedCatList";
1575 } else if (kind
== "filter") {
1576 opbarid
= "filterOpToolbar";
1579 lname
= "prefFilterList";
1580 } else if (kind
== "label") {
1581 opbarid
= "labelOpToolbar";
1584 lname
= "prefLabelList";
1585 } else if (kind
== "user") {
1586 opbarid
= "userOpToolbar";
1589 lname
= "prefUserList";
1593 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1594 disableContainerChildren(opbarid
, !select
);
1601 function toggleSelectPrefRow(sender
, kind
) {
1603 toggleSelectRow(sender
);
1606 var opbarid
= false;
1609 if (kind
== "feed") {
1610 opbarid
= "feedOpToolbar";
1611 nsel
= getSelectedFeeds();
1612 } else if (kind
== "fcat") {
1613 opbarid
= "catOpToolbar";
1614 nsel
= getSelectedFeedCats();
1615 } else if (kind
== "filter") {
1616 opbarid
= "filterOpToolbar";
1617 nsel
= getSelectedFilters();
1618 } else if (kind
== "label") {
1619 opbarid
= "labelOpToolbar";
1620 nsel
= getSelectedLabels();
1621 } else if (kind
== "user") {
1622 opbarid
= "userOpToolbar";
1623 nsel
= getSelectedUsers();
1626 if (opbarid
&& nsel
!= -1) {
1627 disableContainerChildren(opbarid
, nsel
== false);
1633 function toggleSelectFBListRow(sender
) {
1634 toggleSelectListRow(sender
);
1635 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1640 function pref_hotkey_handler(e
) {
1645 if (!hotkeys_enabled
) return;
1648 keycode
= window
.event
.keyCode
;
1653 if (keycode
== 13 || keycode
== 27) {
1656 seq
= seq
+ "" + keycode
;
1660 if (document
.getElementById("piggie")) {
1662 if (seq
.match("807371717369")) {
1664 localPiggieFunction(true);
1666 localPiggieFunction(false);
1671 exception_error("pref_hotkey_handler", e
);
1675 function userSwitch() {
1676 var chooser
= document
.getElementById("userSwitch");
1677 var user
= chooser
[chooser
.selectedIndex
].value
;
1678 window
.location
= "prefs.php?swu=" + user
;
1681 function editFeedCats() {
1682 if (!xmlhttp_ready(xmlhttp
)) {
1683 printLockingError();
1687 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1690 document
.getElementById("top25_feeds_btn").disabled
= true;
1692 // this button is not always available, no-op if not found
1695 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1696 xmlhttp
.onreadystatechange
=infobox_callback
;
1700 function showFeedsWithErrors() {
1701 displayDlg('feedUpdateErrors');
1704 function changeUserPassword() {
1708 if (!xmlhttp_ready(xmlhttp
)) {
1709 printLockingError();
1713 var query
= Form
.serialize("change_pass_form");
1715 notify_progress("Trying to change password...");
1717 xmlhttp
.open("POST", "backend.php", true);
1718 xmlhttp
.onreadystatechange
=changepass_callback
;
1719 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1720 xmlhttp
.send(query
);
1723 exception_error("changeUserPassword", e
);
1729 function changeUserEmail() {
1733 if (!xmlhttp_ready(xmlhttp
)) {
1734 printLockingError();
1738 var query
= Form
.serialize("change_email_form");
1740 notify_progress("Trying to change e-mail...");
1742 xmlhttp
.open("POST", "backend.php", true);
1743 xmlhttp
.onreadystatechange
=notify_callback
;
1744 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1745 xmlhttp
.send(query
);
1748 exception_error("changeUserPassword", e
);
1755 function feedlistToggleSLAT() {
1756 notify_progress("Loading, please wait...");
1760 function pubRegenKey() {
1762 if (!xmlhttp_ready(xmlhttp
)) {
1763 printLockingError();
1767 var ok
= confirm(__("Replace current publishing address with a new one?"));
1771 notify_progress("Trying to change address...");
1773 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1774 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;