diff options
author | Gehad elrobey <gehadelrobey@gmail.com> | 2014-07-18 16:55:16 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-25 07:14:23 -0700 |
commit | bf68a2ece667504e656df15ac333e911961d5f4d (patch) | |
tree | cd9d96289094311f1aabde5b246fd54cb33f0e16 | |
parent | 6f6ed864bce317e06ecd0283456b9349fcf9bd02 (diff) | |
download | subsurface-bf68a2ece667504e656df15ac333e911961d5f4d.tar.gz |
HTML: fix searching tags from the detailed view.
When clicking a tag in the detailed view a search must take place on the
following tag, the search settings must be specified to search for tags
only and ignore the advanced search settings chosen by the user.
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | theme/dive_export.html | 4 | ||||
-rw-r--r-- | theme/list_lib.js | 33 |
2 files changed, 23 insertions, 14 deletions
diff --git a/theme/dive_export.html b/theme/dive_export.html index d9417e279..ebddf4040 100644 --- a/theme/dive_export.html +++ b/theme/dive_export.html @@ -123,7 +123,7 @@ window.onload=function(){ function changeAdvSearch(e){ searchingModules[e.value].enabled=e.checked; - SearchModules(document.getElementById("search_input").value); + SearchModules(document.getElementById("search_input").value, null); } </script> @@ -137,7 +137,7 @@ function changeAdvSearch(e){ </center> <div id="diveListPanel"> <div id="controlbox"> - <input id="search_input" oninput="SearchModules(this.value)" placeholder="search"/><a id="adv_srch_sp" onClick="showdiv()" >Advanced Search</a> + <input id="search_input" oninput="SearchModules(this.value, null)" placeholder="search"/><a id="adv_srch_sp" onClick="showdiv()" >Advanced Search</a> <div id="advanced_search"> <input type="checkbox" onchange="changeAdvSearch(this)" value="location" checked>Location<br> <input type="checkbox" onchange="changeAdvSearch(this)" value="divemaster" checked>Divemaster<br> diff --git a/theme/list_lib.js b/theme/list_lib.js index dd7be94a9..f40151887 100644 --- a/theme/list_lib.js +++ b/theme/list_lib.js @@ -206,8 +206,7 @@ function getExpanded(dive) { var res = '<table><tr><td class="words">Date: </td><td>' + dive.date + '</td><td class="words"> Time: </td><td>' + dive.time + - '</td><td class="words"> Location: </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\')\">' + - dive.location + '</a>' + + '</td><td class="words"> Location: </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' + '</td></tr></table><table><tr><td class="words">Rating:</td><td>' + putRating(dive.rating) + '</td><td class="words"> Visibilty:</td><td>' + putRating(dive.visibility) + '</td></tr></table>' + @@ -228,7 +227,7 @@ function putTags(tags) { var result = ""; for (var i in tags) { - result += '<a onclick=\"Search_list_Modules(\'' + tags[i] + '\')\">' + tags[i] + '</a>'; + result += '<a onclick=\"Search_list_Modules(\'' + tags[i] + '\', {location:false, divemaster:false, buddy:false, notes:false, tags:true,})\">' + tags[i] + '</a>'; if (i < tags.length - 1) result += ', '; } @@ -481,14 +480,15 @@ function Node(value) this.key = new Set(); } -function Search_list_Modules(searchfor) +function Search_list_Modules(searchfor, searchOptions) { document.getElementById("search_input").value = searchfor; - SearchModules(searchfor); + SearchModules(searchfor, searchOptions); } -function SearchModules(searchfor) +function SearchModules(searchfor, searchOptions) { + unshowDiveDetails(dive_id); var resultKeys = new Set(); //set if (searchfor.length <= 0) { @@ -502,22 +502,31 @@ function SearchModules(searchfor) var keywords = searchfor.split(" "); + if (searchOptions === null) { + searchOptions = {}; + searchOptions.location = searchingModules["location"].enabled; + searchOptions.divemaster = searchingModules["divemaster"].enabled; + searchOptions.buddy = searchingModules["buddy"].enabled; + searchOptions.notes = searchingModules["notes"].enabled; + searchOptions.tags = searchingModules["tags"].enabled; + } + for (var i = 0; i < keywords.length; i++) { var keywordResult = new Set(); - if (searchingModules["location"].enabled === true) + if (searchOptions.location === true) keywordResult.Union(searchingModules["location"].search(keywords[i])); - if (searchingModules["divemaster"].enabled === true) + if (searchOptions.divemaster === true) keywordResult.Union(searchingModules["divemaster"].search(keywords[i])); - if (searchingModules["buddy"].enabled === true) + if (searchOptions.buddy === true) keywordResult.Union(searchingModules["buddy"].search(keywords[i])); - if (searchingModules["notes"].enabled === true) + if (searchOptions.notes === true) keywordResult.Union(searchingModules["notes"].search(keywords[i])); - if (searchingModules["tags"].enabled === true) + if (searchOptions.tags === true) keywordResult.Union(searchingModules["tags"].search(keywords[i])); if (resultKeys.isEmpty()) { @@ -764,7 +773,7 @@ function get_dive_HTML(dive) { return '<h2 class="det_hed">Dive Information</h2><table><tr><td class="words">Date: </td><td>' + dive.date + '</td><td class="words"> Time: </td><td>' + dive.time + - '</td><td class="words"> Location: </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\')\">' + + '</td><td class="words"> Location: </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' + '</td></tr></table><table><tr><td class="words">Rating:</td><td>' + putRating(dive.rating) + '</td><td class="words"> Visibilty:</td><td>' + putRating(dive.visibility) + |