Untitled Diff

Created Diff never expires
51 removals
266 lines
4 additions
221 lines
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html><head>
<head>
<meta charset="UTF-8">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Waking up ・゚✧</title>
<title>Draw, draw, draw!</title>
<noscript>
<meta http-equiv="refresh" content="1">
</noscript>
<style>
<style>
* {
* {
box-sizing: border-box;
box-sizing: border-box;
}
}


body {
body {
background-color: white;
background-color: white;
font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;
font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;
}
}


main {
main {
padding: 1rem;
padding: 1rem;
}
}


p {
p {
max-width: 500px
max-width: 500px
}
}


.note{
.note{
font-size: small;
font-size: small;
color: #9B9B9B;
color: #9B9B9B;
}
}


.content{
.content{
margin: 50px;
margin: 50px;
position: fixed;
position: fixed;
}
}


#loader:after {
#loader:after {
overflow: hidden;
overflow: hidden;
display: inline-block;
display: inline-block;
vertical-align: bottom;
vertical-align: bottom;
animation: ellipsis steps(4,end) 1000ms infinite;
animation: ellipsis steps(4,end) 1000ms infinite;
content: "\2026";
content: "\2026";
width: 0px;
width: 0px;
}
}


@keyframes ellipsis {
@keyframes ellipsis {
to {
to {
width: 1.25em
width: 1.25em
}
}
}
}


canvas#background {
canvas#background {
position: fixed;
position: fixed;
height: 100%;
height: 100%;
width: 100%;
width: 100%;
top: 0;
top: 0;
left: 0;
left: 0;
z-index: -1;
z-index: -1;
}
}
</style>
</style>
</head>
</head>


<body>
<body>
<main>
<canvas id="background" width="603" height="601">
<div class="content">
<p class="status">
<span id="message">Waking up</span>
<span id="loader" ></span>
</p>
<p class="note">
To keep Glitch fast for everyone, inactive projects go to sleep and wake up on request.
</p>
</div>
</main>
<canvas id="background"/>


<script src="https://cdnjs.cloudflare.com/ajax/libs/bowser/1.9.4/bowser.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bowser/1.9.4/bowser.min.js"></script>


<script>
<script>
// drawing
// drawing


var canvas, context, canvasImage;
var canvas, context, canvasImage;


var cursorPosition = {
var cursorPosition = {
x: undefined,
x: undefined,
y: undefined,
y: undefined,
};
};
var color = '#e5e5e5';
var color = '#e5e5e5';
var size = 30;
var size = 30;


function randomColor() {
function randomColor() {
var colors = [
var colors = [
'#fcd1c4',
'#fcd1c4',
'#abfcec',
'#abfcec',
'#a3d9e1',
'#a3d9e1',
'#fbbfff',
'#fbbfff',
'#a9ef8f',
'#a9ef8f',
'#fff0b2',
'#fff0b2',
'#fff0b2',
'#fff0b2',
];
];
color = colors[Math.floor(Math.random() * colors.length)];
color = colors[Math.floor(Math.random() * colors.length)];
}
}


function throttle(ms, fn) {
function throttle(ms, fn) {
var lastCallTime;
var lastCallTime;
return function () {
return function () {
var now = Date.now();
var now = Date.now();
if (!lastCallTime || now - lastCallTime > ms) {
if (!lastCallTime || now - lastCallTime > ms) {
lastCallTime = now;
lastCallTime = now;
fn.apply(this, arguments);
fn.apply(this, arguments);
}
}
}
}
}
}


function drawCircle(event) {
function drawCircle(event) {
context.beginPath();
context.beginPath();
context.arc(cursorPosition.x, cursorPosition.y, size, 0, 2 * Math.PI);
context.arc(cursorPosition.x, cursorPosition.y, size, 0, 2 * Math.PI);
context.closePath();
context.closePath();
context.fillStyle = color;
context.fillStyle = color;
context.fill();
context.fill();
canvasImage = context.getImageData(0, 0, window.innerWidth, window.innerHeight);
canvasImage = context.getImageData(0, 0, window.innerWidth, window.innerHeight);
}
}


window.onload = function () {
window.onload = function () {
randomColor();
randomColor();
canvas = document.getElementById('background');
canvas = document.getElementById('background');
canvas.width = window.innerWidth;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.height = window.innerHeight;
context = canvas.getContext('2d');
context = canvas.getContext('2d');


window.onresize = throttle(100, function () {
window.onresize = throttle(100, function () {
canvas.width = window.innerWidth;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.height = window.innerHeight;
context.clearRect(0,0, window.innerWidth, window.innerHeight);
context.clearRect(0,0, window.innerWidth, window.innerHeight);
canvasImage && context.putImageData(canvasImage, 0, 0);
canvasImage && context.putImageData(canvasImage, 0, 0);
});
});


window.onmousemove = throttle(10, function (event) {
window.onmousemove = throttle(10, function (event) {
cursorPosition = {
cursorPosition = {
x: event.clientX,
x: event.clientX,
y: event.clientY,
y: event.clientY,
};
};
drawCircle(event);
drawCircle(event);
});
});


window.ontouchmove = throttle(10, function (event) {
window.ontouchmove = throttle(10, function (event) {
cursorPosition = {
cursorPosition = {
x: event.touches[0].clientX,
x: event.touches[0].clientX,
y: event.touches[0].clientY,
y: event.touches[0].clientY,
};
};
drawCircle(event);
drawCircle(event);
});
});
}
}
</script>
</script>


