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 // we can be called from some other tab
320 active_tab
= "labelConfig";
322 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
323 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
329 if (!xmlhttp_ready(xmlhttp
)) {
334 var link
= document
.getElementById("fadd_link");
336 if (link
.value
.length
== 0) {
337 alert(__("Error: No feed URL given."));
338 } else if (!isValidURL(link
.value
)) {
339 alert(__("Error: Invalid feed URL."));
341 notify_progress("Adding feed...");
343 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
344 param_escape(link
.value
), true);
345 xmlhttp
.onreadystatechange
=feedlist_callback
;
354 function addFeedCat() {
356 if (!xmlhttp_ready(xmlhttp
)) {
361 var cat
= document
.getElementById("fadd_cat");
363 if (cat
.value
.length
== 0) {
364 alert(__("Can't add category: no name specified."));
366 notify_progress("Adding feed category...");
368 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
369 param_escape(cat
.value
), true);
370 xmlhttp
.onreadystatechange
=infobox_callback
;
380 if (!xmlhttp_ready(xmlhttp
)) {
385 var sqlexp
= document
.getElementById("uadd_box");
387 if (sqlexp
.value
.length
== 0) {
388 alert(__("Can't add user: no login specified."));
390 notify_progress("Adding user...");
392 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
393 param_escape(sqlexp
.value
), true);
395 xmlhttp
.onreadystatechange
=userlist_callback
;
403 function editLabel(id
) {
405 if (!xmlhttp_ready(xmlhttp
)) {
412 notify_progress("Loading, please wait...");
414 document
.getElementById("label_create_btn").disabled
= true;
418 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
419 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
421 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
422 param_escape(id
), true);
423 xmlhttp
.onreadystatechange
=infobox_callback
;
428 function editUser(id
) {
430 if (!xmlhttp_ready(xmlhttp
)) {
437 notify_progress("Loading, please wait...");
439 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
440 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
442 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
443 param_escape(id
), true);
444 xmlhttp
.onreadystatechange
=infobox_callback
;
449 function editFilter(id
) {
451 if (!xmlhttp_ready(xmlhttp
)) {
458 notify_progress("Loading, please wait...");
460 document
.getElementById("create_filter_btn").disabled
= true;
462 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
463 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
465 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
466 xmlhttp
.onreadystatechange
=infobox_callback
;
470 function editFeed(feed
) {
472 // notify("Editing feed...");
474 if (!xmlhttp_ready(xmlhttp
)) {
481 notify_progress("Loading, please wait...");
483 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
486 document
.getElementById("top25_feeds_btn").disabled
= true;
488 // this button is not always available, no-op if not found
491 // clean selection from all rows & select row being edited
492 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
493 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
495 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
496 param_escape(feed
), true);
498 xmlhttp
.onreadystatechange
=infobox_callback
;
503 function editFeedCat(cat
) {
505 if (!xmlhttp_ready(xmlhttp
)) {
512 notify_progress("Loading, please wait...");
514 active_feed_cat
= cat
;
516 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
517 param_escape(cat
), true);
518 xmlhttp
.onreadystatechange
=infobox_callback
;
523 function getSelectedLabels() {
524 return getSelectedTableRowIds("prefLabelList", "LILRR");
527 function getSelectedUsers() {
528 return getSelectedTableRowIds("prefUserList", "UMRR");
531 function getSelectedFeeds() {
532 return getSelectedTableRowIds("prefFeedList", "FEEDR");
535 function getSelectedFilters() {
536 return getSelectedTableRowIds("prefFilterList", "FILRR");
539 function getSelectedFeedCats() {
540 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
543 function getSelectedFeedsFromBrowser() {
545 var list
= document
.getElementById("browseFeedList");
546 if (!list
) list
= document
.getElementById("browseBigFeedList");
548 var selected
= new Array();
550 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
551 var child
= list
.childNodes
[i
];
552 if (child
.id
&& child
.id
.match("FBROW-")) {
553 var id
= child
.id
.replace("FBROW-", "");
555 var cb
= document
.getElementById("FBCHK-" + id
);
566 function removeSelectedLabels() {
568 if (!xmlhttp_ready(xmlhttp
)) {
573 var sel_rows
= getSelectedLabels();
575 if (sel_rows
.length
> 0) {
577 var ok
= confirm(__("Remove selected labels?"));
580 notify_progress("Removing selected labels...");
582 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
583 param_escape(sel_rows
.toString()), true);
584 xmlhttp
.onreadystatechange
=labellist_callback
;
588 alert(__("No labels are selected."));
594 function removeSelectedUsers() {
596 if (!xmlhttp_ready(xmlhttp
)) {
601 var sel_rows
= getSelectedUsers();
603 if (sel_rows
.length
> 0) {
605 var ok
= confirm(__("Remove selected users?"));
608 notify_progress("Removing selected users...");
610 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
611 param_escape(sel_rows
.toString()), true);
612 xmlhttp
.onreadystatechange
=userlist_callback
;
617 alert(__("No users are selected."));
623 function removeSelectedFilters() {
625 if (!xmlhttp_ready(xmlhttp
)) {
630 var sel_rows
= getSelectedFilters();
632 if (sel_rows
.length
> 0) {
634 var ok
= confirm(__("Remove selected filters?"));
637 notify_progress("Removing selected filters...");
639 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
640 param_escape(sel_rows
.toString()), true);
641 xmlhttp
.onreadystatechange
=filterlist_callback
;
645 alert(__("No filters are selected."));
652 function removeSelectedFeeds() {
654 if (!xmlhttp_ready(xmlhttp
)) {
659 var sel_rows
= getSelectedFeeds();
661 if (sel_rows
.length
> 0) {
663 var ok
= confirm(__("Unsubscribe from selected feeds?"));
667 notify_progress("Unsubscribing from selected feeds...");
669 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
670 param_escape(sel_rows
.toString()), true);
671 xmlhttp
.onreadystatechange
=feedlist_callback
;
677 alert(__("No feeds are selected."));
684 function clearSelectedFeeds() {
686 if (!xmlhttp_ready(xmlhttp
)) {
691 var sel_rows
= getSelectedFeeds();
693 if (sel_rows
.length
> 1) {
694 alert(__("Please select only one feed."));
698 if (sel_rows
.length
> 0) {
700 var ok
= confirm(__("Erase all non-starred articles in selected feed?"));
703 notify_progress("Clearing selected feed...");
704 clearFeedArticles(sel_rows
[0]);
709 alert(__("No feeds are selected."));
716 function purgeSelectedFeeds() {
718 if (!xmlhttp_ready(xmlhttp
)) {
723 var sel_rows
= getSelectedFeeds();
725 if (sel_rows
.length
> 0) {
727 var pr
= prompt(__("How many days of articles to keep (0 - use default)?"), "0");
729 if (pr
!= undefined) {
730 notify_progress("Purging selected feed...");
732 var query
= "backend.php?op=rpc&subop=purge&ids="+
733 param_escape(sel_rows
.toString()) + "&days=" + pr
;
737 new Ajax
.Request(query
, {
738 onComplete: function(transport
) {
745 alert(__("No feeds are selected."));
752 function removeSelectedFeedCats() {
754 if (!xmlhttp_ready(xmlhttp
)) {
759 var sel_rows
= getSelectedFeedCats();
761 if (sel_rows
.length
> 0) {
763 var ok
= confirm(__("Remove selected categories?"));
766 notify_progress("Removing selected categories...");
768 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
769 param_escape(sel_rows
.toString()), true);
770 xmlhttp
.onreadystatechange
=infobox_callback
;
776 alert(__("No categories are selected."));
783 function feedEditCancel() {
785 if (!xmlhttp_ready(xmlhttp
)) {
791 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
792 document
.getElementById("top25_feeds_btn").disabled
= false;
794 // this button is not always available, no-op if not found
799 selectPrefRows('feed', false); // cleanup feed selection
804 function feedCatEditCancel() {
806 if (!xmlhttp_ready(xmlhttp
)) {
811 active_feed_cat
= false;
813 // notify("Operation cancelled.");
815 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
816 xmlhttp
.onreadystatechange
=infobox_callback
;
822 function feedEditSave() {
826 if (!xmlhttp_ready(xmlhttp
)) {
831 // FIXME: add parameter validation
833 var query
= Form
.serialize("edit_feed_form");
835 notify_progress("Saving feed...");
837 xmlhttp
.open("POST", "backend.php", true);
838 xmlhttp
.onreadystatechange
=feedlist_callback
;
839 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
847 exception_error("feedEditSave", e
);
851 function feedCatEditSave() {
853 if (!xmlhttp_ready(xmlhttp
)) {
858 notify_progress("Saving category...");
860 var query
= Form
.serialize("feed_cat_edit_form");
862 xmlhttp
.open("GET", "backend.php?" + query
, true);
863 xmlhttp
.onreadystatechange
=infobox_callback
;
866 active_feed_cat
= false;
871 function labelEditCancel() {
873 if (!xmlhttp_ready(xmlhttp
)) {
879 document
.getElementById("label_create_btn").disabled
= false;
880 selectPrefRows('label', false); // cleanup feed selection
883 active_label
= false;
890 function userEditCancel() {
892 if (!xmlhttp_ready(xmlhttp
)) {
897 selectPrefRows('user', false); // cleanup feed selection
903 function filterEditCancel() {
905 if (!xmlhttp_ready(xmlhttp
)) {
911 document
.getElementById("create_filter_btn").disabled
= false;
912 selectPrefRows('filter', false); // cleanup feed selection
920 function labelEditSave() {
922 var label
= active_label
;
924 if (!xmlhttp_ready(xmlhttp
)) {
929 /* if (!is_opera()) {
931 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
932 var description = document.forms["label_edit_form"].description.value;
934 if (sql_exp.length == 0) {
935 alert("SQL Expression cannot be blank.");
939 if (description.length == 0) {
940 alert("Caption field cannot be blank.");
947 notify_progress("Saving label...");
949 active_label
= false;
951 query
= Form
.serialize("label_edit_form");
953 xmlhttp
.open("GET", "backend.php?" + query
, true);
954 xmlhttp
.onreadystatechange
=labellist_callback
;
960 function userEditSave() {
962 if (!xmlhttp_ready(xmlhttp
)) {
967 var login
= document
.forms
["user_edit_form"].login
.value
;
969 if (login
.length
== 0) {
970 alert(__("Login field cannot be blank."));
974 notify_progress("Saving user...");
978 var query
= Form
.serialize("user_edit_form");
980 xmlhttp
.open("GET", "backend.php?" + query
, true);
981 xmlhttp
.onreadystatechange
=userlist_callback
;
988 function filterEditSave() {
990 if (!xmlhttp_ready(xmlhttp
)) {
995 /* if (!is_opera()) {
996 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
998 if (reg_exp.length == 0) {
999 alert("Filter expression field cannot be blank.");
1004 notify_progress("Saving filter...");
1006 var query
= Form
.serialize("filter_edit_form");
1010 document
.getElementById("create_filter_btn").disabled
= false;
1012 xmlhttp
.open("GET", "backend.php?" + query
, true);
1013 xmlhttp
.onreadystatechange
=filterlist_callback
;
1019 function editSelectedLabel() {
1020 var rows
= getSelectedLabels();
1022 if (rows
.length
== 0) {
1023 alert(__("No labels are selected."));
1027 if (rows
.length
> 1) {
1028 alert(__("Please select only one label."));
1038 function editSelectedUser() {
1039 var rows
= getSelectedUsers();
1041 if (rows
.length
== 0) {
1042 alert(__("No users are selected."));
1046 if (rows
.length
> 1) {
1047 alert(__("Please select only one user."));
1056 function resetSelectedUserPass() {
1057 var rows
= getSelectedUsers();
1059 if (rows
.length
== 0) {
1060 alert(__("No users are selected."));
1064 if (rows
.length
> 1) {
1065 alert(__("Please select only one user."));
1069 var ok
= confirm(__("Reset password of selected user?"));
1072 notify_progress("Resetting password for selected user...");
1076 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1077 param_escape(id
), true);
1078 xmlhttp
.onreadystatechange
=userlist_callback
;
1083 function selectedUserDetails() {
1085 if (!xmlhttp_ready(xmlhttp
)) {
1086 printLockingError();
1090 var rows
= getSelectedUsers();
1092 if (rows
.length
== 0) {
1093 alert(__("No users are selected."));
1097 if (rows
.length
> 1) {
1098 alert(__("Please select only one user."));
1102 notify_progress("Loading, please wait...");
1106 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1107 xmlhttp
.onreadystatechange
=infobox_callback
;
1112 function selectedFeedDetails() {
1114 if (!xmlhttp_ready(xmlhttp
)) {
1115 printLockingError();
1119 var rows
= getSelectedFeeds();
1121 if (rows
.length
== 0) {
1122 alert(__("No feeds are selected."));
1126 if (rows
.length
> 1) {
1127 alert(__("Please select only one feed."));
1131 // var id = rows[0];
1135 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1136 param_escape(rows
.toString()), true);
1137 xmlhttp
.onreadystatechange
=infobox_callback
;
1142 function editSelectedFilter() {
1143 var rows
= getSelectedFilters();
1145 if (rows
.length
== 0) {
1146 alert(__("No filters are selected."));
1150 if (rows
.length
> 1) {
1151 alert(__("Please select only one filter."));
1157 editFilter(rows
[0]);
1162 function editSelectedFeed() {
1163 var rows
= getSelectedFeeds();
1165 if (rows
.length
== 0) {
1166 alert(__("No feeds are selected."));
1170 if (rows
.length
> 1) {
1171 alert(__("Please select one feed."));
1181 function editSelectedFeedCat() {
1182 var rows
= getSelectedFeedCats();
1184 if (rows
.length
== 0) {
1185 alert(__("No categories are selected."));
1189 if (rows
.length
> 1) {
1190 alert(__("Please select only one category."));
1196 editFeedCat(rows
[0]);
1200 function localPiggieFunction(enable
) {
1202 debug("I LOVEDED IT!");
1203 var piggie
= document
.getElementById("piggie");
1205 Element
.show(piggie
);
1206 Position
.Center(piggie
);
1207 Effect
.Puff(piggie
);
1212 function validateOpmlImport() {
1214 var opml_file
= document
.getElementById("opml_file");
1216 if (opml_file
.value
.length
== 0) {
1217 alert(__("No OPML file to upload."));
1224 function updateFilterList(sort_key
) {
1226 if (!xmlhttp_ready(xmlhttp
)) {
1227 printLockingError();
1231 var filter_search
= document
.getElementById("filter_search");
1233 if (filter_search
) { search
= filter_search
.value
; }
1235 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1236 param_escape(sort_key
) +
1237 "&search=" + param_escape(search
), true);
1238 xmlhttp
.onreadystatechange
=filterlist_callback
;
1243 function updateLabelList(sort_key
) {
1245 if (!xmlhttp_ready(xmlhttp
)) {
1246 printLockingError();
1250 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1251 param_escape(sort_key
), true);
1252 xmlhttp
.onreadystatechange
=labellist_callback
;
1256 function updatePrefsList() {
1258 if (!xmlhttp_ready(xmlhttp
)) {
1259 printLockingError();
1263 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1264 xmlhttp
.onreadystatechange
=prefslist_callback
;
1269 function selectTab(id
, noupdate
, subop
) {
1273 if (!id
) id
= active_tab
;
1277 if (!xmlhttp_ready(xmlhttp
)) {
1278 printLockingError();
1283 var c
= document
.getElementById('prefContent');
1289 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1291 notify_progress("Loading, please wait...");
1293 // close active infobox if needed
1296 // clean up all current selections, just in case
1297 active_feed_cat
= false;
1298 active_label
= false;
1300 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1301 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1303 if (id
== "feedConfig") {
1305 } else if (id
== "filterConfig") {
1307 } else if (id
== "labelConfig") {
1309 } else if (id
== "genConfig") {
1311 } else if (id
== "userConfig") {
1313 } else if (id
== "feedBrowser") {
1314 updateBigFeedBrowser();
1318 /* clean selection from all tabs */
1320 var tabs_holder
= document
.getElementById("prefTabs");
1321 var tab
= tabs_holder
.firstChild
;
1324 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1325 tab
.className
= "prefsTab";
1327 tab
= tab
.nextSibling
;
1330 /* mark new tab as selected */
1332 tab
= document
.getElementById(id
+ "Tab");
1335 if (!tab
.className
.match("Selected")) {
1336 tab
.className
= tab
.className
+ "Selected";
1343 exception_error("selectTab", e
);
1347 function backend_sanity_check_callback() {
1349 if (xmlhttp
.readyState
== 4) {
1353 if (sanity_check_done
) {
1354 fatalError(11, "Sanity check request received twice. This can indicate "+
1355 "presence of Firebug or some other disrupting extension. "+
1356 "Please disable it and try again.");
1360 if (!xmlhttp
.responseXML
) {
1361 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1365 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1368 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1372 var error_code
= reply
.getAttribute("error-code");
1374 if (error_code
&& error_code
!= 0) {
1375 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1378 debug("sanity check ok");
1380 var params
= reply
.nextSibling
;
1383 debug('reading init-params...');
1384 var param
= params
.firstChild
;
1387 var k
= param
.getAttribute("key");
1388 var v
= param
.getAttribute("value");
1389 debug(k
+ " => " + v
);
1391 param
= param
.nextSibling
;
1395 sanity_check_done
= true;
1397 init_second_stage();
1400 exception_error("backend_sanity_check_callback", e
);
1405 function init_second_stage() {
1408 active_tab
= getInitParam("prefs_active_tab");
1409 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1411 document
.onkeydown
= pref_hotkey_handler
;
1413 var tab
= getURLParam('tab');
1415 caller_subop
= getURLParam('subop');
1421 if (navigator
.userAgent
.match("Opera")) {
1422 setTimeout("selectTab()", 500);
1424 selectTab(active_tab
);
1428 exception_error("init_second_stage", e
);
1436 if (arguments
.callee
.done
) return;
1437 arguments
.callee
.done
= true;
1439 if (getURLParam('debug')) {
1440 document
.getElementById('debug_output').style
.display
= 'block';
1441 debug('debug mode activated');
1446 document
.getElementById("prefContent").innerHTML
=
1447 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1448 "to function properly. Your browser doesn't seem to support it.";
1452 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1453 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1457 exception_error("init", e
);
1461 function categorizeSelectedFeeds() {
1463 if (!xmlhttp_ready(xmlhttp
)) {
1464 printLockingError();
1468 var sel_rows
= getSelectedFeeds();
1470 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1471 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1473 if (sel_rows
.length
> 0) {
1475 notify_progress("Changing category of selected feeds...");
1477 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1478 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1479 xmlhttp
.onreadystatechange
=feedlist_callback
;
1484 alert(__("No feeds are selected."));
1490 function validatePrefsReset() {
1492 var ok
= confirm(__("Reset to defaults?"));
1496 var query
= Form
.serialize("pref_prefs_form");
1497 query
= query
+ "&subop=reset-config";
1500 xmlhttp
.open("POST", "backend.php", true);
1501 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1502 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1503 xmlhttp
.send(query
);
1507 exception_error("validatePrefsSave", e
);
1514 function browseFeeds(limit
) {
1516 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1517 xmlhttp
.onreadystatechange
=infobox_callback
;
1522 function feedBrowserSubscribe() {
1525 var selected
= getSelectedFeedsFromBrowser();
1527 if (selected
.length
> 0) {
1529 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1530 param_escape(selected
.toString()), true);
1531 xmlhttp
.onreadystatechange
=feedlist_callback
;
1534 alert(__("No feeds are selected."));
1538 exception_error("feedBrowserSubscribe", e
);
1542 function updateBigFeedBrowser(limit
) {
1544 if (!xmlhttp_ready(xmlhttp
)) {
1545 printLockingError();
1549 var query
= "backend.php?op=pref-feed-browser";
1551 var limit_sel
= document
.getElementById("feedBrowserLimit");
1554 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1555 query
= query
+ "&limit=" + param_escape(limit
);
1558 xmlhttp
.open("GET", query
, true);
1559 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1563 function browserToggleExpand(id
) {
1565 /* if (feed_to_expand && feed_to_expand != id) {
1566 var d = document.getElementById("BRDET-" + feed_to_expand);
1567 d.style.display = "none";
1570 if (!xmlhttp_ready(xmlhttp
)) {
1571 printLockingError();
1575 /* if (feed_to_expand && id != feed_to_expand) {
1576 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1579 var d
= document
.getElementById("BRDET-" + id
);
1581 if (Element
.visible(d
)) {
1582 Effect
.Fade(d
, {duration
: 0.5});
1584 feed_to_expand
= id
;
1586 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1587 + param_escape(id
), true);
1588 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1593 exception_error("browserToggleExpand", e
);
1597 function selectPrefRows(kind
, select
) {
1600 var opbarid
= false;
1605 if (kind
== "feed") {
1606 opbarid
= "feedOpToolbar";
1609 lname
= "prefFeedList";
1610 } else if (kind
== "fcat") {
1611 opbarid
= "catOpToolbar";
1614 lname
= "prefFeedCatList";
1615 } else if (kind
== "filter") {
1616 opbarid
= "filterOpToolbar";
1619 lname
= "prefFilterList";
1620 } else if (kind
== "label") {
1621 opbarid
= "labelOpToolbar";
1624 lname
= "prefLabelList";
1625 } else if (kind
== "user") {
1626 opbarid
= "userOpToolbar";
1629 lname
= "prefUserList";
1633 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1634 disableContainerChildren(opbarid
, !select
);
1641 function toggleSelectPrefRow(sender
, kind
) {
1643 toggleSelectRow(sender
);
1646 var opbarid
= false;
1649 if (kind
== "feed") {
1650 opbarid
= "feedOpToolbar";
1651 nsel
= getSelectedFeeds();
1652 } else if (kind
== "fcat") {
1653 opbarid
= "catOpToolbar";
1654 nsel
= getSelectedFeedCats();
1655 } else if (kind
== "filter") {
1656 opbarid
= "filterOpToolbar";
1657 nsel
= getSelectedFilters();
1658 } else if (kind
== "label") {
1659 opbarid
= "labelOpToolbar";
1660 nsel
= getSelectedLabels();
1661 } else if (kind
== "user") {
1662 opbarid
= "userOpToolbar";
1663 nsel
= getSelectedUsers();
1666 if (opbarid
&& nsel
!= -1) {
1667 disableContainerChildren(opbarid
, nsel
== false);
1673 function toggleSelectFBListRow(sender
) {
1674 toggleSelectListRow(sender
);
1675 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1680 function pref_hotkey_handler(e
) {
1684 var shift_key
= false;
1687 shift_key
= e
.shiftKey
;
1693 keycode
= window
.event
.keyCode
;
1698 if (keycode
== 27) { // escape
1699 if (Element
.visible("hotkey_help_overlay")) {
1700 Element
.hide("hotkey_help_overlay");
1702 hotkey_prefix
= false;
1706 if (!hotkeys_enabled
) {
1707 debug("hotkeys disabled");
1711 if (keycode
== 16) return; // ignore lone shift
1713 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1714 hotkey_prefix
= keycode
;
1715 debug("KP: PREFIX=" + keycode
);
1719 if (Element
.visible("hotkey_help_overlay")) {
1720 Element
.hide("hotkey_help_overlay");
1723 if (keycode
== 13 || keycode
== 27) {
1726 seq
= seq
+ "" + keycode
;
1729 /* Global hotkeys */
1731 if (!hotkey_prefix
) {
1733 if (keycode
== 68 && shift_key
) { // d
1734 if (!debug_mode_enabled
) {
1735 document
.getElementById('debug_output').style
.display
= 'block';
1736 debug('debug mode activated');
1738 document
.getElementById('debug_output').style
.display
= 'none';
1741 debug_mode_enabled
= !debug_mode_enabled
;
1745 if (keycode
== 191 && shift_key
) { // ?
1746 if (!Element
.visible("hotkey_help_overlay")) {
1747 Element
.show("hotkey_help_overlay");
1749 Element
.hide("hotkey_help_overlay");
1758 if (hotkey_prefix
== 67) { // c
1759 hotkey_prefix
= false;
1761 if (keycode
== 70) { // f
1762 return displayDlg("quickAddFilter");
1765 if (keycode
== 83) { // s
1766 return displayDlg("quickAddFeed");
1769 if (keycode
== 76) { // l
1770 return displayDlg("quickAddLabel");
1773 if (keycode
== 85) { // u
1777 if (keycode
== 67) { // c
1778 return editFeedCats();
1781 if (keycode
== 84 && shift_key
) { // T
1782 return browseFeeds();
1785 if (keycode
== 69) { // e
1786 return editCurrentEntryDispatcher();
1793 if (hotkey_prefix
== 71) { // g
1795 hotkey_prefix
= false;
1797 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1798 selectTab("genConfig");
1801 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1802 return selectTab("feedConfig");
1805 if (keycode
== 51 && document
.getElementById("feedBrowserTab")) { // 3
1806 return selectTab("feedBrowser");
1809 if (keycode
== 52 && document
.getElementById("filterConfigTab")) { // 4
1810 return selectTab("filterConfig");
1813 if (keycode
== 53 && document
.getElementById("labelConfigTab")) { // 5
1814 return selectTab("labelConfig");
1817 if (keycode
== 54 && document
.getElementById("userConfigTab")) { // 6
1818 return selectTab("userConfig");
1821 if (keycode
== 88) { // x
1827 if (document
.getElementById("piggie")) {
1829 if (seq
.match("807371717369")) {
1831 localPiggieFunction(true);
1833 localPiggieFunction(false);
1837 if (hotkey_prefix
) {
1838 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
);
1840 debug("KP: CODE=" + keycode
);
1844 exception_error("pref_hotkey_handler", e
);
1848 function editFeedCats() {
1849 if (!xmlhttp_ready(xmlhttp
)) {
1850 printLockingError();
1854 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1857 document
.getElementById("top25_feeds_btn").disabled
= true;
1859 // this button is not always available, no-op if not found
1862 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1863 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1867 function showFeedsWithErrors() {
1868 displayDlg('feedUpdateErrors');
1871 function changeUserPassword() {
1875 if (!xmlhttp_ready(xmlhttp
)) {
1876 printLockingError();
1880 var f
= document
.forms
["change_pass_form"];
1883 if (f
.OLD_PASSWORD
.value
== "") {
1884 new Effect
.Highlight(f
.OLD_PASSWORD
);
1885 notify_error("Old password cannot be blank.");
1889 if (f
.NEW_PASSWORD
.value
== "") {
1890 new Effect
.Highlight(f
.NEW_PASSWORD
);
1891 notify_error("New password cannot be blank.");
1895 if (f
.CONFIRM_PASSWORD
.value
== "") {
1896 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1897 notify_error("Entered passwords do not match.");
1901 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1902 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1903 new Effect
.Highlight(f
.NEW_PASSWORD
);
1904 notify_error("Entered passwords do not match.");
1910 var query
= Form
.serialize("change_pass_form");
1912 notify_progress("Trying to change password...");
1914 xmlhttp
.open("POST", "backend.php", true);
1915 xmlhttp
.onreadystatechange
=changepass_callback
;
1916 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1917 xmlhttp
.send(query
);
1920 exception_error("changeUserPassword", e
);
1926 function changeUserEmail() {
1930 if (!xmlhttp_ready(xmlhttp
)) {
1931 printLockingError();
1935 var query
= Form
.serialize("change_email_form");
1937 notify_progress("Trying to change e-mail...");
1939 xmlhttp
.open("POST", "backend.php", true);
1940 xmlhttp
.onreadystatechange
=notify_callback
;
1941 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1942 xmlhttp
.send(query
);
1945 exception_error("changeUserPassword", e
);
1952 function feedlistToggleSLAT() {
1953 notify_progress("Loading, please wait...");
1957 function pubRegenKey() {
1959 if (!xmlhttp_ready(xmlhttp
)) {
1960 printLockingError();
1964 var ok
= confirm(__("Replace current publishing address with a new one?"));
1968 notify_progress("Trying to change address...");
1970 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1971 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1978 function pubToClipboard() {
1982 if (!xmlhttp_ready(xmlhttp
)) {
1983 printLockingError();
1987 var link
= document
.getElementById("pubGenAddress");
1991 exception_error("pubToClipboard", e
);
1997 function validatePrefsSave() {
2000 var ok
= confirm(__("Save current configuration?"));
2004 var query
= Form
.serialize("pref_prefs_form");
2005 query
= query
+ "&subop=save-config";
2008 xmlhttp
.open("POST", "backend.php", true);
2009 xmlhttp
.onreadystatechange
=notify_callback
;
2010 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2011 xmlhttp
.send(query
);
2015 exception_error("validatePrefsSave", e
);
2021 function feedActionChange() {
2023 var chooser
= document
.getElementById("feedActionChooser");
2024 var opid
= chooser
[chooser
.selectedIndex
].value
;
2026 chooser
.selectedIndex
= 0;
2029 exception_error("feedActionChange", e
);
2033 function feedActionGo(op
) {
2035 if (op
== "facEdit") {
2039 if (op
== "facClear") {
2040 clearSelectedFeeds();
2043 if (op
== "facPurge") {
2044 purgeSelectedFeeds();
2047 if (op
== "facEditCats") {
2051 if (op
== "facRescore") {
2052 rescoreSelectedFeeds();
2055 if (op
== "facUnsubscribe") {
2056 removeSelectedFeeds();
2060 exception_error("feedActionGo", e
);
2065 function clearFeedArticles(feed_id
) {
2067 notify_progress("Clearing feed...");
2069 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
2071 new Ajax
.Request(query
, {
2072 onComplete: function(transport
) {
2079 function rescoreSelectedFeeds() {
2081 if (!xmlhttp_ready(xmlhttp
)) {
2082 printLockingError();
2086 var sel_rows
= getSelectedFeeds();
2088 if (sel_rows
.length
> 0) {
2090 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2091 var ok
= confirm(__("Rescore articles in selected feeds?"));
2094 notify_progress("Rescoring selected feeds...");
2096 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2097 param_escape(sel_rows
.toString()), true);
2098 xmlhttp
.onreadystatechange
=notify_callback
;
2102 alert(__("No feeds are selected."));
2108 function rescore_all_feeds() {
2109 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
2112 notify_progress("Rescoring feeds...");
2114 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2115 xmlhttp
.onreadystatechange
=notify_callback
;
2120 function editCurrentEntryDispatcher() {