X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;ds=sidebyside;f=js%2Ffunctions.js;h=a7f4b78916185196c794695816421c0f9bfd401d;hb=2f7918ae2e60dc79c962dd0988e682a9a3726aad;hp=8442e1c9fc0f5039d3e6c1227df57805f15f7062;hpb=1e253d1ec9a93ca26e5e54c79a9e61d8e858102c;p=tt-rss.git diff --git a/js/functions.js b/js/functions.js index 8442e1c9..a7f4b789 100644 --- a/js/functions.js +++ b/js/functions.js @@ -47,6 +47,8 @@ function exception_error(location, e, ext_info) { if (ext_info) { if (ext_info.responseText) { ext_info = ext_info.responseText; + } else { + ext_info = JSON.stringify(ext_info); } } @@ -104,13 +106,15 @@ function exception_error(location, e, ext_info) { title: "Unhandled exception", style: "width: 600px", report: function() { - if (confirm(__("Are you sure to report this exception to tt-rss.org? The report will include your browser information. Your IP would be saved in the database."))) { + if (confirm(__("Are you sure to report this exception to tt-rss.org? The report will include information about your web browser and tt-rss configuration. Your IP will be saved in the database."))) { document.forms['exceptionForm'].params.value = $H({ browserName: navigator.appName, browserVersion: navigator.appVersion, browserPlatform: navigator.platform, browserCookies: navigator.cookieEnabled, + ttrssVersion: __ttrss_version, + initParams: JSON.stringify(init_params), }).toQueryString(); document.forms['exceptionForm'].submit(); @@ -226,13 +230,13 @@ function notify_real(msg, no_hide, n_type) { no_hide = true; } else if (n_type == 3) { n.className = "notify error"; - msg = "" + msg; + msg = "" + msg; } else if (n_type == 4) { n.className = "notify info"; - msg = "" + msg; + msg = "" + msg; } - msg += " "; // msg = " " + msg; @@ -829,7 +833,14 @@ function quickAddFeed() { onComplete: function(transport) { try { - var reply = JSON.parse(transport.responseText); + try { + var reply = JSON.parse(transport.responseText); + } catch (e) { + Element.hide("feed_add_spinner"); + alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console.")); + console.log('quickAddFeed, backend returned:' + transport.responseText); + return; + } var rc = reply['result']; @@ -854,6 +865,8 @@ function quickAddFeed() { case 4: feeds = rc['feeds']; + Element.show("fadd_multiple_notify"); + var select = dijit.byId("feedDlg_feedContainerSelect"); while (select.getOptions().length > 0) @@ -1148,33 +1161,48 @@ function quickAddFilter() { href: query}); if (!inPreferences()) { + var selectedText = getSelectionText(); + var lh = dojo.connect(dialog, "onLoad", function(){ dojo.disconnect(lh); - var query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId(); + if (selectedText != "") { - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - var reply = JSON.parse(transport.responseText); + var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) : + getActiveFeedId(); - var title = false; + var rule = { reg_exp: selectedText, feed_id: feed_id, filter_type: 1 }; - if (reply && reply) title = reply.title; + addFilterRule(null, dojo.toJson(rule)); - if (title || getActiveFeedId() || activeFeedIsCat()) { + } else { - console.log(title + " " + getActiveFeedId()); + var query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId(); - var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) : - getActiveFeedId(); + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + var reply = JSON.parse(transport.responseText); - var rule = { reg_exp: title, feed_id: feed_id, filter_type: 1 }; + var title = false; - addFilterRule(null, dojo.toJson(rule)); - } + if (reply && reply) title = reply.title; - } }); + if (title || getActiveFeedId() || activeFeedIsCat()) { + + console.log(title + " " + getActiveFeedId()); + + var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) : + getActiveFeedId(); + + var rule = { reg_exp: title, feed_id: feed_id, filter_type: 1 }; + + addFilterRule(null, dojo.toJson(rule)); + } + + } }); + + } }); } @@ -1269,16 +1297,17 @@ function backend_sanity_check_callback(transport) { if (params) { console.log('reading init-params...'); - if (params) { - for (k in params) { - var v = params[k]; - console.log("IP: " + k + " => " + v); + for (k in params) { + var v = params[k]; + console.log("IP: " + k + " => " + v); - if (k == "label_base_index") _label_base_index = parseInt(v); - } + if (k == "label_base_index") _label_base_index = parseInt(v); } init_params = params; + + // PluginHost might not be available on non-index pages + window.PluginHost && PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, init_params); } sanity_check_done = true; @@ -1933,3 +1962,25 @@ function feed_to_label_id(feed) { return _label_base_index - 1 + Math.abs(feed); } +// http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac + +function getSelectionText() { + var text = ""; + + if (typeof window.getSelection != "undefined") { + var sel = window.getSelection(); + if (sel.rangeCount) { + var container = document.createElement("div"); + for (var i = 0, len = sel.rangeCount; i < len; ++i) { + container.appendChild(sel.getRangeAt(i).cloneContents()); + } + text = container.innerHTML; + } + } else if (typeof document.selection != "undefined") { + if (document.selection.type == "Text") { + text = document.selection.createRange().textText; + } + } + + return text.stripTags(); +}