]> git.wh0rd.org - tt-rss.git/blobdiff - js/prefs.js
fix getfiltertree enabled on psql
[tt-rss.git] / js / prefs.js
index e40d6d7234a9e3cc255b0df5280c2bf71aa25f63..1fbbc55a58c8654a87d218e6a9dd0075fe145c60 100644 (file)
@@ -5,62 +5,8 @@ var hotkey_prefix_pressed = false;
 
 var seq = "";
 
-function instancelist_callback2(transport) {
-       try {
-               dijit.byId('instanceConfigTab').attr('content', transport.responseText);
-               selectTab("instanceConfig", true);
-               notify("");
-       } catch (e) {
-               exception_error("instancelist_callback2", e);
-       }
-}
-
-function feedlist_callback2(transport) {
-       try {
-               dijit.byId('feedConfigTab').attr('content', transport.responseText);
-               selectTab("feedConfig", true);
-               notify("");
-       } catch (e) {
-               exception_error("feedlist_callback2", e);
-       }
-}
-
-function filterlist_callback2(transport) {
-       dijit.byId('filterConfigTab').attr('content', transport.responseText);
-       notify("");
-}
-
-function labellist_callback2(transport) {
-       try {
-               dijit.byId('labelConfigTab').attr('content', transport.responseText);
-               notify("");
-       } catch (e) {
-               exception_error("labellist_callback2", e);
-       }
-}
-
-function userlist_callback2(transport) {
-       try {
-               dijit.byId('userConfigTab').attr('content', transport.responseText);
-
-               notify("");
-       } catch (e) {
-               exception_error("userlist_callback2", e);
-       }
-}
-
-function prefslist_callback2(transport) {
-       try {
-               dijit.byId('genConfigTab').attr('content', transport.responseText);
-
-               notify("");
-       } catch (e) {
-               exception_error("prefslist_callback2", e);
-       }
-}
-
-function notify_callback2(transport) {
-       notify_info(transport.responseText);
+function notify_callback2(transport, sticky) {
+       notify_info(transport.responseText, sticky);
 }
 
 function updateFeedList(sort_key) {
@@ -72,7 +18,9 @@ function updateFeedList(sort_key) {
        new Ajax.Request("backend.php", {
                parameters: "?op=pref-feeds&search=" + param_escape(search),
                onComplete: function(transport) {
-                       feedlist_callback2(transport);
+                       dijit.byId('feedConfigTab').attr('content', transport.responseText);
+                       selectTab("feedConfig", true);
+                       notify("");
                } });
 }
 
@@ -80,14 +28,14 @@ function updateInstanceList(sort_key) {
        new Ajax.Request("backend.php", {
                parameters: "?op=pref-instances&sort=" + param_escape(sort_key),
                onComplete: function(transport) {
-                       instancelist_callback2(transport);
+                       dijit.byId('instanceConfigTab').attr('content', transport.responseText);
+                       selectTab("instanceConfig", true);
+                       notify("");
                } });
 }
 
 function updateUsersList(sort_key) {
-
        try {
-
                var user_search = $("user_search");
                var search = "";
                if (user_search) { search = user_search.value; }
@@ -99,7 +47,9 @@ function updateUsersList(sort_key) {
                new Ajax.Request("backend.php", {
                        parameters: query,
                        onComplete: function(transport) {
-                               userlist_callback2(transport);
+                               dijit.byId('userConfigTab').attr('content', transport.responseText);
+                               selectTab("userConfig", true)
+                               notify("");
                        } });
 
        } catch (e) {
@@ -124,13 +74,14 @@ function addUser() {
 
                notify_progress("Adding user...");
 
-               var query = "?op=pref-users&subop=add&login=" +
+               var query = "?op=pref-users&method=add&login=" +
                        param_escape(login);
 
                new Ajax.Request("backend.php", {
                        parameters: query,
                        onComplete: function(transport) {
-                               userlist_callback2(transport);
+                               notify_callback2(transport);
+                               updateUsersList();
                        } });
 
        } catch (e) {
@@ -148,7 +99,7 @@ function editUser(id, event) {
                selectTableRows('prefUserList', 'none');
                selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true);
 
-               var query = "?op=pref-users&subop=edit&id=" +
+               var query = "?op=pref-users&method=edit&id=" +
                        param_escape(id);
 
                new Ajax.Request("backend.php", {
@@ -173,7 +124,10 @@ function editUser(id, event) {
 function editFilter(id) {
        try {
 
-               var query = "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id);
+               var query = "backend.php?op=pref-filters&method=edit&id=" + param_escape(id);
+
+               if (dijit.byId("feedEditDlg"))
+                       dijit.byId("feedEditDlg").destroyRecursive();
 
                if (dijit.byId("filterEditDlg"))
                        dijit.byId("filterEditDlg").destroyRecursive();
@@ -182,9 +136,18 @@ function editFilter(id) {
                        id: "filterEditDlg",
                        title: __("Edit Filter"),
                        style: "width: 600px",
+                       editRule: function(e) {
+                               var li = e.parentNode;
+                               var rule = li.getElementsByTagName("INPUT")[1].value;
+                               addFilterRule(li, rule);
+                       },
+                       editAction: function(e) {
+                               var li = e.parentNode;
+                               var action = li.getElementsByTagName("INPUT")[1].value;
+                               addFilterAction(li, action);
+                       },
                        removeFilter: function() {
-                               var title = this.attr('value').reg_exp;
-                               var msg = __("Remove filter %s?").replace("%s", title);
+                               var msg = __("Remove filter?");
 
                                if (confirm(msg)) {
                                        this.hide();
@@ -193,7 +156,7 @@ function editFilter(id) {
 
                                        var id = this.attr('value').id;
 
-                                       var query = "?op=pref-filters&subop=remove&ids="+
+                                       var query = "?op=pref-filters&method=remove&ids="+
                                                param_escape(id);
 
                                        new Ajax.Request("backend.php", {
@@ -203,57 +166,29 @@ function editFilter(id) {
                                                } });
                                }
                        },
-                       test: function() {
-                               if (this.validate()) {
-
-                                       if (dijit.byId("filterTestDlg"))
-                                               dijit.byId("filterTestDlg").destroyRecursive();
-
-                                       tdialog = new dijit.Dialog({
-                                               id: "filterTestDlg",
-                                               title: __("Filter Test Results"),
-                                               style: "width: 600px",
-                                               href: "backend.php?savemode=test&" +
-                                                       dojo.objectToQuery(dialog.attr('value')),
-                                               });
-
-                                       tdialog.show();
-
-                               }
+                       addAction: function() { addFilterAction(); },
+                       addRule: function() { addFilterRule(); },
+                       deleteAction: function() {
+                               $$("#filterDlg_Actions li.[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
+                       },
+                       deleteRule: function() {
+                               $$("#filterDlg_Matches li.[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
                        },
                        execute: function() {
                                if (this.validate()) {
 
-                                       var query = "?op=rpc&subop=verifyRegexp&reg_exp=" +
-                                               param_escape(dialog.attr('value').reg_exp);
+                                       notify_progress("Saving data...", true);
 
-                                       notify_progress("Verifying regular expression...");
+                                       var query = dojo.formToQuery("filter_edit_form");
 
-                                       new Ajax.Request("backend.php", {
+                                       console.log(query);
+
+                                       new Ajax.Request("backend.php", {
                                                parameters: query,
                                                onComplete: function(transport) {
-                                                       var reply = JSON.parse(transport.responseText);
-
-                                                       if (reply) {
-                                                               notify('');
-
-                                                               if (!reply['status']) {
-                                                                       alert("Match regular expression seems to be invalid.");
-                                                                       return;
-                                                               } else {
-                                                                       notify_progress("Saving data...", true);
-
-                                                                       console.log(dojo.objectToQuery(dialog.attr('value')));
-
-                                                                       new Ajax.Request("backend.php", {
-                                                                               parameters: dojo.objectToQuery(dialog.attr('value')),
-                                                                               onComplete: function(transport) {
-                                                                                       dialog.hide();
-                                                                                       updateFilterList();
-                                                                       }});
-                                                               }
-                                                       }
-                                       }});
+                                                       dialog.hide();
+                                                       updateFilterList();
+                                               }});
                                }
                        },
                        href: query});
@@ -323,13 +258,13 @@ function removeSelectedLabels() {
                if (ok) {
                        notify_progress("Removing selected labels...");
 
-                       var query = "?op=pref-labels&subop=remove&ids="+
+                       var query = "?op=pref-labels&method=remove&ids="+
                                param_escape(sel_rows.toString());
 
                        new Ajax.Request("backend.php", {
                                parameters: query,
                                onComplete: function(transport) {
-                                               labellist_callback2(transport);
+                                               updateLabelList();
                                        } });
 
                }
@@ -353,13 +288,13 @@ function removeSelectedUsers() {
                        if (ok) {
                                notify_progress("Removing selected users...");
 
-                               var query = "?op=pref-users&subop=remove&ids="+
+                               var query = "?op=pref-users&method=remove&ids="+
                                        param_escape(sel_rows.toString());
 
                                new Ajax.Request("backend.php", {
                                        parameters: query,
                                        onComplete: function(transport) {
-                                               userlist_callback2(transport);
+                                               updateUsersList();
                                        } });
 
                        }
@@ -388,7 +323,7 @@ function removeSelectedFilters() {
                        if (ok) {
                                notify_progress("Removing selected filters...");
 
-                               var query = "?op=pref-filters&subop=remove&ids="+
+                               var query = "?op=pref-filters&method=remove&ids="+
                                        param_escape(sel_rows.toString());
 
                                new Ajax.Request("backend.php", {
@@ -423,7 +358,7 @@ function removeSelectedFeeds() {
 
                                notify_progress("Unsubscribing from selected feeds...", true);
 
-                               var query = "?op=pref-feeds&subop=remove&ids="+
+                               var query = "?op=pref-feeds&method=remove&ids="+
                                        param_escape(sel_rows.toString());
 
                                console.log(query);
@@ -484,7 +419,7 @@ function purgeSelectedFeeds() {
                if (pr != undefined) {
                        notify_progress("Purging selected feed...");
 
-                       var query = "?op=rpc&subop=purge&ids="+
+                       var query = "?op=rpc&method=purge&ids="+
                                param_escape(sel_rows.toString()) + "&days=" + pr;
 
                        console.log(query);
@@ -530,7 +465,7 @@ function userEditSave() {
                new Ajax.Request("backend.php", {
                        parameters: query,
                        onComplete: function(transport) {
-                               userlist_callback2(transport);
+                               updateUsersList();
                        } });
 
        } catch (e) {
@@ -583,13 +518,13 @@ function resetSelectedUserPass() {
 
                        var id = rows[0];
 
-                       var query = "?op=pref-users&subop=resetPass&id=" +
+                       var query = "?op=pref-users&method=resetPass&id=" +
                                param_escape(id);
 
                        new Ajax.Request("backend.php", {
                                parameters: query,
                                onComplete: function(transport) {
-                                       userlist_callback2(transport);
+                                       notify_info(transport.responseText);
                                } });
 
                }
@@ -619,7 +554,7 @@ function selectedUserDetails() {
 
                var id = rows[0];
 
-               var query = "?op=pref-users&subop=user-details&id=" + id;
+               var query = "?op=pref-users&method=userdetails&id=" + id;
 
                new Ajax.Request("backend.php", {
                        parameters: query,
@@ -651,6 +586,31 @@ function editSelectedFilter() {
 
 }
 
+function joinSelectedFilters() {
+       var rows = getSelectedFilters();
+
+       if (rows.length == 0) {
+               alert(__("No filters are selected."));
+               return;
+       }
+
+       var ok = confirm(__("Combine selected filters?"));
+
+       if (ok) {
+               notify_progress("Joining filters...");
+
+               var query = "?op=pref-filters&method=join&ids="+
+                       param_escape(rows.toString());
+
+               console.log(query);
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) {
+                                       updateFilterList();
+                       } });
+       }
+}
 
 function editSelectedFeed() {
        var rows = getSelectedFeeds();
@@ -682,7 +642,7 @@ function editSelectedFeeds() {
 
                notify_progress("Loading, please wait...");
 
-               var query = "backend.php?op=pref-feeds&subop=editfeeds&ids=" +
+               var query = "backend.php?op=pref-feeds&method=editfeeds&ids=" +
                        param_escape(rows.toString());
 
                console.log(query);
@@ -803,6 +763,8 @@ function opmlImportComplete(iframe) {
        try {
                if (!iframe.contentDocument.body.innerHTML) return false;
 
+               Element.show(iframe);
+
                notify('');
 
                if (dijit.byId('opmlImportDlg'))
@@ -816,6 +778,14 @@ function opmlImportComplete(iframe) {
                        style: "width: 600px",
                        onCancel: function() {
                                updateFeedList();
+                               updateFilterList();
+                               updateLabelList();
+                       },
+                       execute: function() {
+                               updateFeedList();
+                               updateFilterList();
+                               updateLabelList();
+                               this.hide();
                        },
                        content: content});
 
@@ -835,15 +805,40 @@ function opmlImport() {
                return false;
        } else {
                notify_progress("Importing, please wait...", true);
+
+               Element.show("upload_iframe");
+
                return true;
        }
 }
 
+function importData() {
+
+       var file = $("export_file");
+
+       if (file.value.length == 0) {
+               alert(__("Please choose the file first."));
+               return false;
+       } else {
+               notify_progress("Importing, please wait...", true);
+
+               Element.show("data_upload_iframe");
+
+               return true;
+       }
+}
+
+
 function updateFilterList() {
+       var user_search = $("filter_search");
+       var search = "";
+       if (user_search) { search = user_search.value; }
+
        new Ajax.Request("backend.php", {
-               parameters: "?op=pref-filters",
+               parameters: "?op=pref-filters&search=" + param_escape(search),
                onComplete: function(transport) {
-                       filterlist_callback2(transport);
+                       dijit.byId('filterConfigTab').attr('content', transport.responseText);
+                       notify("");
                } });
 }
 
@@ -851,7 +846,8 @@ function updateLabelList() {
        new Ajax.Request("backend.php", {
                parameters: "?op=pref-labels",
                onComplete: function(transport) {
-                       labellist_callback2(transport);
+                       dijit.byId('labelConfigTab').attr('content', transport.responseText);
+                       notify("");
                } });
 }
 
@@ -859,11 +855,12 @@ function updatePrefsList() {
        new Ajax.Request("backend.php", {
                parameters: "?op=pref-prefs",
                onComplete: function(transport) {
-                       prefslist_callback2(transport);
+                       dijit.byId('genConfigTab').attr('content', transport.responseText);
+                       notify("");
                } });
 }
 
-function selectTab(id, noupdate, subop) {
+function selectTab(id, noupdate, method) {
        try {
                if (!noupdate) {
                        notify_progress("Loading, please wait...");
@@ -905,10 +902,10 @@ function init_second_stage() {
                                if (tab) dijit.byId("pref-tabs").selectChild(tab);
                        }
 
-                       var subop = getURLParam('subop');
+                       var method = getURLParam('method');
 
-                       if (subop == 'editFeed') {
-                               var param = getURLParam('subopparam');
+                       if (method == 'editFeed') {
+                               var param = getURLParam('methodparam');
 
                                window.setTimeout('editFeed(' + param + ')', 100);
                        }
@@ -927,6 +924,31 @@ function init() {
                dojo.registerModulePath("lib", "..");
                dojo.registerModulePath("fox", "../../js/");
 
+               dojo.require("dijit.ColorPalette");
+               dojo.require("dijit.Dialog");
+               dojo.require("dijit.form.Button");
+               dojo.require("dijit.form.CheckBox");
+               dojo.require("dijit.form.DropDownButton");
+               dojo.require("dijit.form.FilteringSelect");
+               dojo.require("dijit.form.Form");
+               dojo.require("dijit.form.RadioButton");
+               dojo.require("dijit.form.Select");
+               dojo.require("dijit.form.SimpleTextarea");
+               dojo.require("dijit.form.TextBox");
+               dojo.require("dijit.form.ValidationTextBox");
+               dojo.require("dijit.InlineEditBox");
+               dojo.require("dijit.layout.AccordionContainer");
+               dojo.require("dijit.layout.BorderContainer");
+               dojo.require("dijit.layout.ContentPane");
+               dojo.require("dijit.layout.TabContainer");
+               dojo.require("dijit.Menu");
+               dojo.require("dijit.ProgressBar");
+               dojo.require("dijit.ProgressBar");
+               dojo.require("dijit.Toolbar");
+               dojo.require("dijit.Tree");
+               dojo.require("dijit.tree.dndSource");
+               dojo.require("dojo.data.ItemFileWriteStore");
+
                dojo.require("lib.CheckBoxTree");
                dojo.require("fox.PrefFeedTree");
                dojo.require("fox.PrefFilterTree");
@@ -938,7 +960,7 @@ function init() {
                        loading_set_progress(50);
 
                        new Ajax.Request("backend.php", {
-                               parameters: {op: "rpc", subop: "sanityCheck"},
+                               parameters: {op: "rpc", method: "sanityCheck"},
                                        onComplete: function(transport) {
                                        backend_sanity_check_callback(transport);
                                } });
@@ -955,7 +977,7 @@ function validatePrefsReset() {
 
                if (ok) {
 
-                       query = "?op=pref-prefs&subop=reset-config";
+                       query = "?op=pref-prefs&method=resetconfig";
                        console.log(query);
 
                        new Ajax.Request("backend.php", {
@@ -983,7 +1005,7 @@ function validatePrefsReset() {
 
 function pref_hotkey_handler(e) {
        try {
-               if (e.target.nodeName == "INPUT") return;
+               if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
 
                var keycode = false;
                var shift_key = false;
@@ -1047,12 +1069,7 @@ function pref_hotkey_handler(e) {
                if (!hotkey_prefix) {
 
                        if ((keycode == 191 || keychar == '?') && shift_key) { // ?
-                               if (!Element.visible("hotkey_help_overlay")) {
-                                       //Element.show("hotkey_help_overlay");
-                                       Effect.Appear("hotkey_help_overlay", {duration : 0.3, to: 0.9});
-                               } else {
-                                       Element.hide("hotkey_help_overlay");
-                               }
+                               showHelp();
                                return false;
                        }
 
@@ -1158,78 +1175,57 @@ function pref_hotkey_handler(e) {
        }
 }
 
-function editFeedCats() {
+function removeCategory(id, item) {
        try {
-               var query = "backend.php?op=pref-feeds&subop=editCats";
-
-               if (dijit.byId("feedCatEditDlg"))
-                       dijit.byId("feedCatEditDlg").destroyRecursive();
 
-               dialog = new dijit.Dialog({
-                       id: "feedCatEditDlg",
-                       title: __("Feed Categories"),
-                       style: "width: 600px",
-                       getSelectedCategories: function() {
-                               return getSelectedTableRowIds("prefFeedCatList");
-                       },
-                       removeSelected: function() {
-                               var sel_rows = this.getSelectedCategories();
+               var ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name));
 
-                               if (sel_rows.length > 0) {
-                                       var ok = confirm(__("Remove selected categories?"));
+               if (ok) {
+                       var query = "?op=pref-feeds&method=removeCat&ids="+
+                               param_escape(id);
 
-                                       if (ok) {
-                                               notify_progress("Removing selected categories...", true);
+                       notify_progress("Removing category...");
 
-                                               var query = "?op=pref-feeds&subop=editCats&action=remove&ids="+
-                                                       param_escape(sel_rows.toString());
+                       new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) {
+                                       notify('');
+                                       updateFeedList();
+                               } });
+                       }
 
-                                               new Ajax.Request("backend.php", {
-                                                       parameters: query,
-                                                       onComplete: function(transport) {
-                                                               notify('');
-                                                               dialog.attr('content', transport.responseText);
-                                                               updateFeedList();
-                                                       } });
+       } catch (e) {
+               exception_error("removeCategory", e);
+       }
+}
 
-                                       }
+function createCategory() {
+       try {
+               var title = prompt(__("Category title:"));
 
-                               } else {
-                                       alert(__("No categories are selected."));
-                               }
-                       },
-                       addCategory: function() {
-                               if (this.validate()) {
-                                       notify_progress("Creating category...");
+               if (title) {
 
-                                       var query = "?op=pref-feeds&subop=editCats&action=add&cat=" +
-                                               param_escape(this.attr('value').newcat);
+                       notify_progress("Creating category...");
 
-                                       new Ajax.Request("backend.php", {
-                                               parameters: query,
-                                               onComplete: function(transport) {
-                                                       notify('');
-                                                       dialog.attr('content', transport.responseText);
-                                                       updateFeedList();
-                                               } });
-                               }
-                       },
-                       execute: function() {
-                               if (this.validate()) {
-                               }
-                       },
-                       href: query});
+                       var query = "?op=pref-feeds&method=addCat&cat=" +
+                               param_escape(title);
 
-               dialog.show();
+                       new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) {
+                                       notify('');
+                                       updateFeedList();
+                               } });
+               }
 
        } catch (e) {
-               exception_error("editFeedCats", e);
+               exception_error("createCategory", e);
        }
 }
 
 function showInactiveFeeds() {
        try {
-               var query = "backend.php?op=dlg&id=inactiveFeeds";
+               var query = "backend.php?op=dlg&method=inactiveFeeds";
 
                if (dijit.byId("inactiveFeedsDlg"))
                        dijit.byId("inactiveFeedsDlg").destroyRecursive();
@@ -1252,7 +1248,7 @@ function showInactiveFeeds() {
                                        if (ok) {
                                                notify_progress("Removing selected feeds...", true);
 
-                                               var query = "?op=pref-feeds&subop=remove&ids="+
+                                               var query = "?op=pref-feeds&method=remove&ids="+
                                                        param_escape(sel_rows.toString());
 
                                                new Ajax.Request("backend.php", {
@@ -1291,7 +1287,7 @@ function opmlRegenKey() {
 
                        notify_progress("Trying to change address...", true);
 
-                       var query = "?op=rpc&subop=regenOPMLKey";
+                       var query = "?op=rpc&method=regenOPMLKey";
 
                        new Ajax.Request("backend.php", {
                                parameters: query,
@@ -1376,7 +1372,7 @@ function clearFeedArticles(feed_id) {
 
        notify_progress("Clearing feed...");
 
-       var query = "?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id;
+       var query = "?op=pref-feeds&quiet=1&method=clear&id=" + feed_id;
 
        new Ajax.Request("backend.php", {
                parameters: query,
@@ -1399,7 +1395,7 @@ function rescoreSelectedFeeds() {
                if (ok) {
                        notify_progress("Rescoring selected feeds...", true);
 
-                       var query = "?op=pref-feeds&subop=rescore&quiet=1&ids="+
+                       var query = "?op=pref-feeds&method=rescore&quiet=1&ids="+
                                param_escape(sel_rows.toString());
 
                        new Ajax.Request("backend.php", {
@@ -1422,7 +1418,7 @@ function rescore_all_feeds() {
        if (ok) {
                notify_progress("Rescoring feeds...", true);
 
-               var query = "?op=pref-feeds&subop=rescoreAll&quiet=1";
+               var query = "?op=pref-feeds&method=rescoreAll&quiet=1";
 
                new Ajax.Request("backend.php", {
                        parameters: query,
@@ -1440,13 +1436,13 @@ function labelColorReset() {
                        var ok = confirm(__("Reset selected labels to default colors?"));
 
                        if (ok) {
-                               var query = "?op=pref-labels&subop=color-reset&ids="+
+                               var query = "?op=pref-labels&method=colorreset&ids="+
                                        param_escape(labels.toString());
 
                                new Ajax.Request("backend.php", {
                                        parameters: query,
                                        onComplete: function(transport) {
-                                               labellist_callback2(transport);
+                                               updateLabelList();
                                        } });
                        }
 
@@ -1470,7 +1466,7 @@ function editProfiles() {
                if (dijit.byId("profileEditDlg"))
                        dijit.byId("profileEditDlg").destroyRecursive();
 
-               var query = "backend.php?op=dlg&id=editPrefProfiles";
+               var query = "backend.php?op=dlg&method=editPrefProfiles";
 
                dialog = new dijit.Dialog({
                        id: "profileEditDlg",
@@ -1488,7 +1484,7 @@ function editProfiles() {
                                        if (ok) {
                                                notify_progress("Removing selected profiles...", true);
 
-                                               var query = "?op=rpc&subop=remprofiles&ids="+
+                                               var query = "?op=rpc&method=remprofiles&ids="+
                                                        param_escape(sel_rows.toString());
 
                                                new Ajax.Request("backend.php", {
@@ -1514,7 +1510,7 @@ function editProfiles() {
                                        if (ok) {
                                                notify_progress("Loading, please wait...");
 
-                                               var query = "?op=rpc&subop=setprofile&id="+
+                                               var query = "?op=rpc&method=setprofile&id="+
                                                        param_escape(sel_rows.toString());
 
                                                new Ajax.Request("backend.php", {
@@ -1532,7 +1528,7 @@ function editProfiles() {
                                if (this.validate()) {
                                        notify_progress("Creating profile...", true);
 
-                                       var query = "?op=rpc&subop=addprofile&title=" +
+                                       var query = "?op=rpc&method=addprofile&title=" +
                                                param_escape(dialog.attr('value').newprofile);
 
                                        new Ajax.Request("backend.php", {
@@ -1567,7 +1563,7 @@ function activatePrefProfile() {
                if (ok) {
                        notify_progress("Loading, please wait...");
 
-                       var query = "?op=rpc&subop=setprofile&id="+
+                       var query = "?op=rpc&method=setprofile&id="+
                                param_escape(sel_rows.toString());
 
                        new Ajax.Request("backend.php", {
@@ -1591,7 +1587,7 @@ function clearFeedAccessKeys() {
        if (ok) {
                notify_progress("Clearing URLs...");
 
-               var query = "?op=rpc&subop=clearKeys";
+               var query = "?op=rpc&method=clearKeys";
 
                new Ajax.Request("backend.php", {
                        parameters: query,
@@ -1610,7 +1606,7 @@ function clearArticleAccessKeys() {
        if (ok) {
                notify_progress("Clearing URLs...");
 
-               var query = "?op=rpc&subop=clearArticleKeys";
+               var query = "?op=rpc&method=clearArticleKeys";
 
                new Ajax.Request("backend.php", {
                        parameters: query,
@@ -1626,7 +1622,7 @@ function resetFeedOrder() {
                notify_progress("Loading, please wait...");
 
                new Ajax.Request("backend.php", {
-                       parameters: "?op=pref-feeds&subop=feedsortreset",
+                       parameters: "?op=pref-feeds&method=feedsortreset",
                        onComplete: function(transport) {
                                updateFeedList();
                        } });
@@ -1642,7 +1638,7 @@ function resetCatOrder() {
                notify_progress("Loading, please wait...");
 
                new Ajax.Request("backend.php", {
-                       parameters: "?op=pref-feeds&subop=catsortreset",
+                       parameters: "?op=pref-feeds&method=catsortreset",
                        onComplete: function(transport) {
                                updateFeedList();
                        } });
@@ -1653,6 +1649,21 @@ function resetCatOrder() {
        }
 }
 
+function toggleHiddenFeedCats() {
+       try {
+               notify_progress("Loading, please wait...");
+
+               new Ajax.Request("backend.php", {
+                       parameters: "?op=pref-feeds&method=togglehiddenfeedcats",
+                       onComplete: function(transport) {
+                               updateFeedList();
+                       } });
+
+       } catch (e) {
+               exception_error("toggleHiddenFeedCats");
+       }
+}
+
 function editCat(id, item, event) {
        try {
                var new_name = prompt(__('Rename category to:'), item.name);
@@ -1664,7 +1675,7 @@ function editCat(id, item, event) {
                        new Ajax.Request("backend.php", {
                        parameters: {
                                op: 'pref-feeds',
-                               subop: 'renamecat',
+                               method: 'renamecat',
                                id: id,
                                title: new_name,
                        },
@@ -1680,7 +1691,7 @@ function editCat(id, item, event) {
 
 function editLabel(id, event) {
        try {
-               var query = "backend.php?op=pref-labels&subop=edit&id=" +
+               var query = "backend.php?op=pref-labels&method=edit&id=" +
                        param_escape(id);
 
                if (dijit.byId("labelEditDlg"))
@@ -1705,7 +1716,7 @@ function editLabel(id, event) {
                                        color = bg;
                                }
 
-                               var query = "?op=pref-labels&subop=color-set&kind="+kind+
+                               var query = "?op=pref-labels&method=colorset&kind="+kind+
                                        "&ids=" + param_escape(id) + "&fg=" + param_escape(fg) +
                                        "&bg=" + param_escape(bg) + "&color=" + param_escape(color);
 
@@ -1756,7 +1767,7 @@ function clearTwitterCredentials() {
                if (ok) {
                        notify_progress("Clearing credentials...");
 
-                       var query = "?op=pref-feeds&subop=remtwitterinfo";
+                       var query = "?op=pref-feeds&method=remtwitterinfo";
 
                        new Ajax.Request("backend.php", {
                                parameters: query,
@@ -1773,7 +1784,7 @@ function clearTwitterCredentials() {
 
 function customizeCSS() {
        try {
-               var query = "backend.php?op=dlg&id=customizeCSS";
+               var query = "backend.php?op=dlg&method=customizeCSS";
 
                if (dijit.byId("cssEditDlg"))
                        dijit.byId("cssEditDlg").destroyRecursive();
@@ -1815,7 +1826,7 @@ function getSelectedInstances() {
 
 function addInstance() {
        try {
-               var query = "backend.php?op=dlg&id=addInstance";
+               var query = "backend.php?op=dlg&method=addInstance";
 
                if (dijit.byId("instanceAddDlg"))
                        dijit.byId("instanceAddDlg").destroyRecursive();
@@ -1826,7 +1837,7 @@ function addInstance() {
                        style: "width: 600px",
                        regenKey: function() {
                                new Ajax.Request("backend.php", {
-                                       parameters: "?op=rpc&subop=genHash",
+                                       parameters: "?op=rpc&method=genHash",
                                        onComplete: function(transport) {
                                                var reply = JSON.parse(transport.responseText);
                                                if (reply)
@@ -1865,7 +1876,7 @@ function editInstance(id, event) {
                selectTableRows('prefInstanceList', 'none');
                selectTableRowById('LIRR-'+id, 'LICHK-'+id, true);
 
-               var query = "backend.php?op=pref-instances&subop=edit&id=" +
+               var query = "backend.php?op=pref-instances&method=edit&id=" +
                        param_escape(id);
 
                if (dijit.byId("instanceEditDlg"))
@@ -1877,7 +1888,7 @@ function editInstance(id, event) {
                        style: "width: 600px",
                        regenKey: function() {
                                new Ajax.Request("backend.php", {
-                                       parameters: "?op=rpc&subop=genHash",
+                                       parameters: "?op=rpc&method=genHash",
                                        onComplete: function(transport) {
                                                var reply = JSON.parse(transport.responseText);
                                                if (reply)
@@ -1927,7 +1938,7 @@ function removeSelectedInstances() {
                        if (ok) {
                                notify_progress("Removing selected instances...");
 
-                               var query = "?op=pref-instances&subop=remove&ids="+
+                               var query = "?op=pref-instances&method=remove&ids="+
                                        param_escape(sel_rows.toString());
 
                                new Ajax.Request("backend.php", {
@@ -1965,3 +1976,246 @@ function editSelectedInstance() {
        editInstance(rows[0]);
 }
 
+function showHelp() {
+       try {
+               new Ajax.Request("backend.php", {
+                       parameters: "?op=backend&method=help&topic=prefs",
+                       onComplete: function(transport) {
+                               $("hotkey_help_overlay").innerHTML = transport.responseText;
+                               Effect.Appear("hotkey_help_overlay", {duration : 0.3});
+                       } });
+
+       } catch (e) {
+               exception_error("showHelp", e);
+       }
+}
+
+function exportData() {
+       try {
+
+               var query = "backend.php?op=dlg&method=exportData";
+
+               if (dijit.byId("dataExportDlg"))
+                       dijit.byId("dataExportDlg").destroyRecursive();
+
+               var exported = 0;
+
+               dialog = new dijit.Dialog({
+                       id: "dataExportDlg",
+                       title: __("Export Data"),
+                       style: "width: 600px",
+                       prepare: function() {
+
+                               notify_progress("Loading, please wait...");
+
+                               new Ajax.Request("backend.php", {
+                                       parameters: "?op=rpc&method=exportrun&offset=" + exported,
+                                       onComplete: function(transport) {
+                                               try {
+                                                       var rv = JSON.parse(transport.responseText);
+
+                                                       if (rv && rv.exported != undefined) {
+                                                               if (rv.exported > 0) {
+
+                                                                       exported += rv.exported;
+
+                                                                       $("export_status_message").innerHTML =
+                                                                               "<img src='images/indicator_tiny.gif'> " +
+                                                                               "Exported %d articles, please wait...".replace("%d",
+                                                                                       exported);
+
+                                                                       setTimeout('dijit.byId("dataExportDlg").prepare()', 2000);
+
+                                                               } else {
+
+                                                                       $("export_status_message").innerHTML =
+                                                                               __("Finished, exported %d articles. You can download the data <a class='visibleLink' href='%u'>here</a>.")
+                                                                               .replace("%d", exported)
+                                                                               .replace("%u", "backend.php?op=rpc&subop=exportget");
+
+                                                                       exported = 0;
+
+                                                               }
+
+                                                       } else {
+                                                               $("export_status_message").innerHTML =
+                                                                       "Error occured, could not export data.";
+                                                       }
+                                               } catch (e) {
+                                                       exception_error("exportData", e, transport.responseText);
+                                               }
+
+                                               notify('');
+
+                                       } });
+
+                       },
+                       execute: function() {
+                               if (this.validate()) {
+
+
+
+                               }
+                       },
+                       href: query});
+
+               dialog.show();
+
+
+       } catch (e) {
+               exception_error("exportData", e);
+       }
+}
+
+function dataImportComplete(iframe) {
+       try {
+               if (!iframe.contentDocument.body.innerHTML) return false;
+
+               Element.hide(iframe);
+
+               notify('');
+
+               if (dijit.byId('dataImportDlg'))
+                       dijit.byId('dataImportDlg').destroyRecursive();
+
+               var content = iframe.contentDocument.body.innerHTML;
+
+               dialog = new dijit.Dialog({
+                       id: "dataImportDlg",
+                       title: __("Data Import"),
+                       style: "width: 600px",
+                       onCancel: function() {
+
+                       },
+                       content: content});
+
+               dialog.show();
+
+       } catch (e) {
+               exception_error("dataImportComplete", e);
+       }
+}
+
+function gotoExportOpml(filename, settings) {
+       tmp = settings ? 1 : 0;
+       document.location.href = "backend.php?op=opml&method=export&filename=" + filename + "&settings=" + tmp;
+}
+
+
+function batchSubscribe() {
+       try {
+               var query = "backend.php?op=dlg&method=batchSubscribe";
+
+               if (dijit.byId("batchSubDlg"))
+                       dijit.byId("batchSubDlg").destroyRecursive();
+
+               var dialog = new dijit.Dialog({
+                       id: "batchSubDlg",
+                       title: __("Batch subscribe"),
+                       style: "width: 600px",
+                       execute: function() {
+                               if (this.validate()) {
+                                       console.log(dojo.objectToQuery(this.attr('value')));
+
+                                       notify_progress(__("Subscribing to feeds..."), true);
+
+                                       new Ajax.Request("backend.php", {
+                                               parameters: dojo.objectToQuery(this.attr('value')),
+                                               onComplete: function(transport) {
+                                                       notify("");
+                                                       updateFeedList();
+                                                       dialog.hide();
+                                               } });
+                                       }
+                       },
+                       href: query});
+
+               dialog.show();
+       } catch (e) {
+               exception_error("batchSubscribe", e);
+       }
+}
+
+function updateSelf() {
+       try {
+               var query = "backend.php?op=pref-prefs&method=updateSelf";
+
+               if (dijit.byId("updateSelfDlg"))
+                       dijit.byId("updateSelfDlg").destroyRecursive();
+
+               var dialog = new dijit.Dialog({
+                       id: "updateSelfDlg",
+                       title: __("Update Tiny Tiny RSS"),
+                       style: "width: 600px",
+                       closable: false,
+                       performUpdate: function(step) {
+                               dijit.byId("self_update_start_btn").attr("disabled", true);
+                               dijit.byId("self_update_stop_btn").attr("disabled", true);
+
+                               notify_progress("Loading, please wait...", true);
+                               new Ajax.Request("backend.php", {
+                               parameters: "?op=pref-prefs&method=performUpdate&step=" + step +
+                                       "&params=" + param_escape(JSON.stringify(dialog.attr("update-params"))),
+                               onComplete: function(transport) {
+                                       try {
+                                               rv = JSON.parse(transport.responseText);
+                                               if (rv) {
+                                                       notify('');
+
+                                                       rv['log'].each(function(line) {
+                                                               $("self_update_log").innerHTML += "<li>" + line + "</li>";
+                                                       });
+
+                                                       dialog.attr("update-params", rv['params']);
+
+                                                       if (!rv['stop']) {
+                                                               window.setTimeout("dijit.byId('updateSelfDlg').performUpdate("+(step+1)+")", 500);
+                                                       } else {
+                                                               dijit.byId("self_update_stop_btn").attr("disabled", false);
+                                                       }
+
+                                               } else {
+                                                       console.log(transport.responseText);
+                                                       notify_error("Received invalid data from server.");
+                                               }
+
+                                               dialog.attr("updated", true);
+                                       } catch (e) {
+                                               exception_error("updateSelf/inner", e);
+                                       }
+                               } });
+                       },
+                       close: function() {
+                               if (dialog.attr("updated")) {
+                                       window.location.reload();
+                               } else {
+                                       dialog.hide();
+                               }
+                       },
+                       start: function() {
+                               if (prompt(__("Live updating is considered experimental. Backup your tt-rss directory before continuing. Please type 'yes' to continue.")) == 'yes') {
+                                       dialog.performUpdate(0);
+                               }
+                       },
+                       href: query});
+
+               dialog.show();
+       } catch (e) {
+               exception_error("batchSubscribe", e);
+       }
+}
+
+function toggleAdvancedPrefs() {
+       try {
+               notify_progress("Loading, please wait...");
+
+               new Ajax.Request("backend.php", {
+                       parameters: "?op=pref-prefs&method=toggleadvanced",
+                       onComplete: function(transport) {
+                               updatePrefsList();
+                       } });
+
+       } catch (e) {
+               exception_error("toggleAdvancedPrefs", e);
+       }
+}