noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 36/38: Fix : Bug cannot filter a list of elem


From: dwm
Subject: [Noalyss-commit] [noalyss] 36/38: Fix : Bug cannot filter a list of element
Date: Sun, 18 Feb 2024 07:30:48 -0500 (EST)

sparkyx pushed a commit to branch devel
in repository noalyss.

commit 8d3f5b61371a0ab554242d43c50b554681748fcc
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Feb 18 13:05:50 2024 +0100

    Fix : Bug cannot filter a list of element
---
 html/js/noalyss_script.js        | 20 ++++++++++++--------
 include/lib/html_input.class.php | 12 +++++++++++-
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/html/js/noalyss_script.js b/html/js/noalyss_script.js
index dace8e4b0..540f0b4aa 100644
--- a/html/js/noalyss_script.js
+++ b/html/js/noalyss_script.js
@@ -2266,7 +2266,7 @@ function filter_table(phrase, _id, colnr, start_row) {
 }
 /**
  *  filter quickly a list
- * @param  phrase : DOM id of the input text where we find the word to seach
+ * @param  phrase : DOM id of the input text where we find the word to seach, 
the searchable content use the className searchContent
  * @param  _id : id of the list
  * @returns nothing
  * @see HtmlInput::filter_list
@@ -2277,20 +2277,24 @@ function filter_list(phrase, _id) {
     var words = $(phrase).value.toLowerCase();
     var l_list = document.getElementById(_id);
 
-    var ele;
+
     var tot_found = 0;
 
     for (var r = 0; r < l_list.childNodes.length; r++) {
         var found = 0;
-        if (l_list.childNodes[r].nodeType != 1 ){
+
+        if (l_list.childNodes[r].nodeType != 1) {
             continue;
         }
-        if (l_list.childNodes[r].childElementCount == 0)
-        {
-            ele = l_list.childNodes[r].innerHTML;
-        } else {
-            ele = l_list.childNodes[r].childNodes[0].innerHTML;
+        let ele = "";
+        let la_content = 
l_list.childNodes[r].getElementsByClassName("search-content");
+
+        let e = 0;
+        for (e = 0; e < la_content.length; e++) {
+               ele += la_content[e].innerText;
         }
+
+        console.debug (`ele = ${ele}`);
         if (ele.toLowerCase().indexOf(words) >= 0) {
             tot_found++;
             l_list.childNodes[r].style.display = 'block';
diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php
index a18b85a68..86e2f7465 100755
--- a/include/lib/html_input.class.php
+++ b/include/lib/html_input.class.php
@@ -1050,8 +1050,18 @@ class HtmlInput
         return $r;
     }
     /**
-     * Display a field for searching an element in a list 
+     * @brief Display a field for searching an element in a list, the 
searchable text must be in an element with the className search-content
      * @param string $p_list_id DOM ID of the list (ul or ol)
+     * @code
+
+     <ul id="xx">
+     <li><span class="search-content"> Content used for searching</span> 
Content not used for search </li>
+     <li><span class="search-content"> Content used for searching</span> <a 
href="">Content not used for search</a> </li>
+     <li><span class="search-content"> Content used for searching</span> 
Content not used for search </li>
+     <li><a href=""><span class="search-content"> Content used for 
searching</span> </a></li>
+     <ul>
+     *
+     * @endcode
      * @return string
      */
     static function filter_list($p_list_id)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]