forked from formula1/NodeOS-Blog
-
Notifications
You must be signed in to change notification settings - Fork 2
/
api.min.js
65 lines (35 loc) · 29.8 KB
/
api.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var errorHandler;jQuery(function(){var e=require("template");errorHandler=new e("script.template.error","div.container.error",["four-zero-three"]);var r=window.onerror;window.onerror=function(e,a,n,o,t){console.log(arguments),t?void 0!==t&&t.hasOwnProperty("name")&&"Magic"==t.name&&errorHandler.add({name:"Uncaught Error: "+t.name,message:e+"<pre>"+t.stack+"</pre>"}):errorHandler.add({name:"Uncaught Error: "+e,message:a+": "+n+", "+o}),r&&r(e,a,n,o,t)}}),window.addError=function(e){errorHandler.add(e.status?{name:"Ajax: "+e.status,message:e.responseText}:{name:e.name,message:e.stack})},window.add403=function(){var e={"class":"four-zero-three",name:"You've hit max data"};e.message=user.isLoggedIn?"Apparently, people have been using our app too much...":"If you'd like to continue, please ",e.message+="<button class=\"btn btn-primary\" onclick='user.login()'>Log in</button>",errorHandler.add(e)},window.add404=function(){errorHandler.add({name:"Your in the wrong place my friend.",message:"<a href='/'>Heres a hand, we'll get you back on the right track</a>"})};
},{"template":"template"}],2:[function(require,module,exports){
function compileYQL(e){if(Array.isArray(e)&&(e=e.join(";")),"string"!=typeof e)throw new Error("A yql query must be a string");return"https://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent(e)+"&diagnostics=true&format=json"}function yql_access(e){return function(r,o){var t;try{t=compileYQL(['env "'+e+'"','select * from github where CODE="'+r+'"'])}catch(n){return setTimeout(o.bind(o,n),1)}jQuery.ajax(t).done(function(e){o(void 0,e.query.results.OAuth.access_token)}).fail(function(e,r,t){o(t)})}}var config={cid:"dafb27cb88db35267e75",yqluri:"store://gdDAnJkTXAuVgzAQ8wboA2"},AuthProvider=require("auth-provider");AuthProvider.init({github:{client_id:config.cid,access_retriever:yql_access(config.yqluri)}}),window.user=new AuthProvider,user.on("error",function(e){console.error(e)}),user.on("login",function(){jQuery(".four-zero-three .content").text("You've authenticated!")});
},{"auth-provider":7}],3:[function(require,module,exports){
jQuery(function(a){a("#westoredata>p a").click(function(t){t.preventDefault(),a("#westoredata>div .more").toggle()})}),window.parseMarkdown=function(a,t){user.asAuthority("https://api.github.com/markdown/raw",function(e){jQuery.ajax({url:e,type:"POST",headers:{"Content-Type":"text/plain"},data:a.body}).done(function(t){a.bodyHTML=t}).fail(function(t,e,n){403===t.status?add403():addError({name:"Bad markdown call: "+t.status,message:n.message}),a.bodyHTML="<pre>"+a.body+"</pre>"}).always(function(){t(a)})})};
},{}],4:[function(require,module,exports){
(function (process){
!function(){function n(n){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,n.apply(t,arguments)}}var t,e,r={};t=this,null!=t&&(e=t.async),r.noConflict=function(){return t.async=e,r};var u=Object.prototype.toString,i=Array.isArray||function(n){return"[object Array]"===u.call(n)},c=function(n,t){if(n.forEach)return n.forEach(t);for(var e=0;e<n.length;e+=1)t(n[e],e,n)},a=function(n,t){if(n.map)return n.map(t);var e=[];return c(n,function(n,r,u){e.push(t(n,r,u))}),e},o=function(n,t,e){return n.reduce?n.reduce(t,e):(c(n,function(n,r,u){e=t(e,n,r,u)}),e)},l=function(n){if(Object.keys)return Object.keys(n);var t=[];for(var e in n)n.hasOwnProperty(e)&&t.push(e);return t};"undefined"!=typeof process&&process.nextTick?(r.nextTick=process.nextTick,r.setImmediate="undefined"!=typeof setImmediate?function(n){setImmediate(n)}:r.nextTick):"function"==typeof setImmediate?(r.nextTick=function(n){setImmediate(n)},r.setImmediate=r.nextTick):(r.nextTick=function(n){setTimeout(n,0)},r.setImmediate=r.nextTick),r.each=function(t,e,r){function u(n){n?(r(n),r=function(){}):(i+=1,i>=t.length&&r())}if(r=r||function(){},!t.length)return r();var i=0;c(t,function(t){e(t,n(u))})},r.forEach=r.each,r.eachSeries=function(n,t,e){if(e=e||function(){},!n.length)return e();var r=0,u=function(){t(n[r],function(t){t?(e(t),e=function(){}):(r+=1,r>=n.length?e():u())})};u()},r.forEachSeries=r.eachSeries,r.eachLimit=function(n,t,e,r){var u=f(t);u.apply(null,[n,e,r])},r.forEachLimit=r.eachLimit;var f=function(n){return function(t,e,r){if(r=r||function(){},!t.length||0>=n)return r();var u=0,i=0,c=0;!function a(){if(u>=t.length)return r();for(;n>c&&i<t.length;)i+=1,c+=1,e(t[i-1],function(n){n?(r(n),r=function(){}):(u+=1,c-=1,u>=t.length?r():a())})}()}},s=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.each].concat(t))}},p=function(n,t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[f(n)].concat(e))}},d=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.eachSeries].concat(t))}},y=function(n,t,e,r){if(t=a(t,function(n,t){return{index:t,value:n}}),r){var u=[];n(t,function(n,t){e(n.value,function(e,r){u[n.index]=r,t(e)})},function(n){r(n,u)})}else n(t,function(n,t){e(n.value,function(n){t(n)})})};r.map=s(y),r.mapSeries=d(y),r.mapLimit=function(n,t,e,r){return m(t)(n,e,r)};var m=function(n){return p(n,y)};r.reduce=function(n,t,e,u){r.eachSeries(n,function(n,r){e(t,n,function(n,e){t=e,r(n)})},function(n){u(n,t)})},r.inject=r.reduce,r.foldl=r.reduce,r.reduceRight=function(n,t,e,u){var i=a(n,function(n){return n}).reverse();r.reduce(i,t,e,u)},r.foldr=r.reduceRight;var v=function(n,t,e,r){var u=[];t=a(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e&&u.push(n),t()})},function(){r(a(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.filter=s(v),r.filterSeries=d(v),r.select=r.filter,r.selectSeries=r.filterSeries;var h=function(n,t,e,r){var u=[];t=a(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e||u.push(n),t()})},function(){r(a(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.reject=s(h),r.rejectSeries=d(h);var g=function(n,t,e,r){n(t,function(n,t){e(n,function(e){e?(r(n),r=function(){}):t()})},function(){r()})};r.detect=s(g),r.detectSeries=d(g),r.some=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n&&(e(!0),e=function(){}),r()})},function(){e(!1)})},r.any=r.some,r.every=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n||(e(!1),e=function(){}),r()})},function(){e(!0)})},r.all=r.every,r.sortBy=function(n,t,e){r.map(n,function(n,e){t(n,function(t,r){t?e(t):e(null,{value:n,criteria:r})})},function(n,t){if(n)return e(n);var r=function(n,t){var e=n.criteria,r=t.criteria;return r>e?-1:e>r?1:0};e(null,a(t.sort(r),function(n){return n.value}))})},r.auto=function(n,t){t=t||function(){};var e=l(n),u=e.length;if(!u)return t();var a={},f=[],s=function(n){f.unshift(n)},p=function(n){for(var t=0;t<f.length;t+=1)if(f[t]===n)return void f.splice(t,1)},d=function(){u--,c(f.slice(0),function(n){n()})};s(function(){if(!u){var n=t;t=function(){},n(null,a)}}),c(e,function(e){var u=i(n[e])?n[e]:[n[e]],f=function(n){var u=Array.prototype.slice.call(arguments,1);if(u.length<=1&&(u=u[0]),n){var i={};c(l(a),function(n){i[n]=a[n]}),i[e]=u,t(n,i),t=function(){}}else a[e]=u,r.setImmediate(d)},y=u.slice(0,Math.abs(u.length-1))||[],m=function(){return o(y,function(n,t){return n&&a.hasOwnProperty(t)},!0)&&!a.hasOwnProperty(e)};if(m())u[u.length-1](f,a);else{var v=function(){m()&&(p(v),u[u.length-1](f,a))};s(v)}})},r.retry=function(n,t,e){var u=5,i=[];"function"==typeof n&&(e=t,t=n,n=u),n=parseInt(n,10)||u;var c=function(u,c){for(var a=function(n,t){return function(e){n(function(n,r){e(!n||t,{err:n,result:r})},c)}};n;)i.push(a(t,!(n-=1)));r.series(i,function(n,t){t=t[t.length-1],(u||e)(t.err,t.result)})};return e?c():c},r.waterfall=function(n,t){if(t=t||function(){},!i(n)){var e=new Error("First argument to waterfall must be an array of functions");return t(e)}if(!n.length)return t();var u=function(n){return function(e){if(e)t.apply(null,arguments),t=function(){};else{var i=Array.prototype.slice.call(arguments,1),c=n.next();i.push(c?u(c):t),r.setImmediate(function(){n.apply(null,i)})}}};u(r.iterator(n))()};var k=function(n,t,e){if(e=e||function(){},i(t))n.map(t,function(n,t){n&&n(function(n){var e=Array.prototype.slice.call(arguments,1);e.length<=1&&(e=e[0]),t.call(null,n,e)})},e);else{var r={};n.each(l(t),function(n,e){t[n](function(t){var u=Array.prototype.slice.call(arguments,1);u.length<=1&&(u=u[0]),r[n]=u,e(t)})},function(n){e(n,r)})}};r.parallel=function(n,t){k({map:r.map,each:r.each},n,t)},r.parallelLimit=function(n,t,e){k({map:m(t),each:f(t)},n,e)},r.series=function(n,t){if(t=t||function(){},i(n))r.mapSeries(n,function(n,t){n&&n(function(n){var e=Array.prototype.slice.call(arguments,1);e.length<=1&&(e=e[0]),t.call(null,n,e)})},t);else{var e={};r.eachSeries(l(n),function(t,r){n[t](function(n){var u=Array.prototype.slice.call(arguments,1);u.length<=1&&(u=u[0]),e[t]=u,r(n)})},function(n){t(n,e)})}},r.iterator=function(n){var t=function(e){var r=function(){return n.length&&n[e].apply(null,arguments),r.next()};return r.next=function(){return e<n.length-1?t(e+1):null},r};return t(0)},r.apply=function(n){var t=Array.prototype.slice.call(arguments,1);return function(){return n.apply(null,t.concat(Array.prototype.slice.call(arguments)))}};var A=function(n,t,e,r){var u=[];n(t,function(n,t){e(n,function(n,e){u=u.concat(e||[]),t(n)})},function(n){r(n,u)})};r.concat=s(A),r.concatSeries=d(A),r.whilst=function(n,t,e){n()?t(function(u){return u?e(u):void r.whilst(n,t,e)}):e()},r.doWhilst=function(n,t,e){n(function(u){if(u)return e(u);var i=Array.prototype.slice.call(arguments,1);t.apply(null,i)?r.doWhilst(n,t,e):e()})},r.until=function(n,t,e){n()?e():t(function(u){return u?e(u):void r.until(n,t,e)})},r.doUntil=function(n,t,e){n(function(u){if(u)return e(u);var i=Array.prototype.slice.call(arguments,1);t.apply(null,i)?e():r.doUntil(n,t,e)})},r.queue=function(t,e){function u(n,t,e,u){return n.started||(n.started=!0),i(t)||(t=[t]),0==t.length?r.setImmediate(function(){n.drain&&n.drain()}):void c(t,function(t){var i={data:t,callback:"function"==typeof u?u:null};e?n.tasks.unshift(i):n.tasks.push(i),n.saturated&&n.tasks.length===n.concurrency&&n.saturated(),r.setImmediate(n.process)})}void 0===e&&(e=1);var a=0,o={tasks:[],concurrency:e,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(n,t){u(o,n,!1,t)},kill:function(){o.drain=null,o.tasks=[]},unshift:function(n,t){u(o,n,!0,t)},process:function(){if(!o.paused&&a<o.concurrency&&o.tasks.length){var e=o.tasks.shift();o.empty&&0===o.tasks.length&&o.empty(),a+=1;var r=function(){a-=1,e.callback&&e.callback.apply(e,arguments),o.drain&&o.tasks.length+a===0&&o.drain(),o.process()},u=n(r);t(e.data,u)}},length:function(){return o.tasks.length},running:function(){return a},idle:function(){return o.tasks.length+a===0},pause:function(){o.paused!==!0&&(o.paused=!0,o.process())},resume:function(){o.paused!==!1&&(o.paused=!1,o.process())}};return o},r.priorityQueue=function(n,t){function e(n,t){return n.priority-t.priority}function u(n,t,e){for(var r=-1,u=n.length-1;u>r;){var i=r+(u-r+1>>>1);e(t,n[i])>=0?r=i:u=i-1}return r}function a(n,t,a,o){return n.started||(n.started=!0),i(t)||(t=[t]),0==t.length?r.setImmediate(function(){n.drain&&n.drain()}):void c(t,function(t){var i={data:t,priority:a,callback:"function"==typeof o?o:null};n.tasks.splice(u(n.tasks,i,e)+1,0,i),n.saturated&&n.tasks.length===n.concurrency&&n.saturated(),r.setImmediate(n.process)})}var o=r.queue(n,t);return o.push=function(n,t,e){a(o,n,t,e)},delete o.unshift,o},r.cargo=function(n,t){var e=!1,u=[],o={tasks:u,payload:t,saturated:null,empty:null,drain:null,drained:!0,push:function(n,e){i(n)||(n=[n]),c(n,function(n){u.push({data:n,callback:"function"==typeof e?e:null}),o.drained=!1,o.saturated&&u.length===t&&o.saturated()}),r.setImmediate(o.process)},process:function l(){if(!e){if(0===u.length)return o.drain&&!o.drained&&o.drain(),void(o.drained=!0);var r="number"==typeof t?u.splice(0,t):u.splice(0,u.length),i=a(r,function(n){return n.data});o.empty&&o.empty(),e=!0,n(i,function(){e=!1;var n=arguments;c(r,function(t){t.callback&&t.callback.apply(null,n)}),l()})}},length:function(){return u.length},running:function(){return e}};return o};var x=function(n){return function(t){var e=Array.prototype.slice.call(arguments,1);t.apply(null,e.concat([function(t){var e=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(t?console.error&&console.error(t):console[n]&&c(e,function(t){console[n](t)}))}]))}};r.log=x("log"),r.dir=x("dir"),r.memoize=function(n,t){var e={},u={};t=t||function(n){return n};var i=function(){var i=Array.prototype.slice.call(arguments),c=i.pop(),a=t.apply(null,i);a in e?r.nextTick(function(){c.apply(null,e[a])}):a in u?u[a].push(c):(u[a]=[c],n.apply(null,i.concat([function(){e[a]=arguments;var n=u[a];delete u[a];for(var t=0,r=n.length;r>t;t++)n[t].apply(null,arguments)}])))};return i.memo=e,i.unmemoized=n,i},r.unmemoize=function(n){return function(){return(n.unmemoized||n).apply(null,arguments)}},r.times=function(n,t,e){for(var u=[],i=0;n>i;i++)u.push(i);return r.map(u,t,e)},r.timesSeries=function(n,t,e){for(var u=[],i=0;n>i;i++)u.push(i);return r.mapSeries(u,t,e)},r.seq=function(){var n=arguments;return function(){var t=this,e=Array.prototype.slice.call(arguments),u=e.pop();r.reduce(n,e,function(n,e,r){e.apply(t,n.concat([function(){var n=arguments[0],t=Array.prototype.slice.call(arguments,1);r(n,t)}]))},function(n,e){u.apply(t,[n].concat(e))})}},r.compose=function(){return r.seq.apply(null,Array.prototype.reverse.call(arguments))};var S=function(n,t){var e=function(){var e=this,r=Array.prototype.slice.call(arguments),u=r.pop();return n(t,function(n,t){n.apply(e,r.concat([t]))},u)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return e.apply(this,r)}return e};r.applyEach=s(S),r.applyEachSeries=d(S),r.forever=function(n,t){function e(r){if(r){if(t)return t(r);throw r}n(e)}e()},"undefined"!=typeof module&&module.exports?module.exports=r:"undefined"!=typeof define&&define.amd?define([],function(){return r}):t.async=r}();
}).call(this,require('_process'))
},{"_process":11}],5:[function(require,module,exports){
module.exports={getItem:function(e){return e?decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null:null},setItem:function(e,n,o,t,r,c){if(!e||/^(?:expires|max\-age|path|domain|secure)$/i.test(e))return!1;var s="";if(o)switch(o.constructor){case Number:s=o===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+o;break;case String:s="; expires="+o;break;case Date:s="; expires="+o.toUTCString()}return document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(n)+s+(r?"; domain="+r:"")+(t?"; path="+t:"")+(c?"; secure":""),!0},removeItem:function(e,n,o){return this.hasItem(e)?(document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"+(o?"; domain="+o:"")+(n?"; path="+n:""),!0):!1},hasItem:function(e){return e?new RegExp("(?:^|;\\s*)"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie):!1},keys:function(){for(var e=document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g,"").split(/\s*(?:\=[^;]*)?;\s*/),n=e.length,o=0;n>o;o++)e[o]=decodeURIComponent(e[o]);return e}};
},{}],6:[function(require,module,exports){
module.exports={name:"github",authLocation:function(e,o,t){return"https://github.com/login/oauth/authorize?client_id="+encodeURIComponent(e)+"&state="+encodeURIComponent(o)+"&redirect_uri="+encodeURIComponent(t)}};
},{}],7:[function(require,module,exports){
function AuthProvider(t){EventEmitter.call(this),this.uri_queue=[],this.is_authed=0,Object.defineProperty(this,"isLoggedIn",{get:function(){return 1===this.is_authed}}),t=t?t:{},this.storage=t.storage||require("./CookieStore"),this.identity=t.identity||"global";for(var i in ux)ux[i].init&&ux[i].init.call(this,t);this.asAuthority=this.asAuthority.bind(this),this.info={},setTimeout(this.parseURL.bind(this),1)}var querystring=require("querystring"),EventEmitter=require("events").EventEmitter,ux={popup:require("./user-experience/popup"),redirect:require("./user-experience/redirect")},auth={github:require("./auth-providers/github")},validauths={};AuthProvider.prototype=Object.create(EventEmitter.prototype),AuthProvider.prototype.constructor=AuthProvider,AuthProvider.init=function(t){for(var i in t){if(!(i in auth))throw new Error(i+" is not currently supported");if(!t[i].client_id)throw new Error(i+" needs a client id");if(!t[i].access_retriever)throw new Error(i+" needs an access_token provider")}validauths=t},AuthProvider.prototype.parseURL=function(){if(this.info=this.storage.getItem(this.identity+"_authority"),null===this.info||!this.info)return this.info={},this.fail("not expecting to login");if(this.info=JSON.parse(this.info),console.log(this.info),this.info.access_token)return this.finish();var t=window.location.href,i=t.indexOf("?");return-1===i?this.fail("no code"):(t=t.substring(i+1),t=querystring.parse(t),t.code?t.state?t.state.substring(0,this.identity.length)!=this.identity?this.fail("not me"):this.info.state!=t.state?this.fail("improper state"):void(ux[this.info.ux].code?ux[this.info.ux].code.call(this,t.code,function(){this.getAccess(t.code)}):this.getAccess(t.code)):this.fail("no state"):this.fail("no code"))},AuthProvider.prototype.getAccess=function(t){this.is_authed=0,delete this.info.state,validauths[this.info.auth].access_retriever(t,function(t,i){t?this.fail(t):(this.info.access_token=i,this.storage.setItem(this.identity+"_authority",JSON.stringify(this.info)),this.finish())}.bind(this))},AuthProvider.prototype.fail=function(t){console.error(t);var i=function(){this.is_authed=-1,this.storage.removeItem(this.identity+"_authority"),this.emit("error",t),this.runQueue()}.bind(this);return this.info&&this.info.ux&&ux[this.info.ux].error?ux[this.info.ux].error.call(this,t,i):void i()},AuthProvider.prototype.finish=function(){this.is_authed=1,this.emit("login",this),this.runQueue()},AuthProvider.prototype.runQueue=function(){for(var t=this.uri_queue.length;t--;)this.asAuthority.apply(void 0,this.uri_queue.shift())},AuthProvider.prototype.asAuthority=function(t,i){if(-1===this.is_authed)return void setTimeout(i.bind(i,t),1);if(0===this.is_authed)return void this.uri_queue.push([t,i]);var e=t.split("?");1===e.length?e.push({}):e[1]=querystring.parse(e[1]),e[1].access_token=this.info.access_token,e[1]=querystring.stringify(e[1]),setTimeout(i.bind(i,e.join("?")),1)},AuthProvider.prototype.login=function(t,i){if(this.isLoggedIn&&this.logout(),t=t||"github",i=i||"redirect",!(t in auth))throw new Error("This auth type is not available");if(!(t in validauths))throw new Error("You did not initialize this authtype");if(!(i in ux))throw new Error("This is not an available method for user experience");var e=this.identity+Date.now()+"_"+Math.random();this.info={state:e,auth:t,ux:i},this.storage.setItem(this.identity+"_authority",JSON.stringify(this.info));var r=auth[t].authLocation(validauths[t].client_id,e,document.location),o=this;ux[i].tryToAuth.call(this,r,function(t,i){return t?o.fail(t):void o.getAccess(i)})},AuthProvider.prototype.logout=function(){this.storage.removeItem(this.identity+"_authority"),this.info=void 0,this.is_authed=-1,this.emit("logout")},module.exports=AuthProvider;
},{"./CookieStore":5,"./auth-providers/github":6,"./user-experience/popup":8,"./user-experience/redirect":9,"events":10,"querystring":14}],8:[function(require,module,exports){
var popupSizes=function(){var e={},i=document.documentElement,o=void 0!==window.screenLeft?window.screenLeft:screen.left,n=void 0!==window.screenTop?window.screenTop:screen.top;return e.width=window.innerWidth||i.clientWidth||screen.width,e.height=window.innerHeight||i.clientHeight||screen.height,e.left=(e.width-windowWidth)/2+o,e.top=(e.height-windowHeight)/2+n,e};module.exports={initialize:function(e){this.origin=e.origin||window.location.host},error:function(e,i){if(!window.opener)return i();try{window.opener.postMessage("failure"+e,this.origin)}catch(o){console.log("window probably doesn't exist anymore")}window.close()},code:function(){try{window.opener.postMessage(query.code,this.origin)}catch(e){console.log("window probably doesn't exist anymore")}window.close()},tryToAuth:function(e,i){this.is_authed=0;var o=popupSizes(),n=window.open(location,"_blank","resizeable=true,height="+o.height+",width="+o.width+",left="+o.left+",top="+o.top);n.addEventListener("message",function(e){return e.origin==this.origin?"failure"==e.data.substring(0,7)?i(e.data.substring(7)):void i(void 0,e.data):void 0},!1)}};
},{}],9:[function(require,module,exports){
module.exports={tryToAuth:function(o){window.location.href=o}};
},{}],10:[function(require,module,exports){
function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(e){return"function"==typeof e}function isNumber(e){return"number"==typeof e}function isObject(e){return"object"==typeof e&&null!==e}function isUndefined(e){return void 0===e}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(e){if(!isNumber(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},EventEmitter.prototype.emit=function(e){var t,n,s,i,r,o;if(this._events||(this._events={}),"error"===e&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],isUndefined(n))return!1;if(isFunction(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(s=arguments.length,i=new Array(s-1),r=1;s>r;r++)i[r-1]=arguments[r];n.apply(this,i)}else if(isObject(n)){for(s=arguments.length,i=new Array(s-1),r=1;s>r;r++)i[r-1]=arguments[r];for(o=n.slice(),s=o.length,r=0;s>r;r++)o[r].apply(this,i)}return!0},EventEmitter.prototype.addListener=function(e,t){var n;if(!isFunction(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,isFunction(t.listener)?t.listener:t),this._events[e]?isObject(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,isObject(this._events[e])&&!this._events[e].warned){var n;n=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){function n(){this.removeListener(e,n),s||(s=!0,t.apply(this,arguments))}if(!isFunction(t))throw TypeError("listener must be a function");var s=!1;return n.listener=t,this.on(e,n),this},EventEmitter.prototype.removeListener=function(e,t){var n,s,i,r;if(!isFunction(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],i=n.length,s=-1,n===t||isFunction(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(isObject(n)){for(r=i;r-->0;)if(n[r]===t||n[r].listener&&n[r].listener===t){s=r;break}if(0>s)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],isFunction(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},EventEmitter.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?isFunction(e._events[t])?1:e._events[t].length:0};
},{}],11:[function(require,module,exports){
function drainQueue(){if(!draining){draining=!0;for(var e,o=queue.length;o;){e=queue,queue=[];for(var r=-1;++r<o;)e[r]();o=queue.length}draining=!1}}function noop(){}var process=module.exports={},queue=[],draining=!1;process.nextTick=function(e){queue.push(e),draining||setTimeout(drainQueue,0)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.binding=function(){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(){throw new Error("process.chdir is not supported")},process.umask=function(){return 0};
},{}],12:[function(require,module,exports){
"use strict";function hasOwnProperty(r,e){return Object.prototype.hasOwnProperty.call(r,e)}module.exports=function(r,e,t,n){e=e||"&",t=t||"=";var o={};if("string"!=typeof r||0===r.length)return o;var a=/\+/g;r=r.split(e);var s=1e3;n&&"number"==typeof n.maxKeys&&(s=n.maxKeys);var p=r.length;s>0&&p>s&&(p=s);for(var y=0;p>y;++y){var u,c,i,l,f=r[y].replace(a,"%20"),v=f.indexOf(t);v>=0?(u=f.substr(0,v),c=f.substr(v+1)):(u=f,c=""),i=decodeURIComponent(u),l=decodeURIComponent(c),hasOwnProperty(o,i)?isArray(o[i])?o[i].push(l):o[i]=[o[i],l]:o[i]=l}return o};var isArray=Array.isArray||function(r){return"[object Array]"===Object.prototype.toString.call(r)};
},{}],13:[function(require,module,exports){
"use strict";function map(r,e){if(r.map)return r.map(e);for(var t=[],n=0;n<r.length;n++)t.push(e(r[n],n));return t}var stringifyPrimitive=function(r){switch(typeof r){case"string":return r;case"boolean":return r?"true":"false";case"number":return isFinite(r)?r:"";default:return""}};module.exports=function(r,e,t,n){return e=e||"&",t=t||"=",null===r&&(r=void 0),"object"==typeof r?map(objectKeys(r),function(n){var i=encodeURIComponent(stringifyPrimitive(n))+t;return isArray(r[n])?map(r[n],function(r){return i+encodeURIComponent(stringifyPrimitive(r))}).join(e):i+encodeURIComponent(stringifyPrimitive(r[n]))}).join(e):n?encodeURIComponent(stringifyPrimitive(n))+t+encodeURIComponent(stringifyPrimitive(r)):""};var isArray=Array.isArray||function(r){return"[object Array]"===Object.prototype.toString.call(r)},objectKeys=Object.keys||function(r){var e=[];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.push(t);return e};
},{}],14:[function(require,module,exports){
"use strict";exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode");
},{"./decode":12,"./encode":13}],"cache-or-load":[function(require,module,exports){
function getCacheData(e,r){try{var t=localStorage.getItem(e)}catch(n){return setTimeout(r.bind(r,n),1)}if(!t||/^\[?undefined(?:\]?)$|\[\]|\[?null(?:\]?)$/.test(t))return setTimeout(r.bind(r,"empty"),1);try{t=JSON.parse(t)}catch(n){return setTimeout(r.bind(r,n),1)}Array.isArray(t)||(t=[t]),setTimeout(r.bind(r,void 0,t),1)}function UriIterator(e,r,t){r.timestamp2URI(e,function(e){jQuery.get(e).done(function(e){Array.isArray(e)||(e=[e]),async.eachSeries(e,function(e,t){r.prep(e,function(){t()})},function(r){t(r,e)})}).fail(r.error.bind(r.error))})}function finalize(e,r,t,n){try{localStorage.setItem(e,JSON.stringify(r))}catch(a){return}async.eachSeries(r,function(e,r){t.ready(e,r)},n)}var async=require("async"),version=1,userversion=localStorage.getItem("cacheorUri-version");(!userversion||"undefined"===userversion||version>userversion)&&localStorage.clear(),localStorage.setItem("cacheorUri-version",version);var checkArrayOrder,reOrderAndConsolidate;module.exports=function(e,r){getCacheData(e,function(t,n){var a;t?n=[]:a="desc"==checkArrayOrder(n)?n[0].timestamp:n[n.length-1].timestamp,UriIterator(a,r,function(t,i){if(t)return r.error(t);var o=reOrderAndConsolidate(n,i);finalize(e,o,r,function(e){return e?r.error(t):0===o.length?r.done(a):"desc"==checkArrayOrder(o)?r.done(o.shift().timestamp):void r.done(o.pop().timestamp)})})})},checkArrayOrder=module.exports.checkArrayOrder=function(e){return!e||e.length<2?"unk":e[0].timestamp<e[1].timestamp?"asc":"desc"},reOrderAndConsolidate=module.exports.reOrderAndConsolidate=function(e,r){var t,n=checkArrayOrder(e),a=checkArrayOrder(r);return"unk"==n&&"unk"==a?t="asc":n==a&&(t=a),"unk"==n||"unk"==a?t="unk"==n?a:n:n!=a&&(e.sort(function(e,r){return"asc"==a?e.timestamp-r.timestamp:r.timestamp-e.timestamp}),t=a),"asc"==t?e.concat(r):r.concat(e)};
},{"async":4}],"template":[function(require,module,exports){
function Template(e,t,i){if(this.template=Handlebars.compile(jQuery(e).html()),this.contain=jQuery(t),this.unique={},Array.isArray(i))for(var n=i.length;n--;)this.unique[i[n]]=!1;this.contain.find(".remove").on("click",this.remove.bind(this))}Template.prototype.add=function(e){if(e["class"]&&"undefined"!=typeof this.unique[e["class"]]){if(this.unique[e["class"]])return;this.unique[e["class"]]=!0}console.log("appending"),this.contain.append(this.template(e))},Template.prototype.remove=function(e){e.preventDefault();var t=$(this).closest("article"),i=t.attr("data-unique");i&&(this.unique[i]=!1),t.remove()},module.exports=Template;
},{}]},{},[3,1,2]);