This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 78ad7bf532d23fdd914da765c8be2c9b8e7cd216 Author: Sebb <s...@apache.org> AuthorDate: Sat May 11 15:49:15 2024 +0100 Link wordCloud entries to correct daterange --- webui/js/source/sidebar-stats.js | 7 ++++++- webui/js/wordcloud.js | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/webui/js/source/sidebar-stats.js b/webui/js/source/sidebar-stats.js index a75a4b5..44241b8 100644 --- a/webui/js/source/sidebar-stats.js +++ b/webui/js/source/sidebar-stats.js @@ -80,7 +80,12 @@ async function sidebar_stats(json) { // word cloud is delayed by 50ms to let the rest render first // this is a chrome-specific slowdown we're addressing. window.setTimeout(function() { - wordCloud(json.cloud, 220, 100, wc); + if (G_current_month) { + daterange = G_current_year + '-' + G_current_month + } else { + daterange = G_current_year + } + wordCloud(json.cloud, 220, 100, wc, daterange); }, 50); } if (G_show_stats_sidebar === false) { diff --git a/webui/js/wordcloud.js b/webui/js/wordcloud.js index 8594012..2fed3dd 100644 --- a/webui/js/wordcloud.js +++ b/webui/js/wordcloud.js @@ -33,18 +33,18 @@ function fastIntersect(x,y,nx,ny) { || b.bottom+spacing < (a.top+ny)); } -function makeWord(word, size) { +function makeWord(word, size, daterange) { let textBox = document.createElementNS(SVG_NAMESPACE, "text"); textBox.setAttribute("font-size", size + "px") textBox.setAttribute("x", "0") textBox.setAttribute("y", "40") textBox.setAttribute("class", "cloudword") - textBox.setAttribute("onclick", "search(\"" + word + "\", 'lte=1M')") + textBox.setAttribute("onclick", "search(\"" + word + "\", '" + daterange + "')") textBox.textContent = word return textBox } -async function wordCloud(hash, width, height, obj) { +async function wordCloud(hash, width, height, obj, daterange) { let total = 0 let boxes = [] let space = width * height @@ -85,7 +85,7 @@ async function wordCloud(hash, width, height, obj) { // Try with random placement - textBox = makeWord(word, size) + textBox = makeWord(word, size, daterange) textBox.setAttribute("id", "svg_wc_" + word) svg.appendChild(textBox) if (!popped) {