Created
March 17, 2012 09:36
-
-
Save ilkerde/2057075 to your computer and use it in GitHub Desktop.
A spike on jsh...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jLog = (function($){ | |
var log = { | |
info: function(s){ | |
s = s || ""; | |
this.isReady && this.write(s); | |
this.isReady || this.messageQueue.push(s); | |
return true; | |
}, | |
log: function(s){ | |
s = s || ""; | |
this.isReady && this.write(s); | |
this.isReady || this.messageQueue.push(s); | |
return true; | |
}, | |
addFilter: function(id, condition){ | |
this.filters = this.filters || {}; | |
this.filters[id] = condition; | |
}, | |
removeFilter: function(id){ | |
this.filters = this.filters || {}; | |
delete this.filters[id]; | |
}, | |
toggleConsole: function(){ | |
$("#_j_").slideToggle('fast'); | |
}, | |
boot: function(){ | |
this.isReady = true; | |
for(var index in this.messageQueue) | |
this.log(this.messageQueue[index]); | |
this.messageQueue = []; | |
}, | |
write: function(s){ | |
this.filters = this.filters || {}; | |
var doWrite = true; | |
for (var id in this.filters) | |
doWrite = doWrite && this.filters[id](s); | |
doWrite && $("#_j_ ._sh_").prepend('> ' + s + ' '); | |
}, | |
isReady:false, | |
messageQueue:[], | |
filters:[] | |
}; | |
$(function(){ | |
$("body").append(""); | |
var o=$('#ca')[0]; | |
var c=o.getContext('2d'); | |
var x,y,mp=2*Math.PI,m=[ | |
// 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], //01 | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], //02 | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,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,0,0,0,0,0], //38 | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], //39 | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], //40 | |
]; | |
var dp=function(x,y,r,co,a,rx,ry) { | |
if(m[ry][rx]==1) { | |
c.beginPath(); | |
c.arc(x,y,r,0,mp,true); | |
c.globalAlpha=a; | |
c.lineWidth=1; | |
c.fillStyle=co; | |
c.fill(); | |
c.closePath(); | |
} | |
}; | |
for(y=0;y<40;y++) { | |
for(x=0;x<40;x++) { | |
if(x<39) dp(x,y,0.7,'#a0a0ff',0.1,x+1,y); | |
dp(x,y,1,'#707080',0.1,x,y); | |
if(x>0) | |
dp(x-1,y,1,'#101020',0.1,x-1,y); | |
} | |
} | |
$("body").append(" "); | |
$("#_j_").css({ | |
'position': 'absolute', | |
'display': 'none', | |
'width': '100%', | |
'height': '300px', | |
'left': '0px', | |
'top': '0px', | |
'margin': '0px', | |
'padding': '0px', | |
'border-bottom': '1px solid #777', | |
'font-family': 'monospace', | |
'font-size': '10pt', | |
'color': '#ccc', | |
'background-color': '#333', | |
'opacity': '0.9', | |
'z-index': '1000', | |
'overflow': 'auto', | |
'overflow-x': 'hidden', | |
'overflow-y': 'scroll', | |
'background-image': 'url(' + o.toDataURL() + ')' | |
}); | |
$("#_j_ ._sh_").css({ | |
'margin': '2px 2px 2px 10px' | |
}); | |
log.boot(); | |
}); | |
return log; | |
})(jQuery); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment