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 purgeSelectedFeeds() {
705 if (!xmlhttp_ready(xmlhttp
)) {
710 var sel_rows
= getSelectedFeeds();
712 if (sel_rows
.length
> 0) {
714 var pr
= prompt(__("How many days of articles to keep (0 - use default)?"), "0");
716 if (pr
!= undefined) {
717 notify_progress("Purging selected feed...");
719 var query
= "backend.php?op=rpc&subop=purge&ids="+
720 param_escape(sel_rows
.toString()) + "&days=" + pr
;
724 new Ajax
.Request(query
, {
725 onComplete: function(transport
) {
732 alert(__("No feeds are selected."));
739 function removeSelectedFeedCats() {
741 if (!xmlhttp_ready(xmlhttp
)) {
746 var sel_rows
= getSelectedFeedCats();
748 if (sel_rows
.length
> 0) {
750 var ok
= confirm(__("Remove selected categories?"));
753 notify_progress("Removing selected categories...");
755 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
756 param_escape(sel_rows
.toString()), true);
757 xmlhttp
.onreadystatechange
=infobox_callback
;
763 alert(__("No categories are selected."));
770 function feedEditCancel() {
772 if (!xmlhttp_ready(xmlhttp
)) {
777 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
780 document
.getElementById("top25_feeds_btn").disabled
= false;
782 // this button is not always available, no-op if not found
787 selectPrefRows('feed', false); // cleanup feed selection
792 function feedCatEditCancel() {
794 if (!xmlhttp_ready(xmlhttp
)) {
799 active_feed_cat
= false;
801 // notify("Operation cancelled.");
803 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
804 xmlhttp
.onreadystatechange
=infobox_callback
;
810 function feedEditSave() {
814 if (!xmlhttp_ready(xmlhttp
)) {
819 // FIXME: add parameter validation
821 var query
= Form
.serialize("edit_feed_form");
823 notify_progress("Saving feed...");
825 xmlhttp
.open("POST", "backend.php", true);
826 xmlhttp
.onreadystatechange
=feedlist_callback
;
827 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
835 exception_error("feedEditSave", e
);
839 function feedCatEditSave() {
841 if (!xmlhttp_ready(xmlhttp
)) {
846 notify_progress("Saving category...");
848 var query
= Form
.serialize("feed_cat_edit_form");
850 xmlhttp
.open("GET", "backend.php?" + query
, true);
851 xmlhttp
.onreadystatechange
=infobox_callback
;
854 active_feed_cat
= false;
861 function displayHelpInfobox(topic_id
) {
863 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
865 var w
= window
.open(url
, "ttrss_help",
866 "status=0,toolbar=0,location=0,width=450,height=500,scrollbars=1,menubar=0");
871 function labelEditCancel() {
873 if (!xmlhttp_ready(xmlhttp
)) {
878 document
.getElementById("label_create_btn").disabled
= false;
880 active_label
= false;
882 selectPrefRows('label', false); // cleanup feed selection
888 function userEditCancel() {
890 if (!xmlhttp_ready(xmlhttp
)) {
895 selectPrefRows('user', false); // cleanup feed selection
901 function filterEditCancel() {
903 if (!xmlhttp_ready(xmlhttp
)) {
908 document
.getElementById("create_filter_btn").disabled
= false;
910 selectPrefRows('filter', false); // cleanup feed selection
916 function labelEditSave() {
918 var label
= active_label
;
920 if (!xmlhttp_ready(xmlhttp
)) {
925 /* if (!is_opera()) {
927 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
928 var description = document.forms["label_edit_form"].description.value;
930 if (sql_exp.length == 0) {
931 alert("SQL Expression cannot be blank.");
935 if (description.length == 0) {
936 alert("Caption field cannot be blank.");
943 notify_progress("Saving label...");
945 active_label
= false;
947 query
= Form
.serialize("label_edit_form");
949 xmlhttp
.open("GET", "backend.php?" + query
, true);
950 xmlhttp
.onreadystatechange
=labellist_callback
;
956 function userEditSave() {
958 if (!xmlhttp_ready(xmlhttp
)) {
963 var login
= document
.forms
["user_edit_form"].login
.value
;
965 if (login
.length
== 0) {
966 alert(__("Login field cannot be blank."));
970 notify_progress("Saving user...");
974 var query
= Form
.serialize("user_edit_form");
976 xmlhttp
.open("GET", "backend.php?" + query
, true);
977 xmlhttp
.onreadystatechange
=userlist_callback
;
984 function filterEditSave() {
986 if (!xmlhttp_ready(xmlhttp
)) {
991 /* if (!is_opera()) {
992 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
994 if (reg_exp.length == 0) {
995 alert("Filter expression field cannot be blank.");
1000 notify_progress("Saving filter...");
1002 var query
= Form
.serialize("filter_edit_form");
1006 document
.getElementById("create_filter_btn").disabled
= false;
1008 xmlhttp
.open("GET", "backend.php?" + query
, true);
1009 xmlhttp
.onreadystatechange
=filterlist_callback
;
1015 function editSelectedLabel() {
1016 var rows
= getSelectedLabels();
1018 if (rows
.length
== 0) {
1019 alert(__("No labels are selected."));
1023 if (rows
.length
> 1) {
1024 alert(__("Please select only one label."));
1034 function editSelectedUser() {
1035 var rows
= getSelectedUsers();
1037 if (rows
.length
== 0) {
1038 alert(__("No users are selected."));
1042 if (rows
.length
> 1) {
1043 alert(__("Please select only one user."));
1052 function resetSelectedUserPass() {
1053 var rows
= getSelectedUsers();
1055 if (rows
.length
== 0) {
1056 alert(__("No users are selected."));
1060 if (rows
.length
> 1) {
1061 alert(__("Please select only one user."));
1065 var ok
= confirm(__("Reset password of selected user?"));
1068 notify_progress("Resetting password for selected user...");
1072 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1073 param_escape(id
), true);
1074 xmlhttp
.onreadystatechange
=userlist_callback
;
1079 function selectedUserDetails() {
1081 if (!xmlhttp_ready(xmlhttp
)) {
1082 printLockingError();
1086 var rows
= getSelectedUsers();
1088 if (rows
.length
== 0) {
1089 alert(__("No users are selected."));
1093 if (rows
.length
> 1) {
1094 alert(__("Please select only one user."));
1098 notify_progress("Loading, please wait...");
1102 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1103 xmlhttp
.onreadystatechange
=infobox_callback
;
1108 function selectedFeedDetails() {
1110 if (!xmlhttp_ready(xmlhttp
)) {
1111 printLockingError();
1115 var rows
= getSelectedFeeds();
1117 if (rows
.length
== 0) {
1118 alert(__("No feeds are selected."));
1122 if (rows
.length
> 1) {
1123 alert(__("Please select only one feed."));
1127 // var id = rows[0];
1131 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1132 param_escape(rows
.toString()), true);
1133 xmlhttp
.onreadystatechange
=infobox_callback
;
1138 function editSelectedFilter() {
1139 var rows
= getSelectedFilters();
1141 if (rows
.length
== 0) {
1142 alert(__("No filters are selected."));
1146 if (rows
.length
> 1) {
1147 alert(__("Please select only one filter."));
1153 editFilter(rows
[0]);
1158 function editSelectedFeed() {
1159 var rows
= getSelectedFeeds();
1161 if (rows
.length
== 0) {
1162 alert(__("No feeds are selected."));
1166 if (rows
.length
> 1) {
1167 alert(__("Please select one feed."));
1177 function editSelectedFeedCat() {
1178 var rows
= getSelectedFeedCats();
1180 if (rows
.length
== 0) {
1181 alert(__("No categories are selected."));
1185 if (rows
.length
> 1) {
1186 alert(__("Please select only one category."));
1192 editFeedCat(rows
[0]);
1196 function localPiggieFunction(enable
) {
1198 debug("I LOVEDED IT!");
1199 var piggie
= document
.getElementById("piggie");
1201 Element
.show(piggie
);
1202 Position
.Center(piggie
);
1203 Effect
.Puff(piggie
);
1208 function validateOpmlImport() {
1210 var opml_file
= document
.getElementById("opml_file");
1212 if (opml_file
.value
.length
== 0) {
1213 alert(__("No OPML file to upload."));
1220 function updateFilterList(sort_key
) {
1222 if (!xmlhttp_ready(xmlhttp
)) {
1223 printLockingError();
1227 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1228 param_escape(sort_key
), true);
1229 xmlhttp
.onreadystatechange
=filterlist_callback
;
1234 function updateLabelList(sort_key
) {
1236 if (!xmlhttp_ready(xmlhttp
)) {
1237 printLockingError();
1241 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1242 param_escape(sort_key
), true);
1243 xmlhttp
.onreadystatechange
=labellist_callback
;
1247 function updatePrefsList() {
1249 if (!xmlhttp_ready(xmlhttp
)) {
1250 printLockingError();
1254 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1255 xmlhttp
.onreadystatechange
=prefslist_callback
;
1260 function selectTab(id
, noupdate
, subop
) {
1264 if (!id
) id
= active_tab
;
1268 if (!xmlhttp_ready(xmlhttp
)) {
1269 printLockingError();
1274 var c
= document
.getElementById('prefContent');
1280 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1282 notify_progress("Loading, please wait...");
1284 // close active infobox if needed
1287 // clean up all current selections, just in case
1288 active_feed_cat
= false;
1289 active_label
= false;
1291 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1292 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1294 if (id
== "feedConfig") {
1296 } else if (id
== "filterConfig") {
1298 } else if (id
== "labelConfig") {
1300 } else if (id
== "genConfig") {
1302 } else if (id
== "userConfig") {
1304 } else if (id
== "feedBrowser") {
1305 updateBigFeedBrowser();
1309 var tab
= document
.getElementById(active_tab
+ "Tab");
1312 if (tab
.className
.match("Selected")) {
1313 tab
.className
= "prefsTab";
1317 tab
= document
.getElementById(id
+ "Tab");
1320 if (!tab
.className
.match("Selected")) {
1321 tab
.className
= tab
.className
+ "Selected";
1328 exception_error("selectTab", e
);
1332 function backend_sanity_check_callback() {
1334 if (xmlhttp
.readyState
== 4) {
1338 if (sanity_check_done
) {
1339 fatalError(11, "Sanity check request received twice. This can indicate "+
1340 "presence of Firebug or some other disrupting extension. "+
1341 "Please disable it and try again.");
1345 if (!xmlhttp
.responseXML
) {
1346 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1350 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1353 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1357 var error_code
= reply
.getAttribute("error-code");
1359 if (error_code
&& error_code
!= 0) {
1360 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1363 debug("sanity check ok");
1365 var params
= reply
.nextSibling
;
1368 debug('reading init-params...');
1369 var param
= params
.firstChild
;
1372 var k
= param
.getAttribute("key");
1373 var v
= param
.getAttribute("value");
1374 debug(k
+ " => " + v
);
1376 param
= param
.nextSibling
;
1380 sanity_check_done
= true;
1382 init_second_stage();
1385 exception_error("backend_sanity_check_callback", e
);
1390 function init_second_stage() {
1393 active_tab
= getInitParam("prefs_active_tab");
1394 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1396 document
.onkeydown
= pref_hotkey_handler
;
1398 var tab
= getURLParam('tab');
1400 caller_subop
= getURLParam('subop');
1406 if (navigator
.userAgent
.match("Opera")) {
1407 setTimeout("selectTab()", 500);
1409 selectTab(active_tab
);
1413 exception_error("init_second_stage", e
);
1421 if (arguments
.callee
.done
) return;
1422 arguments
.callee
.done
= true;
1424 if (getURLParam('debug')) {
1425 document
.getElementById('debug_output').style
.display
= 'block';
1426 debug('debug mode activated');
1431 document
.getElementById("prefContent").innerHTML
=
1432 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1433 "to function properly. Your browser doesn't seem to support it.";
1437 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1438 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1442 exception_error("init", e
);
1446 function categorizeSelectedFeeds() {
1448 if (!xmlhttp_ready(xmlhttp
)) {
1449 printLockingError();
1453 var sel_rows
= getSelectedFeeds();
1455 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1456 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1458 if (sel_rows
.length
> 0) {
1460 notify_progress("Changing category of selected feeds...");
1462 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1463 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1464 xmlhttp
.onreadystatechange
=feedlist_callback
;
1469 alert(__("No feeds are selected."));
1475 function validatePrefsReset() {
1477 var ok
= confirm(__("Reset to defaults?"));
1481 var query
= Form
.serialize("pref_prefs_form");
1482 query
= query
+ "&subop=reset-config";
1485 xmlhttp
.open("POST", "backend.php", true);
1486 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1487 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1488 xmlhttp
.send(query
);
1492 exception_error("validatePrefsSave", e
);
1499 function browseFeeds(limit
) {
1501 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1502 xmlhttp
.onreadystatechange
=infobox_callback
;
1507 function feedBrowserSubscribe() {
1510 var selected
= getSelectedFeedsFromBrowser();
1512 if (selected
.length
> 0) {
1514 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1515 param_escape(selected
.toString()), true);
1516 xmlhttp
.onreadystatechange
=feedlist_callback
;
1519 alert(__("No feeds are selected."));
1523 exception_error("feedBrowserSubscribe", e
);
1527 function updateBigFeedBrowser(limit
) {
1529 if (!xmlhttp_ready(xmlhttp
)) {
1530 printLockingError();
1534 var query
= "backend.php?op=pref-feed-browser";
1536 var limit_sel
= document
.getElementById("feedBrowserLimit");
1539 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1540 query
= query
+ "&limit=" + param_escape(limit
);
1543 xmlhttp
.open("GET", query
, true);
1544 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1548 function browserToggleExpand(id
) {
1550 /* if (feed_to_expand && feed_to_expand != id) {
1551 var d = document.getElementById("BRDET-" + feed_to_expand);
1552 d.style.display = "none";
1555 if (!xmlhttp_ready(xmlhttp
)) {
1556 printLockingError();
1560 /* if (feed_to_expand && id != feed_to_expand) {
1561 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1564 var d
= document
.getElementById("BRDET-" + id
);
1566 if (Element
.visible(d
)) {
1567 Effect
.Fade(d
, {duration
: 0.5});
1569 feed_to_expand
= id
;
1571 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1572 + param_escape(id
), true);
1573 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1578 exception_error("browserToggleExpand", e
);
1582 function selectPrefRows(kind
, select
) {
1585 var opbarid
= false;
1590 if (kind
== "feed") {
1591 opbarid
= "feedOpToolbar";
1594 lname
= "prefFeedList";
1595 } else if (kind
== "fcat") {
1596 opbarid
= "catOpToolbar";
1599 lname
= "prefFeedCatList";
1600 } else if (kind
== "filter") {
1601 opbarid
= "filterOpToolbar";
1604 lname
= "prefFilterList";
1605 } else if (kind
== "label") {
1606 opbarid
= "labelOpToolbar";
1609 lname
= "prefLabelList";
1610 } else if (kind
== "user") {
1611 opbarid
= "userOpToolbar";
1614 lname
= "prefUserList";
1618 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1619 disableContainerChildren(opbarid
, !select
);
1626 function toggleSelectPrefRow(sender
, kind
) {
1628 toggleSelectRow(sender
);
1631 var opbarid
= false;
1634 if (kind
== "feed") {
1635 opbarid
= "feedOpToolbar";
1636 nsel
= getSelectedFeeds();
1637 } else if (kind
== "fcat") {
1638 opbarid
= "catOpToolbar";
1639 nsel
= getSelectedFeedCats();
1640 } else if (kind
== "filter") {
1641 opbarid
= "filterOpToolbar";
1642 nsel
= getSelectedFilters();
1643 } else if (kind
== "label") {
1644 opbarid
= "labelOpToolbar";
1645 nsel
= getSelectedLabels();
1646 } else if (kind
== "user") {
1647 opbarid
= "userOpToolbar";
1648 nsel
= getSelectedUsers();
1651 if (opbarid
&& nsel
!= -1) {
1652 disableContainerChildren(opbarid
, nsel
== false);
1658 function toggleSelectFBListRow(sender
) {
1659 toggleSelectListRow(sender
);
1660 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1665 function pref_hotkey_handler(e
) {
1670 if (!hotkeys_enabled
) return;
1673 keycode
= window
.event
.keyCode
;
1678 if (keycode
== 13 || keycode
== 27) {
1681 seq
= seq
+ "" + keycode
;
1685 if (document
.getElementById("piggie")) {
1687 if (seq
.match("807371717369")) {
1689 localPiggieFunction(true);
1691 localPiggieFunction(false);
1696 exception_error("pref_hotkey_handler", e
);
1700 function editFeedCats() {
1701 if (!xmlhttp_ready(xmlhttp
)) {
1702 printLockingError();
1706 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1709 document
.getElementById("top25_feeds_btn").disabled
= true;
1711 // this button is not always available, no-op if not found
1714 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1715 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1719 function showFeedsWithErrors() {
1720 displayDlg('feedUpdateErrors');
1723 function changeUserPassword() {
1727 if (!xmlhttp_ready(xmlhttp
)) {
1728 printLockingError();
1732 var f
= document
.forms
["change_pass_form"];
1735 if (f
.OLD_PASSWORD
.value
== "") {
1736 new Effect
.Highlight(f
.OLD_PASSWORD
);
1737 notify_error("Old password cannot be blank.");
1741 if (f
.NEW_PASSWORD
.value
== "") {
1742 new Effect
.Highlight(f
.NEW_PASSWORD
);
1743 notify_error("New password cannot be blank.");
1747 if (f
.CONFIRM_PASSWORD
.value
== "") {
1748 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1749 notify_error("Entered passwords do not match.");
1753 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1754 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1755 new Effect
.Highlight(f
.NEW_PASSWORD
);
1756 notify_error("Entered passwords do not match.");
1762 var query
= Form
.serialize("change_pass_form");
1764 notify_progress("Trying to change password...");
1766 xmlhttp
.open("POST", "backend.php", true);
1767 xmlhttp
.onreadystatechange
=changepass_callback
;
1768 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1769 xmlhttp
.send(query
);
1772 exception_error("changeUserPassword", e
);
1778 function changeUserEmail() {
1782 if (!xmlhttp_ready(xmlhttp
)) {
1783 printLockingError();
1787 var query
= Form
.serialize("change_email_form");
1789 notify_progress("Trying to change e-mail...");
1791 xmlhttp
.open("POST", "backend.php", true);
1792 xmlhttp
.onreadystatechange
=notify_callback
;
1793 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1794 xmlhttp
.send(query
);
1797 exception_error("changeUserPassword", e
);
1804 function feedlistToggleSLAT() {
1805 notify_progress("Loading, please wait...");
1809 function pubRegenKey() {
1811 if (!xmlhttp_ready(xmlhttp
)) {
1812 printLockingError();
1816 var ok
= confirm(__("Replace current publishing address with a new one?"));
1820 notify_progress("Trying to change address...");
1822 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1823 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1830 function validatePrefsSave() {
1833 var ok
= confirm(__("Save current configuration?"));
1837 var query
= Form
.serialize("pref_prefs_form");
1838 query
= query
+ "&subop=save-config";
1841 xmlhttp
.open("POST", "backend.php", true);
1842 xmlhttp
.onreadystatechange
=notify_callback
;
1843 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1844 xmlhttp
.send(query
);
1848 exception_error("validatePrefsSave", e
);
1854 function feedActionChange() {
1856 var chooser
= document
.getElementById("feedActionChooser");
1857 var opid
= chooser
[chooser
.selectedIndex
].value
;
1859 chooser
.selectedIndex
= 0;
1862 exception_error("feedActionChange", e
);
1866 function feedActionGo(op
) {
1868 if (op
== "facEdit") {
1872 if (op
== "facClear") {
1873 clearSelectedFeeds();
1876 if (op
== "facPurge") {
1877 purgeSelectedFeeds();
1880 if (op
== "facEditCats") {
1884 if (op
== "facUnsubscribe") {
1885 removeSelectedFeeds();
1889 exception_error("feedActionGo", e
);
1894 function clearFeedArticles(feed_id
) {
1896 notify_progress("Clearing feed...");
1898 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
1900 new Ajax
.Request(query
, {
1901 onComplete: function(transport
) {