]> git.wh0rd.org - tt-rss.git/blobdiff - functions.js
experimental split of public calls into public.php (refs #389)
[tt-rss.git] / functions.js
index e9a6d928c673a95fa8b1dca3212186e648072d0a..1fd421809267b57d0be66ddede63ab1c4cd97640 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;
 }
 
 
@@ -628,7 +631,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."));
@@ -969,6 +972,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()) {
 
@@ -1115,13 +1136,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 {
@@ -1412,7 +1433,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();
 
@@ -1426,26 +1447,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 {
@@ -1521,4 +1564,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("");
+}