]> git.wh0rd.org - tt-rss.git/blobdiff - functions.js
use css for help overlay, css cleanup
[tt-rss.git] / functions.js
index ba82ebe111b731214231bca2e0c28864cf406358..c47070ed3e3e78f2ec3cc52b0f705b8fd90ac5b6 100644 (file)
@@ -61,6 +61,8 @@ function exception_error(location, e, ext_info) {
                                __('Close') + "</button>";
                content += "</div>";
 
+               if (dijit.byId("exceptionDlg"))
+                       dijit.byId("exceptionDlg").destroyRecursive();
 
                var dialog = new dijit.Dialog({
                        id: "exceptionDlg",
@@ -275,8 +277,9 @@ function gotoMain() {
        document.location.href = "tt-rss.php";
 }
 
-function gotoExportOpml() {
-       document.location.href = "opml.php?op=Export";
+function gotoExportOpml(filename, settings) {
+    tmp = settings ? 1 : 0;
+       document.location.href = "opml.php?op=Export&filename=" + filename + "&settings=" + tmp;
 }
 
 
@@ -391,16 +394,6 @@ function make_timestamp() {
 }
 
 
-function closeErrorBox() {
-
-       if (Element.visible("errorBoxShadow")) {
-               Element.hide("dialog_overlay");
-               Element.hide("errorBoxShadow");
-       }
-
-       return false;
-}
-
 function closeInfoBox(cleanup) {
        try {
                dialog = dijit.byId("infoBox");
@@ -628,7 +621,7 @@ function filterDlgCheckDate() {
                                var reply = JSON.parse(transport.responseText);
 
                                if (reply['result'] == true) {
-                                       alert(__("Date syntax appears to be correct."));
+                                       alert(__("Date syntax appears to be correct:") + " " + reply['date']);
                                        return;
                                } else {
                                        alert(__("Date syntax is incorrect."));
@@ -943,7 +936,7 @@ function quickAddFeed() {
                                                                }
 
                                                        } catch (e) {
-                                                               exception_error("subscribeToFeed", e);
+                                                               exception_error("subscribeToFeed", e, transport);
                                                        }
 
                                                } });
@@ -969,6 +962,24 @@ function quickAddFilter() {
                        id: "filterEditDlg",
                        title: __("Create Filter"),
                        style: "width: 600px",
+                       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();
+
+                               }
+                       },
                        execute: function() {
                                if (this.validate()) {
 
@@ -1015,6 +1026,27 @@ function quickAddFilter() {
        }
 }
 
+function resetPubSub(feed_id, title) {
+
+       var msg = __("Reset subscription? Tiny Tiny RSS will try to subscribe to the notification hub again on next feed update.").replace("%s", title);
+
+       if (title == undefined || confirm(msg)) {
+               notify_progress("Loading, please wait...");
+
+               var query = "?op=pref-feeds&quiet=1&subop=resetPubSub&ids=" + feed_id;
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) {
+                               dijit.byId("pubsubReset_Btn").attr('disabled', true);
+                               notify_info("Subscription reset.");
+                       } });
+       }
+
+       return false;
+}
+
+
 function unsubscribeFeed(feed_id, title) {
 
        var msg = __("Unsubscribe from %s?").replace("%s", title);
@@ -1094,13 +1126,13 @@ function backend_sanity_check_callback(transport) {
        }
 }
 
-function has_local_storage() {
+/*function has_local_storage() {
        try {
                return 'sessionStorage' in window && window['sessionStorage'] != null;
        } catch (e) {
                return false;
        }
-}
+} */
 
 function catSelectOnChange(elem) {
        try {
@@ -1177,8 +1209,8 @@ function genUrlChangeKey(feed, is_cat) {
                                                        e.innerHTML = e.innerHTML.replace(/\&amp;key=.*$/,
                                                                "&amp;key=" + new_link);
 
-                                                       e.href = e.href.replace(/\&amp;key=.*$/,
-                                                               "&amp;key=" + new_link);
+                                                       e.href = e.href.replace(/\&key=.*$/,
+                                                               "&key=" + new_link);
 
                                                        new Effect.Highlight(e);
 
@@ -1391,7 +1423,7 @@ function feedBrowser() {
                        id: "feedBrowserDlg",
                        title: __("More Feeds"),
                        style: "width: 600px",
-                       getSelectedFeeds: function() {
+                       getSelectedFeedIds: function() {
                                var list = $$("#browseFeedList li[id*=FBROW]");
                                var selected = new Array();
 
@@ -1405,26 +1437,48 @@ function feedBrowser() {
 
                                return selected;
                        },
+                       getSelectedFeeds: function() {
+                               var list = $$("#browseFeedList li.Selected");
+                               var selected = new Array();
+
+                               list.each(function(child) {
+                                       var title = child.getElementsBySelector("span.fb_feedTitle")[0].innerHTML;
+                                       var url = child.getElementsBySelector("a.fb_feedUrl")[0].href;
+
+                                       selected.push([title,url]);
+
+                               });
+
+                               return selected;
+                       },
+
                        subscribe: function() {
-                               var selected = this.getSelectedFeeds();
                                var mode = this.attr('value').mode;
+                               var selected = [];
+
+                               if (mode == "1")
+                                       selected = this.getSelectedFeeds();
+                               else
+                                       selected = this.getSelectedFeedIds();
 
                                if (selected.length > 0) {
                                        dijit.byId("feedBrowserDlg").hide();
 
                                        notify_progress("Loading, please wait...", true);
 
-                                       var query = "?op=rpc&subop=massSubscribe&ids="+
-                                               param_escape(selected.toString()) + "&mode=" + param_escape(mode);
+                                       // we use dojo.toJson instead of JSON.stringify because
+                                       // it somehow escapes everything TWICE, at least in Chrome 9
+
+                                       var query = "?op=rpc&subop=massSubscribe&payload="+
+                                               param_escape(dojo.toJson(selected)) + "&mode=" + param_escape(mode);
 
                                        console.log(query);
 
                                        new Ajax.Request("backend.php", {
                                                parameters: query,
                                                onComplete: function(transport) {
-                                                       if (inPreferences()) {
-                                                               updateFeedList();
-                                                       }
+                                                       notify('');
+                                                       updateFeedList();
                                                } });
 
                                } else {
@@ -1500,4 +1554,109 @@ function feedBrowser() {
        }
 }
 
+function showFeedsWithErrors() {
+       try {
+               var query = "backend.php?op=dlg&id=feedsWithErrors";
+
+               if (dijit.byId("errorFeedsDlg"))
+                       dijit.byId("errorFeedsDlg").destroyRecursive();
+
+               dialog = new dijit.Dialog({
+                       id: "errorFeedsDlg",
+                       title: __("Feeds with update errors"),
+                       style: "width: 600px",
+                       getSelectedFeeds: function() {
+                               return getSelectedTableRowIds("prefErrorFeedList");
+                       },
+                       removeSelected: function() {
+                               var sel_rows = this.getSelectedFeeds();
 
+                               console.log(sel_rows);
+
+                               if (sel_rows.length > 0) {
+                                       var ok = confirm(__("Remove selected feeds?"));
+
+                                       if (ok) {
+                                               notify_progress("Removing selected feeds...", true);
+
+                                               var query = "?op=pref-feeds&subop=remove&ids="+
+                                                       param_escape(sel_rows.toString());
+
+                                               new Ajax.Request("backend.php", {
+                                                       parameters: query,
+                                                       onComplete: function(transport) {
+                                                               notify('');
+                                                               dialog.hide();
+                                                               updateFeedList();
+                                                       } });
+                                       }
+
+                               } else {
+                                       alert(__("No feeds are selected."));
+                               }
+                       },
+                       execute: function() {
+                               if (this.validate()) {
+                               }
+                       },
+                       href: query});
+
+               dialog.show();
+
+       } catch (e) {
+               exception_error("showFeedsWithErrors", e);
+       }
+
+}
+
+/* new support functions for SelectByTag */
+
+function get_all_tags(selObj){
+       try {
+               if( !selObj ) return "";
+
+               var result = "";
+               var len = selObj.options.length;
+
+               for (var i=0; i < len; i++){
+                       if (selObj.options[i].selected) {
+                               result += selObj[i].value + "%2C";   // is really a comma
+                       }
+               }
+
+               if (result.length > 0){
+                       result = result.substr(0, result.length-3);  // remove trailing %2C
+               }
+
+               return(result);
+
+       } catch (e) {
+               exception_error("get_all_tags", e);
+       }
+}
+
+function get_radio_checked(radioObj) {
+       try {
+               if (!radioObj) return "";
+
+               var len = radioObj.length;
+
+               if (len == undefined){
+                       if(radioObj.checked){
+                               return(radioObj.value);
+                       } else {
+                               return("");
+                       }
+               }
+
+               for( var i=0; i < len; i++ ){
+                       if( radioObj[i].checked ){
+                               return( radioObj[i].value);
+                       }
+               }
+
+       } catch (e) {
+               exception_error("get_radio_checked", e);
+       }
+       return("");
+}