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 a36fb3e930cf933195d8748bfd3f7b505f956f05
Author: Sebb <s...@apache.org>
AuthorDate: Wed May 1 19:48:21 2024 +0100

    pony mail search result url does not work as link
    
    This fixes #255
---
 webui/js/source/search.js | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/webui/js/source/search.js b/webui/js/source/search.js
index f9e7c8d..79047d9 100644
--- a/webui/js/source/search.js
+++ b/webui/js/source/search.js
@@ -32,12 +32,33 @@ function search(query, date) {
     let listid = '%s@%s'.format(list, domain);
     G_current_list = list;
     G_current_domain = domain;
-    let newhref = "list?%s:%s:%s".format(listid, date, query);
 
     let header_from = document.getElementById('header_from');
     let header_subject = document.getElementById('header_subject');
     let header_to = document.getElementById('header_to');
     let header_body = document.getElementById('header_body');
+    let qparts = query.split('&'); // look for additional query options
+    if (qparts.length > 0) { // i.e. query + header bits
+        query = qparts.shift(); // Keep only the query
+        // store the values to be picked up below
+        for (let part of qparts) {
+            let hv = part.split('=',2);
+            if (hv[0] == 'header_from') {
+                header_from.value = hv[1];
+            }
+            if (hv[0] == 'header_subject') {
+                header_subject.value = hv[1];
+            }
+            if (hv[0] == 'header_to') {
+                header_to.value = hv[1];
+            }
+            if (hv[0] == 'header_body') {
+                header_body.value = hv[1];
+            }
+            // N.B. other options are currently ignored
+        }
+    }
+    let newhref = "list?%s:%s:%s".format(listid, date, query);
     let sURL = '%sapi/stats.lua?d=%s&list=%s&domain=%s&q=%s'.format(
         G_apiURL, encodeURIComponent(date), encodeURIComponent(list), 
encodeURIComponent(domain), encodeURIComponent(query)
         );
@@ -95,4 +116,4 @@ function search_set_list(what) {
         }
     }
     document.getElementById('q').setAttribute("placeholder", "Search 
%s...".format(whatxt));
-}
\ No newline at end of file
+}

Reply via email to