From 3857536f70057370810c70145cf8e54af5fdcd78 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 9 Sep 2015 22:13:43 +0300 Subject: fix testing in create filter dialog, woops --- js/functions.js | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 95 insertions(+), 10 deletions(-) mode change 100644 => 100755 js/functions.js (limited to 'js/functions.js') diff --git a/js/functions.js b/js/functions.js old mode 100644 new mode 100755 index 8e5694960..2e9e544a9 --- a/js/functions.js +++ b/js/functions.js @@ -1051,6 +1051,100 @@ function addFilterAction(replaceNode, actionStr) { } } +function editFilterTest(query) { + try { + + if (dijit.byId("filterTestDlg")) + dijit.byId("filterTestDlg").destroyRecursive(); + + var test_dlg = new dijit.Dialog({ + id: "filterTestDlg", + title: "Test Filter", + style: "width: 600px", + results: 0, + limit: 100, + max_offset: 10000, + getTestResults: function(query, offset) { + var updquery = query + "&offset=" + offset + "&limit=" + test_dlg.limit; + + console.log("getTestResults:" + offset); + + new Ajax.Request("backend.php", { + parameters: updquery, + onComplete: function (transport) { + try { + var result = JSON.parse(transport.responseText); + + if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) { + test_dlg.results += result.size(); + + console.log("got results:" + result.size()); + + $("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d processed, %f found)...") + .replace("%f", test_dlg.results) + .replace("%d", offset); + + console.log(offset + " " + test_dlg.max_offset); + + for (var i = 0; i < result.size(); i++) { + var tmp = new Element("table"); + tmp.innerHTML = result[i]; + dojo.parser.parse(tmp); + + $("prefFilterTestResultList").innerHTML += tmp.innerHTML; + } + + if (test_dlg.results < 30 && offset < test_dlg.max_offset) { + + // get the next batch + window.setTimeout(function () { + test_dlg.getTestResults(query, offset + test_dlg.limit); + }, 0); + + } else { + // all done + + Element.hide("prefFilterLoadingIndicator"); + + if (test_dlg.results == 0) { + $("prefFilterTestResultList").innerHTML = "No recent articles matching this filter have been found."; + $("prefFilterProgressMsg").innerHTML = "Articles matching this filter:"; + } else { + $("prefFilterProgressMsg").innerHTML = __("Found %d articles matching this filter:") + .replace("%d", test_dlg.results); + } + + } + + } else if (!result) { + console.log("getTestResults: can't parse results object"); + + Element.hide("prefFilterLoadingIndicator"); + + notify_error("Error while trying to get filter test results."); + + } else { + console.log("getTestResults: dialog closed, bailing out."); + } + } catch (e) { + exception_error("editFilterTest/inner", e); + } + + } }); + }, + href: query}); + + dojo.connect(test_dlg, "onLoad", null, function(e) { + test_dlg.getTestResults(query, 0); + }); + + test_dlg.show(); + + } catch (e) { + exception_error("editFilterTest", e); + } +} + function quickAddFilter() { try { var query = ""; @@ -1077,16 +1171,7 @@ function quickAddFilter() { test: function() { var query = "backend.php?" + dojo.formToQuery("filter_new_form") + "&savemode=test"; - if (dijit.byId("filterTestDlg")) - dijit.byId("filterTestDlg").destroyRecursive(); - - var test_dlg = new dijit.Dialog({ - id: "filterTestDlg", - title: "Test Filter", - style: "width: 600px", - href: query}); - - test_dlg.show(); + editFilterTest(query); }, selectRules: function(select) { $$("#filterDlg_Matches input[type=checkbox]").each(function(e) { -- cgit v1.2.3-54-g00ecf From f48f292d2b9c3274aeb742c343df1d2f536a6a65 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 11 Sep 2015 13:05:08 +0300 Subject: tweak filter preview layout a bit; allow previewing matched articles in a popup --- classes/article.php | 4 ++-- classes/pref/filters.php | 17 +++++++++-------- js/functions.js | 7 +++++++ 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'js/functions.js') diff --git a/classes/article.php b/classes/article.php index bcd249873..01f6b5126 100644 --- a/classes/article.php +++ b/classes/article.php @@ -41,12 +41,12 @@ class Article extends Handler_Protected { } else if ($mode == "zoom") { array_push($articles, format_article($id, true, true)); } else if ($mode == "raw") { - if ($_REQUEST['html']) { + if (isset($_REQUEST['html'])) { header("Content-Type: text/html"); print ''; } - $article = format_article($id, false); + $article = format_article($id, false, isset($_REQUEST["zoom"])); print $article['content']; return; } diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 6170f7a08..427ce79a1 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -134,7 +134,7 @@ class Pref_Filters extends Handler_Protected { if (count($rc) > 0) { - $line["content_preview"] = truncate_string(strip_tags($line["content"]), 100, '...'); + $line["content_preview"] = truncate_string(strip_tags($line["content"]), 200, '…'); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 100); @@ -142,10 +142,12 @@ class Pref_Filters extends Handler_Protected { $content_preview = $line["content_preview"]; - if ($line["feed_title"]) $feed_title = "(" . $line["feed_title"] . ")"; + $tmp = ""; - $tmp = ""; + $id = $line['id']; + $tmp .= ""; foreach ($filter['rules'] as $rule) { $reg_exp = str_replace('/', '\/', $rule["reg_exp"]); @@ -157,10 +159,9 @@ class Pref_Filters extends Handler_Protected { "$1", $content_preview); } - $tmp .= "" . $line["title"] . ""; - $tmp .= "
" . $feed_title . "
"; - $tmp .= "
" . $content_preview . "
"; - $tmp .= " " . mb_substr($line["date_entered"], 0, 16); + $tmp .= "" . $line["title"] . "
"; + $tmp .= $line['feed_title'] . ", " . mb_substr($line["date_entered"], 0, 16); + $tmp .= "
" . $content_preview . "
"; $tmp .= ""; array_push($rv, $tmp); diff --git a/js/functions.js b/js/functions.js index 2e9e544a9..24e585847 100755 --- a/js/functions.js +++ b/js/functions.js @@ -2053,3 +2053,10 @@ function getSelectionText() { return text.stripTags(); } + +function openArticlePopup(id) { + window.open("backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + + "&csrf_token=" + getInitParam("csrf_token"), + "ttrss_article_popup", + "height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no"); +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf