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
);
159 if (typeof correctPNG
!= 'undefined') {
167 exception_error("labellist_callback", e
);
171 function feed_browser_callback() {
172 var container
= document
.getElementById('prefContent');
173 if (xmlhttp
.readyState
== 4) {
174 container
.innerHTML
=xmlhttp
.responseText
;
180 function userlist_callback() {
181 var container
= document
.getElementById('prefContent');
182 if (xmlhttp
.readyState
== 4) {
183 container
.innerHTML
=xmlhttp
.responseText
;
189 function prefslist_callback() {
190 var container
= document
.getElementById('prefContent');
191 if (xmlhttp
.readyState
== 4) {
192 container
.innerHTML
=xmlhttp
.responseText
;
198 function gethelp_callback() {
199 var container
= document
.getElementById('prefHelpBox');
200 if (xmlhttp
.readyState
== 4) {
202 container
.innerHTML
= xmlhttp
.responseText
;
203 container
.style
.display
= "block";
208 function notify_callback() {
209 if (xmlhttp
.readyState
== 4) {
210 notify_info(xmlhttp
.responseText
);
214 function prefs_reset_callback() {
215 if (xmlhttp
.readyState
== 4) {
216 notify_info(xmlhttp
.responseText
);
222 function changepass_callback() {
224 if (xmlhttp
.readyState
== 4) {
226 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
227 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
229 notify_info(xmlhttp
.responseText
);
230 var warn
= document
.getElementById("default_pass_warning");
231 if (warn
) warn
.style
.display
= "none";
234 document
.forms
['change_pass_form'].reset();
238 exception_error("changepass_callback", e
);
242 function infobox_feed_cat_callback() {
243 if (xmlhttp
.readyState
== 4) {
248 if (document
.getElementById("prefFeedCatList")) {
249 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
251 for (var i
= 0; i
< elems
.length
; i
++) {
252 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
253 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
255 new Ajax
.InPlaceEditor(elems
[i
],
256 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
262 exception_error("infobox_feed_cat_callback", e
);
267 function updateFeedList(sort_key
) {
269 if (!xmlhttp_ready(xmlhttp
)) {
274 var feed_search
= document
.getElementById("feed_search");
276 if (feed_search
) { search
= feed_search
.value
; }
278 var slat
= document
.getElementById("show_last_article_times");
280 var slat_checked
= false;
282 slat_checked
= slat
.checked
;
285 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
286 "&sort=" + param_escape(sort_key
) +
287 "&slat=" + param_escape(slat_checked
) +
288 "&search=" + param_escape(search
), true);
289 xmlhttp
.onreadystatechange
=feedlist_callback
;
294 function updateUsersList(sort_key
) {
296 if (!xmlhttp_ready(xmlhttp
)) {
301 var user_search
= document
.getElementById("user_search");
303 if (user_search
) { search
= user_search
.value
; }
305 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
306 + param_escape(sort_key
) +
307 "&search=" + param_escape(search
), true);
308 xmlhttp
.onreadystatechange
=userlist_callback
;
313 function addLabel() {
317 if (!xmlhttp_ready(xmlhttp
)) {
322 var caption
= prompt(__("Please enter label caption:"), "");
324 if (caption
== null) {
329 alert(__("Can't create label: missing caption."));
333 // we can be called from some other tab
334 active_tab
= "labelConfig";
336 var query
= "caption=" + param_escape(caption
);
338 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
339 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
343 exception_error("addLabel", e
);
349 if (!xmlhttp_ready(xmlhttp
)) {
354 var link
= document
.getElementById("fadd_link");
356 if (link
.value
.length
== 0) {
357 alert(__("Error: No feed URL given."));
358 } else if (!isValidURL(link
.value
)) {
359 alert(__("Error: Invalid feed URL."));
361 notify_progress("Adding feed...");
363 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
364 param_escape(link
.value
), true);
365 xmlhttp
.onreadystatechange
=feedlist_callback
;
374 function addFeedCat() {
376 if (!xmlhttp_ready(xmlhttp
)) {
381 var cat
= document
.getElementById("fadd_cat");
383 if (cat
.value
.length
== 0) {
384 alert(__("Can't add category: no name specified."));
386 notify_progress("Adding feed category...");
388 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
389 param_escape(cat
.value
), true);
390 xmlhttp
.onreadystatechange
=infobox_callback
;
400 if (!xmlhttp_ready(xmlhttp
)) {
405 var sqlexp
= document
.getElementById("uadd_box");
407 if (sqlexp
.value
.length
== 0) {
408 alert(__("Can't add user: no login specified."));
410 notify_progress("Adding user...");
412 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
413 param_escape(sqlexp
.value
), true);
415 xmlhttp
.onreadystatechange
=userlist_callback
;
423 function editLabel(id
) {
425 if (!xmlhttp_ready(xmlhttp
)) {
432 notify_progress("Loading, please wait...");
434 // document.getElementById("label_create_btn").disabled = true;
438 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
439 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
441 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
442 param_escape(id
), true);
443 xmlhttp
.onreadystatechange
=infobox_callback
;
448 function editUser(id
) {
450 if (!xmlhttp_ready(xmlhttp
)) {
457 notify_progress("Loading, please wait...");
459 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
460 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
462 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
463 param_escape(id
), true);
464 xmlhttp
.onreadystatechange
=infobox_callback
;
469 function editFilter(id
) {
471 if (!xmlhttp_ready(xmlhttp
)) {
478 notify_progress("Loading, please wait...");
480 // document.getElementById("create_filter_btn").disabled = true;
482 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
483 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
485 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
486 xmlhttp
.onreadystatechange
=infobox_callback
;
490 function editFeed(feed
) {
492 // notify("Editing feed...");
494 if (!xmlhttp_ready(xmlhttp
)) {
501 notify_progress("Loading, please wait...");
503 /* document.getElementById("subscribe_to_feed_btn").disabled = true;
506 document.getElementById("top25_feeds_btn").disabled = true;
508 // this button is not always available, no-op if not found
511 // clean selection from all rows & select row being edited
512 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
513 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
515 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
516 param_escape(feed
), true);
518 xmlhttp
.onreadystatechange
=infobox_callback
;
523 function editFeedCat(cat
) {
525 if (!xmlhttp_ready(xmlhttp
)) {
532 notify_progress("Loading, please wait...");
534 active_feed_cat
= cat
;
536 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
537 param_escape(cat
), true);
538 xmlhttp
.onreadystatechange
=infobox_callback
;
543 function getSelectedLabels() {
544 return getSelectedTableRowIds("prefLabelList", "LILRR");
547 function getSelectedUsers() {
548 return getSelectedTableRowIds("prefUserList", "UMRR");
551 function getSelectedFeeds() {
552 return getSelectedTableRowIds("prefFeedList", "FEEDR");
555 function getSelectedFilters() {
556 return getSelectedTableRowIds("prefFilterList", "FILRR");
559 function getSelectedFeedCats() {
560 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
563 function getSelectedFeedsFromBrowser() {
565 var list
= document
.getElementById("browseFeedList");
566 if (!list
) list
= document
.getElementById("browseBigFeedList");
568 var selected
= new Array();
570 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
571 var child
= list
.childNodes
[i
];
572 if (child
.id
&& child
.id
.match("FBROW-")) {
573 var id
= child
.id
.replace("FBROW-", "");
575 var cb
= document
.getElementById("FBCHK-" + id
);
586 function removeSelectedLabels() {
588 if (!xmlhttp_ready(xmlhttp
)) {
593 var sel_rows
= getSelectedLabels();
595 if (sel_rows
.length
> 0) {
597 var ok
= confirm(__("Remove selected labels?"));
600 notify_progress("Removing selected labels...");
602 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
603 param_escape(sel_rows
.toString()), true);
604 xmlhttp
.onreadystatechange
=labellist_callback
;
608 alert(__("No labels are selected."));
614 function removeSelectedUsers() {
616 if (!xmlhttp_ready(xmlhttp
)) {
621 var sel_rows
= getSelectedUsers();
623 if (sel_rows
.length
> 0) {
625 var ok
= confirm(__("Remove selected users?"));
628 notify_progress("Removing selected users...");
630 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
631 param_escape(sel_rows
.toString()), true);
632 xmlhttp
.onreadystatechange
=userlist_callback
;
637 alert(__("No users are selected."));
643 function removeSelectedFilters() {
645 if (!xmlhttp_ready(xmlhttp
)) {
650 var sel_rows
= getSelectedFilters();
652 if (sel_rows
.length
> 0) {
654 var ok
= confirm(__("Remove selected filters?"));
657 notify_progress("Removing selected filters...");
659 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
660 param_escape(sel_rows
.toString()), true);
661 xmlhttp
.onreadystatechange
=filterlist_callback
;
665 alert(__("No filters are selected."));
672 function removeSelectedFeeds() {
674 if (!xmlhttp_ready(xmlhttp
)) {
679 var sel_rows
= getSelectedFeeds();
681 if (sel_rows
.length
> 0) {
683 var ok
= confirm(__("Unsubscribe from selected feeds?"));
687 notify_progress("Unsubscribing from selected feeds...");
689 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
690 param_escape(sel_rows
.toString()), true);
691 xmlhttp
.onreadystatechange
=feedlist_callback
;
697 alert(__("No feeds are selected."));
704 function clearSelectedFeeds() {
706 if (!xmlhttp_ready(xmlhttp
)) {
711 var sel_rows
= getSelectedFeeds();
713 if (sel_rows
.length
> 1) {
714 alert(__("Please select only one feed."));
718 if (sel_rows
.length
> 0) {
720 var ok
= confirm(__("Erase all non-starred articles in selected feed?"));
723 notify_progress("Clearing selected feed...");
724 clearFeedArticles(sel_rows
[0]);
729 alert(__("No feeds are selected."));
736 function purgeSelectedFeeds() {
738 if (!xmlhttp_ready(xmlhttp
)) {
743 var sel_rows
= getSelectedFeeds();
745 if (sel_rows
.length
> 0) {
747 var pr
= prompt(__("How many days of articles to keep (0 - use default)?"), "0");
749 if (pr
!= undefined) {
750 notify_progress("Purging selected feed...");
752 var query
= "backend.php?op=rpc&subop=purge&ids="+
753 param_escape(sel_rows
.toString()) + "&days=" + pr
;
757 new Ajax
.Request(query
, {
758 onComplete: function(transport
) {
765 alert(__("No feeds are selected."));
772 function removeSelectedFeedCats() {
774 if (!xmlhttp_ready(xmlhttp
)) {
779 var sel_rows
= getSelectedFeedCats();
781 if (sel_rows
.length
> 0) {
783 var ok
= confirm(__("Remove selected categories?"));
786 notify_progress("Removing selected categories...");
788 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
789 param_escape(sel_rows
.toString()), true);
790 xmlhttp
.onreadystatechange
=infobox_callback
;
796 alert(__("No categories are selected."));
803 function feedEditCancel() {
805 if (!xmlhttp_ready(xmlhttp
)) {
811 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
812 document
.getElementById("top25_feeds_btn").disabled
= false;
814 // this button is not always available, no-op if not found
819 selectPrefRows('feed', false); // cleanup feed selection
824 function feedCatEditCancel() {
826 if (!xmlhttp_ready(xmlhttp
)) {
831 active_feed_cat
= false;
833 // notify("Operation cancelled.");
835 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
836 xmlhttp
.onreadystatechange
=infobox_callback
;
842 function feedEditSave() {
846 if (!xmlhttp_ready(xmlhttp
)) {
851 // FIXME: add parameter validation
853 var query
= Form
.serialize("edit_feed_form");
855 notify_progress("Saving feed...");
857 xmlhttp
.open("POST", "backend.php", true);
858 xmlhttp
.onreadystatechange
=feedlist_callback
;
859 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
867 exception_error("feedEditSave", e
);
871 function feedCatEditSave() {
873 if (!xmlhttp_ready(xmlhttp
)) {
878 notify_progress("Saving category...");
880 var query
= Form
.serialize("feed_cat_edit_form");
882 xmlhttp
.open("GET", "backend.php?" + query
, true);
883 xmlhttp
.onreadystatechange
=infobox_callback
;
886 active_feed_cat
= false;
891 function labelEditCancel() {
893 if (!xmlhttp_ready(xmlhttp
)) {
899 document
.getElementById("label_create_btn").disabled
= false;
900 selectPrefRows('label', false); // cleanup feed selection
903 active_label
= false;
910 function userEditCancel() {
912 if (!xmlhttp_ready(xmlhttp
)) {
917 selectPrefRows('user', false); // cleanup feed selection
923 function filterEditCancel() {
925 if (!xmlhttp_ready(xmlhttp
)) {
931 document
.getElementById("create_filter_btn").disabled
= false;
932 selectPrefRows('filter', false); // cleanup feed selection
940 function labelEditSave() {
942 var label
= active_label
;
944 if (!xmlhttp_ready(xmlhttp
)) {
949 /* if (!is_opera()) {
951 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
952 var description = document.forms["label_edit_form"].description.value;
954 if (sql_exp.length == 0) {
955 alert("SQL Expression cannot be blank.");
959 if (description.length == 0) {
960 alert("Caption field cannot be blank.");
967 notify_progress("Saving label...");
969 active_label
= false;
971 query
= Form
.serialize("label_edit_form");
973 xmlhttp
.open("GET", "backend.php?" + query
, true);
974 xmlhttp
.onreadystatechange
=labellist_callback
;
980 function userEditSave() {
982 if (!xmlhttp_ready(xmlhttp
)) {
987 var login
= document
.forms
["user_edit_form"].login
.value
;
989 if (login
.length
== 0) {
990 alert(__("Login field cannot be blank."));
994 notify_progress("Saving user...");
998 var query
= Form
.serialize("user_edit_form");
1000 xmlhttp
.open("GET", "backend.php?" + query
, true);
1001 xmlhttp
.onreadystatechange
=userlist_callback
;
1008 function filterEditSave() {
1010 if (!xmlhttp_ready(xmlhttp
)) {
1011 printLockingError();
1015 /* if (!is_opera()) {
1016 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
1018 if (reg_exp.length == 0) {
1019 alert("Filter expression field cannot be blank.");
1024 notify_progress("Saving filter...");
1026 var query
= Form
.serialize("filter_edit_form");
1030 document
.getElementById("create_filter_btn").disabled
= false;
1032 xmlhttp
.open("GET", "backend.php?" + query
, true);
1033 xmlhttp
.onreadystatechange
=filterlist_callback
;
1039 function editSelectedLabel() {
1040 var rows
= getSelectedLabels();
1042 if (rows
.length
== 0) {
1043 alert(__("No labels are selected."));
1047 if (rows
.length
> 1) {
1048 alert(__("Please select only one label."));
1058 function editSelectedUser() {
1059 var rows
= getSelectedUsers();
1061 if (rows
.length
== 0) {
1062 alert(__("No users are selected."));
1066 if (rows
.length
> 1) {
1067 alert(__("Please select only one user."));
1076 function resetSelectedUserPass() {
1077 var rows
= getSelectedUsers();
1079 if (rows
.length
== 0) {
1080 alert(__("No users are selected."));
1084 if (rows
.length
> 1) {
1085 alert(__("Please select only one user."));
1089 var ok
= confirm(__("Reset password of selected user?"));
1092 notify_progress("Resetting password for selected user...");
1096 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1097 param_escape(id
), true);
1098 xmlhttp
.onreadystatechange
=userlist_callback
;
1103 function selectedUserDetails() {
1105 if (!xmlhttp_ready(xmlhttp
)) {
1106 printLockingError();
1110 var rows
= getSelectedUsers();
1112 if (rows
.length
== 0) {
1113 alert(__("No users are selected."));
1117 if (rows
.length
> 1) {
1118 alert(__("Please select only one user."));
1122 notify_progress("Loading, please wait...");
1126 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=user-details&id=" + id
, true);
1127 xmlhttp
.onreadystatechange
=infobox_callback
;
1132 function selectedFeedDetails() {
1134 if (!xmlhttp_ready(xmlhttp
)) {
1135 printLockingError();
1139 var rows
= getSelectedFeeds();
1141 if (rows
.length
== 0) {
1142 alert(__("No feeds are selected."));
1146 if (rows
.length
> 1) {
1147 alert(__("Please select only one feed."));
1151 // var id = rows[0];
1155 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1156 param_escape(rows
.toString()), true);
1157 xmlhttp
.onreadystatechange
=infobox_callback
;
1162 function editSelectedFilter() {
1163 var rows
= getSelectedFilters();
1165 if (rows
.length
== 0) {
1166 alert(__("No filters are selected."));
1170 if (rows
.length
> 1) {
1171 alert(__("Please select only one filter."));
1177 editFilter(rows
[0]);
1182 function editSelectedFeed() {
1183 var rows
= getSelectedFeeds();
1185 if (rows
.length
== 0) {
1186 alert(__("No feeds are selected."));
1190 if (rows
.length
> 1) {
1191 alert(__("Please select one feed."));
1201 function editSelectedFeeds() {
1203 if (!xmlhttp_ready(xmlhttp
)) {
1204 printLockingError();
1208 var rows
= getSelectedFeeds();
1210 if (rows
.length
== 0) {
1211 alert(__("No feeds are selected."));
1219 notify_progress("Loading, please wait...");
1221 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeeds&ids=" +
1222 param_escape(rows
.toString()), true);
1224 xmlhttp
.onreadystatechange
=infobox_callback
;
1229 function editSelectedFeedCat() {
1230 var rows
= getSelectedFeedCats();
1232 if (rows
.length
== 0) {
1233 alert(__("No categories are selected."));
1237 if (rows
.length
> 1) {
1238 alert(__("Please select only one category."));
1244 editFeedCat(rows
[0]);
1248 function piggie(enable
) {
1250 debug("I LOVEDED IT!");
1251 var piggie
= document
.getElementById("piggie");
1253 Element
.show(piggie
);
1254 Position
.Center(piggie
);
1255 Effect
.Puff(piggie
);
1260 function validateOpmlImport() {
1262 var opml_file
= document
.getElementById("opml_file");
1264 if (opml_file
.value
.length
== 0) {
1265 alert(__("No OPML file to upload."));
1272 function updateFilterList(sort_key
) {
1274 if (!xmlhttp_ready(xmlhttp
)) {
1275 printLockingError();
1279 var filter_search
= document
.getElementById("filter_search");
1281 if (filter_search
) { search
= filter_search
.value
; }
1283 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1284 param_escape(sort_key
) +
1285 "&search=" + param_escape(search
), true);
1286 xmlhttp
.onreadystatechange
=filterlist_callback
;
1291 function updateLabelList(sort_key
) {
1293 if (!xmlhttp_ready(xmlhttp
)) {
1294 printLockingError();
1298 var label_search
= document
.getElementById("label_search");
1300 if (label_search
) { search
= label_search
.value
; }
1302 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1303 param_escape(sort_key
) +
1304 "&search=" + param_escape(search
), true);
1305 xmlhttp
.onreadystatechange
=labellist_callback
;
1309 function updatePrefsList() {
1311 if (!xmlhttp_ready(xmlhttp
)) {
1312 printLockingError();
1316 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1317 xmlhttp
.onreadystatechange
=prefslist_callback
;
1322 function selectTab(id
, noupdate
, subop
) {
1326 if (!id
) id
= active_tab
;
1330 if (!xmlhttp_ready(xmlhttp
)) {
1331 printLockingError();
1336 var c
= document
.getElementById('prefContent');
1342 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1344 notify_progress("Loading, please wait...");
1346 // close active infobox if needed
1349 // clean up all current selections, just in case
1350 active_feed_cat
= false;
1351 active_label
= false;
1353 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1354 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1356 if (id
== "feedConfig") {
1358 } else if (id
== "filterConfig") {
1360 } else if (id
== "labelConfig") {
1362 } else if (id
== "genConfig") {
1364 } else if (id
== "userConfig") {
1366 } else if (id
== "feedBrowser") {
1367 updateBigFeedBrowser();
1371 /* clean selection from all tabs */
1373 var tabs_holder
= document
.getElementById("prefTabs");
1374 var tab
= tabs_holder
.firstChild
;
1377 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1378 tab
.className
= "prefsTab";
1380 tab
= tab
.nextSibling
;
1383 /* mark new tab as selected */
1385 tab
= document
.getElementById(id
+ "Tab");
1388 if (!tab
.className
.match("Selected")) {
1389 tab
.className
= tab
.className
+ "Selected";
1396 exception_error("selectTab", e
);
1400 function backend_sanity_check_callback() {
1402 if (xmlhttp
.readyState
== 4) {
1406 if (sanity_check_done
) {
1407 fatalError(11, "Sanity check request received twice. This can indicate "+
1408 "presence of Firebug or some other disrupting extension. "+
1409 "Please disable it and try again.");
1413 if (!xmlhttp
.responseXML
) {
1414 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1418 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1421 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1425 var error_code
= reply
.getAttribute("error-code");
1427 if (error_code
&& error_code
!= 0) {
1428 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1431 debug("sanity check ok");
1433 var params
= reply
.nextSibling
;
1436 debug('reading init-params...');
1437 var param
= params
.firstChild
;
1440 var k
= param
.getAttribute("key");
1441 var v
= param
.getAttribute("value");
1442 debug(k
+ " => " + v
);
1444 param
= param
.nextSibling
;
1448 sanity_check_done
= true;
1450 init_second_stage();
1453 exception_error("backend_sanity_check_callback", e
);
1458 function init_second_stage() {
1461 active_tab
= getInitParam("prefs_active_tab");
1462 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1464 document
.onkeydown
= pref_hotkey_handler
;
1466 var tab
= getURLParam('tab');
1468 caller_subop
= getURLParam('subop');
1474 if (navigator
.userAgent
.match("Opera")) {
1475 setTimeout("selectTab()", 500);
1477 selectTab(active_tab
);
1481 loading_set_progress(60);
1484 exception_error("init_second_stage", e
);
1492 if (arguments
.callee
.done
) return;
1493 arguments
.callee
.done
= true;
1495 if (getURLParam('debug')) {
1496 Element
.show("debug_output");
1497 debug('debug mode activated');
1502 document
.getElementById("prefContent").innerHTML
=
1503 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1504 "to function properly. Your browser doesn't seem to support it.";
1508 loading_set_progress(30);
1510 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1511 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1515 exception_error("init", e
);
1519 function categorizeSelectedFeeds() {
1521 if (!xmlhttp_ready(xmlhttp
)) {
1522 printLockingError();
1526 var sel_rows
= getSelectedFeeds();
1528 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1529 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1531 if (sel_rows
.length
> 0) {
1533 notify_progress("Changing category of selected feeds...");
1535 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1536 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1537 xmlhttp
.onreadystatechange
=feedlist_callback
;
1542 alert(__("No feeds are selected."));
1548 function validatePrefsReset() {
1550 var ok
= confirm(__("Reset to defaults?"));
1554 var query
= Form
.serialize("pref_prefs_form");
1555 query
= query
+ "&subop=reset-config";
1558 xmlhttp
.open("POST", "backend.php", true);
1559 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1560 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1561 xmlhttp
.send(query
);
1565 exception_error("validatePrefsSave", e
);
1572 function browseFeeds(limit
) {
1574 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1575 xmlhttp
.onreadystatechange
=infobox_callback
;
1580 function feedBrowserSubscribe() {
1583 var selected
= getSelectedFeedsFromBrowser();
1585 if (selected
.length
> 0) {
1587 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1588 param_escape(selected
.toString()), true);
1589 xmlhttp
.onreadystatechange
=feedlist_callback
;
1592 alert(__("No feeds are selected."));
1596 exception_error("feedBrowserSubscribe", e
);
1600 function updateBigFeedBrowserBtn() {
1601 notify_progress("Loading, please wait...");
1602 return updateBigFeedBrowser();
1605 function updateBigFeedBrowser(limit
, from_button
) {
1607 if (!xmlhttp_ready(xmlhttp
)) {
1608 printLockingError();
1612 var query
= "backend.php?op=pref-feed-browser";
1614 var limit_sel
= document
.getElementById("feedBrowserLimit");
1617 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1618 query
= query
+ "&limit=" + param_escape(limit
);
1621 xmlhttp
.open("GET", query
, true);
1622 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1626 function browserToggleExpand(id
) {
1628 /* if (feed_to_expand && feed_to_expand != id) {
1629 var d = document.getElementById("BRDET-" + feed_to_expand);
1630 d.style.display = "none";
1633 if (!xmlhttp_ready(xmlhttp
)) {
1634 printLockingError();
1638 /* if (feed_to_expand && id != feed_to_expand) {
1639 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1642 var d
= document
.getElementById("BRDET-" + id
);
1644 if (Element
.visible(d
)) {
1645 Effect
.Fade(d
, {duration
: 0.5});
1647 feed_to_expand
= id
;
1649 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1650 + param_escape(id
), true);
1651 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1656 exception_error("browserToggleExpand", e
);
1660 function selectPrefRows(kind
, select
) {
1663 var opbarid
= false;
1668 if (kind
== "feed") {
1669 opbarid
= "feedOpToolbar";
1672 lname
= "prefFeedList";
1673 } else if (kind
== "fcat") {
1674 opbarid
= "catOpToolbar";
1677 lname
= "prefFeedCatList";
1678 } else if (kind
== "filter") {
1679 opbarid
= "filterOpToolbar";
1682 lname
= "prefFilterList";
1683 } else if (kind
== "label") {
1684 opbarid
= "labelOpToolbar";
1687 lname
= "prefLabelList";
1688 } else if (kind
== "user") {
1689 opbarid
= "userOpToolbar";
1692 lname
= "prefUserList";
1696 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1697 disableContainerChildren(opbarid
, !select
);
1704 function toggleSelectPrefRow(sender
, kind
) {
1706 toggleSelectRow(sender
);
1709 var opbarid
= false;
1712 if (kind
== "feed") {
1713 opbarid
= "feedOpToolbar";
1714 nsel
= getSelectedFeeds();
1715 } else if (kind
== "fcat") {
1716 opbarid
= "catOpToolbar";
1717 nsel
= getSelectedFeedCats();
1718 } else if (kind
== "filter") {
1719 opbarid
= "filterOpToolbar";
1720 nsel
= getSelectedFilters();
1721 } else if (kind
== "label") {
1722 opbarid
= "labelOpToolbar";
1723 nsel
= getSelectedLabels();
1724 } else if (kind
== "user") {
1725 opbarid
= "userOpToolbar";
1726 nsel
= getSelectedUsers();
1729 if (opbarid
&& nsel
!= -1) {
1730 disableContainerChildren(opbarid
, nsel
== false);
1736 function toggleSelectFBListRow(sender
) {
1737 toggleSelectListRow(sender
);
1738 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1743 function pref_hotkey_handler(e
) {
1747 var shift_key
= false;
1750 shift_key
= e
.shiftKey
;
1756 keycode
= window
.event
.keyCode
;
1761 var keychar
= String
.fromCharCode(keycode
);
1763 if (keycode
== 27) { // escape
1764 if (Element
.visible("hotkey_help_overlay")) {
1765 Element
.hide("hotkey_help_overlay");
1767 hotkey_prefix
= false;
1771 if (!hotkeys_enabled
) {
1772 debug("hotkeys disabled");
1776 if (keycode
== 16) return; // ignore lone shift
1778 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1779 hotkey_prefix
= keycode
;
1780 debug("KP: PREFIX=" + keycode
+ " CHAR=" + keychar
);
1784 if (Element
.visible("hotkey_help_overlay")) {
1785 Element
.hide("hotkey_help_overlay");
1788 if (keycode
== 13 || keycode
== 27) {
1791 seq
= seq
+ "" + keycode
;
1794 /* Global hotkeys */
1796 if (!hotkey_prefix
) {
1798 if (keycode
== 68 && shift_key
) { // d
1799 if (!Element
.visible("debug_output")) {
1800 Element
.show("debug_output");
1801 debug('debug mode activated');
1803 Element
.hide("debug_output");
1808 if ((keycode
== 191 || keychar
== '?') && shift_key
) { // ?
1809 if (!Element
.visible("hotkey_help_overlay")) {
1810 //Element.show("hotkey_help_overlay");
1811 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
1813 Element
.hide("hotkey_help_overlay");
1818 if (keycode
== 191 || keychar
== '/') { // /
1819 var search_boxes
= new Array("label_search",
1820 "feed_search", "filter_search", "user_search");
1822 for (var i
= 0; i
< search_boxes
.length
; i
++) {
1823 var elem
= document
.getElementById(search_boxes
[i
]);
1825 focus_element(search_boxes
[i
]);
1834 if (hotkey_prefix
== 67) { // c
1835 hotkey_prefix
= false;
1837 if (keycode
== 70) { // f
1838 displayDlg("quickAddFilter");
1842 if (keycode
== 83) { // s
1843 displayDlg("quickAddFeed");
1847 /* if (keycode == 76) { // l
1848 displayDlg("quickAddLabel");
1852 if (keycode
== 85) { // u
1856 if (keycode
== 67) { // c
1861 if (keycode
== 84 && shift_key
) { // T
1870 if (hotkey_prefix
== 71) { // g
1872 hotkey_prefix
= false;
1874 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1875 selectTab("genConfig");
1879 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1880 selectTab("feedConfig");
1884 if (keycode
== 51 && document
.getElementById("feedBrowserTab")) { // 3
1885 selectTab("feedBrowser");
1889 if (keycode
== 52 && document
.getElementById("filterConfigTab")) { // 4
1890 selectTab("filterConfig");
1894 if (keycode
== 53 && document
.getElementById("labelConfigTab")) { // 5
1895 selectTab("labelConfig");
1899 if (keycode
== 54 && document
.getElementById("userConfigTab")) { // 6
1900 selectTab("userConfig");
1904 if (keycode
== 88) { // x
1910 if (document
.getElementById("piggie")) {
1912 if (seq
.match("807371717369")) {
1920 if (hotkey_prefix
) {
1921 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
+ " CHAR=" + keychar
);
1923 debug("KP: CODE=" + keycode
+ " CHAR=" + keychar
);
1927 exception_error("pref_hotkey_handler", e
);
1931 function editFeedCats() {
1932 if (!xmlhttp_ready(xmlhttp
)) {
1933 printLockingError();
1937 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1940 document
.getElementById("top25_feeds_btn").disabled
= true;
1942 // this button is not always available, no-op if not found
1945 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1946 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1950 function showFeedsWithErrors() {
1951 displayDlg('feedUpdateErrors');
1954 function changeUserPassword() {
1958 if (!xmlhttp_ready(xmlhttp
)) {
1959 printLockingError();
1963 var f
= document
.forms
["change_pass_form"];
1966 if (f
.OLD_PASSWORD
.value
== "") {
1967 new Effect
.Highlight(f
.OLD_PASSWORD
);
1968 notify_error("Old password cannot be blank.");
1972 if (f
.NEW_PASSWORD
.value
== "") {
1973 new Effect
.Highlight(f
.NEW_PASSWORD
);
1974 notify_error("New password cannot be blank.");
1978 if (f
.CONFIRM_PASSWORD
.value
== "") {
1979 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1980 notify_error("Entered passwords do not match.");
1984 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1985 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1986 new Effect
.Highlight(f
.NEW_PASSWORD
);
1987 notify_error("Entered passwords do not match.");
1993 var query
= Form
.serialize("change_pass_form");
1995 notify_progress("Trying to change password...");
1997 xmlhttp
.open("POST", "backend.php", true);
1998 xmlhttp
.onreadystatechange
=changepass_callback
;
1999 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2000 xmlhttp
.send(query
);
2003 exception_error("changeUserPassword", e
);
2009 function changeUserEmail() {
2013 if (!xmlhttp_ready(xmlhttp
)) {
2014 printLockingError();
2018 var query
= Form
.serialize("change_email_form");
2020 notify_progress("Trying to change e-mail...");
2022 xmlhttp
.open("POST", "backend.php", true);
2023 xmlhttp
.onreadystatechange
=notify_callback
;
2024 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2025 xmlhttp
.send(query
);
2028 exception_error("changeUserPassword", e
);
2035 function feedlistToggleSLAT() {
2036 notify_progress("Loading, please wait...");
2040 function pubRegenKey() {
2042 if (!xmlhttp_ready(xmlhttp
)) {
2043 printLockingError();
2047 var ok
= confirm(__("Replace current publishing address with a new one?"));
2051 notify_progress("Trying to change address...");
2053 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
2054 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
2061 function pubToClipboard() {
2065 if (!xmlhttp_ready(xmlhttp
)) {
2066 printLockingError();
2070 var link
= document
.getElementById("pubGenAddress");
2074 exception_error("pubToClipboard", e
);
2080 function validatePrefsSave() {
2083 var ok
= confirm(__("Save current configuration?"));
2087 var query
= Form
.serialize("pref_prefs_form");
2088 query
= query
+ "&subop=save-config";
2091 xmlhttp
.open("POST", "backend.php", true);
2092 xmlhttp
.onreadystatechange
=notify_callback
;
2093 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2094 xmlhttp
.send(query
);
2098 exception_error("validatePrefsSave", e
);
2104 function feedActionChange() {
2106 var chooser
= document
.getElementById("feedActionChooser");
2107 var opid
= chooser
[chooser
.selectedIndex
].value
;
2109 chooser
.selectedIndex
= 0;
2112 exception_error("feedActionChange", e
);
2116 function feedActionGo(op
) {
2118 if (op
== "facEdit") {
2120 var rows
= getSelectedFeeds();
2122 if (rows
.length
> 1) {
2123 editSelectedFeeds();
2129 if (op
== "facClear") {
2130 clearSelectedFeeds();
2133 if (op
== "facPurge") {
2134 purgeSelectedFeeds();
2137 if (op
== "facEditCats") {
2141 if (op
== "facRescore") {
2142 rescoreSelectedFeeds();
2145 if (op
== "facUnsubscribe") {
2146 removeSelectedFeeds();
2150 exception_error("feedActionGo", e
);
2155 function clearFeedArticles(feed_id
) {
2157 notify_progress("Clearing feed...");
2159 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
2161 new Ajax
.Request(query
, {
2162 onComplete: function(transport
) {
2169 function rescoreSelectedFeeds() {
2171 if (!xmlhttp_ready(xmlhttp
)) {
2172 printLockingError();
2176 var sel_rows
= getSelectedFeeds();
2178 if (sel_rows
.length
> 0) {
2180 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2181 var ok
= confirm(__("Rescore articles in selected feeds?"));
2184 notify_progress("Rescoring selected feeds...", true);
2186 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2187 param_escape(sel_rows
.toString()), true);
2188 xmlhttp
.onreadystatechange
=notify_callback
;
2192 alert(__("No feeds are selected."));
2198 function rescore_all_feeds() {
2199 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
2202 notify_progress("Rescoring feeds...", true);
2204 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2205 xmlhttp
.onreadystatechange
=notify_callback
;
2210 function removeFilter(id
, title
) {
2212 if (!xmlhttp_ready(xmlhttp
)) {
2213 printLockingError();
2217 var msg
= __("Remove filter %s?").replace("%s", title
);
2219 var ok
= confirm(msg
);
2224 notify_progress("Removing filter...");
2226 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
2227 param_escape(id
), true);
2228 xmlhttp
.onreadystatechange
=filterlist_callback
;
2235 function unsubscribeFeed(id
, title
) {
2237 if (!xmlhttp_ready(xmlhttp
)) {
2238 printLockingError();
2242 var msg
= __("Unsubscribe from %s?").replace("%s", title
);
2244 var ok
= confirm(msg
);
2249 notify_progress("Removing feed...");
2251 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
2252 param_escape(id
), true);
2253 xmlhttp
.onreadystatechange
=filterlist_callback
;
2263 function feedsEditSave() {
2266 if (!xmlhttp_ready(xmlhttp
)) {
2267 printLockingError();
2271 var ok
= confirm(__("Save changes to selected feeds?"));
2275 var f
= document
.forms
["batch_edit_feed_form"];
2277 var query
= Form
.serialize("batch_edit_feed_form");
2279 /* Form.serialize ignores unchecked checkboxes */
2281 if (!query
.match("&hidden=") &&
2282 f
.hidden
.disabled
== false) {
2283 query
= query
+ "&hidden=false";
2286 if (!query
.match("&rtl_content=") &&
2287 f
.rtl_content
.disabled
== false) {
2288 query
= query
+ "&rtl_content=false";
2291 if (!query
.match("&private=") &&
2292 f
.private.disabled
== false) {
2293 query
= query
+ "&private=false";
2296 if (!query
.match("&cache_images=") &&
2297 f
.cache_images
.disabled
== false) {
2298 query
= query
+ "&cache_images=false";
2301 if (!query
.match("&include_in_digest=") &&
2302 f
.include_in_digest
.disabled
== false) {
2303 query
= query
+ "&include_in_digest=false";
2308 notify_progress("Saving feeds...");
2310 xmlhttp
.open("POST", "backend.php", true);
2311 xmlhttp
.onreadystatechange
=feedlist_callback
;
2312 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2313 xmlhttp
.send(query
);
2318 exception_error("feedsEditSave", e
);
2322 function batchFeedsToggleField(cb
, elem
, label
) {
2324 var f
= document
.forms
["batch_edit_feed_form"];
2325 var l
= document
.getElementById(label
);
2328 f
[elem
].disabled
= false;
2334 // new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5",
2335 // queue: { position:'end', scope: 'BPEFQ', limit: 1 } } );
2338 f
[elem
].disabled
= true;
2341 l
.className
= "insensitive";
2346 exception_error("batchFeedsToggleField", e
);