Added proxy to xml request

This commit is contained in:
Kenneth Jao 2017-09-30 22:06:56 -04:00
parent 58a74a95d4
commit 25f6826113

View File

@ -53,36 +53,14 @@ function generateFrames(frame, string, width, height, rate) {
} catch(err) {} } catch(err) {}
} }
return output; return output;
}
/*var currentBit = ((frame/30)*scrollRate)/width;
var shift = currentBit - Math.floor(currentBit);
for(var i = Math.floor(currentBit); i++; i<(bitsPerSection+(Math.floor(currentBit)+1))){
var xVal = ((i-Math.Math.floor(currentBit))-shift)*width;
var yVal = canvas.height/2
if(string[i-1]=== 1 && string[i]=== 1){
frame.push([xVal,yVal+100]);//Assuming height is 100px
frame.push([xVal+width,yVal+100]);
frame.push([xVal+width,yVal]);
}
else if(string[i]===1){
frame.push([xVal,yVal]);
frame.push([xVal,yVal+100]);
frame.push([xVal+width,yVal+100]);
frame.push([xVal+width,yVal]);
}
else {
frame.push([xVal,yVal]);
frame.push([xVal.width,yVal]);
}
}
return uniq(frame);*/
}
var string = toBinary(getWebsite("https://www.google.com")); var string = toBinary(getWebsite("https://www.google.com"));
function drawFrame(frame) { function drawFrame(frame) {
ctx.fillRect(0,0, canvas.width, canvas.height); ctx.fillRect(0,0, canvas.width, canvas.height);
ctx.beginPath(); ctx.beginPath();
var frame = generateFrames(frame, string, 100, 100, 10); var frame = generateFrames(frame, string, 100, 100, 10000000000000);
console.log(frame); console.log(frame);
ctx.moveTo(0, canvas.height/2); ctx.moveTo(0, canvas.height/2);
for(var i = 0; i < frame.length; i++) { for(var i = 0; i < frame.length; i++) {
@ -92,22 +70,25 @@ function drawFrame(frame) {
ctx.stroke(); ctx.stroke();
} }
function getWebsite(geturl) { function getWebsite(url) {
xmlhttp=new XMLHttpRequest(); var proxy = "https://cors-anywhere.herokuapp.com/";
xmlhttp.open("GET", geturl, false); var xhr = new XMLHttpRequest();
xmlhttp.send(); xhr.open("GET", proxy+url, false);
var data = xmlhttp.responseText; xhr.send();
return xhr.responseText;
}
function animate(n) {
if(!doAnimate) return;
drawFrame(n);
setTimeout(function() { animate(n+1) }, 100/3);
} }
ctx.fillStyle = "#000"; ctx.fillStyle = "#000";
ctx.fillRect(0,0, canvas.width, canvas.height); ctx.fillRect(0,0, canvas.width, canvas.height);
function animate(n) { var doAnimate = true;
if(!animate) return;
drawFrame(n);
setTimeout(function() { animate(n+1) }, 100/3);
}
animate(0); animate(0);
var animate = false;