summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xstatic/css/dump.css40
-rw-r--r--static/js/pichat.js834
-rw-r--r--template/banner.st10
-rw-r--r--template/head.st2
-rw-r--r--template/messagepane.st10
-rw-r--r--template/search_files.st132
6 files changed, 533 insertions, 495 deletions
diff --git a/static/css/dump.css b/static/css/dump.css
index a68bd0c..d215674 100755
--- a/static/css/dump.css
+++ b/static/css/dump.css
@@ -473,8 +473,8 @@ a.msg-image-zoom img.zoom-icon:hover {
/*searchstuff*/
#searchbox{
position:absolute;
- top:18px;
- right:100px;
+ top:20px;
+ right:80px;
}
#search-query{
@@ -484,7 +484,6 @@ a.msg-image-zoom img.zoom-icon:hover {
font-size: 13px;
padding: 3px 12px 3px 37px;
padding-left: 10px;
- ztext-indent:5px;
border-radius: 8px;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
@@ -502,24 +501,26 @@ a.msg-image-zoom img.zoom-icon:hover {
top:3px;
width:32px;
}
-#search-results{
+#inpage-search-results{
position: absolute;
- top:55px;
+ top:50px;
width:100%;
text-align: center;
left: 0;
z-index: 1000;
}
-#search-results-images{
+#inpage-search-results #search-results-images{
display: none;
+ position:relative;
overflow:auto;
background-image:url(/static/img/bg.dither.gif);
background-color:#eee;
width:95%;
+ height: 500px;
margin-left: auto;
margin-right: auto;
- margin-top: -22px;
+ margin-top: 0px;
padding-top: 30px;
-moz-box-shadow: 0 0 10px #D8DBDE, 0 0 2px #000000;
-webkit-box-shadow: 0 0 10px #D8DBDE, 0 0 2px #000000;
@@ -528,25 +529,22 @@ a.msg-image-zoom img.zoom-icon:hover {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
}
-#search-results-images img{
- max-width:300px;
- max-height:100px;
- border:1px solid #eee;
- float:right;
- display:inline;
- margin-right:10px;
-}
+#fullpage-search-results #search-results-images { position: relative; width: 100%; overflow: visible; }
+
+#search-results-images a.animating canvas { display: none }
+
#search-controls {
width: 95%;
margin-left: auto;
margin-right: auto;
- position: relative;
+ position: absolute;
+ z-index: 1005;
text-align: right;
display: none;
top: 0;
padding-right: 8px;
}
-#search-control-text {
+#search-message {
font-size: medium;
padding: 4px;
}
@@ -559,14 +557,6 @@ a.msg-image-zoom img.zoom-icon:hover {
-moz-border-radius: 8px;
padding: 4px;
}
-#search-message {
- display: inline;
- font-size: medium;
-}
-#search-control-previous, #search-control-next {
- visibility: hidden;
-}
-
/* pichat.css */
diff --git a/static/js/pichat.js b/static/js/pichat.js
index 0ee71bc..7734aa7 100644
--- a/static/js/pichat.js
+++ b/static/js/pichat.js
@@ -33,6 +33,12 @@ Anim = {
// Utils
+EmptyFunction = function(){};
+
+isImgBroken = function(img){
+ return (img.height == 0 || img.width == 0 || img.height == NaN || img.width == NaN)
+}
+
isEmptyObject = function(obj) {
for (key in obj) {
if (obj.hasOwnProperty(key)) return false;
@@ -132,6 +138,7 @@ function linkify(text) {
return text
}
+// use this in escapeHtml to turn everyone's text lIkE tHiS
function annoyingCaps(text){
var chunks = text.split(" ")
for(var i=0; i<chunks.length; i++){
@@ -577,7 +584,7 @@ function paletteClicked(){
function initChat() {
- Search.init()
+ Search.initInpage()
$('.oldmsg').each(function() {
var dump = $(this);
@@ -662,7 +669,7 @@ function enableProfileEdit() {
}
function initProfile() {
- Search.init()
+ Search.initInpage()
$(".linkify").each(function() {
var text = jQuery(this).text();
jQuery(this).html(linkifyWithoutImage(text));
@@ -678,7 +685,7 @@ function initProfile() {
};
function initLog() {
- Search.init()
+ Search.initInpage()
$('.logged-dump .content').each(function() {
var t = $(this);
t.html(buildMsgContent(t.text()));
@@ -877,140 +884,6 @@ function setupUploadAvatar(elementId) {
}
-/*
- search adds a script to the page... the script will call either Search.searchResult() or Search.searchError()
- todo: clean this up. remove duplicated function names etc
-*/
-
-var Search = {
-
- 'term': "",
- 'imagesPerPage': 25,
- 'images': [],
- 'tokens': [],
-
- 'init': function(){
- $("#search-query").val("search dump.fm")
- $("#search-query").focus(function(){
- if ($("#search-query").val() == 'search dump.fm')
- $("#search-query").val("")
- })
- $("#search-query").blur(function(){
- if ($("#search-query").val().trim() == '')
- $("#search-query").val("search dump.fm")
- })
- $("#search-query").keydown(ifEnter(Search.doSearch))
- $("#search-results-images a").live("mouseup", Search.click)
- },
-
- 'addScript': function(term) {
- $("#search-script").remove()
- $("head").append("<scr"+"ipt src='/cmd/ghettosearch/"+term+"' id='search-script'></sc"+"ript>")
- },
- 'setContent': function(x){
- $("#search-results-images").html(x)
- },
- 'setMessage': function(x){
- $("#search-controls").css("display", "block")
- $("#search-control-text").html(x)
- },
- 'searchError': function(error){
- Search.setContent("")
- $('#search-control-previous').css("visibility", "hidden")
- $('#search-control-next').css("visibility", "hidden")
- Search.setMessage(error)
- },
-
- 'doSearch': function(){
- term = $("#search-query").val().trim().toLowerCase()
- var rawTokens = term.split(" ")
- Search.tokens = []
- for(var t = 0; t < rawTokens.length; t++) {
- if (rawTokens[t].length > 2)
- Search.tokens.push(rawTokens[t])
- }
- if (Search.tokens.length == 0) {
- Search.setMessage("search query too small")
- } else {
- Search.setMessage("searching for '"+Search.tokens.join(" and ")+"'")
- Search.addScript(Search.tokens.join("+"))
- }
- },
-
- 'renderPage': function(num){
- $("#search-results-images").css("display", "block")
- $("#search-controls").css("display", "block")
- if (Search.images.length > 0)
- Search.setMessage("results for '"+Search.tokens.join(" and ")+"' (page " + (num + 1) + ")");
- var contentString = ''
- var start = num * Search.imagesPerPage
- var imageCounter = 0
- for(var i = start; i < Search.images.length; i++){
- if(imageCounter > Search.imagesPerPage) break;
- contentString += '<a href="'+Search.images[i]+'" target="_blank" onclick="return false"><img src="'+Search.images[i]+'"></a>'
- imageCounter += 1
- }
- contentString += '<br><br><div id="search-commands">'
- if(num > 0) {
- $('#search-control-previous').attr("href", 'javascript:Search.renderPage('+(num-1)+')')
- $('#search-control-previous').css("visibility", "visible")
- } else {
- $('#search-control-previous').attr("href", 'javascript:void()')
- $('#search-control-previous').css("visibility", "hidden")
- }
-
- if (Search.images.length > start + imageCounter) {
- $('#search-control-next').attr("href", 'javascript:Search.renderPage('+(num+1)+')')
- $('#search-control-next').css("visibility", "visible")
- } else {
- $('#search-control-next').attr("href", 'javascript:void()')
- $('#search-control-next').css("visibility", "hidden")
- }
- Search.setContent(contentString)
- },
-
- 'click': function(e){
- if (e.which == 1) // left click
- if (Search.addToChatBoxIfPossible(this))
- window.open(this.href)
- else if (e.which == 2) // middle click
- window.open(this.href)
- },
-
- 'addToChatBoxIfPossible': function(img){
- var chatBoxExists = $("#msgInput").length
- if (chatBoxExists) {
- var chatText = $("#msgInput").val()
- if (chatText.length && chatText[chatText.length - 1] != " ")
- chatText += " "
- chatText += $(img).attr("href") + " "
- $("#msgInput").val(chatText)
- $("#msgInput").focus().val($("#msgInput").val()) //http://stackoverflow.com/questions/1056359/
- return false
- } else return true
- },
-
- 'searchResult': function(results){
- Search.images = []
- if(results === null || results.length == 0) {
- Search.setContent("")
- Search.setMessage("no results found")
- } else {
- for(var r = 0; r<results.length; r++)
- Search.images.push(results[r].url)
- Search.renderPage(0)
- }
- },
- 'close': function(){
- Search.setContent("")
- $('#search-control-previous').css("visibility", "hidden")
- $('#search-control-next').css("visibility", "hidden")
- $("#search-results-images").css("display", "none")
- $("#search-controls").css("display", "none")
- }
-
-
-}
// scrolling stuff
@@ -1062,7 +935,7 @@ function initDirectory() {
var t = $(this);
t.html(buildMsgContent(t.text()));
});
- Search.init()
+ Search.initInpage()
initLogThumb('.dlogged-dump .thumb', '.dlogged-dump');
}
@@ -1215,6 +1088,410 @@ Tag = {
}
}
+/*
+ timb:
+ the ImgCache manages loading images and keeping track of image sizes...
+ it can be passed a bunch of urls to load and a callback that gets called when more images are ready
+ image loading can also be paused and started again.
+ there can be separate ImageCaches, eg, one for search result images, one for chat images (but they all share the actual image cache)
+ In theory it should also avoid a few http requests bc we can just dup DOM nodes for images that are already loaded that don't have cache headers (not sure tho, browsers probably pretty aggressive with that already)
+*/
+
+var ImgCache = {
+ "imgs": {}, // <img> nodes indexed by url
+ "caches": {},
+
+ "init": function(name){
+ // don't clear callback
+ var callback = EmptyFunction
+ if (name in ImgCache.caches)
+ callback = ImgCache.caches[name].onImgsLoaded
+ delete ImgCache.caches[name]
+
+ ImgCache.caches[name] = {
+ "loadAtATime": 10,
+ "urlsToLoad": [],
+ "imgsLoading": {},
+ "imgsLoadingCounter" : 0, // a hack so i don't have to iterate over the object to always get its size...
+ "imgsLoaded": {},
+ "onImgsLoaded": callback,
+ "paused": false
+ }
+ },
+
+ "add": function(name, urls){
+ if (!(name in ImgCache.caches)) ImgCache.init(name)
+ if (!$.isArray(urls)) urls = [urls];
+
+ var cache = ImgCache.caches[name]
+
+ urls.forEach(function(url){
+ cache.urlsToLoad.push(url)
+ })
+
+ },
+
+ "config": function(name, cfg){
+ if (!(name in ImgCache.caches)) ImgCache.init(name)
+ var cache = ImgCache.caches[name]
+ for(var key in cfg)
+ cache[key] = cfg[key]
+ },
+
+ "clear": function(name){
+ ImgCache.init(name)
+ },
+
+ "loadImages": function(cache){
+ if (cache.paused) return;
+
+ while(cache.urlsToLoad.length && cache.imgsLoadingCounter < cache.loadAtATime) {
+ var url = cache.urlsToLoad.shift()
+ if (url in ImgCache.imgs) { // already loading this image
+ var img = ImgCache.imgs[url]
+ if (img.complete) {
+ cache.imgsLoaded[url] = ImgCache.imgs[url]
+ } else if (!(url in cache.imgsLoading)) {
+ cache.imgsLoading[url] = ImgCache.imgs[url]
+ cache.imgsLoadingCounter += 1
+ }
+ } else {
+ var img = new Image()
+ img.src = url
+ img.animated = (parseUri(url)["file"].toLowerCase().substr(-3) == "gif") ? true : false;
+ ImgCache.imgs[url] = img
+ cache.imgsLoading[url] = img
+ cache.imgsLoadingCounter += 1
+ }
+ }
+ },
+ "processLoadingImages": function(cache){
+ for (var url in cache.imgsLoading) {
+ var img = cache.imgsLoading[url]
+ if (img.complete) {
+ cache.imgsLoaded[url] = img
+ delete cache.imgsLoading[url]
+ cache.imgsLoadingCounter -= 1
+ }
+ }
+ },
+
+ "loader": function(){
+ for (name in ImgCache.caches){
+ var cache = ImgCache.caches[name]
+ ImgCache.processLoadingImages(cache) // move images from imgsLoading into imgsLoaded
+ ImgCache.loadImages(cache) // put new images in imgsLoading/imgsLoaded from urlsToLoad
+ for (var url in cache.imgsLoaded) {
+ cache.onImgsLoaded(cache.imgsLoaded) // only call if new images actually loaded
+ delete cache.imgsLoaded
+ cache.imgsLoaded = {}
+ break;
+ }
+
+ }
+ setTimeout(ImgCache.loader, 500)
+ }
+}
+
+ImgCache.loader()
+
+
+var Search = {
+
+ 'term': "",
+ 'images': [],
+ 'tokens': [],
+ 'closed': true,
+
+ 'initFullpage': function(){
+ Search.init()
+ Search.initSpaceFill = Search.initSpaceFillFullpage
+ },
+
+ 'initInpage': function(){
+ Search.init()
+ Search.initSpaceFill = Search.initSpaceFillInpage
+ },
+
+ 'init': function(){
+ ImgCache.config("search", {"onImgsLoaded": Search.imgsLoaded})
+
+ $('#search-results-images a').live('hover', Search.resultsHover)
+
+ var input = Search.$input = $("#search-query")
+ var label = "search dump.fm"
+ Search.$container = $("#search-results-images")
+
+ input.val(label)
+ input.focus(function(){
+ if (input.val() == label) input.val("")
+ })
+ input.blur(function(){
+ if (input.val().trim() == '') input.val(label)
+ })
+ input.keydown(ifEnter(Search.doSearch))
+ $("#search-results-images a").live("mouseup", Search.click)
+ },
+
+ 'initSpaceFillFullpage': function() {
+ SpaceFill.init({
+ "container": "#search-results-images",
+ "width": $(document).width(),
+ "height": $(document).height(),
+ "type": "columns",
+ "spacing": "justify",
+ "minMargin": 16,
+ "columnWidth": 250
+ })
+ },
+
+ 'initSpaceFillInpage': function() {
+ SpaceFill.init({
+ "container": "#search-results-images",
+ "width": $(document).width() * 0.93,
+ "height": $(document).height(),
+ "type": "columns",
+ "spacing": "justify",
+ "minMargin": 16,
+ "columnWidth": 120
+ })
+ },
+
+ "resultsHover": function(e){
+ if (e.type == 'mouseover') {
+ var img = ImgCache.imgs[this.href]
+ if (img.animated) {
+ img.width = img.adjWidth
+ img.height = img.adjHeight
+ $(this).addClass("animating")
+ $(this).append(img)
+ }
+ } else {
+ var img = ImgCache.imgs[this.href]
+ if (img.animated) {
+ $(this).removeClass("animating")
+ this.removeChild(img)
+ }
+ }
+ },
+
+ "imgsLoaded": function(imgs){
+ //if (ColumnFill.isSpaceFilled()) return;
+
+ if (Search.closed) return;
+
+ if (Search.$container[0].style.display != "block") {
+ Search.$container.css("display", "block")
+ Search.setMessage("results for '"+Search.tokens.join(" and ")+"'")
+ }
+
+ for (var url in imgs){
+ var img = imgs[url]
+ if (isImgBroken(img)) continue;
+ var width = img.width
+ var height = img.height
+
+ if (width > SpaceFill.config.columnWidth) {
+ scaleFactor = SpaceFill.config.columnWidth / width
+ width = SpaceFill.config.columnWidth
+ height = Math.floor(height * scaleFactor)
+ }
+ img.adjWidth = width
+ img.adjHeight = height
+
+ var c = document.createElement("canvas")
+ c.width = width
+ c.height = height
+ var ctx = c.getContext('2d');
+ ctx.drawImage(img, 0, 0, c.width, c.height)
+
+ var a = document.createElement("a")
+ a.href = img.src
+ a.style.width = width + "px"
+ a.style.height = height + "px"
+
+ a.appendChild(c)
+
+ SpaceFill.add(a)
+ }
+ },
+
+ 'setContent': function(x){
+ $("#search-results-images").html(x)
+ },
+
+ 'setMessage': function(x){
+ $("#search-controls").css("display", "block")
+ $("#search-message").html(x)
+ },
+
+ 'searchError': function(error){
+ Search.setContent("")
+ Search.setMessage(error)
+ },
+
+ 'doSearch': function(){
+ Search.closed = false
+ term = $("#search-query").val().trim().toLowerCase()
+ var rawTokens = term.split(" ")
+ Search.tokens = []
+ rawTokens.forEach(function(t){ if (t.length > 2) Search.tokens.push(t) })
+ if (Search.tokens.length == 0) {
+ Search.setMessage("search query too small")
+ } else {
+ Search.setMessage("searching for '"+Search.tokens.join(" and ")+"'")
+ Search.doAjax(Search.tokens.join("+"))
+ }
+ },
+
+ 'doAjax': function(term) {
+ if (Domain == "http://dump.fm") {
+ $.ajax({
+ "url": "/cmd/search/" + term,
+ "success": Search.results,
+ "error": Search.error,
+ "timeout": 20000,
+ })
+ } else { // search main site via jsonp
+ $("#search-script").remove()
+ $("head").append("<s"+"cript src='http://dump.fm/cmd/ghettosearch/"+term+"?callback=Search.results' id='search-script'></s"+"cript>")
+ }
+ },
+
+ 'click': function(e){
+ if (e.which == 1) // left click
+ if (Search.addToChatBoxIfPossible(this))
+ window.open(this.href)
+ else if (e.which == 2) // middle click
+ window.open(this.href)
+ },
+
+ 'addToChatBoxIfPossible': function(img){
+ var chatBoxExists = $("#msgInput").length
+ if (chatBoxExists) {
+ var chatText = $("#msgInput").val()
+ if (chatText.length && chatText[chatText.length - 1] != " ")
+ chatText += " "
+ chatText += $(img).attr("href") + " "
+ $("#msgInput").val(chatText)
+ $("#msgInput").focus().val($("#msgInput").val()) //http://stackoverflow.com/questions/1056359/
+ return false
+ } else return true
+ },
+ // 'results'
+ 'searchResult': function(results){
+ Search.resultsClear()
+ if(results === null || results.length == 0) {
+ Search.setMessage("no results found")
+ } else {
+ Search.initSpaceFill()
+ var urls = []
+ results.forEach(function(r){ urls.push(r.url) })
+ ImgCache.add("search", urls)
+ }
+ },
+
+ 'resultsClear': function(){
+ $("#search-results-images").html("")
+ ImgCache.clear("search")
+ },
+
+ 'close': function(){
+ Search.resultsClear()
+ Search.closed = true
+ Search.$container.css("display", "none")
+ $("#search-controls").css("display", "none")
+ }
+
+}
+
+var ColumnFill = {
+ "init": function(){
+ var cfg = SpaceFill.config
+ var numColumns = ColumnFill.calcColumns()
+ ColumnFill.columns = []
+ for (var i = 0; i < numColumns; i++) {
+ ColumnFill.columns.push({"height": 0})
+ }
+
+ cfg.marginWidth = cfg.marginHeight = cfg.minMargin
+
+ if (cfg.spacing == "center") {
+ cfg.columnSpacingAmt = (cfg.width - (numColumns * (cfg.columnWidth + cfg.marginWidth) + cfg.marginWidth)) / 2
+ } else if (cfg.spacing == "justify") {
+ cfg.marginWidth = (cfg.width - (numColumns * cfg.columnWidth)) / (numColumns + 1)
+ }
+
+
+ },
+ "add": function(obj){
+ var cfg = SpaceFill.config
+ var colIndex = ColumnFill.shortestColumn()
+ var col = ColumnFill.columns[colIndex]
+
+ if (cfg.spacing == "center") {
+ var colLeft = colIndex * (cfg.marginWidth + cfg.columnWidth) + cfg.columnSpacingAmt
+ var imgLeft = Math.floor((cfg.marginWidth / 2) + (cfg.columnWidth / 2) - (parseInt(obj.style.width) / 2)) + colLeft + "px"
+ } else if (cfg.spacing == "justify") {
+ var colLeft = (colIndex * (cfg.marginWidth + cfg.columnWidth))
+ var imgLeft = Math.floor((cfg.marginWidth / 2) + (cfg.columnWidth / 2) - (parseInt(obj.style.width) / 2)) + colLeft + "px"
+ }
+
+ obj.style.position = 'absolute'
+ obj.style.top = col.height + cfg.marginHeight + "px"
+ obj.style.left = imgLeft
+
+ col.height += cfg.marginHeight + parseInt(obj.style.height)
+
+ $(cfg.container).append(obj)
+
+ },
+ "calcColumns": function(){
+ var cfg = SpaceFill.config
+ var numColumns = 0
+ var width = cfg.width - cfg.minMargin
+ var columnSub = cfg.columnWidth + cfg.minMargin
+ while (width > columnSub) {
+ width -= columnSub
+ numColumns++
+ }
+ return numColumns
+ },
+
+ "shortestColumn": function(){
+ var min = Infinity
+ var mindex = 0
+ for(var i = 0; i< ColumnFill.columns.length; i++){
+ var col = ColumnFill.columns[i]
+ if ( min > col.height) {
+ min = col.height
+ mindex = i
+ }
+ }
+ return mindex
+ },
+
+ "isSpaceFilled": function(){
+ var config = SpaceFill.config
+ var colIndex = ColumnFill.shortestColumn()
+ var col = ColumnFill.columns[colIndex]
+
+ if (col.height > 4 * config.height) return true;
+ else return false;
+ }
+
+}
+
+var SpaceFill = {
+ "init": function(config){
+ config.type = "columns"
+ SpaceFill.config = config
+
+ SpaceFill.types[config.type].init()
+ SpaceFill.add = SpaceFill.types[config.type].add
+ },
+ "types": { "columns": ColumnFill }
+}
// uhhh todo: move preload stuff into js:
// var nextImage = new Image();
@@ -1367,142 +1644,73 @@ function initChatMsgs() {
});
}
-// sha1.js
-/*
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
- * in FIPS 180-1
+/* SHA1.js (timb: compressed this)
* Version 2.2 Copyright Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
- * See http://pajhome.org.uk/crypt/md5 for details.
- */
-
-/*
- * Configurable variables. You may need to tweak these to be compatible with
- * the server-side, but the defaults work in most cases.
+ * from http://pajhome.org.uk/crypt/md5/sha1.html
*/
-var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
-var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
-
-/*
- * These are the functions you'll usually want to call
- * They take string arguments and return either hex or base-64 encoded strings
- */
-function hex_sha1(s) { return rstr2hex(rstr_sha1(str2rstr_utf8(s))); }
-function b64_sha1(s) { return rstr2b64(rstr_sha1(str2rstr_utf8(s))); }
-function any_sha1(s, e) { return rstr2any(rstr_sha1(str2rstr_utf8(s)), e); }
-function hex_hmac_sha1(k, d)
- { return rstr2hex(rstr_hmac_sha1(str2rstr_utf8(k), str2rstr_utf8(d))); }
-function b64_hmac_sha1(k, d)
- { return rstr2b64(rstr_hmac_sha1(str2rstr_utf8(k), str2rstr_utf8(d))); }
-function any_hmac_sha1(k, d, e)
- { return rstr2any(rstr_hmac_sha1(str2rstr_utf8(k), str2rstr_utf8(d)), e); }
-
-/*
- * Perform a simple self-test to see if the VM is working
- */
-function sha1_vm_test()
-{
- return hex_sha1("abc").toLowerCase() == "a9993e364706816aba3e25717850c26c9cd0d89d";
-}
-
-/*
- * Calculate the SHA1 of a raw string
- */
-function rstr_sha1(s)
-{
- return binb2rstr(binb_sha1(rstr2binb(s), s.length * 8));
-}
-
-/*
- * Calculate the HMAC-SHA1 of a key and some data (raw strings)
- */
-function rstr_hmac_sha1(key, data)
-{
- var bkey = rstr2binb(key);
- if(bkey.length > 16) bkey = binb_sha1(bkey, key.length * 8);
-
+var SHA1 = {
+"hexcase": 0,
+"b64pad": "",
+"hex": function(s) { return SHA1.rstr2hex(SHA1.rstr(SHA1.str2rstr_utf8(s))); },
+"b64": function(s) { return SHA1.rstr2b64(SHA1.rstr(SHA1.str2rstr_utf8(s))); },
+"any": function(s, e) { return SHA1.rstr2any(SHA1.rstr(SHA1.str2rstr_utf8(s)), e); },
+"hex_hmac": function(k, d){ return SHA1.rstr2hex(SHA1.rstr_hmac(SHA1.str2rstr_utf8(k), SHA1.str2rstr_utf8(d))); },
+"b64_hmac": function(k, d){ return SHA1.rstr2b64(SHA1.rstr_hmac(SHA1.str2rstr_utf8(k), SHA1.str2rstr_utf8(d))); },
+"any_hmac": function(k, d, e){ return SHA1.rstr2any(SHA1.rstr_hmac(SHA1.str2rstr_utf8(k), SHA1.str2rstr_utf8(d)), e); },
+"rstr": function(s) { return SHA1.binb2rstr(SHA1.binb(SHA1.rstr2binb(s), s.length * 8)); },
+"rstr_hmac": function(key, data){
+ var bkey = SHA1.rstr2binb(key);
+ if(bkey.length > 16) bkey = SHA1.binb(bkey, key.length * 8);
var ipad = Array(16), opad = Array(16);
- for(var i = 0; i < 16; i++)
- {
+ for(var i = 0; i < 16; i++){
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
-
- var hash = binb_sha1(ipad.concat(rstr2binb(data)), 512 + data.length * 8);
- return binb2rstr(binb_sha1(opad.concat(hash), 512 + 160));
-}
-
-/*
- * Convert a raw string to a hex string
- */
-function rstr2hex(input)
-{
- try { hexcase } catch(e) { hexcase=0; }
- var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
+ var hash = SHA1.binb(ipad.concat(SHA1.rstr2binb(data)), 512 + data.length * 8);
+ return SHA1.binb2rstr(SHA1.binb(opad.concat(hash), 512 + 160));
+},
+"rstr2hex": function(input){
+ try { SHA1.hexcase } catch(e) { SHA1.hexcase=0; }
+ var hex_tab = SHA1.hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var output = "";
var x;
- for(var i = 0; i < input.length; i++)
- {
+ for(var i = 0; i < input.length; i++){
x = input.charCodeAt(i);
output += hex_tab.charAt((x >>> 4) & 0x0F)
+ hex_tab.charAt( x & 0x0F);
}
return output;
-}
-
-/*
- * Convert a raw string to a base-64 string
- */
-function rstr2b64(input)
-{
- try { b64pad } catch(e) { b64pad=''; }
+},
+"rstr2b64": function(input){
+ try { SHA1.b64pad } catch(e) { SHA1.b64pad=''; }
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var output = "";
var len = input.length;
- for(var i = 0; i < len; i += 3)
- {
+ for(var i = 0; i < len; i += 3){
var triplet = (input.charCodeAt(i) << 16)
| (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
| (i + 2 < len ? input.charCodeAt(i+2) : 0);
- for(var j = 0; j < 4; j++)
- {
- if(i * 8 + j * 6 > input.length * 8) output += b64pad;
+ for(var j = 0; j < 4; j++){
+ if(i * 8 + j * 6 > input.length * 8) output += SHA1.b64pad;
else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
}
}
return output;
-}
-
-/*
- * Convert a raw string to an arbitrary string encoding
- */
-function rstr2any(input, encoding)
-{
+},
+"rstr2any": function(input, encoding){
var divisor = encoding.length;
var remainders = Array();
var i, q, x, quotient;
-
- /* Convert to an array of 16-bit big-endian values, forming the dividend */
var dividend = Array(Math.ceil(input.length / 2));
for(i = 0; i < dividend.length; i++)
- {
dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
- }
-
- /*
- * Repeatedly perform a long division. The binary array forms the dividend,
- * the length of the encoding is the divisor. Once computed, the quotient
- * forms the dividend for the next step. We stop when the dividend is zero.
- * All remainders are stored for later use.
- */
- while(dividend.length > 0)
- {
+ while(dividend.length > 0){
quotient = Array();
x = 0;
- for(i = 0; i < dividend.length; i++)
- {
+ for(i = 0; i < dividend.length; i++){
x = (x << 16) + dividend[i];
q = Math.floor(x / divisor);
x -= q * divisor;
@@ -1512,43 +1720,27 @@ function rstr2any(input, encoding)
remainders[remainders.length] = x;
dividend = quotient;
}
-
- /* Convert the remainders to the output string */
var output = "";
for(i = remainders.length - 1; i >= 0; i--)
output += encoding.charAt(remainders[i]);
-
- /* Append leading zero equivalents */
var full_length = Math.ceil(input.length * 8 /
(Math.log(encoding.length) / Math.log(2)))
for(i = output.length; i < full_length; i++)
output = encoding[0] + output;
return output;
-}
-
-/*
- * Encode a string as utf-8.
- * For efficiency, this assumes the input is valid utf-16.
- */
-function str2rstr_utf8(input)
-{
+},
+"str2rstr_utf8": function(input){
var output = "";
var i = -1;
var x, y;
-
- while(++i < input.length)
- {
- /* Decode utf-16 surrogate pairs */
+ while(++i < input.length){
x = input.charCodeAt(i);
y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
- if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
- {
+ if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF){
x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
i++;
}
-
- /* Encode output as utf-8 */
if(x <= 0x7F)
output += String.fromCharCode(x);
else if(x <= 0x7FF)
@@ -1565,137 +1757,83 @@ function str2rstr_utf8(input)
0x80 | ( x & 0x3F));
}
return output;
-}
-
-/*
- * Encode a string as utf-16
- */
-function str2rstr_utf16le(input)
-{
+},
+"str2rstr_utf16le": function(input){
var output = "";
for(var i = 0; i < input.length; i++)
output += String.fromCharCode( input.charCodeAt(i) & 0xFF,
(input.charCodeAt(i) >>> 8) & 0xFF);
return output;
-}
-
-function str2rstr_utf16be(input)
-{
+},
+"str2rstr_utf16be": function(input){
var output = "";
for(var i = 0; i < input.length; i++)
output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
input.charCodeAt(i) & 0xFF);
return output;
-}
-
-/*
- * Convert a raw string to an array of big-endian words
- * Characters >255 have their high-byte silently ignored.
- */
-function rstr2binb(input)
-{
+},
+"rstr2binb": function(input){
var output = Array(input.length >> 2);
for(var i = 0; i < output.length; i++)
output[i] = 0;
for(var i = 0; i < input.length * 8; i += 8)
output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32);
return output;
-}
-
-/*
- * Convert an array of big-endian words to a string
- */
-function binb2rstr(input)
-{
+},
+"binb2rstr": function(input){
var output = "";
for(var i = 0; i < input.length * 32; i += 8)
output += String.fromCharCode((input[i>>5] >>> (24 - i % 32)) & 0xFF);
return output;
-}
-
-/*
- * Calculate the SHA-1 of an array of big-endian words, and a bit length
- */
-function binb_sha1(x, len)
-{
- /* append padding */
+},
+"binb": function(x, len){
x[len >> 5] |= 0x80 << (24 - len % 32);
x[((len + 64 >> 9) << 4) + 15] = len;
-
var w = Array(80);
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
var e = -1009589776;
-
- for(var i = 0; i < x.length; i += 16)
- {
+ for(var i = 0; i < x.length; i += 16){
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
var olde = e;
-
- for(var j = 0; j < 80; j++)
- {
+ for(var j = 0; j < 80; j++){
if(j < 16) w[j] = x[i + j];
- else w[j] = bit_rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
- var t = safe_add(safe_add(bit_rol(a, 5), sha1_ft(j, b, c, d)),
- safe_add(safe_add(e, w[j]), sha1_kt(j)));
+ else w[j] = SHA1.bit_rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
+ var t = SHA1.safe_add(SHA1.safe_add(SHA1.bit_rol(a, 5), SHA1.ft(j, b, c, d)),
+ SHA1.safe_add(SHA1.safe_add(e, w[j]), SHA1.kt(j)));
e = d;
d = c;
- c = bit_rol(b, 30);
+ c = SHA1.bit_rol(b, 30);
b = a;
a = t;
}
-
- a = safe_add(a, olda);
- b = safe_add(b, oldb);
- c = safe_add(c, oldc);
- d = safe_add(d, oldd);
- e = safe_add(e, olde);
+ a = SHA1.safe_add(a, olda);
+ b = SHA1.safe_add(b, oldb);
+ c = SHA1.safe_add(c, oldc);
+ d = SHA1.safe_add(d, oldd);
+ e = SHA1.safe_add(e, olde);
}
return Array(a, b, c, d, e);
-
-}
-
-/*
- * Perform the appropriate triplet combination function for the current
- * iteration
- */
-function sha1_ft(t, b, c, d)
-{
+},
+"ft": function(t, b, c, d){
if(t < 20) return (b & c) | ((~b) & d);
if(t < 40) return b ^ c ^ d;
if(t < 60) return (b & c) | (b & d) | (c & d);
return b ^ c ^ d;
-}
-
-/*
- * Determine the appropriate additive constant for the current iteration
- */
-function sha1_kt(t)
-{
+},
+"kt": function(t){
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
- (t < 60) ? -1894007588 : -899497514;
-}
-
-/*
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
- * to work around bugs in some JS interpreters.
- */
-function safe_add(x, y)
-{
- var lsw = (x & 0xFFFF) + (y & 0xFFFF);
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
- return (msw << 16) | (lsw & 0xFFFF);
-}
-
-/*
- * Bitwise rotate a 32-bit number to the left.
- */
-function bit_rol(num, cnt)
-{
- return (num << cnt) | (num >>> (32 - cnt));
-}
+ (t < 60) ? -1894007588 : -899497514;
+},
+"safe_add": function(x, y){
+ var lsw = (x & 0xFFFF) + (y & 0xFFFF);
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+ return (msw << 16) | (lsw & 0xFFFF);
+},
+"bit_rol": function(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)) }
+} \ No newline at end of file
diff --git a/template/banner.st b/template/banner.st
index a4229f5..530555c 100644
--- a/template/banner.st
+++ b/template/banner.st
@@ -68,11 +68,11 @@
$if(user_nick)$
<!-- <div id="facebooklike">
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2Fdumpfm%2F240317626149%3Fref%3Dts&amp;layout=button_count&amp;show_faces=true&amp;width=100&amp;action=like&amp;font=segoe+ui&amp;colorscheme=dark&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
- </div> ---!>
+ </div> -->
<div id="searchbox">
- <input type="text" name="search-query" id="search-query" />
+ <input type="text" name="search-query" id="search-query" searchstyle="mini" />
<!--<div class="search_icon"></div>-->
</div>
$else$
@@ -109,11 +109,9 @@
- <div id="search-results" style="background-color: white;">
+ <div id="inpage-search-results" style="background-color: white;">
<div id="search-controls">
- <a id="search-control-previous">previous</a>
- <span id="search-control-text"></span>
- <a id="search-control-next">next</a>
+ <span id="search-message"></span>
<a id="search-control-close" href="javascript:Search.close()">close</a>
</div>
<div id="search-results-images"></div>
diff --git a/template/head.st b/template/head.st
index 4171858..ad23a44 100644
--- a/template/head.st
+++ b/template/head.st
@@ -5,7 +5,7 @@
<script type="text/javascript" src="$domain$/static/js/jquery-ui-1.8.effects.min.js"></script>
<script type="text/javascript" src="$domain$/static/js/pichat.js"></script>
<link rel="stylesheet" type="text/css" href="$domain$/static/css/dump.css">
-
+<script>Domain = "$domain$"</script>
$if(!user_nick)$
<link href="$domain$/static/form_login/front.css" media="screen, projection" rel="stylesheet" type="text/css">
diff --git a/template/messagepane.st b/template/messagepane.st
index 673c2ec..d5247f0 100644
--- a/template/messagepane.st
+++ b/template/messagepane.st
@@ -1,13 +1,14 @@
<div id="messagePane">
<style>
#chatbuttons {
- position: absolute;
- right: 25px;
- top: 0px;
+ font-size: 9px;
+ position: fixed;
+ right: 5px;
+ bottom: 0px;
}
#textbutton, #imgbutton, #clearbutton {
float: right;
- background: #CDF8FF;
+ background: #fff;
color: #666;
z-index: 0;
margin-left: 15px;
@@ -16,6 +17,7 @@
#clearbutton {
text-decoration: underline
cursor: pointer;
+ display: none;
}
</style>
<div id="chatbuttons">
diff --git a/template/search_files.st b/template/search_files.st
index 9759f07..4ef0118 100644
--- a/template/search_files.st
+++ b/template/search_files.st
@@ -1,121 +1,31 @@
+<!DOCTYPE html>
<html>
<head>
<title>dump.fm image search</title>
$head()$
<style>
- body{margin:6%;}
- img { max-width: 400px; max-height: 400px;}
- h1 { width: 40%; display:inline-block; margin: 20px; font-size: 30px;}
+ img { max-width: 400px; max-height: 400px;} /* FIX THIS */
+ html,body,img,div{margin:0; border:0; padding:0}
+ body { overflow: visible;}
+ h1 { display:inline-block; margin: 20px; font-size: 30px;}
+ fieldset { display: inline }
+ p { margin-left: 20px; display: inline-block; }
</style>
- </head>
- <body class="profile" style="margin:1%;">
-
+
+<script>
+
+jQuery(document).ready(Search.initFullpage)
+
+</script>
+</head>
+<body>
+
<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 id="footerc">
- $footer()$
- </div></div>
+ <center><div id="search-message"></div><br><br></center>
+ <div id="fullpage-search-results">
+ <div id="search-results-images"></div>
+ </div>
- </body>
-
- <script>
- var term = ""
- var imagesPerPage = 25;
- var images = []
-
- var Search = {};
-
- 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("#content").html(x)
- }
-
- function setMessage(x){
- jQuery("#message").html(x)
- }
-
- Search.searchError = function(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]+'"><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)
- }
-
- Search.searchResult = function(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("+"))
- }
- }
- jQuery("#search-query").keydown(ifEnter(doSearch))
-
- </script>
-
+</body>
</html>