]> git.wh0rd.org - tt-rss.git/blobdiff - js/functions.js
move db-updater functionality to public, remove db-updater.php
[tt-rss.git] / js / functions.js
index a9367da60704e4f14c00794adf087a135d3cfb9d..82cfa90549d27dccf83f1065ebea817ec2c365b2 100644 (file)
@@ -2,6 +2,7 @@ var notify_silent = false;
 var loading_progress = 0;
 var sanity_check_done = false;
 var init_params = {};
+var _label_base_index = -1024;
 
 Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(
        function (callOriginal, options) {
@@ -193,30 +194,29 @@ function notify_real(msg, no_hide, n_type) {
 
        */
 
-       if (typeof __ != 'undefined') {
-               msg = __(msg);
-       }
+       msg = __(msg);
 
        if (n_type == 1) {
                n.className = "notify";
        } else if (n_type == 2) {
-               n.className = "notifyProgress";
+               n.className = "notify progress";
                msg = "<img src='images/indicator_white.gif'> " + msg;
        } else if (n_type == 3) {
-               n.className = "notifyError";
+               n.className = "notify error";
                msg = "<img src='images/sign_excl.svg'> " + msg;
        } else if (n_type == 4) {
-               n.className = "notifyInfo";
+               n.className = "notify info";
                msg = "<img src='images/sign_info.svg'> " + msg;
        }
 
-//     msg = "<img src='images/live_com_loading.gif'> " + msg;
-
        if (no_hide) {
-               msg += " (<a href='#' onclick=\"notify('')\">X</a>)";
+               msg += " <span>(<a href='#' onclick=\"notify('')\">" +
+                       __("close") + "</a>)</span>";
        }
 
 
+//     msg = "<img src='images/live_com_loading.gif'> " + msg;
+
        nb.innerHTML = msg;
 
        if (!no_hide) {
@@ -415,7 +415,7 @@ function closeInfoBox(cleanup) {
 }
 
 
-function displayDlg(id, param, callback) {
+function displayDlg(title, id, param, callback) {
 
        notify_progress("Loading, please wait...", true);
 
@@ -425,14 +425,14 @@ function displayDlg(id, param, callback) {
        new Ajax.Request("backend.php", {
                parameters: query,
                onComplete: function (transport) {
-                       infobox_callback2(transport);
+                       infobox_callback2(transport, title);
                        if (callback) callback(transport);
                } });
 
        return false;
 }
 
-function infobox_callback2(transport) {
+function infobox_callback2(transport, title) {
        try {
                var dialog = false;
 
@@ -443,13 +443,7 @@ function infobox_callback2(transport) {
                //console.log("infobox_callback2");
                notify('');
 
-               var title = transport.responseXML.getElementsByTagName("title")[0];
-               if (title)
-                       title = title.firstChild.nodeValue;
-
-               var content = transport.responseXML.getElementsByTagName("content")[0];
-
-               content = content.firstChild.nodeValue;
+               var content = transport.responseText;
 
                if (!dialog) {
                        dialog = new dijit.Dialog({
@@ -514,7 +508,7 @@ function fatalError(code, msg, ext_info) {
                if (code == 6) {
                        window.location.href = "index.php";
                } else if (code == 5) {
-                       window.location.href = "db-updater.php";
+                       window.location.href = "public.php?op=dbupdate";
                } else {
 
                        if (msg == "") msg = "Unknown error";
@@ -554,28 +548,6 @@ function fatalError(code, msg, ext_info) {
        }
 }
 
-/* function filterDlgCheckType(sender) {
-
-       try {
-
-               var ftype = sender.value;
-
-               // if selected filter type is 5 (Date) enable the modifier dropbox
-               if (ftype == 5) {
-                       Element.show("filterDlg_dateModBox");
-                       Element.show("filterDlg_dateChkBox");
-               } else {
-                       Element.hide("filterDlg_dateModBox");
-                       Element.hide("filterDlg_dateChkBox");
-
-               }
-
-       } catch (e) {
-               exception_error("filterDlgCheckType", e);
-       }
-
-} */
-
 function filterDlgCheckAction(sender) {
 
        try {
@@ -609,37 +581,9 @@ function filterDlgCheckAction(sender) {
 
 }
 
-function filterDlgCheckDate() {
-       try {
-               var dialog = dijit.byId("filterEditDlg");
-
-               var reg_exp = dialog.attr('value').reg_exp;
-
-               var query = "?op=rpc&method=checkDate&date=" + reg_exp;
-
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) {
-
-                               var reply = JSON.parse(transport.responseText);
-
-                               if (reply['result'] == true) {
-                                       alert(__("Date syntax appears to be correct:") + " " + reply['date']);
-                                       return;
-                               } else {
-                                       alert(__("Date syntax is incorrect."));
-                               }
-
-                       } });
-
-
-       } catch (e) {
-               exception_error("filterDlgCheckDate", e);
-       }
-}
 
 function explainError(code) {
-       return displayDlg("explainError", code);
+       return displayDlg(__("Error explained"), "explainError", code);
 }
 
 function loading_set_progress(p) {
@@ -717,15 +661,6 @@ function hotkey_prefix_timeout() {
        }
 }
 
-function hideAuxDlg() {
-       try {
-               Element.hide('auxDlg');
-       } catch (e) {
-               exception_error("hideAuxDlg", e);
-       }
-}
-
-
 function uploadIconHandler(rc) {
        try {
                switch (rc) {
@@ -845,7 +780,7 @@ function addLabel(select, callback) {
 
 function quickAddFeed() {
        try {
-               var query = "backend.php?op=dlg&method=quickAddFeed";
+               var query = "backend.php?op=feeds&method=quickAddFeed";
 
                // overlapping widgets
                if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
@@ -1338,6 +1273,8 @@ function backend_sanity_check_callback(transport) {
                                for (k in params) {
                                        var v = params[k];
                                        console.log("IP: " + k + " => " + v);
+
+                                       if (k == "label_base_index") _label_base_index = parseInt(v);
                                }
                        }
 
@@ -1420,7 +1357,7 @@ function genUrlChangeKey(feed, is_cat) {
 
                        notify_progress("Trying to change address...", true);
 
-                       var query = "?op=rpc&method=regenFeedKey&id=" + param_escape(feed) +
+                       var query = "?op=pref-feeds&method=regenFeedKey&id=" + param_escape(feed) +
                                "&is_cat=" + param_escape(is_cat);
 
                        new Ajax.Request("backend.php", {
@@ -1648,7 +1585,7 @@ function editFeed(feed, event) {
 
 function feedBrowser() {
        try {
-               var query = "backend.php?op=dlg&method=feedBrowser";
+               var query = "backend.php?op=feeds&method=feedBrowser";
 
                if (dijit.byId("feedAddDlg"))
                        dijit.byId("feedAddDlg").hide();
@@ -1986,3 +1923,13 @@ function htmlspecialchars_decode (string, quote_style) {
 
   return string;
 }
+
+
+function label_to_feed_id(label) {
+       return _label_base_index - 1 - Math.abs(label);
+}
+
+function feed_to_label_id(feed) {
+       return _label_base_index - 1 + Math.abs(feed);
+}
+