From d7c088b5ec377fd85742fe4f661c790d5a0af059 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Wed, 26 Jun 2013 15:32:29 -0400 Subject: doooo stoooof --- www/css/index.css | 9 ++--- www/index.html | 10 +++--- www/js/api.js | 49 ++++++++++++--------------- www/js/html5ks.js | 65 ++++++++++++++++++++++++++---------- www/js/lib/modernizr.custom.44609.js | 4 +++ www/js/lib/modernizr.custom.71672.js | 4 --- www/js/play.js | 5 ++- 7 files changed, 85 insertions(+), 61 deletions(-) create mode 100644 www/js/lib/modernizr.custom.44609.js delete mode 100644 www/js/lib/modernizr.custom.71672.js (limited to 'www') diff --git a/www/css/index.css b/www/css/index.css index 9a96f3b..b1e1a78 100644 --- a/www/css/index.css +++ b/www/css/index.css @@ -15,11 +15,11 @@ body { margin: 0; padding: 0; - overflow: hidden; background: gray; font: 22px/27px Playtime, sans-serif; } #container { + cursor: url("/dump/ui/mousecursor.png"), auto; width: 800px; height: 600px; position: absolute; @@ -27,8 +27,6 @@ body { margin-top: -300px; left: 50%; margin-left: -400px; - overflow: hidden; - cursor: url("/dump/ui/mousecursor.png"), default; } @keyframes toright { from { @@ -79,6 +77,9 @@ body { visibility: hidden; cursor: auto; } +html.no-js #warn-container { + visibility: visible; +} #warn { background-color: rgb(128, 128, 128); background-color: rgba(128, 128, 128, 0.8); @@ -97,7 +98,7 @@ body { font: 28px/34px Playtime; font-weight: bold; } -html.js #warn li#js { display: none; } +html.no-js #warn li:not(#js) { display: none; } html.video #warn li#video { display: none; } html.audio #warn li#audio { display: none; } html.fontface #warn li#fontface { display: none; } diff --git a/www/index.html b/www/index.html index 824347d..62d790f 100644 --- a/www/index.html +++ b/www/index.html @@ -17,20 +17,20 @@ - + - +
We use a lot of new features in this; your browser seems to have some issues...
- +
- +
diff --git a/www/js/api.js b/www/js/api.js index 1738ddf..1171533 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -17,7 +17,7 @@ window.html5ks.api = { } else { audio.volume += step * dir; setTimeout(function () { - this.fading(audio, dir, fade); + html5ks.api.fading(audio, dir, fade); }, fadeSet); } }, @@ -34,7 +34,7 @@ window.html5ks.api = { audio.addEventListener("playing", function playing() { audio.removeEventListener("playing", playing, false); deferred.resolve(); - html5ks.fading(audio, 1, fade); + html5ks.api.fading(audio, 1, fade); }, false); audio.addEventListener("error", function error() { audio.removeEventListener("error", error, false); @@ -136,31 +136,26 @@ window.html5ks.api = { deferred.resolve(); return deferred.promise; }, - run: function (label) { - label.forEach(function (inst) { - var cmd = inst[0], - args = inst.slice(1); - switch (cmd) { - case "extend": - case "hide": - case "ksgallery_unlock": - case "nvl": - case "play": - case "scene": - case "set_volume": - case "show": - case "stop": - case "window": - html5ks.api[cmd].apply(html5ks, args); - break; - default: - if (html5ks.data.characters[cmd]) { - this.character(cmd, args); - } else { - console.error("instruction not implemented: %o", inst); - } - } - }); + with: function (transition, action) { + return this.runInst(action); + }, + runInst: function (inst) { + var cmd = inst[0], + args = inst.slice(1); + if (html5ks.data.characters[cmd]) { + return this.character(cmd, args); + } else { + console.log(arguments); + return this[cmd].apply(this, args); + } + }, + runScript: function (label) { + var i = 0; + (function run() { + console.log(label[i]); + html5ks.api.runInst(label[i]).then(run, console.error); + i++; + }()); }, character: function (name, str) { var deferred = when.defer(), diff --git a/www/js/html5ks.js b/www/js/html5ks.js index 4c87763..08b8e73 100644 --- a/www/js/html5ks.js +++ b/www/js/html5ks.js @@ -1,6 +1,9 @@ (function () { "use strict"; window.html5ks = { + data: { + scripts: {} + }, persistent: { seen_scenes: {}, attraction: { @@ -13,7 +16,8 @@ // ms per character autospeed: 20, fade: 100, - gotit: false + gotit: false, + scale: true } }, state: { @@ -46,22 +50,28 @@ localStorage.persistent = JSON.stringify(this.persistent); }, scale: function () { - var height = document.documentElement.clientHeight, - width = document.documentElement.clientWidth, - newScale = 1; - if (height / width <= 0.75) { // widescreen - newScale = height / 600; + var newScale = 1; + if (html5ks.persistent.settings.scale) { + var height = document.documentElement.clientHeight, + width = document.documentElement.clientWidth; + if (height / width <= 0.75) { // widescreen + newScale = height / 600; + } else { + newScale = width / 800; + } } else { - newScale = width / 800; + newScale = 1; } html5ks.elements.container.style.webkitTransform = "scale(" + newScale + ")"; html5ks.elements.container.style.mozTransform = "scale(" + newScale + ")"; html5ks.elements.container.style.transform = "scale(" + newScale + ")"; }, next: function () {}, - loadChars: function () { - for (var character in this.characters) { - } + initEvents: function () { + window.addEventListener("resize", html5ks.scale, false); + this.elements.container.addEventListener("mouseup", function () { + html5ks.next(); + }, false); }, warnUnsupported: function () { if (!html5ks.persistent.settings.gotit) { @@ -84,25 +94,44 @@ } } }, - initEvents: function () { - window.addEventListener("resize", html5ks.scale, false); - this.elements.container.addEventListener("mouseup", function () { - html5ks.next(); - }, false); - }, onload: function () { this.initElements(); - this.loadChars(); this.load(); this.scale(); this.initEvents(); this.warnUnsupported(); }, winload: function () { + this.fetch("script", "a1-monday").then(function () { + html5ks.api.runScript(html5ks.data.scripts["a1-monday"].en_NOP1) + }); this.elements.img.bg.src = ""; + }, + fetch: function (type, name) { + var deferred = when.defer(); + switch (type) { + case "script": + var scripts = html5ks.data.scripts; + if (typeof scripts[name] === "object") { + deferred.resolve(); + } else { + var xhr = new XMLHttpRequest(); + xhr.open("GET", "/scripts/script-" + name + ".json"); + xhr.onreadystatechange = function () { + if (xhr.readyState === 4) { + scripts[name] = JSON.parse(xhr.responseText); + deferred.resolve(); + } + }; + xhr.send(); + } + break; + default: + throw new Error("fetchtype " + type + " not implemented"); + } + return deferred.promise; } }; - window.html5ks.data = {}; document.addEventListener("DOMContentLoaded", function () { html5ks.onload(); }, false); diff --git a/www/js/lib/modernizr.custom.44609.js b/www/js/lib/modernizr.custom.44609.js new file mode 100644 index 0000000..01c9ed0 --- /dev/null +++ b/www/js/lib/modernizr.custom.44609.js @@ -0,0 +1,4 @@ +/* Modernizr 2.6.2 (Custom Build) | MIT & BSD + * Build: http://modernizr.com/download/#-fontface-csstransforms-csstransforms3d-csstransitions-canvas-audio-video-localstorage-inlinesvg-svg-svgclippaths-cssclasses-teststyles-testprop-testallprops-prefixes-domprefixes-img_webp-json-svg_filters + */ +;window.Modernizr=function(a,b,c){function A(a){j.cssText=a}function B(a,b){return A(m.join(a+";")+(b||""))}function C(a,b){return typeof a===b}function D(a,b){return!!~(""+a).indexOf(b)}function E(a,b){for(var d in a){var e=a[d];if(!D(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function F(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:C(f,"function")?f.bind(d||b):f}return!1}function G(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+o.join(d+" ")+d).split(" ");return C(b,"string")||C(b,"undefined")?E(e,b):(e=(a+" "+p.join(d+" ")+d).split(" "),F(e,b,c))}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m=" -webkit- -moz- -o- -ms- ".split(" "),n="Webkit Moz O ms",o=n.split(" "),p=n.toLowerCase().split(" "),q={svg:"http://www.w3.org/2000/svg"},r={},s={},t={},u=[],v=u.slice,w,x=function(a,c,d,e){var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);return f=["­",'"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},y={}.hasOwnProperty,z;!C(y,"undefined")&&!C(y.call,"undefined")?z=function(a,b){return y.call(a,b)}:z=function(a,b){return b in a&&C(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=v.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(v.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(v.call(arguments)))};return e}),r.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},r.csstransforms=function(){return!!G("transform")},r.csstransforms3d=function(){var a=!!G("perspective");return a&&"webkitPerspective"in g.style&&x("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},r.csstransitions=function(){return G("transition")},r.fontface=function(){var a;return x('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},r.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},r.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},r.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},r.svg=function(){return!!b.createElementNS&&!!b.createElementNS(q.svg,"svg").createSVGRect},r.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML="",(a.firstChild&&a.firstChild.namespaceURI)==q.svg},r.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(l.call(b.createElementNS(q.svg,"clipPath")))};for(var H in r)z(r,H)&&(w=H.toLowerCase(),e[w]=r[H](),u.push((e[w]?"":"no-")+w));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)z(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},A(""),i=k=null,e._version=d,e._prefixes=m,e._domPrefixes=p,e._cssomPrefixes=o,e.testProp=function(a){return E([a])},e.testAllProps=G,e.testStyles=x,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+u.join(" "):""),e}(this,this.document),function(){var a=new Image;a.onerror=function(){Modernizr.addTest("webp",!1)},a.onload=function(){Modernizr.addTest("webp",function(){return a.width==1})},a.src="data:image/webp;base64,UklGRiwAAABXRUJQVlA4ICAAAAAUAgCdASoBAAEAL/3+/3+CAB/AAAFzrNsAAP5QAAAAAA=="}(),Modernizr.addTest("json",!!window.JSON&&!!JSON.parse),Modernizr.addTest("svgfilters",function(){var a=!1;try{a=typeof SVGFEColorMatrixElement!==undefined&&SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_SATURATE==2}catch(b){}return a}); \ No newline at end of file diff --git a/www/js/lib/modernizr.custom.71672.js b/www/js/lib/modernizr.custom.71672.js deleted file mode 100644 index cef48ac..0000000 --- a/www/js/lib/modernizr.custom.71672.js +++ /dev/null @@ -1,4 +0,0 @@ -/* Modernizr 2.6.2 (Custom Build) | MIT & BSD - * Build: http://modernizr.com/download/#-fontface-borderradius-boxshadow-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-hashchange-history-audio-video-input-inputtypes-localstorage-inlinesvg-svg-svgclippaths-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load - */ -;window.Modernizr=function(a,b,c){function C(a){j.cssText=a}function D(a,b){return C(n.join(a+";")+(b||""))}function E(a,b){return typeof a===b}function F(a,b){return!!~(""+a).indexOf(b)}function G(a,b){for(var d in a){var e=a[d];if(!F(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function H(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:E(f,"function")?f.bind(d||b):f}return!1}function I(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return E(b,"string")||E(b,"undefined")?G(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),H(e,b,c))}function J(){e.input=function(c){for(var d=0,e=c.length;d',a,""].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},z=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=E(e[d],"function"),E(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),A={}.hasOwnProperty,B;!E(A,"undefined")&&!E(A.call,"undefined")?B=function(a,b){return A.call(a,b)}:B=function(a,b){return b in a&&E(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.hashchange=function(){return z("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.rgba=function(){return C("background-color:rgba(150,255,150,.5)"),F(j.backgroundColor,"rgba")},s.hsla=function(){return C("background-color:hsla(120,40%,100%,.5)"),F(j.backgroundColor,"rgba")||F(j.backgroundColor,"hsla")},s.multiplebgs=function(){return C("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.borderradius=function(){return I("borderRadius")},s.boxshadow=function(){return I("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return D("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return I("animationName")},s.csscolumns=function(){return I("columnCount")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return C((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),F(j.backgroundImage,"gradient")},s.cssreflections=function(){return I("boxReflect")},s.csstransforms=function(){return!!I("transform")},s.csstransforms3d=function(){var a=!!I("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return I("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(["#",h,"{font:0/0 a}#",h,':after{content:"',l,'";visibility:hidden;font:3px/1 a}'].join(""),function(b){a=b.offsetHeight>=3}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect},s.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML="",(a.firstChild&&a.firstChild.namespaceURI)==r.svg},s.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))};for(var K in s)B(s,K)&&(x=K.toLowerCase(),e[x]=s[K](),v.push((e[x]?"":"no-")+x));return e.input||J(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)B(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},C(""),i=k=null,e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.hasEvent=z,e.testProp=function(a){return G([a])},e.testAllProps=I,e.testStyles=y,e.prefixed=function(a,b,c){return b?I(a,b,c):I(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f