diff options
| author | tim b <timb@camcompu.home> | 2010-07-17 00:03:19 -0700 |
|---|---|---|
| committer | tim b <timb@camcompu.home> | 2010-07-17 00:03:19 -0700 |
| commit | c1fc8bcf052c2c7e9d912c4af0f3c33f345ac64d (patch) | |
| tree | 837dbf8cf2bf22c583362d102e2a01cfef1633e8 /template | |
| parent | b411efc9142bcf874cb93cdc4436fafa36f92d79 (diff) | |
better search
Diffstat (limited to 'template')
| -rw-r--r-- | template/banner.st | 38 | ||||
| -rw-r--r-- | template/google_analytics.st | 2 | ||||
| -rw-r--r-- | template/head.st | 20 | ||||
| -rw-r--r-- | template/search_script.st | 98 |
4 files changed, 19 insertions, 139 deletions
diff --git a/template/banner.st b/template/banner.st index 9630bd2..d9ff644 100644 --- a/template/banner.st +++ b/template/banner.st @@ -35,45 +35,43 @@ </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> + <input type="text" name="search-query" id="search-query" /> + <!--<div class="search_icon"></div>--> </div> - $endif$ <div id="topic"></div> <div id="dumplist"> - $if(user_nick)$ +$if(user_nick)$ want a room? <a href="mailto:info@dump.fm">contact us! - <a href="$domain$/chat/vortex"> checkout the image vortex!! </a>$else$ Talk with pictures! - <a href="$domain$/chat/vortex"> checkout the nifty dump fm image vortex! </a> $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> -<a href="http://vip.dump.fm/"> NAUGHTY BOYS DELIGHT </a> - $endif$ +$endif$ </div> - $if(user_nick)$ +$if(user_nick)$ <div id="logout7" class="white"> <div align="center"> <a href="/logout" onclick="pageTracker._trackEvent('button', 'logout'); return true;">Logout</a> </div> - $else$ + </div> +$else$ <div id="toplogin" class="white"> - $form_login()$ + $form_login()$ + </div> +$endif$ + <div id="search-results"> + <div id="search-controls"> + <a id="search-control-previous">previous</a> + <span id="search-control-text"></span> + <a id="search-control-next">next</a> + <a id="search-control-close" href="javascript:Search.close()">close</a> + </div> + <div id="search-results-images"></div> </div> - $endif$ - <div id="searchresults"></div> </div> <div align="center"><br /></div> </div> </div> -$if(isadmin)$ -<script> - $search_script()$ -</script> -$endif$ <div class="apple_overlay black" id="overlay"> <center> diff --git a/template/google_analytics.st b/template/google_analytics.st index 4d81b8b..48cda8b 100644 --- a/template/google_analytics.st +++ b/template/google_analytics.st @@ -13,4 +13,4 @@ qacct:"p-a3mCwIEHECjGE" <script type="text/javascript" src="http://edge.quantserve.com/quant.js"></script> <noscript> <img src="http://pixel.quantserve.com/pixel/p-a3mCwIEHECjGE.gif" style="display: none;" border="0" height="1" width="1" alt="Quantcast"/> -</noscript> +</noscript>
\ No newline at end of file diff --git a/template/head.st b/template/head.st index 7ff5828..a898df8 100644 --- a/template/head.st +++ b/template/head.st @@ -3,26 +3,6 @@ <meta name="description" content="dump.fm - Talk with pictures!" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="$domain$/static/js/jquery-ui-1.8.effects.min.js"></script> -<!-- <script src="http://cdn.jquerytools.org/1.1.2/full/jquery.tools.min.js"></script> --> - -<script> -/* -jQuery(function() { - jQuery("a[rel]").overlay({ - expose: '#eee', - effect: 'apple', - onBeforeLoad: function() { - var wrap = this.getContent().find(".contentWrap"); - wrap.load(this.getTrigger().attr("href")); - } - - }); -}); -jQuery(function() { - jQuery("#triggers img[rel]").overlay({effect: 'apple'}); -}); -*/ -</script> <script type="text/javascript" src="$domain$/static/js/pichat.js"></script> <link rel="stylesheet" type="text/css" href="$domain$/static/css/dump.css"> diff --git a/template/search_script.st b/template/search_script.st deleted file mode 100644 index 94461b3..0000000 --- a/template/search_script.st +++ /dev/null @@ -1,98 +0,0 @@ -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)
\ No newline at end of file |
