summaryrefslogtreecommitdiff
path: root/template/banner.st
diff options
context:
space:
mode:
Diffstat (limited to 'template/banner.st')
-rw-r--r--template/banner.st119
1 files changed, 116 insertions, 3 deletions
diff --git a/template/banner.st b/template/banner.st
index ea7c826..8f8ffbe 100644
--- a/template/banner.st
+++ b/template/banner.st
@@ -48,10 +48,19 @@ a.img_roll:hover{
</div>
</div>
</div>
-
+$if(isadmin)$
+<div id="searchbox">
+<input type="text" name="search-query" id="search-query" value="search dump.fm"
+onblur="this.className = ''; resume_key_commands(); if (this.value == '') { this.value = default_search_text; this.style.color = '#c0c8d3'; }" onfocus="suspend_key_commands(); if (this.value == default_search_text) { this.value = ''; this.style.color = '#5c7480'; }" style="color: rgb(192, 200, 211);" class=""/>
+<a href=# onclick="hideItem(searchresults);"><div class="search_icon"></div></a>
+</div>
+$endif$
<div id="topic"></div>
- <div id="dumplist"> dump.fm - let pictures do the talking $if(user_nick)$<a href="http://bieber.dump.fm"> - justin bieber </a>$endif$ $if(isadmin)$
+ $if(user_nick)$
+ <div id="dumplist">
+
+ want a room in dump.fm? <a href="mailto:info@dump.fm">contact us!</a>$else$ let pictures do the talking $endif$ $if(isadmin)$
<a href="http://news.dump.fm">- news</a> - <a href="http://gossip.dump.fm">gossip</a> - <a href="http://art.dump.fm">art</a> - <a href="http://gif.dump.fm">gif</a> - <a href="http://design.dump.fm">design</a> - <a href="http://fashion.dump.fm">fashion</a>
@@ -61,10 +70,114 @@ a.img_roll:hover{
$if(user_nick)$
<div id="logout7" class="white">
<div align="center"> <a href="/logout"> Logout</a> </div>$else$ <div id="toplogin" class="white"> $form_login()$</div> $endif$
-
+<div id="searchresults"></div>
</div>
<div align="center"><br /></div>
</div>
</div>
+$if(isadmin)$
+ <script>
+ var term = ""
+ var imagesPerPage = 25;
+ var images = []
+
+ function addScript(term){
+ jQuery("#search-script").remove()
+ jQuery("head").append("<scr"+"ipt src='/cmd/ghettosearch/"+term+"' id='search-script'></sc"+"ript>")
+ }
+
+ function setContent(x){
+ jQuery("#searchresults").html(x)
+ }
+
+ function setMessage(x){
+ jQuery("#message").html(x)
+ }
+
+ function searchError(error){
+ setContent("")
+ setMessage(error)
+ }
+
+ function renderPage(num){
+ if (images.length > 0)
+ setMessage("page " + (num + 1));
+ var contentString = ''
+ var start = num * imagesPerPage
+ var imageCounter = 0
+ for(var i = start; i < images.length; i++){
+ if(imageCounter > imagesPerPage) break;
+ contentString += '<a href="'+images[i]+'"target="_blank"><img src="'+images[i]+'"></a>'
+ imageCounter += 1
+ }
+ contentString += '<br><br>'
+ if(num > 0)
+ contentString += '<a href="javascript:renderPage('+(num-1)+')"><h1>previous</h1></a> '
+ if (images.length > start + imageCounter)
+ contentString += ' <a href="javascript:renderPage('+(num+1)+')"><h1>next</h1></a>'
+ setContent(contentString)
+ }
+
+ function searchResult(results){
+ images = []
+ var alreadyGot = {}
+ if(results === null || results.length == 0) {
+ setContent("")
+ setMessage("no results found")
+ } else {
+ for(var r = 0; r<results.length; r++){
+ var content = results[r]['content']
+ if (content.substring(0,6) == "<safe>") continue; // skip html posts
+ var imageUrls = getImagesAsArray(content);
+ for (var i=0; i<imageUrls.length; i++){
+ var imageUrl = imageUrls[i];
+ if (imageUrl in alreadyGot) continue;
+ alreadyGot[imageUrl] = true
+ 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) {
+ setMessage("no results found")
+ }
+ renderPage(0)
+ }
+ }
+
+ var tokens = []
+
+ function doSearch(){
+ 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 '"+tokens.join(" and ")+"'")
+ addScript(tokens.join("+"))
+ }
+ }
+
+ // only search every 800ms while someone is typing
+ function keyHandler(){
+ if (keyHandler.timeout) clearTimeout(keyHandler.timeout);
+ keyHandler.timeout = setTimeout(doSearch, 800)
+ }
+
+ jQuery("#search-query").keyup(keyHandler)
+
+ </script>
+ $endif$ \ No newline at end of file