1 var init_params = new Array();
3 var hotkey_prefix = false;
4 var hotkey_prefix_pressed = false;
8 function notify_callback2(transport, sticky) {
9 notify_info(transport.responseText, sticky);
12 function updateFeedList(sort_key) {
14 var user_search = $("feed_search");
16 if (user_search) { search = user_search.value; }
18 new Ajax.Request("backend.php", {
19 parameters: "?op=pref-feeds&search=" + param_escape(search),
20 onComplete: function(transport) {
21 dijit.byId('feedConfigTab').attr('content', transport.responseText);
22 selectTab("feedConfig", true);
27 function updateInstanceList(sort_key) {
28 new Ajax.Request("backend.php", {
29 parameters: "?op=pref-instances&sort=" + param_escape(sort_key),
30 onComplete: function(transport) {
31 dijit.byId('instanceConfigTab').attr('content', transport.responseText);
32 selectTab("instanceConfig", true);
37 function updateUsersList(sort_key) {
39 var user_search = $("user_search");
41 if (user_search) { search = user_search.value; }
43 var query = "?op=pref-users&sort="
44 + param_escape(sort_key) +
45 "&search=" + param_escape(search);
47 new Ajax.Request("backend.php", {
49 onComplete: function(transport) {
50 dijit.byId('userConfigTab').attr('content', transport.responseText);
51 selectTab("userConfig", true)
56 exception_error("updateUsersList", e);
64 var login = prompt(__("Please enter login:"), "");
71 alert(__("Can't create user: no login specified."));
75 notify_progress("Adding user...");
77 var query = "?op=pref-users&method=add&login=" +
80 new Ajax.Request("backend.php", {
82 onComplete: function(transport) {
83 notify_callback2(transport);
88 exception_error("addUser", e);
92 function editUser(id, event) {
95 if (!event || !event.ctrlKey) {
97 notify_progress("Loading, please wait...");
99 selectTableRows('prefUserList', 'none');
100 selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true);
102 var query = "?op=pref-users&method=edit&id=" +
105 new Ajax.Request("backend.php", {
107 onComplete: function(transport) {
108 infobox_callback2(transport);
109 document.forms['user_edit_form'].login.focus();
112 } else if (event.ctrlKey) {
113 var cb = $('UMCHK-' + id);
114 cb.checked = !cb.checked;
119 exception_error("editUser", e);
124 function editFilter(id) {
127 var query = "backend.php?op=pref-filters&method=edit&id=" + param_escape(id);
129 if (dijit.byId("feedEditDlg"))
130 dijit.byId("feedEditDlg").destroyRecursive();
132 if (dijit.byId("filterEditDlg"))
133 dijit.byId("filterEditDlg").destroyRecursive();
135 dialog = new dijit.Dialog({
137 title: __("Edit Filter"),
138 style: "width: 600px",
140 var query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test";
142 if (dijit.byId("filterTestDlg"))
143 dijit.byId("filterTestDlg").destroyRecursive();
145 var test_dlg = new dijit.Dialog({
147 title: "Test Filter",
148 style: "width: 600px",
153 selectRules: function(select) {
154 $$("#filterDlg_Matches input[type=checkbox]").each(function(e) {
157 e.parentNode.addClassName("Selected");
159 e.parentNode.removeClassName("Selected");
162 selectActions: function(select) {
163 $$("#filterDlg_Actions input[type=checkbox]").each(function(e) {
167 e.parentNode.addClassName("Selected");
169 e.parentNode.removeClassName("Selected");
173 editRule: function(e) {
174 var li = e.parentNode;
175 var rule = li.getElementsByTagName("INPUT")[1].value;
176 addFilterRule(li, rule);
178 editAction: function(e) {
179 var li = e.parentNode;
180 var action = li.getElementsByTagName("INPUT")[1].value;
181 addFilterAction(li, action);
183 removeFilter: function() {
184 var msg = __("Remove filter?");
189 notify_progress("Removing filter...");
191 var id = this.attr('value').id;
193 var query = "?op=pref-filters&method=remove&ids="+
196 new Ajax.Request("backend.php", {
198 onComplete: function(transport) {
203 addAction: function() { addFilterAction(); },
204 addRule: function() { addFilterRule(); },
205 deleteAction: function() {
206 $$("#filterDlg_Actions li.[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
208 deleteRule: function() {
209 $$("#filterDlg_Matches li.[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
211 execute: function() {
212 if (this.validate()) {
214 notify_progress("Saving data...", true);
216 var query = dojo.formToQuery("filter_edit_form");
220 new Ajax.Request("backend.php", {
222 onComplete: function(transport) {
234 exception_error("editFilter", e);
238 function getSelectedLabels() {
239 var tree = dijit.byId("labelTree");
240 var items = tree.model.getCheckedItems();
243 items.each(function(item) {
244 rv.push(tree.model.store.getValue(item, 'bare_id'));
250 function getSelectedUsers() {
251 return getSelectedTableRowIds("prefUserList");
254 function getSelectedFeeds() {
255 var tree = dijit.byId("feedTree");
256 var items = tree.model.getCheckedItems();
259 items.each(function(item) {
260 if (item.id[0].match("FEED:"))
261 rv.push(tree.model.store.getValue(item, 'bare_id'));
267 function getSelectedCategories() {
268 var tree = dijit.byId("feedTree");
269 var items = tree.model.getCheckedItems();
272 items.each(function(item) {
273 if (item.id[0].match("CAT:"))
274 rv.push(tree.model.store.getValue(item, 'bare_id'));
280 function getSelectedFilters() {
281 var tree = dijit.byId("filterTree");
282 var items = tree.model.getCheckedItems();
285 items.each(function(item) {
286 rv.push(tree.model.store.getValue(item, 'bare_id'));
293 function removeSelectedLabels() {
295 var sel_rows = getSelectedLabels();
297 if (sel_rows.length > 0) {
299 var ok = confirm(__("Remove selected labels?"));
302 notify_progress("Removing selected labels...");
304 var query = "?op=pref-labels&method=remove&ids="+
305 param_escape(sel_rows.toString());
307 new Ajax.Request("backend.php", {
309 onComplete: function(transport) {
315 alert(__("No labels are selected."));
321 function removeSelectedUsers() {
325 var sel_rows = getSelectedUsers();
327 if (sel_rows.length > 0) {
329 var ok = confirm(__("Remove selected users? Neither default admin nor your account will be removed."));
332 notify_progress("Removing selected users...");
334 var query = "?op=pref-users&method=remove&ids="+
335 param_escape(sel_rows.toString());
337 new Ajax.Request("backend.php", {
339 onComplete: function(transport) {
346 alert(__("No users are selected."));
350 exception_error("removeSelectedUsers", e);
356 function removeSelectedFilters() {
360 var sel_rows = getSelectedFilters();
362 if (sel_rows.length > 0) {
364 var ok = confirm(__("Remove selected filters?"));
367 notify_progress("Removing selected filters...");
369 var query = "?op=pref-filters&method=remove&ids="+
370 param_escape(sel_rows.toString());
372 new Ajax.Request("backend.php", {
374 onComplete: function(transport) {
379 alert(__("No filters are selected."));
383 exception_error("removeSelectedFilters", e);
390 function removeSelectedFeeds() {
394 var sel_rows = getSelectedFeeds();
396 if (sel_rows.length > 0) {
398 var ok = confirm(__("Unsubscribe from selected feeds?"));
402 notify_progress("Unsubscribing from selected feeds...", true);
404 var query = "?op=pref-feeds&method=remove&ids="+
405 param_escape(sel_rows.toString());
409 new Ajax.Request("backend.php", {
411 onComplete: function(transport) {
417 alert(__("No feeds are selected."));
421 exception_error("removeSelectedFeeds", e);
427 function clearSelectedFeeds() {
429 var sel_rows = getSelectedFeeds();
431 if (sel_rows.length > 1) {
432 alert(__("Please select only one feed."));
436 if (sel_rows.length > 0) {
438 var ok = confirm(__("Erase all non-starred articles in selected feed?"));
441 notify_progress("Clearing selected feed...");
442 clearFeedArticles(sel_rows[0]);
447 alert(__("No feeds are selected."));
454 function purgeSelectedFeeds() {
456 var sel_rows = getSelectedFeeds();
458 if (sel_rows.length > 0) {
460 var pr = prompt(__("How many days of articles to keep (0 - use default)?"), "0");
462 if (pr != undefined) {
463 notify_progress("Purging selected feed...");
465 var query = "?op=rpc&method=purge&ids="+
466 param_escape(sel_rows.toString()) + "&days=" + pr;
470 new Ajax.Request("prefs.php", {
472 onComplete: function(transport) {
479 alert(__("No feeds are selected."));
486 function userEditCancel() {
491 function userEditSave() {
495 var login = document.forms["user_edit_form"].login.value;
497 if (login.length == 0) {
498 alert(__("Login field cannot be blank."));
502 notify_progress("Saving user...");
506 var query = Form.serialize("user_edit_form");
508 new Ajax.Request("backend.php", {
510 onComplete: function(transport) {
515 exception_error("userEditSave", e);
523 function editSelectedUser() {
524 var rows = getSelectedUsers();
526 if (rows.length == 0) {
527 alert(__("No users are selected."));
531 if (rows.length > 1) {
532 alert(__("Please select only one user."));
541 function resetSelectedUserPass() {
545 var rows = getSelectedUsers();
547 if (rows.length == 0) {
548 alert(__("No users are selected."));
552 if (rows.length > 1) {
553 alert(__("Please select only one user."));
557 var ok = confirm(__("Reset password of selected user?"));
560 notify_progress("Resetting password for selected user...");
564 var query = "?op=pref-users&method=resetPass&id=" +
567 new Ajax.Request("backend.php", {
569 onComplete: function(transport) {
570 notify_info(transport.responseText);
576 exception_error("resetSelectedUserPass", e);
580 function selectedUserDetails() {
584 var rows = getSelectedUsers();
586 if (rows.length == 0) {
587 alert(__("No users are selected."));
591 if (rows.length > 1) {
592 alert(__("Please select only one user."));
596 notify_progress("Loading, please wait...");
600 var query = "?op=pref-users&method=userdetails&id=" + id;
602 new Ajax.Request("backend.php", {
604 onComplete: function(transport) {
605 infobox_callback2(transport);
608 exception_error("selectedUserDetails", e);
613 function editSelectedFilter() {
614 var rows = getSelectedFilters();
616 if (rows.length == 0) {
617 alert(__("No filters are selected."));
621 if (rows.length > 1) {
622 alert(__("Please select only one filter."));
632 function joinSelectedFilters() {
633 var rows = getSelectedFilters();
635 if (rows.length == 0) {
636 alert(__("No filters are selected."));
640 var ok = confirm(__("Combine selected filters?"));
643 notify_progress("Joining filters...");
645 var query = "?op=pref-filters&method=join&ids="+
646 param_escape(rows.toString());
650 new Ajax.Request("backend.php", {
652 onComplete: function(transport) {
658 function editSelectedFeed() {
659 var rows = getSelectedFeeds();
661 if (rows.length == 0) {
662 alert(__("No feeds are selected."));
666 if (rows.length > 1) {
667 return editSelectedFeeds();
672 editFeed(rows[0], {});
676 function editSelectedFeeds() {
679 var rows = getSelectedFeeds();
681 if (rows.length == 0) {
682 alert(__("No feeds are selected."));
686 notify_progress("Loading, please wait...");
688 var query = "backend.php?op=pref-feeds&method=editfeeds&ids=" +
689 param_escape(rows.toString());
693 if (dijit.byId("feedEditDlg"))
694 dijit.byId("feedEditDlg").destroyRecursive();
696 new Ajax.Request("backend.php", {
698 onComplete: function(transport) {
702 var dialog = new dijit.Dialog({
704 title: __("Edit Multiple Feeds"),
705 style: "width: 600px",
706 getChildByName: function (name) {
708 this.getChildren().each(
710 if (child.name == name) {
717 toggleField: function (checkbox, elem, label) {
718 this.getChildByName(elem).attr('disabled', !checkbox.checked);
721 if (checkbox.checked)
722 $(label).removeClassName('insensitive');
724 $(label).addClassName('insensitive');
727 execute: function() {
728 if (this.validate() && confirm(__("Save changes to selected feeds?"))) {
729 var query = dojo.objectToQuery(this.attr('value'));
731 /* Form.serialize ignores unchecked checkboxes */
733 if (!query.match("&rtl_content=") &&
734 this.getChildByName('rtl_content').attr('disabled') == false) {
735 query = query + "&rtl_content=false";
738 if (!query.match("&private=") &&
739 this.getChildByName('private').attr('disabled') == false) {
740 query = query + "&private=false";
744 if (!query.match("&cache_images=") &&
745 this.getChildByName('cache_images').attr('disabled') == false) {
746 query = query + "&cache_images=false";
750 if (!query.match("&include_in_digest=") &&
751 this.getChildByName('include_in_digest').attr('disabled') == false) {
752 query = query + "&include_in_digest=false";
755 if (!query.match("&always_display_enclosures=") &&
756 this.getChildByName('always_display_enclosures').attr('disabled') == false) {
757 query = query + "&always_display_enclosures=false";
760 if (!query.match("&mark_unread_on_update=") &&
761 this.getChildByName('mark_unread_on_update').attr('disabled') == false) {
762 query = query + "&mark_unread_on_update=false";
765 if (!query.match("&update_on_checksum_change=") &&
766 this.getChildByName('update_on_checksum_change').attr('disabled') == false) {
767 query = query + "&update_on_checksum_change=false";
772 notify_progress("Saving data...", true);
774 new Ajax.Request("backend.php", {
776 onComplete: function(transport) {
782 content: transport.responseText});
789 exception_error("editSelectedFeeds", e);
793 function piggie(enable) {
795 console.log("I LOVEDED IT!");
796 var piggie = $("piggie");
798 Element.show(piggie);
799 Position.Center(piggie);
805 function opmlImportComplete(iframe) {
807 if (!iframe.contentDocument.body.innerHTML) return false;
809 Element.show(iframe);
813 if (dijit.byId('opmlImportDlg'))
814 dijit.byId('opmlImportDlg').destroyRecursive();
816 var content = iframe.contentDocument.body.innerHTML;
818 dialog = new dijit.Dialog({
820 title: __("OPML Import"),
821 style: "width: 600px",
822 onCancel: function() {
827 execute: function() {
838 exception_error("opmlImportComplete", e);
842 function opmlImport() {
844 var opml_file = $("opml_file");
846 if (opml_file.value.length == 0) {
847 alert(__("Please choose an OPML file first."));
850 notify_progress("Importing, please wait...", true);
852 Element.show("upload_iframe");
858 function importData() {
860 var file = $("export_file");
862 if (file.value.length == 0) {
863 alert(__("Please choose the file first."));
866 notify_progress("Importing, please wait...", true);
868 Element.show("data_upload_iframe");
875 function updateFilterList() {
876 var user_search = $("filter_search");
878 if (user_search) { search = user_search.value; }
880 new Ajax.Request("backend.php", {
881 parameters: "?op=pref-filters&search=" + param_escape(search),
882 onComplete: function(transport) {
883 dijit.byId('filterConfigTab').attr('content', transport.responseText);
888 function updateLabelList() {
889 new Ajax.Request("backend.php", {
890 parameters: "?op=pref-labels",
891 onComplete: function(transport) {
892 dijit.byId('labelConfigTab').attr('content', transport.responseText);
897 function updatePrefsList() {
898 new Ajax.Request("backend.php", {
899 parameters: "?op=pref-prefs",
900 onComplete: function(transport) {
901 dijit.byId('genConfigTab').attr('content', transport.responseText);
906 function selectTab(id, noupdate, method) {
909 notify_progress("Loading, please wait...");
911 if (id == "feedConfig") {
913 } else if (id == "filterConfig") {
915 } else if (id == "labelConfig") {
917 } else if (id == "genConfig") {
919 } else if (id == "userConfig") {
923 var tab = dijit.byId(id + "Tab");
924 dijit.byId("pref-tabs").selectChild(tab);
929 exception_error("selectTab", e);
933 function init_second_stage() {
936 document.onkeydown = pref_hotkey_handler;
937 loading_set_progress(50);
940 dojo.addOnLoad(function() {
941 var tab = getURLParam('tab');
944 tab = dijit.byId(tab + "Tab");
945 if (tab) dijit.byId("pref-tabs").selectChild(tab);
948 var method = getURLParam('method');
950 if (method == 'editFeed') {
951 var param = getURLParam('methodparam');
953 window.setTimeout('editFeed(' + param + ')', 100);
957 setTimeout("hotkey_prefix_timeout()", 5*1000);
960 exception_error("init_second_stage", e);
967 dojo.registerModulePath("lib", "..");
968 dojo.registerModulePath("fox", "../../js/");
970 dojo.require("dijit.ColorPalette");
971 dojo.require("dijit.Dialog");
972 dojo.require("dijit.form.Button");
973 dojo.require("dijit.form.CheckBox");
974 dojo.require("dijit.form.DropDownButton");
975 dojo.require("dijit.form.FilteringSelect");
976 dojo.require("dijit.form.Form");
977 dojo.require("dijit.form.RadioButton");
978 dojo.require("dijit.form.Select");
979 dojo.require("dijit.form.SimpleTextarea");
980 dojo.require("dijit.form.TextBox");
981 dojo.require("dijit.form.ValidationTextBox");
982 dojo.require("dijit.InlineEditBox");
983 dojo.require("dijit.layout.AccordionContainer");
984 dojo.require("dijit.layout.BorderContainer");
985 dojo.require("dijit.layout.ContentPane");
986 dojo.require("dijit.layout.TabContainer");
987 dojo.require("dijit.Menu");
988 dojo.require("dijit.ProgressBar");
989 dojo.require("dijit.ProgressBar");
990 dojo.require("dijit.Toolbar");
991 dojo.require("dijit.Tree");
992 dojo.require("dijit.tree.dndSource");
993 dojo.require("dojo.data.ItemFileWriteStore");
995 dojo.require("lib.CheckBoxTree");
996 dojo.require("fox.PrefFeedTree");
997 dojo.require("fox.PrefFilterTree");
998 dojo.require("fox.PrefLabelTree");
1000 dojo.parser.parse();
1002 dojo.addOnLoad(function() {
1003 loading_set_progress(50);
1005 new Ajax.Request("backend.php", {
1006 parameters: {op: "rpc", method: "sanityCheck"},
1007 onComplete: function(transport) {
1008 backend_sanity_check_callback(transport);
1013 exception_error("init", e);
1017 function validatePrefsReset() {
1019 var ok = confirm(__("Reset to defaults?"));
1023 query = "?op=pref-prefs&method=resetconfig";
1026 new Ajax.Request("backend.php", {
1028 onComplete: function(transport) {
1029 var msg = transport.responseText;
1030 if (msg.match("PREFS_THEME_CHANGED")) {
1031 window.location.reload();
1041 exception_error("validatePrefsReset", e);
1049 function pref_hotkey_handler(e) {
1051 if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
1053 var keycode = false;
1054 var shift_key = false;
1056 var cmdline = $('cmdline');
1059 shift_key = e.shiftKey;
1065 keycode = window.event.keyCode;
1070 var keychar = String.fromCharCode(keycode);
1072 if (keycode == 27) { // escape
1073 if (Element.visible("hotkey_help_overlay")) {
1074 Element.hide("hotkey_help_overlay");
1076 hotkey_prefix = false;
1080 if (keycode == 16) return; // ignore lone shift
1081 if (keycode == 17) return; // ignore lone ctrl
1083 if ((keycode == 67 || keycode == 71) && !hotkey_prefix) {
1084 hotkey_prefix = keycode;
1086 var date = new Date();
1087 var ts = Math.round(date.getTime() / 1000);
1089 hotkey_prefix_pressed = ts;
1091 cmdline.innerHTML = keychar;
1092 Element.show(cmdline);
1094 console.log("KP: PREFIX=" + keycode + " CHAR=" + keychar);
1098 if (Element.visible("hotkey_help_overlay")) {
1099 Element.hide("hotkey_help_overlay");
1102 if (keycode == 13 || keycode == 27) {
1105 seq = seq + "" + keycode;
1108 /* Global hotkeys */
1110 Element.hide(cmdline);
1112 if (!hotkey_prefix) {
1114 if ((keycode == 191 || keychar == '?') && shift_key) { // ?
1119 if (keycode == 191 || keychar == '/') { // /
1120 var search_boxes = new Array("label_search",
1121 "feed_search", "filter_search", "user_search", "feed_browser_search");
1123 for (var i = 0; i < search_boxes.length; i++) {
1124 var elem = $(search_boxes[i]);
1126 $(search_boxes[i]).focus();
1135 if (hotkey_prefix == 67) { // c
1136 hotkey_prefix = false;
1138 if (keycode == 70) { // f
1143 if (keycode == 83) { // s
1148 if (keycode == 85) { // u
1152 if (keycode == 67) { // c
1157 if (keycode == 84 && shift_key) { // T
1166 if (hotkey_prefix == 71) { // g
1168 hotkey_prefix = false;
1170 if (keycode == 49 && $("genConfigTab")) { // 1
1171 selectTab("genConfig");
1175 if (keycode == 50 && $("feedConfigTab")) { // 2
1176 selectTab("feedConfig");
1180 if (keycode == 51 && $("filterConfigTab")) { // 4
1181 selectTab("filterConfig");
1185 if (keycode == 52 && $("labelConfigTab")) { // 5
1186 selectTab("labelConfig");
1190 if (keycode == 53 && $("userConfigTab")) { // 6
1191 selectTab("userConfig");
1195 if (keycode == 88) { // x
1202 if (seq.match("8073717369")) {
1210 if (hotkey_prefix) {
1211 console.log("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode + " CHAR=" + keychar);
1213 console.log("KP: CODE=" + keycode + " CHAR=" + keychar);
1217 exception_error("pref_hotkey_handler", e);
1221 function removeCategory(id, item) {
1224 var ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name));
1227 var query = "?op=pref-feeds&method=removeCat&ids="+
1230 notify_progress("Removing category...");
1232 new Ajax.Request("backend.php", {
1234 onComplete: function(transport) {
1241 exception_error("removeCategory", e);
1245 function removeSelectedCategories() {
1247 var sel_rows = getSelectedCategories();
1249 if (sel_rows.length > 0) {
1251 var ok = confirm(__("Remove selected categories?"));
1254 notify_progress("Removing selected categories...");
1256 var query = "?op=pref-feeds&method=removeCat&ids="+
1257 param_escape(sel_rows.toString());
1259 new Ajax.Request("backend.php", {
1261 onComplete: function(transport) {
1267 alert(__("No categories are selected."));
1273 function createCategory() {
1275 var title = prompt(__("Category title:"));
1279 notify_progress("Creating category...");
1281 var query = "?op=pref-feeds&method=addCat&cat=" +
1282 param_escape(title);
1284 new Ajax.Request("backend.php", {
1286 onComplete: function(transport) {
1293 exception_error("createCategory", e);
1297 function showInactiveFeeds() {
1299 var query = "backend.php?op=pref-feeds&method=inactiveFeeds";
1301 if (dijit.byId("inactiveFeedsDlg"))
1302 dijit.byId("inactiveFeedsDlg").destroyRecursive();
1304 dialog = new dijit.Dialog({
1305 id: "inactiveFeedsDlg",
1306 title: __("Feeds without recent updates"),
1307 style: "width: 600px",
1308 getSelectedFeeds: function() {
1309 return getSelectedTableRowIds("prefInactiveFeedList");
1311 removeSelected: function() {
1312 var sel_rows = this.getSelectedFeeds();
1314 console.log(sel_rows);
1316 if (sel_rows.length > 0) {
1317 var ok = confirm(__("Remove selected feeds?"));
1320 notify_progress("Removing selected feeds...", true);
1322 var query = "?op=pref-feeds&method=remove&ids="+
1323 param_escape(sel_rows.toString());
1325 new Ajax.Request("backend.php", {
1327 onComplete: function(transport) {
1335 alert(__("No feeds are selected."));
1338 execute: function() {
1339 if (this.validate()) {
1347 exception_error("showInactiveFeeds", e);
1352 function opmlRegenKey() {
1355 var ok = confirm(__("Replace current OPML publishing address with a new one?"));
1359 notify_progress("Trying to change address...", true);
1361 var query = "?op=rpc&method=regenOPMLKey";
1363 new Ajax.Request("backend.php", {
1365 onComplete: function(transport) {
1366 var reply = JSON.parse(transport.responseText);
1368 var new_link = reply.link;
1370 var e = $('pub_opml_url');
1374 e.innerHTML = new_link;
1376 new Effect.Highlight(e);
1381 notify_error("Could not change feed URL.");
1386 exception_error("opmlRegenKey", e);
1391 function feedActionChange() {
1393 var chooser = $("feedActionChooser");
1394 var opid = chooser[chooser.selectedIndex].value;
1396 chooser.selectedIndex = 0;
1399 exception_error("feedActionChange", e);
1403 function feedActionGo(op) {
1405 if (op == "facEdit") {
1407 var rows = getSelectedFeeds();
1409 if (rows.length > 1) {
1410 editSelectedFeeds();
1416 if (op == "facClear") {
1417 clearSelectedFeeds();
1420 if (op == "facPurge") {
1421 purgeSelectedFeeds();
1424 if (op == "facEditCats") {
1428 if (op == "facRescore") {
1429 rescoreSelectedFeeds();
1432 if (op == "facUnsubscribe") {
1433 removeSelectedFeeds();
1437 exception_error("feedActionGo", e);
1442 function clearFeedArticles(feed_id) {
1444 notify_progress("Clearing feed...");
1446 var query = "?op=pref-feeds&quiet=1&method=clear&id=" + feed_id;
1448 new Ajax.Request("backend.php", {
1450 onComplete: function(transport) {
1457 function rescoreSelectedFeeds() {
1459 var sel_rows = getSelectedFeeds();
1461 if (sel_rows.length > 0) {
1463 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
1464 var ok = confirm(__("Rescore articles in selected feeds?"));
1467 notify_progress("Rescoring selected feeds...", true);
1469 var query = "?op=pref-feeds&method=rescore&quiet=1&ids="+
1470 param_escape(sel_rows.toString());
1472 new Ajax.Request("backend.php", {
1474 onComplete: function(transport) {
1475 notify_callback2(transport);
1480 alert(__("No feeds are selected."));
1486 function rescore_all_feeds() {
1487 var ok = confirm(__("Rescore all articles? This operation may take a lot of time."));
1490 notify_progress("Rescoring feeds...", true);
1492 var query = "?op=pref-feeds&method=rescoreAll&quiet=1";
1494 new Ajax.Request("backend.php", {
1496 onComplete: function(transport) {
1497 notify_callback2(transport);
1502 function labelColorReset() {
1504 var labels = getSelectedLabels();
1506 if (labels.length > 0) {
1507 var ok = confirm(__("Reset selected labels to default colors?"));
1510 var query = "?op=pref-labels&method=colorreset&ids="+
1511 param_escape(labels.toString());
1513 new Ajax.Request("backend.php", {
1515 onComplete: function(transport) {
1521 alert(__("No labels are selected."));
1525 exception_error("labelColorReset", e);
1530 function inPreferences() {
1534 function editProfiles() {
1537 if (dijit.byId("profileEditDlg"))
1538 dijit.byId("profileEditDlg").destroyRecursive();
1540 var query = "backend.php?op=dlg&method=editPrefProfiles";
1542 dialog = new dijit.Dialog({
1543 id: "profileEditDlg",
1544 title: __("Settings Profiles"),
1545 style: "width: 600px",
1546 getSelectedProfiles: function() {
1547 return getSelectedTableRowIds("prefFeedProfileList");
1549 removeSelected: function() {
1550 var sel_rows = this.getSelectedProfiles();
1552 if (sel_rows.length > 0) {
1553 var ok = confirm(__("Remove selected profiles? Active and default profiles will not be removed."));
1556 notify_progress("Removing selected profiles...", true);
1558 var query = "?op=rpc&method=remprofiles&ids="+
1559 param_escape(sel_rows.toString());
1561 new Ajax.Request("backend.php", {
1563 onComplete: function(transport) {
1571 alert(__("No profiles are selected."));
1574 activateProfile: function() {
1575 var sel_rows = this.getSelectedProfiles();
1577 if (sel_rows.length == 1) {
1579 var ok = confirm(__("Activate selected profile?"));
1582 notify_progress("Loading, please wait...");
1584 var query = "?op=rpc&method=setprofile&id="+
1585 param_escape(sel_rows.toString());
1587 new Ajax.Request("backend.php", {
1589 onComplete: function(transport) {
1590 window.location.reload();
1595 alert(__("Please choose a profile to activate."));
1598 addProfile: function() {
1599 if (this.validate()) {
1600 notify_progress("Creating profile...", true);
1602 var query = "?op=rpc&method=addprofile&title=" +
1603 param_escape(dialog.attr('value').newprofile);
1605 new Ajax.Request("backend.php", {
1607 onComplete: function(transport) {
1614 execute: function() {
1615 if (this.validate()) {
1622 exception_error("editProfiles", e);
1626 function activatePrefProfile() {
1628 var sel_rows = getSelectedFeedCats();
1630 if (sel_rows.length == 1) {
1632 var ok = confirm(__("Activate selected profile?"));
1635 notify_progress("Loading, please wait...");
1637 var query = "?op=rpc&method=setprofile&id="+
1638 param_escape(sel_rows.toString());
1640 new Ajax.Request("backend.php", {
1642 onComplete: function(transport) {
1643 window.location.reload();
1648 alert(__("Please choose a profile to activate."));
1654 function clearFeedAccessKeys() {
1656 var ok = confirm(__("This will invalidate all previously generated feed URLs. Continue?"));
1659 notify_progress("Clearing URLs...");
1661 var query = "?op=rpc&method=clearKeys";
1663 new Ajax.Request("backend.php", {
1665 onComplete: function(transport) {
1666 notify_info("Generated URLs cleared.");
1673 function clearArticleAccessKeys() {
1675 var ok = confirm(__("This will invalidate all previously shared article URLs. Continue?"));
1678 notify_progress("Clearing URLs...");
1680 var query = "?op=rpc&method=clearArticleKeys";
1682 new Ajax.Request("backend.php", {
1684 onComplete: function(transport) {
1685 notify_info("Shared URLs cleared.");
1691 function resetFeedOrder() {
1693 notify_progress("Loading, please wait...");
1695 new Ajax.Request("backend.php", {
1696 parameters: "?op=pref-feeds&method=feedsortreset",
1697 onComplete: function(transport) {
1703 exception_error("resetFeedOrder");
1707 function resetCatOrder() {
1709 notify_progress("Loading, please wait...");
1711 new Ajax.Request("backend.php", {
1712 parameters: "?op=pref-feeds&method=catsortreset",
1713 onComplete: function(transport) {
1719 exception_error("resetCatOrder");
1723 function toggleHiddenFeedCats() {
1725 notify_progress("Loading, please wait...");
1727 new Ajax.Request("backend.php", {
1728 parameters: "?op=pref-feeds&method=togglehiddenfeedcats",
1729 onComplete: function(transport) {
1734 exception_error("toggleHiddenFeedCats");
1738 function editCat(id, item, event) {
1740 var new_name = prompt(__('Rename category to:'), item.name);
1742 if (new_name && new_name != item.name) {
1744 notify_progress("Loading, please wait...");
1746 new Ajax.Request("backend.php", {
1749 method: 'renamecat',
1753 onComplete: function(transport) {
1759 exception_error("editCat", e);
1763 function editLabel(id, event) {
1765 var query = "backend.php?op=pref-labels&method=edit&id=" +
1768 if (dijit.byId("labelEditDlg"))
1769 dijit.byId("labelEditDlg").destroyRecursive();
1771 dialog = new dijit.Dialog({
1773 title: __("Label Editor"),
1774 style: "width: 600px",
1775 setLabelColor: function(id, fg, bg) {
1790 var query = "?op=pref-labels&method=colorset&kind="+kind+
1791 "&ids=" + param_escape(id) + "&fg=" + param_escape(fg) +
1792 "&bg=" + param_escape(bg) + "&color=" + param_escape(color);
1794 // console.log(query);
1796 var e = $("LICID-" + id);
1799 if (fg) e.style.color = fg;
1800 if (bg) e.style.backgroundColor = bg;
1803 new Ajax.Request("backend.php", { parameters: query });
1807 execute: function() {
1808 if (this.validate()) {
1809 var caption = this.attr('value').caption;
1810 var fg_color = this.attr('value').fg_color;
1811 var bg_color = this.attr('value').bg_color;
1812 var query = dojo.objectToQuery(this.attr('value'));
1814 dijit.byId('labelTree').setNameById(id, caption);
1815 this.setLabelColor(id, fg_color, bg_color);
1818 new Ajax.Request("backend.php", {
1820 onComplete: function(transport) {
1830 exception_error("editLabel", e);
1834 function clearTwitterCredentials() {
1836 var ok = confirm(__("This will clear your stored authentication information for Twitter. Continue?"));
1839 notify_progress("Clearing credentials...");
1841 var query = "?op=pref-feeds&method=remtwitterinfo";
1843 new Ajax.Request("backend.php", {
1845 onComplete: function(transport) {
1846 notify_info("Twitter credentials have been cleared.");
1852 exception_error("clearTwitterCredentials", e);
1856 function customizeCSS() {
1858 var query = "backend.php?op=dlg&method=customizeCSS";
1860 if (dijit.byId("cssEditDlg"))
1861 dijit.byId("cssEditDlg").destroyRecursive();
1863 dialog = new dijit.Dialog({
1865 title: __("Customize stylesheet"),
1866 style: "width: 600px",
1867 execute: function() {
1868 notify_progress('Saving data...', true);
1869 new Ajax.Request("backend.php", {
1870 parameters: dojo.objectToQuery(this.attr('value')),
1871 onComplete: function(transport) {
1873 window.location.reload();
1882 exception_error("customizeCSS", e);
1886 function insertSSLserial(value) {
1888 dijit.byId("SSL_CERT_SERIAL").attr('value', value);
1890 exception_error("insertSSLcerial", e);
1894 function getSelectedInstances() {
1895 return getSelectedTableRowIds("prefInstanceList");
1898 function addInstance() {
1900 var query = "backend.php?op=dlg&method=addInstance";
1902 if (dijit.byId("instanceAddDlg"))
1903 dijit.byId("instanceAddDlg").destroyRecursive();
1905 dialog = new dijit.Dialog({
1906 id: "instanceAddDlg",
1907 title: __("Link Instance"),
1908 style: "width: 600px",
1909 regenKey: function() {
1910 new Ajax.Request("backend.php", {
1911 parameters: "?op=rpc&method=genHash",
1912 onComplete: function(transport) {
1913 var reply = JSON.parse(transport.responseText);
1915 dijit.byId('instance_add_key').attr('value', reply.hash);
1919 execute: function() {
1920 if (this.validate()) {
1921 console.warn(dojo.objectToQuery(this.attr('value')));
1923 notify_progress('Saving data...', true);
1924 new Ajax.Request("backend.php", {
1925 parameters: dojo.objectToQuery(this.attr('value')),
1926 onComplete: function(transport) {
1929 updateInstanceList();
1939 exception_error("addInstance", e);
1943 function editInstance(id, event) {
1945 if (!event || !event.ctrlKey) {
1947 selectTableRows('prefInstanceList', 'none');
1948 selectTableRowById('LIRR-'+id, 'LICHK-'+id, true);
1950 var query = "backend.php?op=pref-instances&method=edit&id=" +
1953 if (dijit.byId("instanceEditDlg"))
1954 dijit.byId("instanceEditDlg").destroyRecursive();
1956 dialog = new dijit.Dialog({
1957 id: "instanceEditDlg",
1958 title: __("Edit Instance"),
1959 style: "width: 600px",
1960 regenKey: function() {
1961 new Ajax.Request("backend.php", {
1962 parameters: "?op=rpc&method=genHash",
1963 onComplete: function(transport) {
1964 var reply = JSON.parse(transport.responseText);
1966 dijit.byId('instance_edit_key').attr('value', reply.hash);
1970 execute: function() {
1971 if (this.validate()) {
1972 // console.warn(dojo.objectToQuery(this.attr('value')));
1974 notify_progress('Saving data...', true);
1975 new Ajax.Request("backend.php", {
1976 parameters: dojo.objectToQuery(this.attr('value')),
1977 onComplete: function(transport) {
1980 updateInstanceList();
1989 } else if (event.ctrlKey) {
1990 var cb = $('LICHK-' + id);
1991 cb.checked = !cb.checked;
1992 toggleSelectRow(cb);
1997 exception_error("editInstance", e);
2001 function removeSelectedInstances() {
2003 var sel_rows = getSelectedInstances();
2005 if (sel_rows.length > 0) {
2007 var ok = confirm(__("Remove selected instances?"));
2010 notify_progress("Removing selected instances...");
2012 var query = "?op=pref-instances&method=remove&ids="+
2013 param_escape(sel_rows.toString());
2015 new Ajax.Request("backend.php", {
2017 onComplete: function(transport) {
2019 updateInstanceList();
2024 alert(__("No instances are selected."));
2028 exception_error("removeInstance", e);
2032 function editSelectedInstance() {
2033 var rows = getSelectedInstances();
2035 if (rows.length == 0) {
2036 alert(__("No instances are selected."));
2040 if (rows.length > 1) {
2041 alert(__("Please select only one instance."));
2047 editInstance(rows[0]);
2050 function showHelp() {
2052 new Ajax.Request("backend.php", {
2053 parameters: "?op=backend&method=help&topic=prefs",
2054 onComplete: function(transport) {
2055 $("hotkey_help_overlay").innerHTML = transport.responseText;
2056 Effect.Appear("hotkey_help_overlay", {duration : 0.3});
2060 exception_error("showHelp", e);
2064 function exportData() {
2067 var query = "backend.php?op=dlg&method=exportData";
2069 if (dijit.byId("dataExportDlg"))
2070 dijit.byId("dataExportDlg").destroyRecursive();
2074 dialog = new dijit.Dialog({
2075 id: "dataExportDlg",
2076 title: __("Export Data"),
2077 style: "width: 600px",
2078 prepare: function() {
2080 notify_progress("Loading, please wait...");
2082 new Ajax.Request("backend.php", {
2083 parameters: "?op=rpc&method=exportrun&offset=" + exported,
2084 onComplete: function(transport) {
2086 var rv = JSON.parse(transport.responseText);
2088 if (rv && rv.exported != undefined) {
2089 if (rv.exported > 0) {
2091 exported += rv.exported;
2093 $("export_status_message").innerHTML =
2094 "<img src='images/indicator_tiny.gif'> " +
2095 "Exported %d articles, please wait...".replace("%d",
2098 setTimeout('dijit.byId("dataExportDlg").prepare()', 2000);
2102 $("export_status_message").innerHTML =
2103 __("Finished, exported %d articles. You can download the data <a class='visibleLink' href='%u'>here</a>.")
2104 .replace("%d", exported)
2105 .replace("%u", "backend.php?op=rpc&subop=exportget");
2112 $("export_status_message").innerHTML =
2113 "Error occured, could not export data.";
2116 exception_error("exportData", e, transport.responseText);
2124 execute: function() {
2125 if (this.validate()) {
2137 exception_error("exportData", e);
2141 function dataImportComplete(iframe) {
2143 if (!iframe.contentDocument.body.innerHTML) return false;
2145 Element.hide(iframe);
2149 if (dijit.byId('dataImportDlg'))
2150 dijit.byId('dataImportDlg').destroyRecursive();
2152 var content = iframe.contentDocument.body.innerHTML;
2154 dialog = new dijit.Dialog({
2155 id: "dataImportDlg",
2156 title: __("Data Import"),
2157 style: "width: 600px",
2158 onCancel: function() {
2166 exception_error("dataImportComplete", e);
2170 function gotoExportOpml(filename, settings) {
2171 tmp = settings ? 1 : 0;
2172 document.location.href = "backend.php?op=opml&method=export&filename=" + filename + "&settings=" + tmp;
2176 function batchSubscribe() {
2178 var query = "backend.php?op=dlg&method=batchSubscribe";
2180 // overlapping widgets
2181 if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
2182 if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive();
2184 var dialog = new dijit.Dialog({
2186 title: __("Batch subscribe"),
2187 style: "width: 600px",
2188 execute: function() {
2189 if (this.validate()) {
2190 console.log(dojo.objectToQuery(this.attr('value')));
2192 notify_progress(__("Subscribing to feeds..."), true);
2194 new Ajax.Request("backend.php", {
2195 parameters: dojo.objectToQuery(this.attr('value')),
2196 onComplete: function(transport) {
2207 exception_error("batchSubscribe", e);
2211 function updateSelf() {
2213 var query = "backend.php?op=pref-prefs&method=updateSelf";
2215 if (dijit.byId("updateSelfDlg"))
2216 dijit.byId("updateSelfDlg").destroyRecursive();
2218 var dialog = new dijit.Dialog({
2219 id: "updateSelfDlg",
2220 title: __("Update Tiny Tiny RSS"),
2221 style: "width: 600px",
2223 performUpdate: function(step) {
2224 dijit.byId("self_update_start_btn").attr("disabled", true);
2225 dijit.byId("self_update_stop_btn").attr("disabled", true);
2227 notify_progress("Loading, please wait...", true);
2228 new Ajax.Request("backend.php", {
2229 parameters: "?op=pref-prefs&method=performUpdate&step=" + step +
2230 "¶ms=" + param_escape(JSON.stringify(dialog.attr("update-params"))),
2231 onComplete: function(transport) {
2233 rv = JSON.parse(transport.responseText);
2237 rv['log'].each(function(line) {
2238 $("self_update_log").innerHTML += "<li>" + line + "</li>";
2241 dialog.attr("update-params", rv['params']);
2244 window.setTimeout("dijit.byId('updateSelfDlg').performUpdate("+(step+1)+")", 500);
2246 dijit.byId("self_update_stop_btn").attr("disabled", false);
2250 console.log(transport.responseText);
2251 notify_error("Received invalid data from server.");
2254 dialog.attr("updated", true);
2256 exception_error("updateSelf/inner", e);
2261 if (dialog.attr("updated")) {
2262 window.location.reload();
2268 if (prompt(__("Live updating is considered experimental. Backup your tt-rss directory before continuing. Please type 'yes' to continue.")) == 'yes') {
2269 dialog.performUpdate(0);
2276 exception_error("batchSubscribe", e);
2280 function toggleAdvancedPrefs() {
2282 notify_progress("Loading, please wait...");
2284 new Ajax.Request("backend.php", {
2285 parameters: "?op=pref-prefs&method=toggleadvanced",
2286 onComplete: function(transport) {
2291 exception_error("toggleAdvancedPrefs", e);