]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
fix edit subscription option button doing nothing after external subscription
[tt-rss.git] / prefs.js
index 55e29d2af613b65473e80f6510f81cbb0406b289..93f5b06c77d25b8fa27f1d6593b69883ac1fbf30 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -1,29 +1,15 @@
 var init_params = new Array();
 
-var caller_subop = false;
 var hotkey_prefix = false;
 var hotkey_prefix_pressed = false;
 
 var seq = "";
 
 function feedlist_callback2(transport) {
-
        try {   
-
                dijit.byId('feedConfigTab').attr('content', transport.responseText); 
-
                selectTab("feedConfig", true);
-
-               if (caller_subop) {
-                       var tuple = caller_subop.split(":");
-                       if (tuple[0] == 'editFeed') {
-                               window.setTimeout('editFeed('+tuple[1]+')', 100);
-                       }                               
-
-                       caller_subop = false;
-               }
                notify("");
-
        } catch (e) {
                exception_error("feedlist_callback2", e);
        }
@@ -35,14 +21,9 @@ function filterlist_callback2(transport) {
 }
 
 function labellist_callback2(transport) {
-
        try {
-
                dijit.byId('labelConfigTab').attr('content', transport.responseText); 
-               closeInfoBox();
-
                notify("");
-
        } catch (e) {
                exception_error("labellist_callback2", e);
        }
@@ -211,15 +192,12 @@ function editFilter(id) {
                                        new Ajax.Request("backend.php", {
                                                parameters: query,
                                                onComplete: function(transport) {
-                                                       handle_rpc_reply(transport);
-                                                       var response = transport.responseXML;
+                                                       var reply = JSON.parse(transport.responseText);
 
-                                                       if (response) {
-                                                               var s = response.getElementsByTagName("status")[0].firstChild.nodeValue;
-       
+                                                       if (reply) {
                                                                notify('');
 
-                                                               if (s == "INVALID") {
+                                                               if (!reply['status']) {
                                                                        alert("Match regular expression seems to be invalid.");
                                                                        return;
                                                                } else {
@@ -850,7 +828,6 @@ function selectTab(id, noupdate, subop) {
        try {
                if (!noupdate) {
                        notify_progress("Loading, please wait...");
-                       closeInfoBox();
 
                        if (id == "feedConfig") {
                                updateFeedList();
@@ -878,15 +855,7 @@ function init_second_stage() {
        try {
 
                document.onkeydown = pref_hotkey_handler;
-
-               caller_subop = getURLParam('subop');
-
-               if (getURLParam("subopparam")) {
-                       caller_subop = caller_subop + ":" + getURLParam("subopparam");
-               }
-
                loading_set_progress(50);
-
                notify("");
 
                dojo.addOnLoad(function() {
@@ -896,6 +865,14 @@ function init_second_stage() {
                                tab = dijit.byId(tab + "Tab");
                                if (tab) dijit.byId("pref-tabs").selectChild(tab);
                        }
+
+                       var subop = getURLParam('subop');
+
+                       if (subop == 'editFeed') {
+                               var param = getURLParam('subopparam');
+
+                               window.setTimeout('editFeed(' + param + ')', 100);
+                       }
                });
 
                setTimeout("hotkey_prefix_timeout()", 5*1000);
@@ -932,6 +909,7 @@ function init() {
                dojo.require("dijit.InlineEditBox");
                dojo.require("dijit.ColorPalette");
                dojo.require("dijit.ProgressBar"); 
+               dojo.require("dijit.form.SimpleTextarea");
 
                dojo.registerModulePath("lib", "..");
                dojo.registerModulePath("fox", "../..");
@@ -1253,13 +1231,15 @@ function opmlRegenKey() {
                        new Ajax.Request("backend.php", {
                                parameters: query,
                                onComplete: function(transport) {
-                                               var new_link = transport.responseXML.getElementsByTagName("link")[0];
+                                               var reply = JSON.parse(transport.responseText);
+
+                                               var new_link = reply.link;
        
                                                var e = $('pub_opml_url');
        
                                                if (new_link) {
-                                                       e.href = new_link.firstChild.nodeValue;
-                                                       e.innerHTML = new_link.firstChild.nodeValue;
+                                                       e.href = new_link;
+                                                       e.innerHTML = new_link;
        
                                                        new Effect.Highlight(e);
 
@@ -1704,4 +1684,54 @@ function editLabel(id, event) {
        }
 }
 
+function clearTwitterCredentials() {
+       try {
+               var ok = confirm(__("This will clear your stored authentication information for Twitter. Continue?"));
 
+               if (ok) {
+                       notify_progress("Clearing credentials...");
+
+                       var query = "?op=pref-feeds&subop=remtwitterinfo";
+
+                       new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) { 
+                                       notify_info("Twitter credentials have been cleared.");
+                                       updateFeedList();
+                               } });
+               }
+
+       } catch (e) {
+               exception_error("clearTwitterCredentials", e);
+       }
+}
+
+function customizeCSS() {
+       try {
+               var query = "backend.php?op=dlg&id=customizeCSS";
+
+               if (dijit.byId("cssEditDlg"))
+                       dijit.byId("cssEditDlg").destroyRecursive();
+
+               dialog = new dijit.Dialog({
+                       id: "cssEditDlg",
+                       title: __("Customize stylesheet"),
+                       style: "width: 600px",
+                       execute: function() {
+                               notify_progress('Saving data...', true);
+                               new Ajax.Request("backend.php", {
+                                       parameters: dojo.objectToQuery(this.attr('value')),
+                                       onComplete: function(transport) { 
+                                               notify('');
+                                               window.location.reload();
+                               } });
+
+                       },
+                       href: query});
+
+               dialog.show();
+
+       } catch (e) {
+               exception_error("customizeCSS", e);
+       }
+}