3 var active_feed_cat
= false;
4 var active_label
= false;
5 var active_tab
= false;
6 var feed_to_expand
= false;
8 var xmlhttp
= Ajax
.getTransport();
10 var init_params
= new Array();
12 var caller_subop
= false;
14 var sanity_check_done
= false;
16 function infobox_callback() {
17 if (xmlhttp
.readyState
== 4) {
18 infobox_callback2(xmlhttp
);
22 function infobox_submit_callback() {
23 if (xmlhttp
.readyState
== 4) {
24 infobox_submit_callback2(xmlhttp
);
29 function replace_pubkey_callback() {
30 if (xmlhttp
.readyState
== 4) {
32 var link
= document
.getElementById("pubGenAddress");
34 if (xmlhttp
.responseXML
) {
36 var new_link
= xmlhttp
.responseXML
.getElementsByTagName("link")[0];
39 link
.href
= new_link
.firstChild
.nodeValue
;
40 link
.innerHTML
= new_link
.firstChild
.nodeValue
;
42 new Effect
.Highlight(link
);
44 notify_info("Address changed.");
46 notify_error("Could not change address.");
50 notify_error("Could not change address.");
53 exception_error("replace_pubkey_callback", e
);
58 function expand_feed_callback() {
59 if (xmlhttp
.readyState
== 4) {
61 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
62 container
.innerHTML
=xmlhttp
.responseText
;
63 // container.style.display = "block";
64 Effect
.Appear(container
, {duration
: 0.5});
66 exception_error("expand_feed_callback", e
);
71 function feedlist_callback() {
72 if (xmlhttp
.readyState
== 4) {
74 var container
= document
.getElementById('prefContent');
75 container
.innerHTML
=xmlhttp
.responseText
;
76 selectTab("feedConfig", true);
79 var tuple
= caller_subop
.split(":");
80 if (tuple
[0] == 'editFeed') {
81 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
86 if (typeof correctPNG
!= 'undefined') {
91 exception_error("feedlist_callback", e
);
96 /* stub for subscription dialog */
98 function dlg_frefresh_callback(transport
) {
101 var container
= document
.getElementById('prefContent');
102 container
.innerHTML
=transport
.responseText
;
103 selectTab("feedConfig", true);
106 var tuple
= caller_subop
.split(":");
107 if (tuple
[0] == 'editFeed') {
108 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
111 caller_subop
= false;
113 if (typeof correctPNG
!= 'undefined') {
118 exception_error("feedlist_callback", e
);
123 function filterlist_callback() {
124 var container
= document
.getElementById('prefContent');
125 if (xmlhttp
.readyState
== 4) {
126 container
.innerHTML
=xmlhttp
.responseText
;
127 if (typeof correctPNG
!= 'undefined') {
134 function labellist_callback() {
135 var container
= document
.getElementById('prefContent');
136 if (xmlhttp
.readyState
== 4) {
138 container
.innerHTML
=xmlhttp
.responseText
;
140 var row
= document
.getElementById("LILRR-" + active_label
);
142 if (!row
.className
.match("Selected")) {
143 row
.className
= row
.className
+ "Selected";
146 var checkbox
= document
.getElementById("LICHK-" + active_label
);
149 checkbox
.checked
= true;
152 if (typeof correctPNG
!= 'undefined') {
159 function feed_browser_callback() {
160 var container
= document
.getElementById('prefContent');
161 if (xmlhttp
.readyState
== 4) {
162 container
.innerHTML
=xmlhttp
.responseText
;
167 function userlist_callback() {
168 var container
= document
.getElementById('prefContent');
169 if (xmlhttp
.readyState
== 4) {
170 container
.innerHTML
=xmlhttp
.responseText
;
175 function prefslist_callback() {
176 var container
= document
.getElementById('prefContent');
177 if (xmlhttp
.readyState
== 4) {
179 container
.innerHTML
=xmlhttp
.responseText
;
185 function gethelp_callback() {
186 var container
= document
.getElementById('prefHelpBox');
187 if (xmlhttp
.readyState
== 4) {
189 container
.innerHTML
= xmlhttp
.responseText
;
190 container
.style
.display
= "block";
195 function notify_callback() {
196 if (xmlhttp
.readyState
== 4) {
197 notify_info(xmlhttp
.responseText
);
201 function prefs_reset_callback() {
202 if (xmlhttp
.readyState
== 4) {
203 notify_info(xmlhttp
.responseText
);
209 function changepass_callback() {
211 if (xmlhttp
.readyState
== 4) {
213 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
214 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
216 notify_info(xmlhttp
.responseText
);
217 var warn
= document
.getElementById("default_pass_warning");
218 if (warn
) warn
.style
.display
= "none";
221 document
.forms
['change_pass_form'].reset();
225 exception_error("changepass_callback", e
);
229 function infobox_feed_cat_callback() {
230 if (xmlhttp
.readyState
== 4) {
235 if (document
.getElementById("prefFeedCatList")) {
236 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
238 for (var i
= 0; i
< elems
.length
; i
++) {
239 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
240 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
242 new Ajax
.InPlaceEditor(elems
[i
],
243 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
249 exception_error("infobox_feed_cat_callback", e
);
254 function updateFeedList(sort_key
) {
256 if (!xmlhttp_ready(xmlhttp
)) {
261 var feed_search
= document
.getElementById("feed_search");
263 if (feed_search
) { search
= feed_search
.value
; }
265 var slat
= document
.getElementById("show_last_article_times");
267 var slat_checked
= false;
269 slat_checked
= slat
.checked
;
272 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
273 "&sort=" + param_escape(sort_key
) +
274 "&slat=" + param_escape(slat_checked
) +
275 "&search=" + param_escape(search
), true);
276 xmlhttp
.onreadystatechange
=feedlist_callback
;
281 function updateUsersList(sort_key
) {
283 if (!xmlhttp_ready(xmlhttp
)) {
288 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
289 + param_escape(sort_key
), true);
290 xmlhttp
.onreadystatechange
=userlist_callback
;
295 function addLabel() {
297 if (!xmlhttp_ready(xmlhttp
)) {
302 var form
= document
.forms
['label_edit_form'];
304 var sql_exp
= form
.sql_exp
.value
;
305 var description
= form
.description
.value
;
308 alert(__("Can't create label: missing SQL expression."));
312 if (description
== "") {
313 alert(__("Can't create label: missing caption."));
317 var query
= Form
.serialize("label_edit_form");
319 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
320 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
326 if (!xmlhttp_ready(xmlhttp
)) {
331 var link
= document
.getElementById("fadd_link");
333 if (link
.value
.length
== 0) {
334 alert(__("Error: No feed URL given."));
335 } else if (!isValidURL(link
.value
)) {
336 alert(__("Error: Invalid feed URL."));
338 notify_progress("Adding feed...");
340 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
341 param_escape(link
.value
), true);
342 xmlhttp
.onreadystatechange
=feedlist_callback
;
351 function addFeedCat() {
353 if (!xmlhttp_ready(xmlhttp
)) {
358 var cat
= document
.getElementById("fadd_cat");
360 if (cat
.value
.length
== 0) {
361 alert(__("Can't add category: no name specified."));
363 notify_progress("Adding feed category...");
365 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
366 param_escape(cat
.value
), true);
367 xmlhttp
.onreadystatechange
=infobox_callback
;
377 if (!xmlhttp_ready(xmlhttp
)) {
382 var sqlexp
= document
.getElementById("uadd_box");
384 if (sqlexp
.value
.length
== 0) {
385 alert(__("Can't add user: no login specified."));
387 notify_progress("Adding user...");
389 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
390 param_escape(sqlexp
.value
), true);
392 xmlhttp
.onreadystatechange
=userlist_callback
;
400 function editLabel(id
) {
402 if (!xmlhttp_ready(xmlhttp
)) {
407 notify_progress("Loading, please wait...");
409 document
.getElementById("label_create_btn").disabled
= true;
413 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
414 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
416 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
417 param_escape(id
), true);
418 xmlhttp
.onreadystatechange
=infobox_callback
;
423 function editUser(id
) {
425 if (!xmlhttp_ready(xmlhttp
)) {
430 notify_progress("Loading, please wait...");
432 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
433 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
435 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
436 param_escape(id
), true);
437 xmlhttp
.onreadystatechange
=infobox_callback
;
442 function editFilter(id
) {
444 if (!xmlhttp_ready(xmlhttp
)) {
449 notify_progress("Loading, please wait...");
451 document
.getElementById("create_filter_btn").disabled
= true;
453 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
454 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
456 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
457 xmlhttp
.onreadystatechange
=infobox_callback
;
461 function editFeed(feed
) {
463 // notify("Editing feed...");
465 if (!xmlhttp_ready(xmlhttp
)) {
470 notify_progress("Loading, please wait...");
472 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
475 document
.getElementById("top25_feeds_btn").disabled
= true;
477 // this button is not always available, no-op if not found
480 // clean selection from all rows & select row being edited
481 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
482 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
484 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
485 param_escape(feed
), true);
487 xmlhttp
.onreadystatechange
=infobox_callback
;
492 function editFeedCat(cat
) {
494 if (!xmlhttp_ready(xmlhttp
)) {
499 notify_progress("Loading, please wait...");
501 active_feed_cat
= cat
;
503 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
504 param_escape(cat
), true);
505 xmlhttp
.onreadystatechange
=infobox_callback
;
510 function getSelectedLabels() {
511 return getSelectedTableRowIds("prefLabelList", "LILRR");
514 function getSelectedUsers() {
515 return getSelectedTableRowIds("prefUserList", "UMRR");
518 function getSelectedFeeds() {
519 return getSelectedTableRowIds("prefFeedList", "FEEDR");
522 function getSelectedFilters() {
523 return getSelectedTableRowIds("prefFilterList", "FILRR");
526 function getSelectedFeedCats() {
527 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
530 function getSelectedFeedsFromBrowser() {
532 var list
= document
.getElementById("browseFeedList");
533 if (!list
) list
= document
.getElementById("browseBigFeedList");
535 var selected
= new Array();
537 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
538 var child
= list
.childNodes
[i
];
539 if (child
.id
&& child
.id
.match("FBROW-")) {
540 var id
= child
.id
.replace("FBROW-", "");
542 var cb
= document
.getElementById("FBCHK-" + id
);
553 function removeSelectedLabels() {
555 if (!xmlhttp_ready(xmlhttp
)) {
560 var sel_rows
= getSelectedLabels();
562 if (sel_rows
.length
> 0) {
564 var ok
= confirm(__("Remove selected labels?"));
567 notify_progress("Removing selected labels...");
569 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
570 param_escape(sel_rows
.toString()), true);
571 xmlhttp
.onreadystatechange
=labellist_callback
;
575 alert(__("No labels are selected."));
581 function removeSelectedUsers() {
583 if (!xmlhttp_ready(xmlhttp
)) {
588 var sel_rows
= getSelectedUsers();
590 if (sel_rows
.length
> 0) {
592 var ok
= confirm(__("Remove selected users?"));
595 notify_progress("Removing selected users...");
597 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
598 param_escape(sel_rows
.toString()), true);
599 xmlhttp
.onreadystatechange
=userlist_callback
;
604 alert(__("No users are selected."));
610 function removeSelectedFilters() {
612 if (!xmlhttp_ready(xmlhttp
)) {
617 var sel_rows
= getSelectedFilters();
619 if (sel_rows
.length
> 0) {
621 var ok
= confirm(__("Remove selected filters?"));
624 notify_progress("Removing selected filters...");
626 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
627 param_escape(sel_rows
.toString()), true);
628 xmlhttp
.onreadystatechange
=filterlist_callback
;
632 alert(__("No filters are selected."));
639 function removeSelectedFeeds() {
641 if (!xmlhttp_ready(xmlhttp
)) {
646 var sel_rows
= getSelectedFeeds();
648 if (sel_rows
.length
> 0) {
650 var ok
= confirm(__("Unsubscribe from selected feeds?"));
654 notify_progress("Unsubscribing from selected feeds...");
656 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
657 param_escape(sel_rows
.toString()), true);
658 xmlhttp
.onreadystatechange
=feedlist_callback
;
664 alert(__("No feeds are selected."));
671 function clearSelectedFeeds() {
673 if (!xmlhttp_ready(xmlhttp
)) {
678 var sel_rows
= getSelectedFeeds();
680 if (sel_rows
.length
> 1) {
681 alert(__("Please select only one feed."));
685 if (sel_rows
.length
> 0) {
687 var ok
= confirm(__("Erase all non-starred articles in selected feed?"));
690 notify_progress("Clearing selected feed...");
691 clearFeedArticles(sel_rows
[0]);
696 alert(__("No feeds are selected."));
703 function removeSelectedFeedCats() {
705 if (!xmlhttp_ready(xmlhttp
)) {
710 var sel_rows
= getSelectedFeedCats();
712 if (sel_rows
.length
> 0) {
714 var ok
= confirm(__("Remove selected categories?"));
717 notify_progress("Removing selected categories...");
719 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
720 param_escape(sel_rows
.toString()), true);
721 xmlhttp
.onreadystatechange
=infobox_callback
;
727 alert(__("No categories are selected."));
734 function feedEditCancel() {
736 if (!xmlhttp_ready(xmlhttp
)) {
741 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
744 document
.getElementById("top25_feeds_btn").disabled
= false;
746 // this button is not always available, no-op if not found
751 selectPrefRows('feed', false); // cleanup feed selection
756 function feedCatEditCancel() {
758 if (!xmlhttp_ready(xmlhttp
)) {
763 active_feed_cat
= false;
765 // notify("Operation cancelled.");
767 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
768 xmlhttp
.onreadystatechange
=infobox_callback
;
774 function feedEditSave() {
778 if (!xmlhttp_ready(xmlhttp
)) {
783 // FIXME: add parameter validation
785 var query
= Form
.serialize("edit_feed_form");
787 notify_progress("Saving feed...");
789 xmlhttp
.open("POST", "backend.php", true);
790 xmlhttp
.onreadystatechange
=feedlist_callback
;
791 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
799 exception_error("feedEditSave", e
);
803 function feedCatEditSave() {
805 if (!xmlhttp_ready(xmlhttp
)) {
810 notify_progress("Saving category...");
812 var query
= Form
.serialize("feed_cat_edit_form");
814 xmlhttp
.open("GET", "backend.php?" + query
, true);
815 xmlhttp
.onreadystatechange
=infobox_callback
;
818 active_feed_cat
= false;
825 function displayHelpInfobox(topic_id
) {
827 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
829 var w
= window
.open(url
, "ttrss_help",
830 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
834 function labelEditCancel() {
836 if (!xmlhttp_ready(xmlhttp
)) {
841 document
.getElementById("label_create_btn").disabled
= false;
843 active_label
= false;
845 selectPrefRows('label', false); // cleanup feed selection
851 function userEditCancel() {
853 if (!xmlhttp_ready(xmlhttp
)) {
858 selectPrefRows('user', false); // cleanup feed selection
864 function filterEditCancel() {
866 if (!xmlhttp_ready(xmlhttp
)) {
871 document
.getElementById("create_filter_btn").disabled
= false;
873 selectPrefRows('filter', false); // cleanup feed selection
879 function labelEditSave() {
881 var label
= active_label
;
883 if (!xmlhttp_ready(xmlhttp
)) {
888 /* if (!is_opera()) {
890 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
891 var description = document.forms["label_edit_form"].description.value;
893 if (sql_exp.length == 0) {
894 alert("SQL Expression cannot be blank.");
898 if (description.length == 0) {
899 alert("Caption field cannot be blank.");
906 notify_progress("Saving label...");
908 active_label
= false;
910 query
= Form
.serialize("label_edit_form");
912 xmlhttp
.open("GET", "backend.php?" + query
, true);
913 xmlhttp
.onreadystatechange
=labellist_callback
;
919 function userEditSave() {
921 if (!xmlhttp_ready(xmlhttp
)) {
926 var login
= document
.forms
["user_edit_form"].login
.value
;
928 if (login
.length
== 0) {
929 alert(__("Login field cannot be blank."));
933 notify_progress("Saving user...");
937 var query
= Form
.serialize("user_edit_form");
939 xmlhttp
.open("GET", "backend.php?" + query
, true);
940 xmlhttp
.onreadystatechange
=userlist_callback
;
947 function filterEditSave() {
949 if (!xmlhttp_ready(xmlhttp
)) {
954 /* if (!is_opera()) {
955 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
957 if (reg_exp.length == 0) {
958 alert("Filter expression field cannot be blank.");
963 notify_progress("Saving filter...");
965 var query
= Form
.serialize("filter_edit_form");
969 document
.getElementById("create_filter_btn").disabled
= false;
971 xmlhttp
.open("GET", "backend.php?" + query
, true);
972 xmlhttp
.onreadystatechange
=filterlist_callback
;
978 function editSelectedLabel() {
979 var rows
= getSelectedLabels();
981 if (rows
.length
== 0) {
982 alert(__("No labels are selected."));
986 if (rows
.length
> 1) {
987 alert(__("Please select only one label."));
997 function editSelectedUser() {
998 var rows
= getSelectedUsers();
1000 if (rows
.length
== 0) {
1001 alert(__("No users are selected."));
1005 if (rows
.length
> 1) {
1006 alert(__("Please select only one user."));
1015 function resetSelectedUserPass() {
1016 var rows
= getSelectedUsers();
1018 if (rows
.length
== 0) {
1019 alert(__("No users are selected."));
1023 if (rows
.length
> 1) {
1024 alert(__("Please select only one user."));
1028 var ok
= confirm(__("Reset password of selected user?"));
1031 notify_progress("Resetting password for selected user...");
1035 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1036 param_escape(id
), true);
1037 xmlhttp
.onreadystatechange
=userlist_callback
;
1042 function selectedUserDetails() {
1044 if (!xmlhttp_ready(xmlhttp
)) {
1045 printLockingError();
1049 var rows
= getSelectedUsers();
1051 if (rows
.length
== 0) {
1052 alert(__("No users are selected."));
1056 if (rows
.length
> 1) {
1057 alert(__("Please select only one user."));
1061 notify_progress("Loading, please wait...");
1065 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1066 xmlhttp
.onreadystatechange
=infobox_callback
;
1071 function selectedFeedDetails() {
1073 if (!xmlhttp_ready(xmlhttp
)) {
1074 printLockingError();
1078 var rows
= getSelectedFeeds();
1080 if (rows
.length
== 0) {
1081 alert(__("No feeds are selected."));
1085 if (rows
.length
> 1) {
1086 alert(__("Please select only one feed."));
1090 // var id = rows[0];
1094 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1095 param_escape(rows
.toString()), true);
1096 xmlhttp
.onreadystatechange
=infobox_callback
;
1101 function editSelectedFilter() {
1102 var rows
= getSelectedFilters();
1104 if (rows
.length
== 0) {
1105 alert(__("No filters are selected."));
1109 if (rows
.length
> 1) {
1110 alert(__("Please select only one filter."));
1116 editFilter(rows
[0]);
1121 function editSelectedFeed() {
1122 var rows
= getSelectedFeeds();
1124 if (rows
.length
== 0) {
1125 alert(__("No feeds are selected."));
1129 if (rows
.length
> 1) {
1130 alert(__("Please select one feed."));
1140 function editSelectedFeedCat() {
1141 var rows
= getSelectedFeedCats();
1143 if (rows
.length
== 0) {
1144 alert(__("No categories are selected."));
1148 if (rows
.length
> 1) {
1149 alert(__("Please select only one category."));
1155 editFeedCat(rows
[0]);
1159 function localPiggieFunction(enable
) {
1161 debug("I LOVEDED IT!");
1162 var piggie
= document
.getElementById("piggie");
1164 Element
.show(piggie
);
1165 Position
.Center(piggie
);
1166 Effect
.Puff(piggie
);
1171 function validateOpmlImport() {
1173 var opml_file
= document
.getElementById("opml_file");
1175 if (opml_file
.value
.length
== 0) {
1176 alert(__("No OPML file to upload."));
1183 function updateFilterList(sort_key
) {
1185 if (!xmlhttp_ready(xmlhttp
)) {
1186 printLockingError();
1190 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1191 param_escape(sort_key
), true);
1192 xmlhttp
.onreadystatechange
=filterlist_callback
;
1197 function updateLabelList(sort_key
) {
1199 if (!xmlhttp_ready(xmlhttp
)) {
1200 printLockingError();
1204 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1205 param_escape(sort_key
), true);
1206 xmlhttp
.onreadystatechange
=labellist_callback
;
1210 function updatePrefsList() {
1212 if (!xmlhttp_ready(xmlhttp
)) {
1213 printLockingError();
1217 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1218 xmlhttp
.onreadystatechange
=prefslist_callback
;
1223 function selectTab(id
, noupdate
, subop
) {
1227 if (!id
) id
= active_tab
;
1231 if (!xmlhttp_ready(xmlhttp
)) {
1232 printLockingError();
1237 var c
= document
.getElementById('prefContent');
1243 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1245 notify_progress("Loading, please wait...");
1247 // close active infobox if needed
1250 // clean up all current selections, just in case
1251 active_feed_cat
= false;
1252 active_label
= false;
1254 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1255 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1257 if (id
== "feedConfig") {
1259 } else if (id
== "filterConfig") {
1261 } else if (id
== "labelConfig") {
1263 } else if (id
== "genConfig") {
1265 } else if (id
== "userConfig") {
1267 } else if (id
== "feedBrowser") {
1268 updateBigFeedBrowser();
1272 var tab
= document
.getElementById(active_tab
+ "Tab");
1275 if (tab
.className
.match("Selected")) {
1276 tab
.className
= "prefsTab";
1280 tab
= document
.getElementById(id
+ "Tab");
1283 if (!tab
.className
.match("Selected")) {
1284 tab
.className
= tab
.className
+ "Selected";
1291 exception_error("selectTab", e
);
1295 function backend_sanity_check_callback() {
1297 if (xmlhttp
.readyState
== 4) {
1301 if (sanity_check_done
) {
1302 fatalError(11, "Sanity check request received twice. This can indicate "+
1303 "presence of Firebug or some other disrupting extension. "+
1304 "Please disable it and try again.");
1308 if (!xmlhttp
.responseXML
) {
1309 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1313 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1316 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1320 var error_code
= reply
.getAttribute("error-code");
1322 if (error_code
&& error_code
!= 0) {
1323 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1326 debug("sanity check ok");
1328 var params
= reply
.nextSibling
;
1331 debug('reading init-params...');
1332 var param
= params
.firstChild
;
1335 var k
= param
.getAttribute("key");
1336 var v
= param
.getAttribute("value");
1337 debug(k
+ " => " + v
);
1339 param
= param
.nextSibling
;
1343 sanity_check_done
= true;
1345 init_second_stage();
1348 exception_error("backend_sanity_check_callback", e
);
1353 function init_second_stage() {
1356 active_tab
= getInitParam("prefs_active_tab");
1357 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1359 document
.onkeydown
= pref_hotkey_handler
;
1361 var tab
= getURLParam('tab');
1363 caller_subop
= getURLParam('subop');
1369 if (navigator
.userAgent
.match("Opera")) {
1370 setTimeout("selectTab()", 500);
1372 selectTab(active_tab
);
1376 exception_error("init_second_stage", e
);
1384 if (arguments
.callee
.done
) return;
1385 arguments
.callee
.done
= true;
1387 if (getURLParam('debug')) {
1388 document
.getElementById('debug_output').style
.display
= 'block';
1389 debug('debug mode activated');
1394 document
.getElementById("prefContent").innerHTML
=
1395 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1396 "to function properly. Your browser doesn't seem to support it.";
1400 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1401 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1405 exception_error("init", e
);
1409 function categorizeSelectedFeeds() {
1411 if (!xmlhttp_ready(xmlhttp
)) {
1412 printLockingError();
1416 var sel_rows
= getSelectedFeeds();
1418 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1419 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1421 if (sel_rows
.length
> 0) {
1423 notify_progress("Changing category of selected feeds...");
1425 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1426 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1427 xmlhttp
.onreadystatechange
=feedlist_callback
;
1432 alert(__("No feeds are selected."));
1438 function validatePrefsReset() {
1440 var ok
= confirm(__("Reset to defaults?"));
1444 var query
= Form
.serialize("pref_prefs_form");
1445 query
= query
+ "&subop=reset-config";
1448 xmlhttp
.open("POST", "backend.php", true);
1449 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1450 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1451 xmlhttp
.send(query
);
1455 exception_error("validatePrefsSave", e
);
1462 function browseFeeds(limit
) {
1464 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1465 xmlhttp
.onreadystatechange
=infobox_callback
;
1470 function feedBrowserSubscribe() {
1473 var selected
= getSelectedFeedsFromBrowser();
1475 if (selected
.length
> 0) {
1477 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1478 param_escape(selected
.toString()), true);
1479 xmlhttp
.onreadystatechange
=feedlist_callback
;
1482 alert(__("No feeds are selected."));
1486 exception_error("feedBrowserSubscribe", e
);
1490 function updateBigFeedBrowser(limit
) {
1492 if (!xmlhttp_ready(xmlhttp
)) {
1493 printLockingError();
1497 var query
= "backend.php?op=pref-feed-browser";
1499 var limit_sel
= document
.getElementById("feedBrowserLimit");
1502 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1503 query
= query
+ "&limit=" + param_escape(limit
);
1506 xmlhttp
.open("GET", query
, true);
1507 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1511 function browserToggleExpand(id
) {
1513 /* if (feed_to_expand && feed_to_expand != id) {
1514 var d = document.getElementById("BRDET-" + feed_to_expand);
1515 d.style.display = "none";
1518 if (!xmlhttp_ready(xmlhttp
)) {
1519 printLockingError();
1523 /* if (feed_to_expand && id != feed_to_expand) {
1524 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1527 var d
= document
.getElementById("BRDET-" + id
);
1529 if (Element
.visible(d
)) {
1530 Effect
.Fade(d
, {duration
: 0.5});
1532 feed_to_expand
= id
;
1534 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1535 + param_escape(id
), true);
1536 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1541 exception_error("browserToggleExpand", e
);
1545 function selectPrefRows(kind
, select
) {
1548 var opbarid
= false;
1553 if (kind
== "feed") {
1554 opbarid
= "feedOpToolbar";
1557 lname
= "prefFeedList";
1558 } else if (kind
== "fcat") {
1559 opbarid
= "catOpToolbar";
1562 lname
= "prefFeedCatList";
1563 } else if (kind
== "filter") {
1564 opbarid
= "filterOpToolbar";
1567 lname
= "prefFilterList";
1568 } else if (kind
== "label") {
1569 opbarid
= "labelOpToolbar";
1572 lname
= "prefLabelList";
1573 } else if (kind
== "user") {
1574 opbarid
= "userOpToolbar";
1577 lname
= "prefUserList";
1581 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1582 disableContainerChildren(opbarid
, !select
);
1589 function toggleSelectPrefRow(sender
, kind
) {
1591 toggleSelectRow(sender
);
1594 var opbarid
= false;
1597 if (kind
== "feed") {
1598 opbarid
= "feedOpToolbar";
1599 nsel
= getSelectedFeeds();
1600 } else if (kind
== "fcat") {
1601 opbarid
= "catOpToolbar";
1602 nsel
= getSelectedFeedCats();
1603 } else if (kind
== "filter") {
1604 opbarid
= "filterOpToolbar";
1605 nsel
= getSelectedFilters();
1606 } else if (kind
== "label") {
1607 opbarid
= "labelOpToolbar";
1608 nsel
= getSelectedLabels();
1609 } else if (kind
== "user") {
1610 opbarid
= "userOpToolbar";
1611 nsel
= getSelectedUsers();
1614 if (opbarid
&& nsel
!= -1) {
1615 disableContainerChildren(opbarid
, nsel
== false);
1621 function toggleSelectFBListRow(sender
) {
1622 toggleSelectListRow(sender
);
1623 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1628 function pref_hotkey_handler(e
) {
1633 if (!hotkeys_enabled
) return;
1636 keycode
= window
.event
.keyCode
;
1641 if (keycode
== 13 || keycode
== 27) {
1644 seq
= seq
+ "" + keycode
;
1648 if (document
.getElementById("piggie")) {
1650 if (seq
.match("807371717369")) {
1652 localPiggieFunction(true);
1654 localPiggieFunction(false);
1659 exception_error("pref_hotkey_handler", e
);
1663 function editFeedCats() {
1664 if (!xmlhttp_ready(xmlhttp
)) {
1665 printLockingError();
1669 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1672 document
.getElementById("top25_feeds_btn").disabled
= true;
1674 // this button is not always available, no-op if not found
1677 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1678 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1682 function showFeedsWithErrors() {
1683 displayDlg('feedUpdateErrors');
1686 function changeUserPassword() {
1690 if (!xmlhttp_ready(xmlhttp
)) {
1691 printLockingError();
1695 var f
= document
.forms
["change_pass_form"];
1698 if (f
.OLD_PASSWORD
.value
== "") {
1699 new Effect
.Highlight(f
.OLD_PASSWORD
);
1700 notify_error("Old password cannot be blank.");
1704 if (f
.NEW_PASSWORD
.value
== "") {
1705 new Effect
.Highlight(f
.NEW_PASSWORD
);
1706 notify_error("New password cannot be blank.");
1710 if (f
.CONFIRM_PASSWORD
.value
== "") {
1711 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1712 notify_error("Entered passwords do not match.");
1716 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1717 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1718 new Effect
.Highlight(f
.NEW_PASSWORD
);
1719 notify_error("Entered passwords do not match.");
1725 var query
= Form
.serialize("change_pass_form");
1727 notify_progress("Trying to change password...");
1729 xmlhttp
.open("POST", "backend.php", true);
1730 xmlhttp
.onreadystatechange
=changepass_callback
;
1731 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1732 xmlhttp
.send(query
);
1735 exception_error("changeUserPassword", e
);
1741 function changeUserEmail() {
1745 if (!xmlhttp_ready(xmlhttp
)) {
1746 printLockingError();
1750 var query
= Form
.serialize("change_email_form");
1752 notify_progress("Trying to change e-mail...");
1754 xmlhttp
.open("POST", "backend.php", true);
1755 xmlhttp
.onreadystatechange
=notify_callback
;
1756 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1757 xmlhttp
.send(query
);
1760 exception_error("changeUserPassword", e
);
1767 function feedlistToggleSLAT() {
1768 notify_progress("Loading, please wait...");
1772 function pubRegenKey() {
1774 if (!xmlhttp_ready(xmlhttp
)) {
1775 printLockingError();
1779 var ok
= confirm(__("Replace current publishing address with a new one?"));
1783 notify_progress("Trying to change address...");
1785 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1786 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1793 function validatePrefsSave() {
1796 var ok
= confirm(__("Save current configuration?"));
1800 var query
= Form
.serialize("pref_prefs_form");
1801 query
= query
+ "&subop=save-config";
1804 xmlhttp
.open("POST", "backend.php", true);
1805 xmlhttp
.onreadystatechange
=notify_callback
;
1806 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1807 xmlhttp
.send(query
);
1811 exception_error("validatePrefsSave", e
);
1817 function feedActionChange() {
1819 var chooser
= document
.getElementById("feedActionChooser");
1820 var opid
= chooser
[chooser
.selectedIndex
].value
;
1822 chooser
.selectedIndex
= 0;
1825 exception_error("feedActionChange", e
);
1829 function feedActionGo(op
) {
1831 if (op
== "facEdit") {
1835 if (op
== "facClear") {
1836 clearSelectedFeeds();
1839 if (op
== "facPurge") {
1840 purgeSelectedFeeds();
1843 if (op
== "facUnsubscribe") {
1844 removeSelectedFeeds();
1848 exception_error("feedActionGo", e
);
1853 function clearFeedArticles(feed_id
) {
1855 notify_progress("Clearing feed...");
1857 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
1859 new Ajax
.Request(query
, {
1860 onComplete: function(transport
) {