Skip to content

Instantly share code, notes, and snippets.

@tlrobinson
Forked from juliangruber/head.html
Created September 9, 2013 22:03
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 tlrobinson/6502140 to your computer and use it in GitHub Desktop.
Save tlrobinson/6502140 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,i){if(!e[n]){if(!t[n]){var s="function"==typeof require&&require;if(!i&&s)return s(n,!0);if(o)return o(n,!0);throw Error("Cannot find module '"+n+"'")}var c=e[n]={exports:{}};t[n][0].call(c.exports,function(e){var o=t[n][1][e];return r(o?o:e)},c,c.exports)}return e[n].exports}for(var o="function"==typeof require&&require,i=0;n.length>i;i++)r(n[i]);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("H4e5f3")},{}],H4e5f3:[function(t,e){(function(){function n(){function t(t){a(function(){u||(document.body.appendChild(t),f=!0)})}o(i);var e=1e3,n=300,u=!1,f=!1,d=document.createElement("div");d.className="overlay",t(d);var p=new r;p.el.className="spinner",t(p.el),c.nextTick(function(){s(d,.8,e),s.in(p.el,e)}),p.remove=function(){s.out(d,n),s.out(p.el,n),u=!0,setTimeout(function(){p.stop(),f&&(document.body.removeChild(d),document.body.removeChild(p.el))},n)};var l=p.size;p.size=function(t){return p.el.style.marginLeft=p.el.style.marginTop="-"+t/2+"px",l.call(p,t)};var h=p.light;return p.light=function(){return d.style.backgroundColor="black",h.call(p)},p["in"]=function(t){e=t},p.out=function(t){n=t},p}var r=t("spinner-browserify"),o=t("insert-css"),i=t("./style"),s=t("fade"),c=t("process"),a=t("domready");e.exports=n})()},{process:2,"./style":1,"insert-css":3,fade:4,domready:5,"spinner-browserify":6}],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:7,vm:8}],9:[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")}},{}],7:[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 o=t[r];"."==o?t.splice(r,1):".."===o?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}var o=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;n.resolve=function(){for(var n="",o=!1,i=arguments.length;i>=-1&&!o;i--){var s=i>=0?arguments[i]:t.cwd();"string"==typeof s&&s&&(n=s+"/"+n,o="/"===s.charAt(0))}return n=r(e(n.split("/"),function(t){return!!t}),!o).join("/"),(o?"/":"")+n||"."},n.normalize=function(t){var n="/"===t.charAt(0),o="/"===t.slice(-1);return t=r(e(t.split("/"),function(t){return!!t}),!n).join("/"),t||n||(t="."),t&&o&&(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=o.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=o.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 o.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 o=r(t.split("/")),i=r(e.split("/")),s=Math.min(o.length,i.length),c=s,a=0;s>a;a++)if(o[a]!==i[a]){c=a;break}for(var u=[],a=c;o.length>a;a++)u.push("..");return u=u.concat(i.slice(c)),u.join("/")}})(t("__browserify_process"))},{__browserify_process:9}],5:[function(t,e){!function(t,n){e!==void 0?e.exports=n():"function"==typeof define&&"object"==typeof define.amd?define(n):this[t]=n()}("domready",function(t){function e(t){for(l=1;t=r.shift();)t()}var n,r=[],o=!1,i=document,s=i.documentElement,c=s.doScroll,a="DOMContentLoaded",u="addEventListener",f="onreadystatechange",d="readyState",p=c?/^loaded|^c/:/^loaded|c/,l=p.test(i[d]);return i[u]&&i[u](a,n=function(){i.removeEventListener(a,n,o),e()},o),c&&i.attachEvent(f,n=function(){/^c/.test(i[d])&&(i.detachEvent(f,n),e())}),t=c?function(e){self!=top?l?e():r.push(e):function(){try{s.doScroll("left")}catch(n){return setTimeout(function(){t(e)},50)}e()}()}:function(t){l?t():r.push(t)}})},{}],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)}}},{}],8:[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 o=r.get(t.style,"transition")||"";r(t.style,"transition","opacity "+n/1e3+"s"),t.style.opacity=e,setTimeout(function(){r(t.style,"transition",o)},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:10}],6:[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||(o(e),t.percent=(t.percent+t._speed/36)%100,t.draw(t.ctx))}()}var r=t("autoscale-canvas"),o=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,o=r/2,i=o,s=o,c=o-1,a=this._fontSize,u=this._light;t.font=a+"px "+this._font;var f=2*Math.PI*(e/100);t.clearRect(0,0,r,r);var d=t.createLinearGradient(o+Math.sin(1.5*Math.PI-f)*o,o+Math.cos(1.5*Math.PI-f)*o,o+Math.sin(.5*Math.PI-f)*o,o+Math.cos(.5*Math.PI-f)*o);u?(d.addColorStop(0,"rgba(255, 255, 255, 0)"),d.addColorStop(1,"rgba(255, 255, 255, 1)")):(d.addColorStop(0,"rgba(0, 0, 0, 0)"),d.addColorStop(1,"rgba(0, 0, 0, 1)")),t.strokeStyle=d,t.beginPath(),t.arc(i,s,c,f-Math.PI,f,!1),t.stroke(),t.strokeStyle=u?"rgba(255, 255, 255, .4)":"#eee",t.beginPath(),t.arc(i,s,c-1,0,2*Math.PI,!0),t.stroke();var p=this._text||"",l=t.measureText(p).width;return u&&(t.fillStyle="rgba(255, 255, 255, .9)"),t.fillText(p,i-l/2+1,s+a/2-1),this}},{"autoscale-canvas":11,"raf-component":12}],10:[function(t,e){function n(t,e,n){for(var o=0;r.length>o;o++)t[r[o]+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 o=t[r[n]+e];if(o&&""!=o)return o}return""}},{}],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}},{}],12:[function(t,e,n){function r(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-o));setTimeout(t,n),o=e}n=e.exports=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||r;var o=(new Date).getTime(),i=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame;n.cancel=function(t){i.call(window,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