<script>
<script>
// container status updates
setTimeout(function () {
function reloadAfterDelay(delay) {
delay = delay || 1000;
return setTimeout(function () {
window.location.reload(true);
}, delay);
}


// Either check that the container is ready and resolve with `true` or
// Either check that the container is ready and resolve with `true` or
// false (when enabled because we are expecting multiple "listening"
// false (when enabled because we are expecting multiple "listening"
// messages) or just resolve `true` (when we aren't).
// messages) or just resolve `true` (when we aren't).
function checkReady(enabled = false) {
function checkReady(enabled = false) {
if (enabled) {
if (enabled) {
return fetch('/.glitch/ready').then(function (response) {
return fetch('/.glitch/ready').then(function (response) {
return response.json();
return response.json();
});
});
} else {
} else {
return Promise.resolve(true);
return Promise.resolve(true);
}
}
}
}


try {
try {
var isValidBrowser = bowser.check({
var isValidBrowser = bowser.check({
ios: "7",
ios: "7",
msie: "10",
msie: "10",
android: "4.4",
android: "4.4",
chrome: "16",
chrome: "16",
firefox: "11",
firefox: "11",
});
});


if (!isValidBrowser) {
if (!isValidBrowser) {
throw new Error("Jump to refresh");
throw new Error("Jump to refresh");
}
}


var initialReloadHandler = reloadAfterDelay(5000);
var initialReloadHandler = reloadAfterDelay(5000);


var ws = new WebSocket("wss://" + document.location.hostname + "/___glitch_loading_status___");
var ws = new WebSocket("wss://" + document.location.hostname + "/___glitch_loading_status___");
ws.onmessage = updateContainerStatus;
ws.onmessage = updateContainerStatus;
ws.onerror = reloadAfterDelay;
ws.onerror = reloadAfterDelay;
ws.onopen = function () {
ws.onopen = function () {
clearTimeout(initialReloadHandler);
clearTimeout(initialReloadHandler);
setInterval(function () {
setInterval(function () {
ws.send("keepalive");
ws.send("keepalive");
}, 15000);
}, 15000);
};
};
ws.onclose = function () {
ws.onclose = function () {
reloadAfterDelay(1000);
reloadAfterDelay(1000);
};
};


function updateContainerStatus(event) {
function updateContainerStatus(event) {
try {
try {
// Interpolate into a string even though an unquoted `true` or `false`
// Interpolate into a string even though an unquoted `true` or `false`
// would be okay, just in case we get something weird.
// would be okay, just in case we get something weird.
var readyCheck = "false" === "true";
var readyCheck = "false" === "true";
var data = JSON.parse(event.data);
var data = JSON.parse(event.data);
var message = document.getElementById('message')
var message = document.getElementById('message')
var text = "";
var text = "";
switch (data.text) {
switch (data.text) {
case "initialize":
case "initialize":
text = "Waking up";
text = "Waking up";
break;
break;
case "install":
case "install":
text = "Preparing";
text = "Preparing";
break;
break;
case "restart":
case "restart":
text = "Starting";
text = "Starting";
break;
break;
case "listening":
case "listening":
// In cases of multiple "listening" messages, this might only
// In cases of multiple "listening" messages, this might only
// be the first one. We're going to rely on `checkReady` for
// be the first one. We're going to rely on `checkReady` for
// the final answer, so don't report "Ready" until that comes
// the final answer, so don't report "Ready" until that comes
// back `true`.
// back `true`.
text = readyCheck ? "Starting" : "Ready";
text = readyCheck ? "Starting" : "Ready";
break;
break;
default:
default:
return;
return;
}
}


message.innerHTML = text;
message.innerHTML = text;
document.title = text + " ・゚✧";
document.title = text + " ・゚✧";


if (data.text === 'listening') {
// Check that the container is ready before reloading in case
// of multiple things sending `listening` messages.
checkReady(readyCheck).then(function (ready) {
if (ready) {
// We may have already set this if `readyCheck` is `false`,
// but that's fine.
message.innerHTML = "Ready";
document.title = text + " ・゚✧";
window.location.reload(true);
}
}).catch((e) => {
reloadAfterDelay();
});
}
} catch (e) {
reloadAfterDelay();
}
}
} catch (e) {
reloadAfterDelay();
}
}, 0);
</script>
</script>
</body>
</html>


</canvas></body></html>