throw the tiny random site scripts in with the rest of app.js

and add JS-disabled and timeout messages... DOS style, of course.
This commit is contained in:
2020-06-08 00:45:21 -04:00
parent 66bf1faec3
commit 0442f9f413
3 changed files with 29 additions and 20 deletions

View File

@ -153,3 +153,23 @@ function TINF(){this.OK=0;this.DATA_ERROR=-3;this.WINDOW_SIZE=32768;this.TREE=fu
* Licensed under MPL 2.0 (see https://github.com/novnc/noVNC/blob/master/LICENSE.txt)
*/
window.Websock_native=!0;window.MozWebSocket&&(window.WebSocket=window.MozWebSocket);function Websock(){var api={},websocket=null,mode="base64",rQ=[],rQi=0,sQ=[],eventHandlers={message:function(){},open:function(){},close:function(){},error:function(){}},test_mode=!1;function get_sQ(){return sQ}function get_rQ(){return rQ}function get_rQi(){return rQi}function set_rQi(val){rQi=val}function rQlen(){return rQ.length-rQi}function rQpeek8(){return rQ[rQi]}function rQshift8(){return rQ[rQi++]}function rQunshift8(num){0===rQi?rQ.unshift(num):rQ[rQi-=1]=num}function rQshift16(){return(rQ[rQi++]<<8)+rQ[rQi++]}function rQshift32(){return(rQ[rQi++]<<24)+(rQ[rQi++]<<16)+(rQ[rQi++]<<8)+rQ[rQi++]}function rQshiftStr(len){void 0===len&&(len=rQlen());var arr=rQ.slice(rQi,rQi+len);rQi+=len;return String.fromCharCode.apply(null,arr)}function rQshiftBytes(len){void 0===len&&(len=rQlen());rQi+=len;return rQ.slice(rQi-len,rQi)}function rQslice(start,end){return end?rQ.slice(rQi+start,rQi+end):rQ.slice(rQi+start)}function rQwait(msg,num,goback){if(rQ.length-rQi<num){if(goback){if(rQi<goback)throw"rQwait cannot backup "+goback+" bytes";rQi-=goback}return!0}return!1}function flush(){websocket.bufferedAmount;if(websocket.bufferedAmount<api.maxBufferedAmount){if(sQ.length>0){websocket.send("binary"===mode?new Uint8Array(sQ).buffer:Base64.encode(sQ));sQ=[]}return!0}Util.Info("Delaying send, bufferedAmount: "+websocket.bufferedAmount);return!1}function send(arr){sQ=sQ.concat(arr);return flush()}function send_string(str){api.send(str.split("").map((function(chr){return chr.charCodeAt(0)})))}function recv_message(e){try{(function(data){if("binary"===mode)for(var u8=new Uint8Array(data),i=0;i<u8.length;i++)rQ.push(u8[i]);else rQ=rQ.concat(Base64.decode(data,0))})(e.data);if(rQlen()>0){eventHandlers.message();if(rQ.length>1e4){rQ=rQ.slice(rQi);rQi=0}}}catch(exc){void 0!==exc.stack?Util.Warn("recv_message, caught exception: "+exc.stack):void 0!==exc.description?Util.Warn("recv_message, caught exception: "+exc.description):Util.Warn("recv_message, caught exception:"+exc);void 0!==exc.name?eventHandlers.error(exc.name+": "+exc.message):eventHandlers.error(exc)}}function on(evt,handler){eventHandlers[evt]=handler}function init(protocols){rQ=[];rQi=0;sQ=[];websocket=null;"Uint8Array"in window&&Uint8Array.prototype;void 0===protocols&&(protocols=["binary","base64"]);return protocols}function open(uri,protocols){protocols=init(protocols);if(test_mode)websocket={};else{websocket=new WebSocket(uri,protocols);protocols.indexOf("binary")>=0&&(websocket.binaryType="arraybuffer")}websocket.onmessage=recv_message;websocket.onopen=function(){if(websocket.protocol){mode=websocket.protocol;Util.Info("Server chose sub-protocol: "+websocket.protocol)}else{mode="base64";Util.Error("Server select no sub-protocol!: "+websocket.protocol)}eventHandlers.open()};websocket.onclose=function(e){eventHandlers.close(e)};websocket.onerror=function(e){eventHandlers.error(e)}}function close(){if(websocket){if(websocket.readyState===WebSocket.OPEN||websocket.readyState===WebSocket.CONNECTING){Util.Info("Closing WebSocket connection");websocket.close()}websocket.onmessage=function(){}}}function testMode(override_send,data_mode){test_mode=!0;mode=data_mode;api.send=override_send;api.close=function(){};return recv_message}return function(){api.maxBufferedAmount=200;api.get_sQ=get_sQ;api.get_rQ=get_rQ;api.get_rQi=get_rQi;api.set_rQi=set_rQi;api.rQlen=rQlen;api.rQpeek8=rQpeek8;api.rQshift8=rQshift8;api.rQunshift8=rQunshift8;api.rQshift16=rQshift16;api.rQshift32=rQshift32;api.rQshiftStr=rQshiftStr;api.rQshiftBytes=rQshiftBytes;api.rQslice=rQslice;api.rQwait=rQwait;api.flush=flush;api.send=send;api.send_string=send_string;api.on=on;api.init=init;api.open=open;api.close=close;api.testMode=testMode;return api}()}var $D,WebUtil={};window.$D||(window.$D=function(id){return document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers?document.layers[id]:void 0});WebUtil.init_logging=function(level){Util._log_level=void 0!==level?level:(document.location.href.match(/logging=([A-Za-z0-9\._\-]*)/)||["",Util._log_level])[1];Util.init_logging()};
/*!
* Custom code for y2k.land, licensed under MIT:
* https://github.com/jakejarvis/y2k
*
* Keeping it somewhat readable until I automate minification.
*/
(function () {
var t = Math.floor(Math.random() * 20);
var s = document.getElementById("status");
document.body.style.backgroundImage = "url('tiles/tile_" + t + ".png')";
if (window.WebSocket) {
var display = document.getElementById("display");
var rfb = new RFB({ target: display, encrypt: true });
rfb.connect("sandbox.y2k.land", 443);
s.innerHTML = "Spinning up your very own personal computer, please wait!";
setTimeout(function () { s.innerHTML = "Oh dear, it looks like we're a little busy right now. :(<br><br>Please try again in a bit!"; }, 35000);
} else {
s.innerHTML = "WebSockets must be enabled to enter Y2K Land!!!<br><br>Press the Any key to continue.";
}
})();

View File

@ -11,7 +11,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Y2K Land — Powered by Windows Me 💾</title>
<title>Y2K Land — Powered by Windows Me 💾</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="My first website on a Windows Me-powered time machine. You've been warned.">
<link rel="stylesheet" href="style.css">
@ -19,26 +19,15 @@
<link rel="preconnect" href="https://sandbox.y2k.land">
<link rel="preconnect" href="https://collect.y2k.land">
<link rel="web-socket" href="wss://sandbox.y2k.land">
<script>window.sa_event=window.sa_event||function(){a=[].slice.call(arguments);sa_event.q?sa_event.q.push(a):sa_event.q=[a]};</script>
</head>
<body>
<div id="wait"><span id="message">Spinning up your very own personal computer, please wait!</span> <span class="blink">_</span></div>
<div id="cmd">
<span id="status">JavaScript is required for this experience, please enable it and refresh the page!<br><br>Press the Any key to continue.</span>
<span class="blink">_</span>
</div>
<canvas id="display"></canvas>
<a class="github" href="https://github.com/jakejarvis/y2k" title="View on GitHub" target="_blank" rel="noopener">
<svg viewBox="0 0 16 16" width="32" height="32"><path d="M8 0a8 8 0 00-2.5 15.6c.4 0 .5-.2.5-.4v-1.5c-2 .4-2.5-.5-2.7-1 0-.1-.5-.9-.8-1-.3-.2-.7-.6 0-.6.6 0 1 .6 1.2.8.7 1.2 1.9 1 2.4.7 0-.5.2-.9.5-1-1.8-.3-3.7-1-3.7-4 0-.9.3-1.6.8-2.2 0-.2-.3-1 .1-2 0 0 .7-.3 2.2.7a7.4 7.4 0 014 0c1.5-1 2.2-.8 2.2-.8.5 1.1.2 2 .1 2.1.5.6.8 1.3.8 2.2 0 3-1.9 3.7-3.6 4 .3.2.5.7.5 1.4v2.2c0 .2.1.5.5.4A8 8 0 0016 8a8 8 0 00-8-8z"/></svg>
</a>
<a class="github" href="https://github.com/jakejarvis/y2k" title="View on GitHub" target="_blank" rel="noopener"><svg viewBox="0 0 16 16" width="32" height="32"><path d="M8 0a8 8 0 00-2.5 15.6c.4 0 .5-.2.5-.4v-1.5c-2 .4-2.5-.5-2.7-1 0-.1-.5-.9-.8-1-.3-.2-.7-.6 0-.6.6 0 1 .6 1.2.8.7 1.2 1.9 1 2.4.7 0-.5.2-.9.5-1-1.8-.3-3.7-1-3.7-4 0-.9.3-1.6.8-2.2 0-.2-.3-1 .1-2 0 0 .7-.3 2.2.7a7.4 7.4 0 014 0c1.5-1 2.2-.8 2.2-.8.5 1.1.2 2 .1 2.1.5.6.8 1.3.8 2.2 0 3-1.9 3.7-3.6 4 .3.2.5.7.5 1.4v2.2c0 .2.1.5.5.4A8 8 0 0016 8a8 8 0 00-8-8z"/></svg></a>
<script src="app.js"></script>
<script>
var random_tile = Math.floor(Math.random() * 20);
document.body.style.backgroundImage = 'url("tiles/tile_' + random_tile + '.png")';
if (window.WebSocket) {
var display = document.getElementById("display");
var rfb = new RFB({ target: display, encrypt: true });
rfb.connect("sandbox.y2k.land", 443);
} else {
document.getElementById("message").innerHTML = "WebSockets must be enabled to enter Y2K Land!!!<br><br>Press the Any key to continue."
}
</script>
<script async defer src="https://collect.y2k.land/latest.js" data-skip-dnt="true"></script>
<noscript><img src="https://collect.y2k.land/noscript.gif" alt=""/></noscript>
</body>

View File

@ -17,7 +17,7 @@ body {
background-attachment: fixed;
background-position: center;
}
canvas, div#wait {
canvas, div#cmd {
display: block;
margin: auto;
position: absolute;
@ -26,12 +26,12 @@ canvas, div#wait {
left: 0;
right: 0;
}
div#wait {
div#cmd {
width: 600px;
height: 300px;
padding: 12px;
background-color: #000;
color: #ccc;
padding: 10px;
user-select: none;
z-index: -100;
}