summaryrefslogtreecommitdiffstats
path: root/nfsw/static
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2019-09-28 15:34:54 -0400
committerrsiddharth <s@ricketyspace.net>2019-09-28 15:34:54 -0400
commitad5145fe3a4a52976fa965bfd4dc57f957d55161 (patch)
tree2991b73438d04f3b8d237f4a56ef04b2729bd2d0 /nfsw/static
parentc937710faeab03d09e754103bb84b69255949892 (diff)
nfsw/static/io.js: Add handling barf intro.
Diffstat (limited to 'nfsw/static')
-rw-r--r--nfsw/static/io.js61
1 files changed, 60 insertions, 1 deletions
diff --git a/nfsw/static/io.js b/nfsw/static/io.js
index f9f907d..c141903 100644
--- a/nfsw/static/io.js
+++ b/nfsw/static/io.js
@@ -4,7 +4,7 @@ document.addEventListener('DOMContentLoaded', function() {
*/
window.qip = false; // query in prograss flag.
function query(q) {
- if (window.qip) {
+ if (window.qip || window.iip) {
return window.setTimeout(query, 10, q);
}
window.qip = true;
@@ -56,6 +56,64 @@ document.addEventListener('DOMContentLoaded', function() {
xhr.send(q);
}
+ window.iip = false;
+ function intro() {
+ if (window.qip) {
+ return window.setTimeout(intro, 10);
+ }
+ window.iip = true;
+
+ var iipoff = function() {
+ window.iip = false;
+ };
+ var spit = function(response, status) {
+ var r;
+ try {
+ r = JSON.parse(response);
+ } catch (e) {
+ return barfslow('💥God is busy sodomizing the waitress.' +
+ '\nTry refreshing the page.', 'error', iipoff);
+ }
+
+ if (!('intro' in r)) {
+ return barfslow(
+ '💥Too bad Dr. Gonad Dick is ' +
+ '\ntoo busy whipping his eggplant.' +
+ '\nTry refreshing the page.',
+ 'error',
+ iipoff
+ );
+ }
+
+ if (status == 200) {
+ barfslow(r.intro, 'concierge', iipoff);
+ } else {
+ barfslow(r.intro, 'error', iipoff);
+ }
+ };
+
+ var xhr = new XMLHttpRequest();
+ xhr.open('POST', '/io/intro', true);
+
+ xhr.onreadystatechange = function() {
+ if (this.readyState != 4) {
+ return;
+ }
+
+ if ([200, 500].indexOf(this.status) >= 0) {
+ return spit(this.responseText, this.status);
+ } else {
+ return barfslow(
+ '💥God just fucked a skunk.' +
+ '\nTry refreshing the page.',
+ 'error',
+ iipoff
+ );
+ }
+ };
+ xhr.send();
+ }
+
/**
* Handling for console.
*/
@@ -143,4 +201,5 @@ document.addEventListener('DOMContentLoaded', function() {
var form = document.querySelector('form');
form.onsubmit = submit;
+ intro();
});