Skip to content

Instantly share code, notes, and snippets.

@unixcult
Forked from juliangruber/head.html
Created July 27, 2013 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unixcult/6096541 to your computer and use it in GitHub Desktop.
Save unixcult/6096541 to your computer and use it in GitHub Desktop.
requirebin sketch
<style type='text/css'> html, body { margin: 0; padding: 0; border: 0; } </style>
var Spinning = require('spinning');
var spinner = Spinning().text('loading...').light().size(200);
setTimeout(function () {
spinner.remove();
}, 3000);
require=function(t,e,n){function r(n,o){if(!e[n]){if(!t[n]){var s="function"==typeof require&&require;if(!o&&s)return s(n,!0);if(i)return i(n,!0);throw Error("Cannot find module '"+n+"'")}var a=e[n]={exports:{}};t[n][0].call(a.exports,function(e){var i=t[n][1][e];return r(i?i:e)},a,a.exports)}return e[n].exports}for(var i="function"==typeof require&&require,o=0;n.length>o;o++)r(n[o]);return r}({1:[function(t,e){e.exports=".spinner, .overlay {\n position: fixed;\n opacity: 0;\n}\n\n.spinner {\n left: 50%;\n top: 50%;\n margin-left: -100px;\n margin-top: -100px;\n z-index: 2222222222;\n}\n\n.overlay {\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: white;\n z-index: 1111111111;\n}\n"},{}],spinning:[function(t,e){e.exports=t("qLju5C")},{}],qLju5C:[function(t,e){(function(){function n(){i(o);var t=1e3,e=300,n=document.createElement("div");n.className="overlay",document.body.appendChild(n);var c=new r;c.el.className="spinner",document.body.appendChild(c.el),a.nextTick(function(){s(n,.8,t),s.in(c.el,t)}),c.remove=function(){s.out(n,e),s.out(c.el,e),setTimeout(function(){c.stop(),document.body.removeChild(n),document.body.removeChild(c.el)},e)};var u=c.size;c.size=function(t){return c.el.style.marginLeft=c.el.style.marginTop="-"+t/2+"px",u.call(c,t)};var f=c.light;return c.light=function(){return n.style.backgroundColor="black",f.call(c)},c["in"]=function(e){t=e},c.out=function(t){e=t},c}var r=t("spinner-browserify"),i=t("insert-css"),o=t("./style"),s=t("fade"),a=t("process");e.exports=n})()},{process:2,"./style":1,"insert-css":3,fade:4,"spinner-browserify":5}],3:[function(t,e){var n=[];e.exports=function(t){if(!(n.indexOf(t)>=0)){n.push(t);var e=document.createElement("style"),r=document.createTextNode(t);e.appendChild(r),document.head.childNodes.length?document.head.insertBefore(e,document.head.childNodes[0]):document.head.appendChild(e)}}},{}],2:[function(t,e){(function(){var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){if(t.source===window&&"browserify-tick"===t.data&&(t.stopPropagation(),n.length>0)){var e=n.shift();e()}},!0),function(t){n.push(t),window.postMessage("browserify-tick","*")}}return function(t){setTimeout(t,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(e){if("evals"===e)return t("vm");throw Error("No such module. (Possibly not yet loaded)")},function(){var e,r="/";n.cwd=function(){return r},n.chdir=function(n){e||(e=t("path")),r=e.resolve(n,r)}}()})()},{path:6,vm:7}],8:[function(t,e){var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){if(t.source===window&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var e=n.shift();e()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw Error("process.chdir is not supported")}},{}],6:[function(t,e,n){(function(t){function e(t,e){for(var n=[],r=0;t.length>r;r++)e(t[r],r,t)&&n.push(t[r]);return n}function r(t,e){for(var n=0,r=t.length;r>=0;r--){var i=t[r];"."==i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}var i=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;n.resolve=function(){for(var n="",i=!1,o=arguments.length;o>=-1&&!i;o--){var s=o>=0?arguments[o]:t.cwd();"string"==typeof s&&s&&(n=s+"/"+n,i="/"===s.charAt(0))}return n=r(e(n.split("/"),function(t){return!!t}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(t){var n="/"===t.charAt(0),i="/"===t.slice(-1);return t=r(e(t.split("/"),function(t){return!!t}),!n).join("/"),t||n||(t="."),t&&i&&(t+="/"),(n?"/":"")+t},n.join=function(){var t=Array.prototype.slice.call(arguments,0);return n.normalize(e(t,function(t){return t&&"string"==typeof t}).join("/"))},n.dirname=function(t){var e=i.exec(t)[1]||"",n=!1;return e?1===e.length||n&&3>=e.length&&":"===e.charAt(1)?e:e.substring(0,e.length-1):"."},n.basename=function(t,e){var n=i.exec(t)[2]||"";return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},n.extname=function(t){return i.exec(t)[3]||""},n.relative=function(t,e){function r(t){for(var e=0;t.length>e&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),s=Math.min(i.length,o.length),a=s,c=0;s>c;c++)if(i[c]!==o[c]){a=c;break}for(var u=[],c=a;i.length>c;c++)u.push("..");return u=u.concat(o.slice(a)),u.join("/")}})(t("__browserify_process"))},{__browserify_process:8}],7:[function(require,module,exports){var Object_keys=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var n in t)e.push(n);return e},forEach=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;t.length>n;n++)e(t[n],n,t)},Script=exports.Script=function NodeScript(t){return this instanceof Script?(this.code=t,void 0):new Script(t)};Script.prototype.runInNewContext=function(t){t||(t={});var e=document.createElement("iframe");e.style||(e.style={}),e.style.display="none",document.body.appendChild(e);var n=e.contentWindow;forEach(Object_keys(t),function(e){n[e]=t[e]}),!n.eval&&n.execScript&&n.execScript("null");var r=n.eval(this.code);return forEach(Object_keys(n),function(e){t[e]=n[e]}),document.body.removeChild(e),r},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInContext=function(t){return this.runInNewContext(t)},forEach(Object_keys(Script.prototype),function(t){exports[t]=Script[t]=function(e){var n=Script(e);return n[t].apply(n,[].slice.call(arguments,1))}}),exports.createScript=function(t){return exports.Script(t)},exports.createContext=Script.createContext=function(t){var e={};return"object"==typeof t&&forEach(Object_keys(t),function(n){e[n]=t[n]}),e}},{}],4:[function(t,e){function n(t,e,n){n===void 0&&(n=1e3);var i=r.get(t.style,"transition")||"";r(t.style,"transition","opacity "+n/1e3+"s"),t.style.opacity=e,setTimeout(function(){r(t.style,"transition",i)},n)}var r=t("prefixed");e.exports=n,n.out=function(t,e){n(t,0,e)},n["in"]=function(t,e){n(t,1,e)}},{prefixed:9}],5:[function(t,e){function n(){var t=this;this.percent=0,this.el=document.createElement("canvas"),this.ctx=this.el.getContext("2d"),this.size(50),this.fontSize(11),this.speed(60),this.font("helvetica, arial, sans-serif"),this.stopped=!1,function e(){t.stopped||(i(e),t.percent=(t.percent+t._speed/36)%100,t.draw(t.ctx))}()}var r=t("autoscale-canvas"),i=t("raf-component");e.exports=n,n.prototype.stop=function(){this.stopped=!0},n.prototype.size=function(t){return this.el.width=t,this.el.height=t,r(this.el),this},n.prototype.text=function(t){return this._text=t,this},n.prototype.fontSize=function(t){return this._fontSize=t,this},n.prototype.font=function(t){return this._font=t,this},n.prototype.speed=function(t){return this._speed=t,this},n.prototype.light=function(){return this._light=!0,this},n.prototype.draw=function(t){var e=Math.min(this.percent,100),n=window.devicePixelRatio||1,r=this.el.width/n,i=r/2,o=i,s=i,a=i-1,c=this._fontSize,u=this._light;t.font=c+"px "+this._font;var f=2*Math.PI*(e/100);t.clearRect(0,0,r,r);var p=t.createLinearGradient(i+Math.sin(1.5*Math.PI-f)*i,i+Math.cos(1.5*Math.PI-f)*i,i+Math.sin(.5*Math.PI-f)*i,i+Math.cos(.5*Math.PI-f)*i);u?(p.addColorStop(0,"rgba(255, 255, 255, 0)"),p.addColorStop(1,"rgba(255, 255, 255, 1)")):(p.addColorStop(0,"rgba(0, 0, 0, 0)"),p.addColorStop(1,"rgba(0, 0, 0, 1)")),t.strokeStyle=p,t.beginPath(),t.arc(o,s,a,f-Math.PI,f,!1),t.stroke(),t.strokeStyle=u?"rgba(255, 255, 255, .4)":"#eee",t.beginPath(),t.arc(o,s,a-1,0,2*Math.PI,!0),t.stroke();var d=this._text||"",l=t.measureText(d).width;return u&&(t.fillStyle="rgba(255, 255, 255, .9)"),t.fillText(d,o-l/2+1,s+c/2-1),this}},{"raf-component":10,"autoscale-canvas":11}],9:[function(t,e){function n(t,e,n){for(var i=0;r.length>i;i++)t[r[i]+e]=n}var r=["-webkit-","-moz-","-o-","-ms-",""];e.exports=n,n.get=function(t,e){for(var n=0;r.length>n;n++){var i=t[r[n]+e];if(i&&""!=i)return i}return""}},{}],10:[function(t,e,n){function r(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-i));setTimeout(t,n),i=e}n=e.exports=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||r;var i=(new Date).getTime(),o=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame;n.cancel=function(t){o.call(window,t)}},{}],11:[function(t,e){e.exports=function(t){var e=t.getContext("2d"),n=window.devicePixelRatio||1;return 1!=n&&(t.style.width=t.width+"px",t.style.height=t.height+"px",t.width*=n,t.height*=n,e.scale(n,n)),t}},{}]},{},[]);var Spinning=require("spinning"),spinner=Spinning().text("loading...").light().size(200);setTimeout(function(){spinner.remove()},3e3);
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
body, html { height: 100%; width: 100%; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment