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') {
93 exception_error("feedlist_callback", e
);
98 /* stub for subscription dialog */
100 function dlg_frefresh_callback(transport
) {
103 var container
= document
.getElementById('prefContent');
104 container
.innerHTML
=transport
.responseText
;
105 selectTab("feedConfig", true);
108 var tuple
= caller_subop
.split(":");
109 if (tuple
[0] == 'editFeed') {
110 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
113 caller_subop
= false;
115 if (typeof correctPNG
!= 'undefined') {
120 exception_error("feedlist_callback", e
);
125 function filterlist_callback() {
126 var container
= document
.getElementById('prefContent');
127 if (xmlhttp
.readyState
== 4) {
128 container
.innerHTML
=xmlhttp
.responseText
;
129 if (typeof correctPNG
!= 'undefined') {
137 function labellist_callback() {
141 var container
= document
.getElementById('prefContent');
142 if (xmlhttp
.readyState
== 4) {
144 container
.innerHTML
=xmlhttp
.responseText
;
146 if (document
.getElementById("prefLabelList")) {
147 var elems
= document
.getElementById("prefLabelList").getElementsByTagName("SPAN");
149 for (var i
= 0; i
< elems
.length
; i
++) {
150 if (elems
[i
].id
&& elems
[i
].id
.match("LILT-")) {
152 var id
= elems
[i
].id
.replace("LILT-", "");
153 new Ajax
.InPlaceEditor(elems
[i
],
154 'backend.php?op=pref-labels&subop=save&id=' + id
,
155 {cols
: 20, rows
: 1});
160 if (typeof correctPNG
!= 'undefined') {
168 exception_error("labellist_callback", e
);
172 function feed_browser_callback() {
173 var container
= document
.getElementById('prefContent');
174 if (xmlhttp
.readyState
== 4) {
175 container
.innerHTML
=xmlhttp
.responseText
;
181 function userlist_callback() {
182 var container
= document
.getElementById('prefContent');
183 if (xmlhttp
.readyState
== 4) {
184 container
.innerHTML
=xmlhttp
.responseText
;
190 function prefslist_callback() {
191 var container
= document
.getElementById('prefContent');
192 if (xmlhttp
.readyState
== 4) {
193 container
.innerHTML
=xmlhttp
.responseText
;
199 function gethelp_callback() {
200 var container
= document
.getElementById('prefHelpBox');
201 if (xmlhttp
.readyState
== 4) {
203 container
.innerHTML
= xmlhttp
.responseText
;
204 container
.style
.display
= "block";
209 function notify_callback() {
210 if (xmlhttp
.readyState
== 4) {
211 notify_info(xmlhttp
.responseText
);
215 function prefs_reset_callback() {
216 if (xmlhttp
.readyState
== 4) {
217 notify_info(xmlhttp
.responseText
);
223 function changepass_callback() {
225 if (xmlhttp
.readyState
== 4) {
227 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
228 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
230 notify_info(xmlhttp
.responseText
);
231 var warn
= document
.getElementById("default_pass_warning");
232 if (warn
) warn
.style
.display
= "none";
235 document
.forms
['change_pass_form'].reset();
239 exception_error("changepass_callback", e
);
243 function infobox_feed_cat_callback() {
244 if (xmlhttp
.readyState
== 4) {
249 if (document
.getElementById("prefFeedCatList")) {
250 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
252 for (var i
= 0; i
< elems
.length
; i
++) {
253 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
254 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
256 new Ajax
.InPlaceEditor(elems
[i
],
257 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
263 exception_error("infobox_feed_cat_callback", e
);
268 function updateFeedList(sort_key
) {
270 if (!xmlhttp_ready(xmlhttp
)) {
275 var feed_search
= document
.getElementById("feed_search");
277 if (feed_search
) { search
= feed_search
.value
; }
279 var slat
= document
.getElementById("show_last_article_times");
281 var slat_checked
= false;
283 slat_checked
= slat
.checked
;
286 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
287 "&sort=" + param_escape(sort_key
) +
288 "&slat=" + param_escape(slat_checked
) +
289 "&search=" + param_escape(search
), true);
290 xmlhttp
.onreadystatechange
=feedlist_callback
;
295 function updateUsersList(sort_key
) {
297 if (!xmlhttp_ready(xmlhttp
)) {
302 var user_search
= document
.getElementById("user_search");
304 if (user_search
) { search
= user_search
.value
; }
306 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
307 + param_escape(sort_key
) +
308 "&search=" + param_escape(search
), true);
309 xmlhttp
.onreadystatechange
=userlist_callback
;
314 function addLabel() {
318 if (!xmlhttp_ready(xmlhttp
)) {
323 var caption
= prompt(__("Please enter label caption:"), "");
325 if (caption
== null) {
330 alert(__("Can't create label: missing caption."));
334 // we can be called from some other tab
335 active_tab
= "labelConfig";
337 var query
= "caption=" + param_escape(caption
);
339 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
340 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
344 exception_error("addLabel", e
);
350 if (!xmlhttp_ready(xmlhttp
)) {
355 var link
= document
.getElementById("fadd_link");
357 if (link
.value
.length
== 0) {
358 alert(__("Error: No feed URL given."));
359 } else if (!isValidURL(link
.value
)) {
360 alert(__("Error: Invalid feed URL."));
362 notify_progress("Adding feed...");
364 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
365 param_escape(link
.value
), true);
366 xmlhttp
.onreadystatechange
=feedlist_callback
;
375 function addFeedCat() {
377 if (!xmlhttp_ready(xmlhttp
)) {
382 var cat
= document
.getElementById("fadd_cat");
384 if (cat
.value
.length
== 0) {
385 alert(__("Can't add category: no name specified."));
387 notify_progress("Adding feed category...");
389 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
390 param_escape(cat
.value
), true);
391 xmlhttp
.onreadystatechange
=infobox_callback
;
401 if (!xmlhttp_ready(xmlhttp
)) {
406 var sqlexp
= document
.getElementById("uadd_box");
408 if (sqlexp
.value
.length
== 0) {
409 alert(__("Can't add user: no login specified."));
411 notify_progress("Adding user...");
413 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
414 param_escape(sqlexp
.value
), true);
416 xmlhttp
.onreadystatechange
=userlist_callback
;
424 function editLabel(id
) {
426 if (!xmlhttp_ready(xmlhttp
)) {
433 notify_progress("Loading, please wait...");
435 // document.getElementById("label_create_btn").disabled = true;
439 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
440 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
442 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
443 param_escape(id
), true);
444 xmlhttp
.onreadystatechange
=infobox_callback
;
449 function editUser(id
) {
451 if (!xmlhttp_ready(xmlhttp
)) {
458 notify_progress("Loading, please wait...");
460 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
461 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
463 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
464 param_escape(id
), true);
465 xmlhttp
.onreadystatechange
=infobox_callback
;
470 function editFilter(id
) {
472 if (!xmlhttp_ready(xmlhttp
)) {
479 notify_progress("Loading, please wait...");
481 // document.getElementById("create_filter_btn").disabled = true;
483 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
484 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
486 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
487 xmlhttp
.onreadystatechange
=infobox_callback
;
491 function editFeed(feed
) {
493 // notify("Editing feed...");
495 if (!xmlhttp_ready(xmlhttp
)) {
502 notify_progress("Loading, please wait...");
504 /* document.getElementById("subscribe_to_feed_btn").disabled = true;
507 document.getElementById("top25_feeds_btn").disabled = true;
509 // this button is not always available, no-op if not found
512 // clean selection from all rows & select row being edited
513 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
514 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
516 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
517 param_escape(feed
), true);
519 xmlhttp
.onreadystatechange
=infobox_callback
;
524 function editFeedCat(cat
) {
526 if (!xmlhttp_ready(xmlhttp
)) {
533 notify_progress("Loading, please wait...");
535 active_feed_cat
= cat
;
537 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
538 param_escape(cat
), true);
539 xmlhttp
.onreadystatechange
=infobox_callback
;
544 function getSelectedLabels() {
545 return getSelectedTableRowIds("prefLabelList", "LILRR");
548 function getSelectedUsers() {
549 return getSelectedTableRowIds("prefUserList", "UMRR");
552 function getSelectedFeeds() {
553 return getSelectedTableRowIds("prefFeedList", "FEEDR");
556 function getSelectedFilters() {
557 return getSelectedTableRowIds("prefFilterList", "FILRR");
560 function getSelectedFeedCats() {
561 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
564 function getSelectedFeedsFromBrowser() {
566 var list
= document
.getElementById("browseFeedList");
567 if (!list
) list
= document
.getElementById("browseBigFeedList");
569 var selected
= new Array();
571 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
572 var child
= list
.childNodes
[i
];
573 if (child
.id
&& child
.id
.match("FBROW-")) {
574 var id
= child
.id
.replace("FBROW-", "");
576 var cb
= document
.getElementById("FBCHK-" + id
);
587 function removeSelectedLabels() {
589 if (!xmlhttp_ready(xmlhttp
)) {
594 var sel_rows
= getSelectedLabels();
596 if (sel_rows
.length
> 0) {
598 var ok
= confirm(__("Remove selected labels?"));
601 notify_progress("Removing selected labels...");
603 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
604 param_escape(sel_rows
.toString()), true);
605 xmlhttp
.onreadystatechange
=labellist_callback
;
609 alert(__("No labels are selected."));
615 function removeSelectedUsers() {
617 if (!xmlhttp_ready(xmlhttp
)) {
622 var sel_rows
= getSelectedUsers();
624 if (sel_rows
.length
> 0) {
626 var ok
= confirm(__("Remove selected users?"));
629 notify_progress("Removing selected users...");
631 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
632 param_escape(sel_rows
.toString()), true);
633 xmlhttp
.onreadystatechange
=userlist_callback
;
638 alert(__("No users are selected."));
644 function removeSelectedFilters() {
646 if (!xmlhttp_ready(xmlhttp
)) {
651 var sel_rows
= getSelectedFilters();
653 if (sel_rows
.length
> 0) {
655 var ok
= confirm(__("Remove selected filters?"));
658 notify_progress("Removing selected filters...");
660 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
661 param_escape(sel_rows
.toString()), true);
662 xmlhttp
.onreadystatechange
=filterlist_callback
;
666 alert(__("No filters are selected."));
673 function removeSelectedFeeds() {
675 if (!xmlhttp_ready(xmlhttp
)) {
680 var sel_rows
= getSelectedFeeds();
682 if (sel_rows
.length
> 0) {
684 var ok
= confirm(__("Unsubscribe from selected feeds?"));
688 notify_progress("Unsubscribing from selected feeds...");
690 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
691 param_escape(sel_rows
.toString()), true);
692 xmlhttp
.onreadystatechange
=feedlist_callback
;
698 alert(__("No feeds are selected."));
705 function clearSelectedFeeds() {
707 if (!xmlhttp_ready(xmlhttp
)) {
712 var sel_rows
= getSelectedFeeds();
714 if (sel_rows
.length
> 1) {
715 alert(__("Please select only one feed."));
719 if (sel_rows
.length
> 0) {
721 var ok
= confirm(__("Erase all non-starred articles in selected feed?"));
724 notify_progress("Clearing selected feed...");
725 clearFeedArticles(sel_rows
[0]);
730 alert(__("No feeds are selected."));
737 function purgeSelectedFeeds() {
739 if (!xmlhttp_ready(xmlhttp
)) {
744 var sel_rows
= getSelectedFeeds();
746 if (sel_rows
.length
> 0) {
748 var pr
= prompt(__("How many days of articles to keep (0 - use default)?"), "0");
750 if (pr
!= undefined) {
751 notify_progress("Purging selected feed...");
753 var query
= "backend.php?op=rpc&subop=purge&ids="+
754 param_escape(sel_rows
.toString()) + "&days=" + pr
;
758 new Ajax
.Request(query
, {
759 onComplete: function(transport
) {
766 alert(__("No feeds are selected."));
773 function removeSelectedFeedCats() {
775 if (!xmlhttp_ready(xmlhttp
)) {
780 var sel_rows
= getSelectedFeedCats();
782 if (sel_rows
.length
> 0) {
784 var ok
= confirm(__("Remove selected categories?"));
787 notify_progress("Removing selected categories...");
789 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
790 param_escape(sel_rows
.toString()), true);
791 xmlhttp
.onreadystatechange
=infobox_callback
;
797 alert(__("No categories are selected."));
804 function feedEditCancel() {
806 if (!xmlhttp_ready(xmlhttp
)) {
812 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
813 document
.getElementById("top25_feeds_btn").disabled
= false;
815 // this button is not always available, no-op if not found
820 selectPrefRows('feed', false); // cleanup feed selection
825 function feedCatEditCancel() {
827 if (!xmlhttp_ready(xmlhttp
)) {
832 active_feed_cat
= false;
834 // notify("Operation cancelled.");
836 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
837 xmlhttp
.onreadystatechange
=infobox_callback
;
843 function feedEditSave() {
847 if (!xmlhttp_ready(xmlhttp
)) {
852 // FIXME: add parameter validation
854 var query
= Form
.serialize("edit_feed_form");
856 notify_progress("Saving feed...");
858 xmlhttp
.open("POST", "backend.php", true);
859 xmlhttp
.onreadystatechange
=feedlist_callback
;
860 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
868 exception_error("feedEditSave", e
);
872 function feedCatEditSave() {
874 if (!xmlhttp_ready(xmlhttp
)) {
879 notify_progress("Saving category...");
881 var query
= Form
.serialize("feed_cat_edit_form");
883 xmlhttp
.open("GET", "backend.php?" + query
, true);
884 xmlhttp
.onreadystatechange
=infobox_callback
;
887 active_feed_cat
= false;
892 function labelEditCancel() {
894 if (!xmlhttp_ready(xmlhttp
)) {
900 document
.getElementById("label_create_btn").disabled
= false;
901 selectPrefRows('label', false); // cleanup feed selection
904 active_label
= false;
911 function userEditCancel() {
913 if (!xmlhttp_ready(xmlhttp
)) {
918 selectPrefRows('user', false); // cleanup feed selection
924 function filterEditCancel() {
926 if (!xmlhttp_ready(xmlhttp
)) {
932 document
.getElementById("create_filter_btn").disabled
= false;
933 selectPrefRows('filter', false); // cleanup feed selection
941 function labelEditSave() {
943 var label
= active_label
;
945 if (!xmlhttp_ready(xmlhttp
)) {
950 /* if (!is_opera()) {
952 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
953 var description = document.forms["label_edit_form"].description.value;
955 if (sql_exp.length == 0) {
956 alert("SQL Expression cannot be blank.");
960 if (description.length == 0) {
961 alert("Caption field cannot be blank.");
968 notify_progress("Saving label...");
970 active_label
= false;
972 query
= Form
.serialize("label_edit_form");
974 xmlhttp
.open("GET", "backend.php?" + query
, true);
975 xmlhttp
.onreadystatechange
=labellist_callback
;
981 function userEditSave() {
983 if (!xmlhttp_ready(xmlhttp
)) {
988 var login
= document
.forms
["user_edit_form"].login
.value
;
990 if (login
.length
== 0) {
991 alert(__("Login field cannot be blank."));
995 notify_progress("Saving user...");
999 var query
= Form
.serialize("user_edit_form");
1001 xmlhttp
.open("GET", "backend.php?" + query
, true);
1002 xmlhttp
.onreadystatechange
=userlist_callback
;
1009 function filterEditSave() {
1011 if (!xmlhttp_ready(xmlhttp
)) {
1012 printLockingError();
1016 /* if (!is_opera()) {
1017 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
1019 if (reg_exp.length == 0) {
1020 alert("Filter expression field cannot be blank.");
1025 notify_progress("Saving filter...");
1027 var query
= Form
.serialize("filter_edit_form");
1031 document
.getElementById("create_filter_btn").disabled
= false;
1033 xmlhttp
.open("GET", "backend.php?" + query
, true);
1034 xmlhttp
.onreadystatechange
=filterlist_callback
;
1040 function editSelectedLabel() {
1041 var rows
= getSelectedLabels();
1043 if (rows
.length
== 0) {
1044 alert(__("No labels are selected."));
1048 if (rows
.length
> 1) {
1049 alert(__("Please select only one label."));
1059 function editSelectedUser() {
1060 var rows
= getSelectedUsers();
1062 if (rows
.length
== 0) {
1063 alert(__("No users are selected."));
1067 if (rows
.length
> 1) {
1068 alert(__("Please select only one user."));
1077 function resetSelectedUserPass() {
1078 var rows
= getSelectedUsers();
1080 if (rows
.length
== 0) {
1081 alert(__("No users are selected."));
1085 if (rows
.length
> 1) {
1086 alert(__("Please select only one user."));
1090 var ok
= confirm(__("Reset password of selected user?"));
1093 notify_progress("Resetting password for selected user...");
1097 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1098 param_escape(id
), true);
1099 xmlhttp
.onreadystatechange
=userlist_callback
;
1104 function selectedUserDetails() {
1106 if (!xmlhttp_ready(xmlhttp
)) {
1107 printLockingError();
1111 var rows
= getSelectedUsers();
1113 if (rows
.length
== 0) {
1114 alert(__("No users are selected."));
1118 if (rows
.length
> 1) {
1119 alert(__("Please select only one user."));
1123 notify_progress("Loading, please wait...");
1127 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=user-details&id=" + id
, true);
1128 xmlhttp
.onreadystatechange
=infobox_callback
;
1133 function selectedFeedDetails() {
1135 if (!xmlhttp_ready(xmlhttp
)) {
1136 printLockingError();
1140 var rows
= getSelectedFeeds();
1142 if (rows
.length
== 0) {
1143 alert(__("No feeds are selected."));
1147 if (rows
.length
> 1) {
1148 alert(__("Please select only one feed."));
1152 // var id = rows[0];
1156 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1157 param_escape(rows
.toString()), true);
1158 xmlhttp
.onreadystatechange
=infobox_callback
;
1163 function editSelectedFilter() {
1164 var rows
= getSelectedFilters();
1166 if (rows
.length
== 0) {
1167 alert(__("No filters are selected."));
1171 if (rows
.length
> 1) {
1172 alert(__("Please select only one filter."));
1178 editFilter(rows
[0]);
1183 function editSelectedFeed() {
1184 var rows
= getSelectedFeeds();
1186 if (rows
.length
== 0) {
1187 alert(__("No feeds are selected."));
1191 if (rows
.length
> 1) {
1192 alert(__("Please select one feed."));
1202 function editSelectedFeeds() {
1204 if (!xmlhttp_ready(xmlhttp
)) {
1205 printLockingError();
1209 var rows
= getSelectedFeeds();
1211 if (rows
.length
== 0) {
1212 alert(__("No feeds are selected."));
1220 notify_progress("Loading, please wait...");
1222 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeeds&ids=" +
1223 param_escape(rows
.toString()), true);
1225 xmlhttp
.onreadystatechange
=infobox_callback
;
1230 function editSelectedFeedCat() {
1231 var rows
= getSelectedFeedCats();
1233 if (rows
.length
== 0) {
1234 alert(__("No categories are selected."));
1238 if (rows
.length
> 1) {
1239 alert(__("Please select only one category."));
1245 editFeedCat(rows
[0]);
1249 function piggie(enable
) {
1251 debug("I LOVEDED IT!");
1252 var piggie
= document
.getElementById("piggie");
1254 Element
.show(piggie
);
1255 Position
.Center(piggie
);
1256 Effect
.Puff(piggie
);
1261 function validateOpmlImport() {
1263 var opml_file
= document
.getElementById("opml_file");
1265 if (opml_file
.value
.length
== 0) {
1266 alert(__("No OPML file to upload."));
1273 function updateFilterList(sort_key
) {
1275 if (!xmlhttp_ready(xmlhttp
)) {
1276 printLockingError();
1280 var filter_search
= document
.getElementById("filter_search");
1282 if (filter_search
) { search
= filter_search
.value
; }
1284 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1285 param_escape(sort_key
) +
1286 "&search=" + param_escape(search
), true);
1287 xmlhttp
.onreadystatechange
=filterlist_callback
;
1292 function updateLabelList(sort_key
) {
1294 if (!xmlhttp_ready(xmlhttp
)) {
1295 printLockingError();
1299 var label_search
= document
.getElementById("label_search");
1301 if (label_search
) { search
= label_search
.value
; }
1303 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1304 param_escape(sort_key
) +
1305 "&search=" + param_escape(search
), true);
1306 xmlhttp
.onreadystatechange
=labellist_callback
;
1310 function updatePrefsList() {
1312 if (!xmlhttp_ready(xmlhttp
)) {
1313 printLockingError();
1317 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1318 xmlhttp
.onreadystatechange
=prefslist_callback
;
1323 function selectTab(id
, noupdate
, subop
) {
1327 if (!id
) id
= active_tab
;
1331 if (!xmlhttp_ready(xmlhttp
)) {
1332 printLockingError();
1337 var c
= document
.getElementById('prefContent');
1343 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1345 notify_progress("Loading, please wait...");
1347 // close active infobox if needed
1350 // clean up all current selections, just in case
1351 active_feed_cat
= false;
1352 active_label
= false;
1354 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1355 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1357 if (id
== "feedConfig") {
1359 } else if (id
== "filterConfig") {
1361 } else if (id
== "labelConfig") {
1363 } else if (id
== "genConfig") {
1365 } else if (id
== "userConfig") {
1367 } else if (id
== "feedBrowser") {
1368 updateBigFeedBrowser();
1372 /* clean selection from all tabs */
1374 var tabs_holder
= document
.getElementById("prefTabs");
1375 var tab
= tabs_holder
.firstChild
;
1378 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1379 tab
.className
= "prefsTab";
1381 tab
= tab
.nextSibling
;
1384 /* mark new tab as selected */
1386 tab
= document
.getElementById(id
+ "Tab");
1389 if (!tab
.className
.match("Selected")) {
1390 tab
.className
= tab
.className
+ "Selected";
1397 exception_error("selectTab", e
);
1401 function backend_sanity_check_callback() {
1403 if (xmlhttp
.readyState
== 4) {
1407 if (sanity_check_done
) {
1408 fatalError(11, "Sanity check request received twice. This can indicate "+
1409 "presence of Firebug or some other disrupting extension. "+
1410 "Please disable it and try again.");
1414 if (!xmlhttp
.responseXML
) {
1415 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1419 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1422 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1426 var error_code
= reply
.getAttribute("error-code");
1428 if (error_code
&& error_code
!= 0) {
1429 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1432 debug("sanity check ok");
1434 var params
= reply
.nextSibling
;
1437 debug('reading init-params...');
1438 var param
= params
.firstChild
;
1441 var k
= param
.getAttribute("key");
1442 var v
= param
.getAttribute("value");
1443 debug(k
+ " => " + v
);
1445 param
= param
.nextSibling
;
1449 sanity_check_done
= true;
1451 init_second_stage();
1454 exception_error("backend_sanity_check_callback", e
);
1459 function init_second_stage() {
1462 active_tab
= getInitParam("prefs_active_tab");
1463 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1465 document
.onkeydown
= pref_hotkey_handler
;
1467 var tab
= getURLParam('tab');
1469 caller_subop
= getURLParam('subop');
1475 if (navigator
.userAgent
.match("Opera")) {
1476 setTimeout("selectTab()", 500);
1478 selectTab(active_tab
);
1482 loading_set_progress(60);
1485 exception_error("init_second_stage", e
);
1493 if (arguments
.callee
.done
) return;
1494 arguments
.callee
.done
= true;
1496 if (getURLParam('debug')) {
1497 Element
.show("debug_output");
1498 debug('debug mode activated');
1503 document
.getElementById("prefContent").innerHTML
=
1504 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1505 "to function properly. Your browser doesn't seem to support it.";
1509 loading_set_progress(30);
1511 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1512 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1516 exception_error("init", e
);
1520 function categorizeSelectedFeeds() {
1522 if (!xmlhttp_ready(xmlhttp
)) {
1523 printLockingError();
1527 var sel_rows
= getSelectedFeeds();
1529 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1530 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1532 if (sel_rows
.length
> 0) {
1534 notify_progress("Changing category of selected feeds...");
1536 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1537 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1538 xmlhttp
.onreadystatechange
=feedlist_callback
;
1543 alert(__("No feeds are selected."));
1549 function validatePrefsReset() {
1551 var ok
= confirm(__("Reset to defaults?"));
1555 var query
= Form
.serialize("pref_prefs_form");
1556 query
= query
+ "&subop=reset-config";
1559 xmlhttp
.open("POST", "backend.php", true);
1560 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1561 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1562 xmlhttp
.send(query
);
1566 exception_error("validatePrefsSave", e
);
1573 function browseFeeds(limit
) {
1575 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1576 xmlhttp
.onreadystatechange
=infobox_callback
;
1581 function feedBrowserSubscribe() {
1584 var selected
= getSelectedFeedsFromBrowser();
1586 if (selected
.length
> 0) {
1588 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1589 param_escape(selected
.toString()), true);
1590 xmlhttp
.onreadystatechange
=feedlist_callback
;
1593 alert(__("No feeds are selected."));
1597 exception_error("feedBrowserSubscribe", e
);
1601 function updateBigFeedBrowserBtn() {
1602 notify_progress("Loading, please wait...");
1603 return updateBigFeedBrowser();
1606 function updateBigFeedBrowser(limit
, from_button
) {
1608 if (!xmlhttp_ready(xmlhttp
)) {
1609 printLockingError();
1613 var query
= "backend.php?op=pref-feed-browser";
1615 var limit_sel
= document
.getElementById("feedBrowserLimit");
1618 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1619 query
= query
+ "&limit=" + param_escape(limit
);
1622 xmlhttp
.open("GET", query
, true);
1623 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1627 function browserToggleExpand(id
) {
1629 /* if (feed_to_expand && feed_to_expand != id) {
1630 var d = document.getElementById("BRDET-" + feed_to_expand);
1631 d.style.display = "none";
1634 if (!xmlhttp_ready(xmlhttp
)) {
1635 printLockingError();
1639 /* if (feed_to_expand && id != feed_to_expand) {
1640 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1643 var d
= document
.getElementById("BRDET-" + id
);
1645 if (Element
.visible(d
)) {
1646 Effect
.Fade(d
, {duration
: 0.5});
1648 feed_to_expand
= id
;
1650 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1651 + param_escape(id
), true);
1652 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1657 exception_error("browserToggleExpand", e
);
1661 function selectPrefRows(kind
, select
) {
1664 var opbarid
= false;
1669 if (kind
== "feed") {
1670 opbarid
= "feedOpToolbar";
1673 lname
= "prefFeedList";
1674 } else if (kind
== "fcat") {
1675 opbarid
= "catOpToolbar";
1678 lname
= "prefFeedCatList";
1679 } else if (kind
== "filter") {
1680 opbarid
= "filterOpToolbar";
1683 lname
= "prefFilterList";
1684 } else if (kind
== "label") {
1685 opbarid
= "labelOpToolbar";
1688 lname
= "prefLabelList";
1689 } else if (kind
== "user") {
1690 opbarid
= "userOpToolbar";
1693 lname
= "prefUserList";
1697 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1698 disableContainerChildren(opbarid
, !select
);
1705 function toggleSelectPrefRow(sender
, kind
) {
1707 toggleSelectRow(sender
);
1710 var opbarid
= false;
1713 if (kind
== "feed") {
1714 opbarid
= "feedOpToolbar";
1715 nsel
= getSelectedFeeds();
1716 } else if (kind
== "fcat") {
1717 opbarid
= "catOpToolbar";
1718 nsel
= getSelectedFeedCats();
1719 } else if (kind
== "filter") {
1720 opbarid
= "filterOpToolbar";
1721 nsel
= getSelectedFilters();
1722 } else if (kind
== "label") {
1723 opbarid
= "labelOpToolbar";
1724 nsel
= getSelectedLabels();
1725 } else if (kind
== "user") {
1726 opbarid
= "userOpToolbar";
1727 nsel
= getSelectedUsers();
1730 if (opbarid
&& nsel
!= -1) {
1731 disableContainerChildren(opbarid
, nsel
== false);
1737 function toggleSelectFBListRow(sender
) {
1738 toggleSelectListRow(sender
);
1739 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1744 function pref_hotkey_handler(e
) {
1748 var shift_key
= false;
1751 shift_key
= e
.shiftKey
;
1757 keycode
= window
.event
.keyCode
;
1762 var keychar
= String
.fromCharCode(keycode
);
1764 if (keycode
== 27) { // escape
1765 if (Element
.visible("hotkey_help_overlay")) {
1766 Element
.hide("hotkey_help_overlay");
1768 hotkey_prefix
= false;
1772 if (!hotkeys_enabled
) {
1773 debug("hotkeys disabled");
1777 if (keycode
== 16) return; // ignore lone shift
1779 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1780 hotkey_prefix
= keycode
;
1781 debug("KP: PREFIX=" + keycode
+ " CHAR=" + keychar
);
1785 if (Element
.visible("hotkey_help_overlay")) {
1786 Element
.hide("hotkey_help_overlay");
1789 if (keycode
== 13 || keycode
== 27) {
1792 seq
= seq
+ "" + keycode
;
1795 /* Global hotkeys */
1797 if (!hotkey_prefix
) {
1799 if (keycode
== 68 && shift_key
) { // d
1800 if (!Element
.visible("debug_output")) {
1801 Element
.show("debug_output");
1802 debug('debug mode activated');
1804 Element
.hide("debug_output");
1809 if ((keycode
== 191 || keychar
== '?') && shift_key
) { // ?
1810 if (!Element
.visible("hotkey_help_overlay")) {
1811 //Element.show("hotkey_help_overlay");
1812 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
1814 Element
.hide("hotkey_help_overlay");
1819 if (keycode
== 191 || keychar
== '/') { // /
1820 var search_boxes
= new Array("label_search",
1821 "feed_search", "filter_search", "user_search");
1823 for (var i
= 0; i
< search_boxes
.length
; i
++) {
1824 var elem
= document
.getElementById(search_boxes
[i
]);
1826 focus_element(search_boxes
[i
]);
1835 if (hotkey_prefix
== 67) { // c
1836 hotkey_prefix
= false;
1838 if (keycode
== 70) { // f
1839 displayDlg("quickAddFilter");
1843 if (keycode
== 83) { // s
1844 displayDlg("quickAddFeed");
1848 /* if (keycode == 76) { // l
1849 displayDlg("quickAddLabel");
1853 if (keycode
== 85) { // u
1857 if (keycode
== 67) { // c
1862 if (keycode
== 84 && shift_key
) { // T
1871 if (hotkey_prefix
== 71) { // g
1873 hotkey_prefix
= false;
1875 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1876 selectTab("genConfig");
1880 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1881 selectTab("feedConfig");
1885 if (keycode
== 51 && document
.getElementById("feedBrowserTab")) { // 3
1886 selectTab("feedBrowser");
1890 if (keycode
== 52 && document
.getElementById("filterConfigTab")) { // 4
1891 selectTab("filterConfig");
1895 if (keycode
== 53 && document
.getElementById("labelConfigTab")) { // 5
1896 selectTab("labelConfig");
1900 if (keycode
== 54 && document
.getElementById("userConfigTab")) { // 6
1901 selectTab("userConfig");
1905 if (keycode
== 88) { // x
1911 if (document
.getElementById("piggie")) {
1913 if (seq
.match("807371717369")) {
1921 if (hotkey_prefix
) {
1922 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
+ " CHAR=" + keychar
);
1924 debug("KP: CODE=" + keycode
+ " CHAR=" + keychar
);
1928 exception_error("pref_hotkey_handler", e
);
1932 function editFeedCats() {
1933 if (!xmlhttp_ready(xmlhttp
)) {
1934 printLockingError();
1938 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1941 document
.getElementById("top25_feeds_btn").disabled
= true;
1943 // this button is not always available, no-op if not found
1946 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1947 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1951 function showFeedsWithErrors() {
1952 displayDlg('feedUpdateErrors');
1955 function changeUserPassword() {
1959 if (!xmlhttp_ready(xmlhttp
)) {
1960 printLockingError();
1964 var f
= document
.forms
["change_pass_form"];
1967 if (f
.OLD_PASSWORD
.value
== "") {
1968 new Effect
.Highlight(f
.OLD_PASSWORD
);
1969 notify_error("Old password cannot be blank.");
1973 if (f
.NEW_PASSWORD
.value
== "") {
1974 new Effect
.Highlight(f
.NEW_PASSWORD
);
1975 notify_error("New password cannot be blank.");
1979 if (f
.CONFIRM_PASSWORD
.value
== "") {
1980 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1981 notify_error("Entered passwords do not match.");
1985 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1986 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1987 new Effect
.Highlight(f
.NEW_PASSWORD
);
1988 notify_error("Entered passwords do not match.");
1994 var query
= Form
.serialize("change_pass_form");
1996 notify_progress("Trying to change password...");
1998 xmlhttp
.open("POST", "backend.php", true);
1999 xmlhttp
.onreadystatechange
=changepass_callback
;
2000 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2001 xmlhttp
.send(query
);
2004 exception_error("changeUserPassword", e
);
2010 function changeUserEmail() {
2014 if (!xmlhttp_ready(xmlhttp
)) {
2015 printLockingError();
2019 var query
= Form
.serialize("change_email_form");
2021 notify_progress("Trying to change e-mail...");
2023 xmlhttp
.open("POST", "backend.php", true);
2024 xmlhttp
.onreadystatechange
=notify_callback
;
2025 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2026 xmlhttp
.send(query
);
2029 exception_error("changeUserPassword", e
);
2036 function feedlistToggleSLAT() {
2037 notify_progress("Loading, please wait...");
2041 function pubRegenKey() {
2043 if (!xmlhttp_ready(xmlhttp
)) {
2044 printLockingError();
2048 var ok
= confirm(__("Replace current publishing address with a new one?"));
2052 notify_progress("Trying to change address...");
2054 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
2055 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
2062 function pubToClipboard() {
2066 if (!xmlhttp_ready(xmlhttp
)) {
2067 printLockingError();
2071 var link
= document
.getElementById("pubGenAddress");
2075 exception_error("pubToClipboard", e
);
2081 function validatePrefsSave() {
2084 var ok
= confirm(__("Save current configuration?"));
2088 var query
= Form
.serialize("pref_prefs_form");
2089 query
= query
+ "&subop=save-config";
2092 xmlhttp
.open("POST", "backend.php", true);
2093 xmlhttp
.onreadystatechange
=notify_callback
;
2094 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2095 xmlhttp
.send(query
);
2099 exception_error("validatePrefsSave", e
);
2105 function feedActionChange() {
2107 var chooser
= document
.getElementById("feedActionChooser");
2108 var opid
= chooser
[chooser
.selectedIndex
].value
;
2110 chooser
.selectedIndex
= 0;
2113 exception_error("feedActionChange", e
);
2117 function feedActionGo(op
) {
2119 if (op
== "facEdit") {
2121 var rows
= getSelectedFeeds();
2123 if (rows
.length
> 1) {
2124 editSelectedFeeds();
2130 if (op
== "facClear") {
2131 clearSelectedFeeds();
2134 if (op
== "facPurge") {
2135 purgeSelectedFeeds();
2138 if (op
== "facEditCats") {
2142 if (op
== "facRescore") {
2143 rescoreSelectedFeeds();
2146 if (op
== "facUnsubscribe") {
2147 removeSelectedFeeds();
2151 exception_error("feedActionGo", e
);
2156 function clearFeedArticles(feed_id
) {
2158 notify_progress("Clearing feed...");
2160 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
2162 new Ajax
.Request(query
, {
2163 onComplete: function(transport
) {
2170 function rescoreSelectedFeeds() {
2172 if (!xmlhttp_ready(xmlhttp
)) {
2173 printLockingError();
2177 var sel_rows
= getSelectedFeeds();
2179 if (sel_rows
.length
> 0) {
2181 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2182 var ok
= confirm(__("Rescore articles in selected feeds?"));
2185 notify_progress("Rescoring selected feeds...", true);
2187 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2188 param_escape(sel_rows
.toString()), true);
2189 xmlhttp
.onreadystatechange
=notify_callback
;
2193 alert(__("No feeds are selected."));
2199 function rescore_all_feeds() {
2200 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
2203 notify_progress("Rescoring feeds...", true);
2205 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2206 xmlhttp
.onreadystatechange
=notify_callback
;
2211 function removeFilter(id
, title
) {
2213 if (!xmlhttp_ready(xmlhttp
)) {
2214 printLockingError();
2218 var msg
= __("Remove filter %s?").replace("%s", title
);
2220 var ok
= confirm(msg
);
2225 notify_progress("Removing filter...");
2227 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
2228 param_escape(id
), true);
2229 xmlhttp
.onreadystatechange
=filterlist_callback
;
2236 function unsubscribeFeed(id
, title
) {
2238 if (!xmlhttp_ready(xmlhttp
)) {
2239 printLockingError();
2243 var msg
= __("Unsubscribe from %s?").replace("%s", title
);
2245 var ok
= confirm(msg
);
2250 notify_progress("Removing feed...");
2252 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
2253 param_escape(id
), true);
2254 xmlhttp
.onreadystatechange
=filterlist_callback
;
2264 function feedsEditSave() {
2267 if (!xmlhttp_ready(xmlhttp
)) {
2268 printLockingError();
2272 var ok
= confirm(__("Save changes to selected feeds?"));
2276 var f
= document
.forms
["batch_edit_feed_form"];
2278 var query
= Form
.serialize("batch_edit_feed_form");
2280 /* Form.serialize ignores unchecked checkboxes */
2282 if (!query
.match("&hidden=") &&
2283 f
.hidden
.disabled
== false) {
2284 query
= query
+ "&hidden=false";
2287 if (!query
.match("&rtl_content=") &&
2288 f
.rtl_content
.disabled
== false) {
2289 query
= query
+ "&rtl_content=false";
2292 if (!query
.match("&private=") &&
2293 f
.private.disabled
== false) {
2294 query
= query
+ "&private=false";
2297 if (!query
.match("&cache_images=") &&
2298 f
.cache_images
.disabled
== false) {
2299 query
= query
+ "&cache_images=false";
2302 if (!query
.match("&include_in_digest=") &&
2303 f
.include_in_digest
.disabled
== false) {
2304 query
= query
+ "&include_in_digest=false";
2309 notify_progress("Saving feeds...");
2311 xmlhttp
.open("POST", "backend.php", true);
2312 xmlhttp
.onreadystatechange
=feedlist_callback
;
2313 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2314 xmlhttp
.send(query
);
2319 exception_error("feedsEditSave", e
);
2323 function batchFeedsToggleField(cb
, elem
, label
) {
2325 var f
= document
.forms
["batch_edit_feed_form"];
2326 var l
= document
.getElementById(label
);
2329 f
[elem
].disabled
= false;
2335 // new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5",
2336 // queue: { position:'end', scope: 'BPEFQ', limit: 1 } } );
2339 f
[elem
].disabled
= true;
2342 l
.className
= "insensitive";
2347 exception_error("batchFeedsToggleField", e
);