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";
54 exception_error("expand_feed_callback", e
);
59 function feedlist_callback() {
60 if (xmlhttp
.readyState
== 4) {
62 var container
= document
.getElementById('prefContent');
63 container
.innerHTML
=xmlhttp
.responseText
;
64 selectTab("feedConfig", true);
67 var tuple
= caller_subop
.split(":");
68 if (tuple
[0] == 'editFeed') {
69 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
74 if (typeof correctPNG
!= 'undefined') {
79 exception_error("feedlist_callback", e
);
84 /* stub for subscription dialog */
86 function dlg_frefresh_callback() {
87 if (xmlhttp
.readyState
== 4) {
88 // setTimeout("updateFeedList()", 500);
91 var container
= document
.getElementById('prefContent');
92 container
.innerHTML
=xmlhttp
.responseText
;
93 selectTab("feedConfig", true);
96 var tuple
= caller_subop
.split(":");
97 if (tuple
[0] == 'editFeed') {
98 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
101 caller_subop
= false;
103 if (typeof correctPNG
!= 'undefined') {
108 exception_error("feedlist_callback", e
);
113 function filterlist_callback() {
114 var container
= document
.getElementById('prefContent');
115 if (xmlhttp
.readyState
== 4) {
116 container
.innerHTML
=xmlhttp
.responseText
;
117 if (typeof correctPNG
!= 'undefined') {
124 function labellist_callback() {
125 var container
= document
.getElementById('prefContent');
126 if (xmlhttp
.readyState
== 4) {
128 container
.innerHTML
=xmlhttp
.responseText
;
130 var row
= document
.getElementById("LILRR-" + active_label
);
132 if (!row
.className
.match("Selected")) {
133 row
.className
= row
.className
+ "Selected";
136 var checkbox
= document
.getElementById("LICHK-" + active_label
);
139 checkbox
.checked
= true;
142 if (typeof correctPNG
!= 'undefined') {
149 function labeltest_callback() {
150 var container
= document
.getElementById('label_test_result');
151 if (xmlhttp
.readyState
== 4) {
152 container
.innerHTML
=xmlhttp
.responseText
;
157 function feed_browser_callback() {
158 var container
= document
.getElementById('prefContent');
159 if (xmlhttp
.readyState
== 4) {
160 container
.innerHTML
=xmlhttp
.responseText
;
165 function userlist_callback() {
166 var container
= document
.getElementById('prefContent');
167 if (xmlhttp
.readyState
== 4) {
168 container
.innerHTML
=xmlhttp
.responseText
;
173 function prefslist_callback() {
174 var container
= document
.getElementById('prefContent');
175 if (xmlhttp
.readyState
== 4) {
177 container
.innerHTML
=xmlhttp
.responseText
;
183 function gethelp_callback() {
184 var container
= document
.getElementById('prefHelpBox');
185 if (xmlhttp
.readyState
== 4) {
187 container
.innerHTML
= xmlhttp
.responseText
;
188 container
.style
.display
= "block";
193 function notify_callback() {
194 if (xmlhttp
.readyState
== 4) {
195 notify_info(xmlhttp
.responseText
);
200 function changepass_callback() {
202 if (xmlhttp
.readyState
== 4) {
204 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
205 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
207 notify_info(xmlhttp
.responseText
);
208 var warn
= document
.getElementById("default_pass_warning");
209 if (warn
) warn
.style
.display
= "none";
212 document
.forms
['change_pass_form'].reset();
216 exception_error("changepass_callback", e
);
220 function updateFeedList(sort_key
) {
222 if (!xmlhttp_ready(xmlhttp
)) {
227 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
229 // p_notify("Loading, please wait...");
231 var feed_search
= document
.getElementById("feed_search");
233 if (feed_search
) { search
= feed_search
.value
; }
235 var slat
= document
.getElementById("show_last_article_times");
237 var slat_checked
= false;
239 slat_checked
= slat
.checked
;
242 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
243 "&sort=" + param_escape(sort_key
) +
244 "&slat=" + param_escape(slat_checked
) +
245 "&search=" + param_escape(search
), true);
246 xmlhttp
.onreadystatechange
=feedlist_callback
;
251 function updateUsersList(sort_key
) {
253 if (!xmlhttp_ready(xmlhttp
)) {
258 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
260 // p_notify("Loading, please wait...");
262 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
263 + param_escape(sort_key
), true);
264 xmlhttp
.onreadystatechange
=userlist_callback
;
269 function addLabel() {
271 if (!xmlhttp_ready(xmlhttp
)) {
276 var form
= document
.forms
['label_edit_form'];
278 var sql_exp
= form
.sql_exp
.value
;
279 var description
= form
.description
.value
;
282 alert(__("Can't create label: missing SQL expression."));
286 if (description
== "") {
287 alert(__("Can't create label: missing caption."));
291 var query
= Form
.serialize("label_edit_form");
293 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
294 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
300 if (!xmlhttp_ready(xmlhttp
)) {
305 var link
= document
.getElementById("fadd_link");
307 if (link
.value
.length
== 0) {
308 alert(__("Error: No feed URL given."));
309 } else if (!isValidURL(link
.value
)) {
310 alert(__("Error: Invalid feed URL."));
312 notify_progress("Adding feed...");
314 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
315 param_escape(link
.value
), true);
316 xmlhttp
.onreadystatechange
=feedlist_callback
;
325 function addFeedCat() {
327 if (!xmlhttp_ready(xmlhttp
)) {
332 var cat
= document
.getElementById("fadd_cat");
334 if (cat
.value
.length
== 0) {
335 alert(__("Can't add category: no name specified."));
337 notify_progress("Adding feed category...");
339 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
340 param_escape(cat
.value
), true);
341 xmlhttp
.onreadystatechange
=infobox_callback
;
351 if (!xmlhttp_ready(xmlhttp
)) {
356 var sqlexp
= document
.getElementById("uadd_box");
358 if (sqlexp
.value
.length
== 0) {
359 alert(__("Can't add user: no login specified."));
361 notify_progress("Adding user...");
363 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
364 param_escape(sqlexp
.value
), true);
366 xmlhttp
.onreadystatechange
=userlist_callback
;
374 function editLabel(id
) {
376 if (!xmlhttp_ready(xmlhttp
)) {
381 notify_progress("Loading, please wait...");
383 document
.getElementById("label_create_btn").disabled
= true;
387 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
388 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
390 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
391 param_escape(id
), true);
392 xmlhttp
.onreadystatechange
=infobox_callback
;
397 function editUser(id
) {
399 if (!xmlhttp_ready(xmlhttp
)) {
404 notify_progress("Loading, please wait...");
406 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
407 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
409 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
410 param_escape(id
), true);
411 xmlhttp
.onreadystatechange
=infobox_callback
;
416 function editFilter(id
) {
418 if (!xmlhttp_ready(xmlhttp
)) {
423 notify_progress("Loading, please wait...");
425 document
.getElementById("create_filter_btn").disabled
= true;
427 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
428 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
430 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
431 xmlhttp
.onreadystatechange
=infobox_callback
;
435 function editFeed(feed
) {
437 // notify("Editing feed...");
439 if (!xmlhttp_ready(xmlhttp
)) {
444 notify_progress("Loading, please wait...");
446 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
449 document
.getElementById("top25_feeds_btn").disabled
= true;
451 // this button is not always available, no-op if not found
454 // clean selection from all rows & select row being edited
455 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
456 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
458 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
459 param_escape(feed
), true);
461 xmlhttp
.onreadystatechange
=infobox_callback
;
466 function editFeedCat(cat
) {
468 if (!xmlhttp_ready(xmlhttp
)) {
473 notify_progress("Loading, please wait...");
475 active_feed_cat
= cat
;
477 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
478 param_escape(cat
), true);
479 xmlhttp
.onreadystatechange
=infobox_callback
;
484 function getSelectedLabels() {
485 return getSelectedTableRowIds("prefLabelList", "LILRR");
488 function getSelectedUsers() {
489 return getSelectedTableRowIds("prefUserList", "UMRR");
492 function getSelectedFeeds() {
493 return getSelectedTableRowIds("prefFeedList", "FEEDR");
496 function getSelectedFilters() {
497 return getSelectedTableRowIds("prefFilterList", "FILRR");
500 function getSelectedFeedCats() {
501 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
504 function getSelectedFeedsFromBrowser() {
506 var list
= document
.getElementById("browseFeedList");
507 if (!list
) list
= document
.getElementById("browseBigFeedList");
509 var selected
= new Array();
511 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
512 var child
= list
.childNodes
[i
];
513 if (child
.id
&& child
.id
.match("FBROW-")) {
514 var id
= child
.id
.replace("FBROW-", "");
516 var cb
= document
.getElementById("FBCHK-" + id
);
527 function removeSelectedLabels() {
529 if (!xmlhttp_ready(xmlhttp
)) {
534 var sel_rows
= getSelectedLabels();
536 if (sel_rows
.length
> 0) {
538 var ok
= confirm(__("Remove selected labels?"));
541 notify_progress("Removing selected labels...");
543 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
544 param_escape(sel_rows
.toString()), true);
545 xmlhttp
.onreadystatechange
=labellist_callback
;
549 alert(__("No labels are selected."));
555 function removeSelectedUsers() {
557 if (!xmlhttp_ready(xmlhttp
)) {
562 var sel_rows
= getSelectedUsers();
564 if (sel_rows
.length
> 0) {
566 var ok
= confirm(__("Remove selected users?"));
569 notify_progress("Removing selected users...");
571 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
572 param_escape(sel_rows
.toString()), true);
573 xmlhttp
.onreadystatechange
=userlist_callback
;
578 alert(__("No users are selected."));
584 function removeSelectedFilters() {
586 if (!xmlhttp_ready(xmlhttp
)) {
591 var sel_rows
= getSelectedFilters();
593 if (sel_rows
.length
> 0) {
595 var ok
= confirm(__("Remove selected filters?"));
598 notify_progress("Removing selected filters...");
600 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
601 param_escape(sel_rows
.toString()), true);
602 xmlhttp
.onreadystatechange
=filterlist_callback
;
606 alert(__("No filters are selected."));
613 function removeSelectedFeeds() {
615 if (!xmlhttp_ready(xmlhttp
)) {
620 var sel_rows
= getSelectedFeeds();
622 if (sel_rows
.length
> 0) {
624 var ok
= confirm(__("Unsubscribe from selected feeds?"));
628 notify_progress("Unsubscribing from selected feeds...");
630 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
631 param_escape(sel_rows
.toString()), true);
632 xmlhttp
.onreadystatechange
=feedlist_callback
;
638 alert(__("No feeds are selected."));
645 function removeSelectedFeedCats() {
647 if (!xmlhttp_ready(xmlhttp
)) {
652 var sel_rows
= getSelectedFeedCats();
654 if (sel_rows
.length
> 0) {
656 var ok
= confirm(__("Remove selected categories?"));
659 notify_progress("Removing selected categories...");
661 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
662 param_escape(sel_rows
.toString()), true);
663 xmlhttp
.onreadystatechange
=infobox_callback
;
669 alert(__("No categories are selected."));
676 function feedEditCancel() {
678 if (!xmlhttp_ready(xmlhttp
)) {
683 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
686 document
.getElementById("top25_feeds_btn").disabled
= false;
688 // this button is not always available, no-op if not found
693 selectPrefRows('feed', false); // cleanup feed selection
698 function feedCatEditCancel() {
700 if (!xmlhttp_ready(xmlhttp
)) {
705 active_feed_cat
= false;
707 // notify("Operation cancelled.");
709 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
710 xmlhttp
.onreadystatechange
=infobox_callback
;
716 function feedEditSave() {
720 if (!xmlhttp_ready(xmlhttp
)) {
725 // FIXME: add parameter validation
727 var query
= Form
.serialize("edit_feed_form");
729 notify_progress("Saving feed...");
731 xmlhttp
.open("POST", "backend.php", true);
732 xmlhttp
.onreadystatechange
=feedlist_callback
;
733 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
741 exception_error("feedEditSave", e
);
745 function feedCatEditSave() {
747 if (!xmlhttp_ready(xmlhttp
)) {
752 notify_progress("Saving category...");
754 var query
= Form
.serialize("feed_cat_edit_form");
756 xmlhttp
.open("GET", "backend.php?" + query
, true);
757 xmlhttp
.onreadystatechange
=infobox_callback
;
760 active_feed_cat
= false;
766 function labelTest() {
768 var container
= document
.getElementById('label_test_result');
769 container
.style
.display
= "block";
770 container
.innerHTML
= "<p>Loading, please wait...</p>";
772 var form
= document
.forms
['label_edit_form'];
774 var sql_exp
= form
.sql_exp
.value
;
775 var description
= form
.description
.value
;
777 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
778 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
780 xmlhttp
.onreadystatechange
=labeltest_callback
;
786 function displayHelpInfobox(topic_id
) {
788 /* if (!xmlhttp_ready(xmlhttp)) {
793 notify_progress("Loading help...");
795 xmlhttp.open("GET", "backend.php?op=help&tid=" +
796 param_escape(topic_id), true);
798 xmlhttp.onreadystatechange=helpbox_callback;
799 xmlhttp.send(null); */
801 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
803 var w
= window
.open(url
, "ttrss_help",
804 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
808 function labelEditCancel() {
810 if (!xmlhttp_ready(xmlhttp
)) {
815 document
.getElementById("label_create_btn").disabled
= false;
817 active_label
= false;
819 selectPrefRows('label', false); // cleanup feed selection
825 function userEditCancel() {
827 if (!xmlhttp_ready(xmlhttp
)) {
832 selectPrefRows('user', false); // cleanup feed selection
838 function filterEditCancel() {
840 if (!xmlhttp_ready(xmlhttp
)) {
845 document
.getElementById("create_filter_btn").disabled
= false;
847 selectPrefRows('filter', false); // cleanup feed selection
853 function labelEditSave() {
855 var label
= active_label
;
857 if (!xmlhttp_ready(xmlhttp
)) {
862 /* if (!is_opera()) {
864 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
865 var description = document.forms["label_edit_form"].description.value;
867 if (sql_exp.length == 0) {
868 alert("SQL Expression cannot be blank.");
872 if (description.length == 0) {
873 alert("Caption field cannot be blank.");
880 notify_progress("Saving label...");
882 active_label
= false;
884 query
= Form
.serialize("label_edit_form");
886 xmlhttp
.open("GET", "backend.php?" + query
, true);
887 xmlhttp
.onreadystatechange
=labellist_callback
;
893 function userEditSave() {
895 if (!xmlhttp_ready(xmlhttp
)) {
900 var login
= document
.forms
["user_edit_form"].login
.value
;
902 if (login
.length
== 0) {
903 alert(__("Login field cannot be blank."));
907 notify_progress("Saving user...");
911 var query
= Form
.serialize("user_edit_form");
913 xmlhttp
.open("GET", "backend.php?" + query
, true);
914 xmlhttp
.onreadystatechange
=userlist_callback
;
921 function filterEditSave() {
923 if (!xmlhttp_ready(xmlhttp
)) {
928 /* if (!is_opera()) {
929 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
931 if (reg_exp.length == 0) {
932 alert("Filter expression field cannot be blank.");
937 notify_progress("Saving filter...");
939 var query
= Form
.serialize("filter_edit_form");
943 document
.getElementById("create_filter_btn").disabled
= false;
945 xmlhttp
.open("GET", "backend.php?" + query
, true);
946 xmlhttp
.onreadystatechange
=filterlist_callback
;
952 function editSelectedLabel() {
953 var rows
= getSelectedLabels();
955 if (rows
.length
== 0) {
956 alert(__("No labels are selected."));
960 if (rows
.length
> 1) {
961 alert(__("Please select only one label."));
971 function editSelectedUser() {
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."));
989 function resetSelectedUserPass() {
990 var rows
= getSelectedUsers();
992 if (rows
.length
== 0) {
993 alert(__("No users are selected."));
997 if (rows
.length
> 1) {
998 alert(__("Please select only one user."));
1002 var ok
= confirm(__("Reset password of selected user?"));
1005 notify_progress("Resetting password for selected user...");
1009 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1010 param_escape(id
), true);
1011 xmlhttp
.onreadystatechange
=userlist_callback
;
1016 function selectedUserDetails() {
1018 if (!xmlhttp_ready(xmlhttp
)) {
1019 printLockingError();
1023 var rows
= getSelectedUsers();
1025 if (rows
.length
== 0) {
1026 alert(__("No users are selected."));
1030 if (rows
.length
> 1) {
1031 alert(__("Please select only one user."));
1035 notify_progress("Loading, please wait...");
1039 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1040 xmlhttp
.onreadystatechange
=infobox_callback
;
1045 function selectedFeedDetails() {
1047 if (!xmlhttp_ready(xmlhttp
)) {
1048 printLockingError();
1052 var rows
= getSelectedFeeds();
1054 if (rows
.length
== 0) {
1055 alert(__("No feeds are selected."));
1059 if (rows
.length
> 1) {
1060 alert(__("Please select only one feed."));
1064 // var id = rows[0];
1068 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1069 param_escape(rows
.toString()), true);
1070 xmlhttp
.onreadystatechange
=infobox_callback
;
1075 function editSelectedFilter() {
1076 var rows
= getSelectedFilters();
1078 if (rows
.length
== 0) {
1079 alert(__("No filters are selected."));
1083 if (rows
.length
> 1) {
1084 alert(__("Please select only one filter."));
1090 editFilter(rows
[0]);
1095 function editSelectedFeed() {
1096 var rows
= getSelectedFeeds();
1098 if (rows
.length
== 0) {
1099 alert(__("No feeds are selected."));
1103 if (rows
.length
> 1) {
1104 alert(__("Please select one feed."));
1114 function editSelectedFeedCat() {
1115 var rows
= getSelectedFeedCats();
1117 if (rows
.length
== 0) {
1118 alert(__("No categories are selected."));
1122 if (rows
.length
> 1) {
1123 alert(__("Please select only one category."));
1129 editFeedCat(rows
[0]);
1133 function piggie_callback() {
1134 var piggie
= document
.getElementById("piggie");
1136 piggie
.style
.top
= piggie_top
;
1137 piggie
.style
.backgroundColor
= "white";
1138 piggie
.style
.borderWidth
= "1px";
1140 if (piggie_fwd
&& piggie_top
< 0) {
1141 setTimeout("piggie_callback()", 50);
1142 piggie_top
= piggie_top
+ 10;
1143 } else if (piggie_fwd
&& piggie_top
>= 0) {
1145 setTimeout("piggie_callback()", 50);
1146 } else if (!piggie_fwd
&& piggie_top
> -400) {
1147 setTimeout("piggie_callback()", 50);
1148 piggie_top
= piggie_top
- 10;
1149 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1150 piggie
.style
.display
= "none";
1155 var piggie_opacity
= 0;
1157 function piggie2_callback() {
1158 var piggie
= document
.getElementById("piggie");
1159 piggie
.style
.top
= 0;
1160 piggie
.style
.opacity
= piggie_opacity
;
1161 piggie
.style
.backgroundColor
= "transparent";
1162 piggie
.style
.borderWidth
= "0px";
1164 if (piggie_fwd
&& piggie_opacity
< 1) {
1165 setTimeout("piggie2_callback()", 50);
1166 piggie_opacity
= piggie_opacity
+ 0.03;
1167 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1169 setTimeout("piggie2_callback()", 50);
1170 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1171 setTimeout("piggie2_callback()", 50);
1172 piggie_opacity
= piggie_opacity
- 0.03;
1173 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1174 piggie
.style
.display
= "none";
1179 function localPiggieFunction(enable
) {
1181 debug("I LOVEDED IT!");
1182 var piggie
= document
.getElementById("piggie");
1183 piggie
.style
.display
= "block";
1185 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1193 function validateOpmlImport() {
1195 var opml_file
= document
.getElementById("opml_file");
1197 if (opml_file
.value
.length
== 0) {
1198 alert(__("No OPML file to upload."));
1205 function updateFilterList(sort_key
) {
1207 if (!xmlhttp_ready(xmlhttp
)) {
1208 printLockingError();
1212 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1214 // p_notify("Loading, please wait...");
1216 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1217 param_escape(sort_key
), true);
1218 xmlhttp
.onreadystatechange
=filterlist_callback
;
1223 function updateLabelList(sort_key
) {
1225 if (!xmlhttp_ready(xmlhttp
)) {
1226 printLockingError();
1230 // p_notify("Loading, please wait...");
1232 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1234 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1235 param_escape(sort_key
), true);
1236 xmlhttp
.onreadystatechange
=labellist_callback
;
1240 function updatePrefsList() {
1242 if (!xmlhttp_ready(xmlhttp
)) {
1243 printLockingError();
1247 // p_notify("Loading, please wait...");
1249 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1250 xmlhttp
.onreadystatechange
=prefslist_callback
;
1255 function selectTab(id
, noupdate
, subop
) {
1259 if (!id
) id
= active_tab
;
1263 if (!xmlhttp_ready(xmlhttp
)) {
1264 printLockingError();
1269 var c
= document
.getElementById('prefContent');
1275 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1277 notify_progress("Loading, please wait...");
1279 // close active infobox if needed
1282 // clean up all current selections, just in case
1283 active_feed_cat
= false;
1284 active_label
= false;
1286 if (id
== "feedConfig") {
1288 } else if (id
== "filterConfig") {
1290 } else if (id
== "labelConfig") {
1292 } else if (id
== "genConfig") {
1294 } else if (id
== "userConfig") {
1296 } else if (id
== "feedBrowser") {
1297 updateBigFeedBrowser();
1301 var tab
= document
.getElementById(active_tab
+ "Tab");
1304 if (tab
.className
.match("Selected")) {
1305 tab
.className
= "prefsTab";
1309 tab
= document
.getElementById(id
+ "Tab");
1312 if (!tab
.className
.match("Selected")) {
1313 tab
.className
= tab
.className
+ "Selected";
1320 exception_error("selectTab", e
);
1324 function backend_sanity_check_callback() {
1326 if (xmlhttp
.readyState
== 4) {
1330 if (sanity_check_done
) {
1331 fatalError(11, "Sanity check request received twice. This can indicate "+
1332 "presence of Firebug or some other disrupting extension. "+
1333 "Please disable it and try again.");
1337 if (!xmlhttp
.responseXML
) {
1338 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1342 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1345 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1349 var error_code
= reply
.getAttribute("error-code");
1351 if (error_code
&& error_code
!= 0) {
1352 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1355 debug("sanity check ok");
1357 var params
= reply
.nextSibling
;
1360 debug('reading init-params...');
1361 var param
= params
.firstChild
;
1364 var k
= param
.getAttribute("key");
1365 var v
= param
.getAttribute("value");
1366 debug(k
+ " => " + v
);
1368 param
= param
.nextSibling
;
1372 sanity_check_done
= true;
1374 init_second_stage();
1377 exception_error("backend_sanity_check_callback", e
);
1382 function init_second_stage() {
1385 active_tab
= getInitParam("prefs_active_tab");
1386 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1388 document
.onkeydown
= pref_hotkey_handler
;
1390 var tab
= getURLParam('tab');
1392 caller_subop
= getURLParam('subop');
1398 if (navigator
.userAgent
.match("Opera")) {
1399 setTimeout("selectTab()", 500);
1401 selectTab(active_tab
);
1405 exception_error("init_second_stage", e
);
1413 if (arguments
.callee
.done
) return;
1414 arguments
.callee
.done
= true;
1416 if (getURLParam('debug')) {
1417 document
.getElementById('debug_output').style
.display
= 'block';
1418 debug('debug mode activated');
1423 document
.getElementById("prefContent").innerHTML
=
1424 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1425 "to function properly. Your browser doesn't seem to support it.";
1429 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1430 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1434 exception_error("init", e
);
1438 function categorizeSelectedFeeds() {
1440 if (!xmlhttp_ready(xmlhttp
)) {
1441 printLockingError();
1445 var sel_rows
= getSelectedFeeds();
1447 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1448 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1450 if (sel_rows
.length
> 0) {
1452 notify_progress("Changing category of selected feeds...");
1454 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1455 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1456 xmlhttp
.onreadystatechange
=feedlist_callback
;
1461 alert(__("No feeds are selected."));
1467 function validatePrefsReset() {
1468 return confirm(__("Reset to defaults?"));
1471 function browseFeeds(limit
) {
1473 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1474 xmlhttp
.onreadystatechange
=infobox_callback
;
1479 function feedBrowserSubscribe() {
1482 var selected
= getSelectedFeedsFromBrowser();
1484 if (selected
.length
> 0) {
1486 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1487 param_escape(selected
.toString()), true);
1488 xmlhttp
.onreadystatechange
=feedlist_callback
;
1491 alert(__("No feeds are selected."));
1495 exception_error("feedBrowserSubscribe", e
);
1499 function updateBigFeedBrowser(limit
) {
1501 if (!xmlhttp_ready(xmlhttp
)) {
1502 printLockingError();
1506 // p_notify("Loading, please wait...");
1508 var query
= "backend.php?op=pref-feed-browser";
1510 var limit_sel
= document
.getElementById("feedBrowserLimit");
1513 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1514 query
= query
+ "&limit=" + param_escape(limit
);
1517 xmlhttp
.open("GET", query
, true);
1518 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1522 function browserToggleExpand(id
) {
1524 /* if (feed_to_expand && feed_to_expand != id) {
1525 var d = document.getElementById("BRDET-" + feed_to_expand);
1526 d.style.display = "none";
1529 if (!xmlhttp_ready(xmlhttp
)) {
1530 printLockingError();
1534 var d
= document
.getElementById("BRDET-" + id
);
1536 if (d
.style
.display
== "block") {
1537 d
.style
.display
= "none";
1541 feed_to_expand
= id
;
1543 d
.style
.display
= "block";
1544 d
.innerHTML
= "Loading, please wait...";
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("browserExpand", 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
;