Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html><head><meta charset="utf-8"><title>Firefox</title><style>body{font-size:small;font-family:Courier, monospace;text-align:center;background-color:#000;color:#000;}</style></head><body><div id="logo"></div><script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g=" crossorigin="anonymous"></script><script>var image=new Image();image.src='https://i.imgur.com/yaRQMnh.png';var text="<!DOCTYPE html>";document.title='fsociety';text+=document.getElementsByTagName('html')[0].innerHTML;text=text.replace(/\s*(\n\s*)+/ig,'').replace(/\s+(?= )/g,'').split("");var span=$('<span>',{'text':'.'});$('#logo').append(span);var span_width=span.width(),span_height=span.height();span.remove();image.crossOrigin='';image.onload=function(){var cnvs=document.createElement('canvas');cnvs.width=image.width;cnvs.height=image.height;$('body').append(cnvs);var ctx=cnvs.getContext('2d');ctx.drawImage(image,0,0);var per_box=Math.floor(((cnvs.width*cnvs.height)/text.length)),ratio=span_height/span_width,x_size=Math.sqrt(per_box/ratio),y_size=per_box/x_size,imageData;try{imageData=ctx.getImageData(0,0,cnvs.width,cnvs.height);}catch(e){return false;}getPoints(imageData);$(cnvs).remove();function getPoints(imagedata){var points=[],i=0,lastSeven='',title=false;for(var y=0;y<cnvs.height-1;y+=y_size){var total=0,row=$('<span>').css({'display':'block','height':span_height});for(var x=0;x<cnvs.width-1;x+=x_size){var color=getColor(imageData,x,y),character=text[i];if(character=="<")title=false;if(title)color="#ffffff";if(!color)color='#000';points.push([x,y]);character=text[i];i++;total++;$(row).append($("<span>",{'style':'color:'+color,'text':character}));lastSeven = (lastSeven + character).substr(-7);if(lastSeven=="<"+"title"+">")title=true;}$('#logo').append(row);}return points;}};function getColor(imageData,x,y) {var x=Math.round(x),y=Math.round(y),index=(y*imageData.width+x)*4,red=imageData.data[index],green=imageData.data[index+1],blue=imageData.data[index+2],alpha=imageData.data[index+3];for(var x2=-1;x2<=1;x2++){for(var y2=-1; y2<=1;y2++){if(!(x2==0&&y2==0)){var index_new=((y+y2)*imageData.width+x+x2)*4;imageData.data[index_new]=255;imageData.data[index_new+1]=255;imageData.data[index_new+2]=255;imageData.data[index_new+3]=alpha;}}}if(red==0&&green==0&&blue==0){return false;}return "rgb("+red+","+green+","+blue+");";}(function(){'use strict';var count=0;var win=false;var x='X';var o='O';var buttons=document.querySelectorAll('#tic button');if(buttons.length<1){return;} Array.prototype.forEach.call(buttons,function(button,i){button.addEventListener('click',function(){play(button);},false);});function turn(i){return(i%2)?x:o;} function play(button){if(count>8||win){return;} if(button.hasChildNodes()){return;} button.appendChild(document.createTextNode(turn(count)));button.classList.add('tic_'+turn(count));count++;check();} function check(){var i;for(i=0;i<9;i+=3){matches(buttons.item(i),buttons.item(i+1),buttons.item(i+2));} for(i=0;i<3;i+=1){matches(buttons.item(i),buttons.item(i+3),buttons.item(i+6));} matches(buttons.item(0),buttons.item(4),buttons.item(8));matches(buttons.item(2),buttons.item(4),buttons.item(6));if(count==9){end();return;}} function matches(first,second,third){if(first.textContent===''){return false;}else if(first.textContent===second.textContent&&second.textContent===third.textContent){end();first.classList.add('tic_win');window.setTimeout(function(){second.classList.add('tic_win');},50);window.setTimeout(function(){third.classList.add('tic_win');},100);return true;}else{return false;}} function end(){win=true;Array.prototype.forEach.call(buttons,function(button,i){button.setAttribute('disabled','disabled');});} function restart(){count=0;win=false;Array.prototype.forEach.call(buttons,function(button,i){button.className='';while(button.firstChild){button.removeChild(button.firstChild);} button.removeAttribute('disabled');});} var restart_button=document.getElementById('tic_restart');restart_button.addEventListener('click',function(){restart();},false);})();/* props gkoberger */</script></body>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers