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;
13 var sanity_check_done
= false;
14 var hotkey_prefix
= 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("Published feed URL changed.");
46 notify_error("Could not change feed URL.");
50 notify_error("Could not change feed URL.");
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;
859 function labelEditCancel() {
861 if (!xmlhttp_ready(xmlhttp
)) {
866 document
.getElementById("label_create_btn").disabled
= false;
868 active_label
= false;
870 selectPrefRows('label', false); // cleanup feed selection
876 function userEditCancel() {
878 if (!xmlhttp_ready(xmlhttp
)) {
883 selectPrefRows('user', false); // cleanup feed selection
889 function filterEditCancel() {
891 if (!xmlhttp_ready(xmlhttp
)) {
896 document
.getElementById("create_filter_btn").disabled
= false;
898 selectPrefRows('filter', false); // cleanup feed selection
904 function labelEditSave() {
906 var label
= active_label
;
908 if (!xmlhttp_ready(xmlhttp
)) {
913 /* if (!is_opera()) {
915 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
916 var description = document.forms["label_edit_form"].description.value;
918 if (sql_exp.length == 0) {
919 alert("SQL Expression cannot be blank.");
923 if (description.length == 0) {
924 alert("Caption field cannot be blank.");
931 notify_progress("Saving label...");
933 active_label
= false;
935 query
= Form
.serialize("label_edit_form");
937 xmlhttp
.open("GET", "backend.php?" + query
, true);
938 xmlhttp
.onreadystatechange
=labellist_callback
;
944 function userEditSave() {
946 if (!xmlhttp_ready(xmlhttp
)) {
951 var login
= document
.forms
["user_edit_form"].login
.value
;
953 if (login
.length
== 0) {
954 alert(__("Login field cannot be blank."));
958 notify_progress("Saving user...");
962 var query
= Form
.serialize("user_edit_form");
964 xmlhttp
.open("GET", "backend.php?" + query
, true);
965 xmlhttp
.onreadystatechange
=userlist_callback
;
972 function filterEditSave() {
974 if (!xmlhttp_ready(xmlhttp
)) {
979 /* if (!is_opera()) {
980 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
982 if (reg_exp.length == 0) {
983 alert("Filter expression field cannot be blank.");
988 notify_progress("Saving filter...");
990 var query
= Form
.serialize("filter_edit_form");
994 document
.getElementById("create_filter_btn").disabled
= false;
996 xmlhttp
.open("GET", "backend.php?" + query
, true);
997 xmlhttp
.onreadystatechange
=filterlist_callback
;
1003 function editSelectedLabel() {
1004 var rows
= getSelectedLabels();
1006 if (rows
.length
== 0) {
1007 alert(__("No labels are selected."));
1011 if (rows
.length
> 1) {
1012 alert(__("Please select only one label."));
1022 function editSelectedUser() {
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."));
1040 function resetSelectedUserPass() {
1041 var rows
= getSelectedUsers();
1043 if (rows
.length
== 0) {
1044 alert(__("No users are selected."));
1048 if (rows
.length
> 1) {
1049 alert(__("Please select only one user."));
1053 var ok
= confirm(__("Reset password of selected user?"));
1056 notify_progress("Resetting password for selected user...");
1060 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1061 param_escape(id
), true);
1062 xmlhttp
.onreadystatechange
=userlist_callback
;
1067 function selectedUserDetails() {
1069 if (!xmlhttp_ready(xmlhttp
)) {
1070 printLockingError();
1074 var rows
= getSelectedUsers();
1076 if (rows
.length
== 0) {
1077 alert(__("No users are selected."));
1081 if (rows
.length
> 1) {
1082 alert(__("Please select only one user."));
1086 notify_progress("Loading, please wait...");
1090 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1091 xmlhttp
.onreadystatechange
=infobox_callback
;
1096 function selectedFeedDetails() {
1098 if (!xmlhttp_ready(xmlhttp
)) {
1099 printLockingError();
1103 var rows
= getSelectedFeeds();
1105 if (rows
.length
== 0) {
1106 alert(__("No feeds are selected."));
1110 if (rows
.length
> 1) {
1111 alert(__("Please select only one feed."));
1115 // var id = rows[0];
1119 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1120 param_escape(rows
.toString()), true);
1121 xmlhttp
.onreadystatechange
=infobox_callback
;
1126 function editSelectedFilter() {
1127 var rows
= getSelectedFilters();
1129 if (rows
.length
== 0) {
1130 alert(__("No filters are selected."));
1134 if (rows
.length
> 1) {
1135 alert(__("Please select only one filter."));
1141 editFilter(rows
[0]);
1146 function editSelectedFeed() {
1147 var rows
= getSelectedFeeds();
1149 if (rows
.length
== 0) {
1150 alert(__("No feeds are selected."));
1154 if (rows
.length
> 1) {
1155 alert(__("Please select one feed."));
1165 function editSelectedFeedCat() {
1166 var rows
= getSelectedFeedCats();
1168 if (rows
.length
== 0) {
1169 alert(__("No categories are selected."));
1173 if (rows
.length
> 1) {
1174 alert(__("Please select only one category."));
1180 editFeedCat(rows
[0]);
1184 function localPiggieFunction(enable
) {
1186 debug("I LOVEDED IT!");
1187 var piggie
= document
.getElementById("piggie");
1189 Element
.show(piggie
);
1190 Position
.Center(piggie
);
1191 Effect
.Puff(piggie
);
1196 function validateOpmlImport() {
1198 var opml_file
= document
.getElementById("opml_file");
1200 if (opml_file
.value
.length
== 0) {
1201 alert(__("No OPML file to upload."));
1208 function updateFilterList(sort_key
) {
1210 if (!xmlhttp_ready(xmlhttp
)) {
1211 printLockingError();
1215 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1216 param_escape(sort_key
), true);
1217 xmlhttp
.onreadystatechange
=filterlist_callback
;
1222 function updateLabelList(sort_key
) {
1224 if (!xmlhttp_ready(xmlhttp
)) {
1225 printLockingError();
1229 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1230 param_escape(sort_key
), true);
1231 xmlhttp
.onreadystatechange
=labellist_callback
;
1235 function updatePrefsList() {
1237 if (!xmlhttp_ready(xmlhttp
)) {
1238 printLockingError();
1242 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1243 xmlhttp
.onreadystatechange
=prefslist_callback
;
1248 function selectTab(id
, noupdate
, subop
) {
1252 if (!id
) id
= active_tab
;
1256 if (!xmlhttp_ready(xmlhttp
)) {
1257 printLockingError();
1262 var c
= document
.getElementById('prefContent');
1268 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1270 notify_progress("Loading, please wait...");
1272 // close active infobox if needed
1275 // clean up all current selections, just in case
1276 active_feed_cat
= false;
1277 active_label
= false;
1279 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1280 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1282 if (id
== "feedConfig") {
1284 } else if (id
== "filterConfig") {
1286 } else if (id
== "labelConfig") {
1288 } else if (id
== "genConfig") {
1290 } else if (id
== "userConfig") {
1292 } else if (id
== "feedBrowser") {
1293 updateBigFeedBrowser();
1297 var tab
= document
.getElementById(active_tab
+ "Tab");
1300 if (tab
.className
.match("Selected")) {
1301 tab
.className
= "prefsTab";
1305 tab
= document
.getElementById(id
+ "Tab");
1308 if (!tab
.className
.match("Selected")) {
1309 tab
.className
= tab
.className
+ "Selected";
1316 exception_error("selectTab", e
);
1320 function backend_sanity_check_callback() {
1322 if (xmlhttp
.readyState
== 4) {
1326 if (sanity_check_done
) {
1327 fatalError(11, "Sanity check request received twice. This can indicate "+
1328 "presence of Firebug or some other disrupting extension. "+
1329 "Please disable it and try again.");
1333 if (!xmlhttp
.responseXML
) {
1334 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1338 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1341 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1345 var error_code
= reply
.getAttribute("error-code");
1347 if (error_code
&& error_code
!= 0) {
1348 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1351 debug("sanity check ok");
1353 var params
= reply
.nextSibling
;
1356 debug('reading init-params...');
1357 var param
= params
.firstChild
;
1360 var k
= param
.getAttribute("key");
1361 var v
= param
.getAttribute("value");
1362 debug(k
+ " => " + v
);
1364 param
= param
.nextSibling
;
1368 sanity_check_done
= true;
1370 init_second_stage();
1373 exception_error("backend_sanity_check_callback", e
);
1378 function init_second_stage() {
1381 active_tab
= getInitParam("prefs_active_tab");
1382 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1384 document
.onkeydown
= pref_hotkey_handler
;
1386 var tab
= getURLParam('tab');
1388 caller_subop
= getURLParam('subop');
1394 if (navigator
.userAgent
.match("Opera")) {
1395 setTimeout("selectTab()", 500);
1397 selectTab(active_tab
);
1401 exception_error("init_second_stage", e
);
1409 if (arguments
.callee
.done
) return;
1410 arguments
.callee
.done
= true;
1412 if (getURLParam('debug')) {
1413 document
.getElementById('debug_output').style
.display
= 'block';
1414 debug('debug mode activated');
1419 document
.getElementById("prefContent").innerHTML
=
1420 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1421 "to function properly. Your browser doesn't seem to support it.";
1425 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1426 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1430 exception_error("init", e
);
1434 function categorizeSelectedFeeds() {
1436 if (!xmlhttp_ready(xmlhttp
)) {
1437 printLockingError();
1441 var sel_rows
= getSelectedFeeds();
1443 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1444 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1446 if (sel_rows
.length
> 0) {
1448 notify_progress("Changing category of selected feeds...");
1450 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1451 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1452 xmlhttp
.onreadystatechange
=feedlist_callback
;
1457 alert(__("No feeds are selected."));
1463 function validatePrefsReset() {
1465 var ok
= confirm(__("Reset to defaults?"));
1469 var query
= Form
.serialize("pref_prefs_form");
1470 query
= query
+ "&subop=reset-config";
1473 xmlhttp
.open("POST", "backend.php", true);
1474 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1475 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1476 xmlhttp
.send(query
);
1480 exception_error("validatePrefsSave", e
);
1487 function browseFeeds(limit
) {
1489 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1490 xmlhttp
.onreadystatechange
=infobox_callback
;
1495 function feedBrowserSubscribe() {
1498 var selected
= getSelectedFeedsFromBrowser();
1500 if (selected
.length
> 0) {
1502 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1503 param_escape(selected
.toString()), true);
1504 xmlhttp
.onreadystatechange
=feedlist_callback
;
1507 alert(__("No feeds are selected."));
1511 exception_error("feedBrowserSubscribe", e
);
1515 function updateBigFeedBrowser(limit
) {
1517 if (!xmlhttp_ready(xmlhttp
)) {
1518 printLockingError();
1522 var query
= "backend.php?op=pref-feed-browser";
1524 var limit_sel
= document
.getElementById("feedBrowserLimit");
1527 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1528 query
= query
+ "&limit=" + param_escape(limit
);
1531 xmlhttp
.open("GET", query
, true);
1532 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1536 function browserToggleExpand(id
) {
1538 /* if (feed_to_expand && feed_to_expand != id) {
1539 var d = document.getElementById("BRDET-" + feed_to_expand);
1540 d.style.display = "none";
1543 if (!xmlhttp_ready(xmlhttp
)) {
1544 printLockingError();
1548 /* if (feed_to_expand && id != feed_to_expand) {
1549 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1552 var d
= document
.getElementById("BRDET-" + id
);
1554 if (Element
.visible(d
)) {
1555 Effect
.Fade(d
, {duration
: 0.5});
1557 feed_to_expand
= id
;
1559 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1560 + param_escape(id
), true);
1561 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1566 exception_error("browserToggleExpand", e
);
1570 function selectPrefRows(kind
, select
) {
1573 var opbarid
= false;
1578 if (kind
== "feed") {
1579 opbarid
= "feedOpToolbar";
1582 lname
= "prefFeedList";
1583 } else if (kind
== "fcat") {
1584 opbarid
= "catOpToolbar";
1587 lname
= "prefFeedCatList";
1588 } else if (kind
== "filter") {
1589 opbarid
= "filterOpToolbar";
1592 lname
= "prefFilterList";
1593 } else if (kind
== "label") {
1594 opbarid
= "labelOpToolbar";
1597 lname
= "prefLabelList";
1598 } else if (kind
== "user") {
1599 opbarid
= "userOpToolbar";
1602 lname
= "prefUserList";
1606 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1607 disableContainerChildren(opbarid
, !select
);
1614 function toggleSelectPrefRow(sender
, kind
) {
1616 toggleSelectRow(sender
);
1619 var opbarid
= false;
1622 if (kind
== "feed") {
1623 opbarid
= "feedOpToolbar";
1624 nsel
= getSelectedFeeds();
1625 } else if (kind
== "fcat") {
1626 opbarid
= "catOpToolbar";
1627 nsel
= getSelectedFeedCats();
1628 } else if (kind
== "filter") {
1629 opbarid
= "filterOpToolbar";
1630 nsel
= getSelectedFilters();
1631 } else if (kind
== "label") {
1632 opbarid
= "labelOpToolbar";
1633 nsel
= getSelectedLabels();
1634 } else if (kind
== "user") {
1635 opbarid
= "userOpToolbar";
1636 nsel
= getSelectedUsers();
1639 if (opbarid
&& nsel
!= -1) {
1640 disableContainerChildren(opbarid
, nsel
== false);
1646 function toggleSelectFBListRow(sender
) {
1647 toggleSelectListRow(sender
);
1648 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1653 function pref_hotkey_handler(e
) {
1657 var shift_key
= false;
1660 shift_key
= e
.shiftKey
;
1666 keycode
= window
.event
.keyCode
;
1671 if (keycode
== 27) { // escape
1672 if (Element
.visible("hotkey_help_overlay")) {
1673 Element
.hide("hotkey_help_overlay");
1675 hotkey_prefix
= false;
1679 if (!hotkeys_enabled
) {
1680 debug("hotkeys disabled");
1684 if (keycode
== 16) return; // ignore lone shift
1686 if (Element
.visible("hotkey_help_overlay")) {
1687 Element
.hide("hotkey_help_overlay");
1690 if (keycode
== 13 || keycode
== 27) {
1693 seq
= seq
+ "" + keycode
;
1696 /* Global hotkeys */
1698 if (!hotkey_prefix
) {
1700 if (keycode
== 68 && shift_key
) { // d
1701 if (!debug_mode_enabled
) {
1702 document
.getElementById('debug_output').style
.display
= 'block';
1703 debug('debug mode activated');
1705 document
.getElementById('debug_output').style
.display
= 'none';
1708 debug_mode_enabled
= !debug_mode_enabled
;
1712 if (keycode
== 191 && shift_key
) { // ?
1713 if (!Element
.visible("hotkey_help_overlay")) {
1714 Element
.show("hotkey_help_overlay");
1716 Element
.hide("hotkey_help_overlay");
1721 if (keycode
== 49) { // 1
1722 selectTab("genConfig");
1725 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1726 return selectTab("feedConfig");
1729 if (keycode
== 51 && document
.getElementById("feedBrowserTab")) { // 3
1730 return selectTab("feedBrowser");
1733 if (keycode
== 52 && document
.getElementById("filterConfigTab")) { // 4
1734 return selectTab("filterConfig");
1737 if (keycode
== 53 && document
.getElementById("labelConfigTab")) { // 5
1738 return selectTab("labelConfig");
1741 if (keycode
== 54 && document
.getElementById("userConfigTab")) { // 6
1742 return selectTab("userConfig");
1747 if (document
.getElementById("piggie")) {
1749 if (seq
.match("807371717369")) {
1751 localPiggieFunction(true);
1753 localPiggieFunction(false);
1757 if (hotkey_prefix
) {
1758 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
);
1760 debug("KP: CODE=" + keycode
);
1764 exception_error("pref_hotkey_handler", e
);
1768 function editFeedCats() {
1769 if (!xmlhttp_ready(xmlhttp
)) {
1770 printLockingError();
1774 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1777 document
.getElementById("top25_feeds_btn").disabled
= true;
1779 // this button is not always available, no-op if not found
1782 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1783 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1787 function showFeedsWithErrors() {
1788 displayDlg('feedUpdateErrors');
1791 function changeUserPassword() {
1795 if (!xmlhttp_ready(xmlhttp
)) {
1796 printLockingError();
1800 var f
= document
.forms
["change_pass_form"];
1803 if (f
.OLD_PASSWORD
.value
== "") {
1804 new Effect
.Highlight(f
.OLD_PASSWORD
);
1805 notify_error("Old password cannot be blank.");
1809 if (f
.NEW_PASSWORD
.value
== "") {
1810 new Effect
.Highlight(f
.NEW_PASSWORD
);
1811 notify_error("New password cannot be blank.");
1815 if (f
.CONFIRM_PASSWORD
.value
== "") {
1816 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1817 notify_error("Entered passwords do not match.");
1821 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1822 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1823 new Effect
.Highlight(f
.NEW_PASSWORD
);
1824 notify_error("Entered passwords do not match.");
1830 var query
= Form
.serialize("change_pass_form");
1832 notify_progress("Trying to change password...");
1834 xmlhttp
.open("POST", "backend.php", true);
1835 xmlhttp
.onreadystatechange
=changepass_callback
;
1836 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1837 xmlhttp
.send(query
);
1840 exception_error("changeUserPassword", e
);
1846 function changeUserEmail() {
1850 if (!xmlhttp_ready(xmlhttp
)) {
1851 printLockingError();
1855 var query
= Form
.serialize("change_email_form");
1857 notify_progress("Trying to change e-mail...");
1859 xmlhttp
.open("POST", "backend.php", true);
1860 xmlhttp
.onreadystatechange
=notify_callback
;
1861 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1862 xmlhttp
.send(query
);
1865 exception_error("changeUserPassword", e
);
1872 function feedlistToggleSLAT() {
1873 notify_progress("Loading, please wait...");
1877 function pubRegenKey() {
1879 if (!xmlhttp_ready(xmlhttp
)) {
1880 printLockingError();
1884 var ok
= confirm(__("Replace current publishing address with a new one?"));
1888 notify_progress("Trying to change address...");
1890 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1891 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1898 function pubToClipboard() {
1902 if (!xmlhttp_ready(xmlhttp
)) {
1903 printLockingError();
1907 var link
= document
.getElementById("pubGenAddress");
1911 exception_error("pubToClipboard", e
);
1917 function validatePrefsSave() {
1920 var ok
= confirm(__("Save current configuration?"));
1924 var query
= Form
.serialize("pref_prefs_form");
1925 query
= query
+ "&subop=save-config";
1928 xmlhttp
.open("POST", "backend.php", true);
1929 xmlhttp
.onreadystatechange
=notify_callback
;
1930 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1931 xmlhttp
.send(query
);
1935 exception_error("validatePrefsSave", e
);
1941 function feedActionChange() {
1943 var chooser
= document
.getElementById("feedActionChooser");
1944 var opid
= chooser
[chooser
.selectedIndex
].value
;
1946 chooser
.selectedIndex
= 0;
1949 exception_error("feedActionChange", e
);
1953 function feedActionGo(op
) {
1955 if (op
== "facEdit") {
1959 if (op
== "facClear") {
1960 clearSelectedFeeds();
1963 if (op
== "facPurge") {
1964 purgeSelectedFeeds();
1967 if (op
== "facEditCats") {
1971 if (op
== "facRescore") {
1972 rescoreSelectedFeeds();
1975 if (op
== "facUnsubscribe") {
1976 removeSelectedFeeds();
1980 exception_error("feedActionGo", e
);
1985 function clearFeedArticles(feed_id
) {
1987 notify_progress("Clearing feed...");
1989 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
1991 new Ajax
.Request(query
, {
1992 onComplete: function(transport
) {
1999 function rescoreSelectedFeeds() {
2001 if (!xmlhttp_ready(xmlhttp
)) {
2002 printLockingError();
2006 var sel_rows
= getSelectedFeeds();
2008 if (sel_rows
.length
> 0) {
2010 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2011 var ok
= confirm(__("Rescore articles in selected feeds?"));
2014 notify_progress("Rescoring selected feeds...");
2016 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2017 param_escape(sel_rows
.toString()), true);
2018 xmlhttp
.onreadystatechange
=notify_callback
;
2022 alert(__("No feeds are selected."));
2028 function rescore_all_feeds() {
2029 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
2032 notify_progress("Rescoring feeds...");
2034 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2035 xmlhttp
.onreadystatechange
=notify_callback
;