summaryrefslogtreecommitdiff
path: root/template/search_files.st
diff options
context:
space:
mode:
authortim b <timb@camcompu.home>2010-06-10 08:42:40 -0700
committertim b <timb@camcompu.home>2010-06-10 08:42:40 -0700
commit899f7fb8f57f01e388a46869ac0f55314b043a37 (patch)
tree9b48fdb7e9288a040d3f94ce211eebbd6cb46975 /template/search_files.st
parent39ec1ea2114ff86e4f318b2994b457716476c4d0 (diff)
search for multiple tokens. fix case issues
Diffstat (limited to 'template/search_files.st')
-rw-r--r--template/search_files.st29
1 files changed, 22 insertions, 7 deletions
diff --git a/template/search_files.st b/template/search_files.st
index f726364..d3deea5 100644
--- a/template/search_files.st
+++ b/template/search_files.st
@@ -9,7 +9,7 @@
</head>
<body>
- <center>search dumps: <input type="text" name="search-query" id="search-query" /></center>
+ <center>search dumps: <input type="text" name="search-query" id="search-query" /></center><br><br>
<center><div id="message"></div><br><br></center>
<div id="content"></div>
@@ -72,8 +72,15 @@
var imageUrl = imageUrls[i];
if (imageUrl in alreadyGot) continue;
alreadyGot[imageUrl] = true
- if (imageUrl.indexOf(term) > -1)
- images.push(imageUrl)
+ var validImage = true;
+ for(var t = 0; t<tokens.length; t++){
+ if (imageUrl.toLowerCase().indexOf(tokens[t]) == -1) {
+ validImage = false;
+ break;
+ }
+ }
+ if (validImage)
+ images.push(imageUrl);
}
}
if (images.length == 0) {
@@ -83,13 +90,21 @@
}
}
+ var tokens = []
+
function doSearch(){
- term = jQuery("#search-query").val().trim()
- if (term.length < 3) {
+ term = jQuery("#search-query").val().trim().toLowerCase()
+ var rawTokens = term.split(" ")
+ tokens = []
+ for(var t = 0; t < rawTokens.length; t++) {
+ if (rawTokens[t].length > 2)
+ tokens.push(rawTokens[t])
+ }
+ if (tokens.length == 0) {
setMessage("search query too small")
} else {
- setMessage("searching for '"+term+"'")
- addScript(term)
+ setMessage("searching for '"+tokens.join(" and ")+"'")
+ addScript(tokens.join("+"))
}
}