310 lines
119 KiB
JavaScript
310 lines
119 KiB
JavaScript
|
|
/* OxJS 0.1.3905 (c) 2023 0x2620, dual-licensed GPL/MIT, see https://oxjs.org for details */'use strict';this.Ox=function(value){return Ox.wrap(value);};Ox.load=function(){var callback=arguments[arguments.length-1],length,loaded=0,localeFiles=[],modules={},succeeded=0,type=Ox.typeOf(arguments[0]);if(type=='string'){modules=Ox.extend({},arguments[0],Ox.isObject(arguments[1])?arguments[1]:{});}else if(type=='array'){arguments[0].forEach(function(value){if(Ox.isString(value)){modules[value]={};}else{Ox.extend(modules,value);}});}else if(type=='object'){modules=arguments[0];}
|
|||
|
|
length=Ox.len(modules);Ox.documentReady(function(){if(!length){callback(true);}else{Ox.forEach(modules,function(options,module){Ox.getFile(Ox.PATH+module+'/'+module+'.js?'+Ox.VERSION,function(){Ox.load[module](options,function(success){succeeded+=success;if(++loaded==length){Ox.setLocale(Ox.LOCALE,function(){callback(succeeded==length);});}});});});}});};Ox.localStorage=function(namespace){var localStorage;try{localStorage=window.localStorage||{};for(var key in localStorage){}
|
|||
|
|
localStorage.setItem('OxJS.test','');localStorage.removeItem('OxJS.test');}catch(e){console.log('localStorage disabled');localStorage={};}
|
|||
|
|
function storage(key,value){var ret;if(arguments.length==0){ret={};Ox.forEach(localStorage,function(value,key){if(Ox.startsWith(key,namespace+'.')){ret[key.slice(namespace.length+1)]=JSON.parse(value);}});}else if(arguments.length==1&&typeof key=='string'){value=localStorage[namespace+'.'+key];ret=value===void 0?void 0:JSON.parse(value);}else{Ox.forEach(Ox.makeObject(arguments),function(value,key){localStorage[namespace+'.'+key]=JSON.stringify(value);});ret=storage;}
|
|||
|
|
return ret;}
|
|||
|
|
storage['delete']=function(){var keys=arguments.length==0?Object.keys(storage()):Ox.slice(arguments);keys.forEach(function(key){delete localStorage[namespace+'.'+key];});return storage;};return storage;};Ox.Log=(function(){var storage=Ox.localStorage('Ox'),log=storage('log')||{filter:[],filterEnabled:true},that=function(){var ret;if(arguments.length==0){ret=log;}else{ret=that.log.apply(null,arguments);}
|
|||
|
|
return ret;};that.filter=function(value){if(!Ox.isUndefined(value)){that.filter.enable();log.filter=Ox.makeArray(value);storage('log',log);}
|
|||
|
|
return log.filter;};that.filter.add=function(value){return that.filter(Ox.unique(log.filter.concat(Ox.makeArray(value))));};that.filter.disable=function(){log.filterEnabled=false;storage('log',log);};that.filter.enable=function(){log.filterEnabled=true;storage('log',log);};that.filter.remove=function(value){value=Ox.makeArray(value);return that.filter(log.filter.filter(function(v){return value.indexOf(v)==-1;}));};that.log=function(){var args=Ox.slice(arguments),date,ret;if(!log.filterEnabled||log.filter.indexOf(args[0])>-1){date=new Date();args.unshift(Ox.formatDate(date,'%H:%M:%S.')+(+date).toString().slice(-3));window.console&&window.console.log&&window.console.log.apply(window.console,args);ret=args.join(' ');}
|
|||
|
|
return ret;};return that;}());Ox.loop=function(){var length=arguments.length,start=length>2?arguments[0]:0,stop=arguments[length>2?1:0],step=length==4?arguments[2]:(start<=stop?1:-1),iterator=arguments[length-1],i;for(i=start;step>0?i<stop:i>stop;i+=step){if(iterator(i)===false){break;}}
|
|||
|
|
return i;};Ox.print=function(){var args=Ox.slice(arguments),date=new Date();args.unshift(date.toString().split(' ')[4]+'.'+(+date).toString().slice(-3));window.console&&window.console.log.apply(window.console,args);return args.join(' ');};Ox.trace=function(){var args=Ox.slice(arguments);try{throw new Error();}catch(e){if(e.stack){args.push('\n'+Ox.clean(e.stack.split('\n').slice(2).join('\n')));}}
|
|||
|
|
return Ox.print.apply(null,args);};Ox.uid=(function(){var uid=0;return function(){return++uid;};}());Ox.wrap=function(value,chained){var wrapper={chain:function(){wrapper.chained=true;return wrapper;},chained:chained||false,value:function(){return value;}};Ox.methods(Ox).filter(function(method){return method[0]==method[0].toLowerCase();}).forEach(function(method){wrapper[method]=function(){var args=Array.prototype.slice.call(arguments),ret;args.unshift(value);ret=Ox[method].apply(Ox,args);return wrapper.chained?Ox.wrap(ret,true):ret;};});return wrapper;};'use strict';Ox.cache=function(fn,options){var cache={},ret;options=options||{};options.async=options.async||false;options.key=options.key||JSON.stringify;ret=function(){var args=Ox.slice(arguments),key=options.key(args);function callback(){cache[key]=Ox.slice(arguments);Ox.last(args).apply(this,arguments);}
|
|||
|
|
if(options.async){if(!(key in cache)){fn.apply(this,args.slice(0,-1).concat(callback));}else{setTimeout(function(){callback.apply(this,cache[key]);});}}else{if(!(key in cache)){cache[key]=fn.apply(this,args);}
|
|||
|
|
return cache[key];}};ret.clear=function(){if(arguments.length==0){cache={};}else{Ox.makeArray(arguments).forEach(function(key){delete cache[key];});}
|
|||
|
|
return ret;};return ret;};Ox.debounce=function(fn){var args,immediate=Ox.last(arguments)===true,ms=Ox.isNumber(arguments[1])?arguments[1]:250,timeout;return function(){args=arguments;if(!timeout){if(immediate){fn.apply(null,args);args=null;}}else{clearTimeout(timeout);}
|
|||
|
|
timeout=setTimeout(function(){if(args!==null){fn.apply(null,args);}
|
|||
|
|
timeout=null;},ms);};};Ox.identity=function(value){return value;};Ox.noop=function(){var callback=Ox.last(arguments);Ox.isFunction(callback)&&callback();};Ox.once=function(fn){var once=false;return function(){if(!once){once=true;fn.apply(null,arguments);}};};Ox.queue=function(fn,maxThreads){maxThreads=maxThreads||10;var processing=[],queued=[],ret=Ox.cache(function(){var args=Ox.slice(arguments);queued.push({args:args,key:getKey(args)});process();},{async:true,key:getKey}),threads=0;ret.cancel=function(){threads-=processing.length;processing=[];return ret;};ret.clear=function(){threads=0;queued=[];return ret;};ret.reset=function(){return ret.cancel().clear();};function getKey(args){return JSON.stringify(args.slice(0,-1));}
|
|||
|
|
function process(){var n=Math.min(queued.length,maxThreads-threads);if(n){threads+=n;processing=processing.concat(queued.splice(0,n));Ox.parallelForEach(processing,function(value,index,array,callback){var args=value.args,key=value.key;fn.apply(this,args.slice(0,-1).concat(function(result){var index=Ox.indexOf(processing,function(value){return value.key==key;});if(index>-1){processing.splice(index,1);args.slice(-1)[0](result);threads--;}
|
|||
|
|
callback();}));},process);}}
|
|||
|
|
return ret;};Ox.throttle=function(fn,ms){var args,timeout;ms=arguments.length==1?250:ms;return function(){args=arguments;if(!timeout){fn.apply(null,args);args=null;timeout=setTimeout(function(){if(args!==null){fn.apply(null,args);}
|
|||
|
|
timeout=null;},ms);}};};Ox.time=function(fn){var time=new Date();fn();return new Date()-time;};'use strict';(function(window){var canDefineProperty=!!Object.defineProperty&&(function(){try{Object.defineProperty({},'a',{});return true;}catch(e){}}()),chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',log;Ox.polyfill={};Ox.polyfill.atob=function(string){var binary='',ret='';String(string).replace(/=/g,'').split('').forEach(function(char){binary+=Ox.pad(chars.indexOf(char).toString(2),'left',6,'0');});while(binary.length>=8){ret+=Ox.char(parseInt(binary.slice(0,8),2));binary=binary.slice(8);}
|
|||
|
|
return ret;};Ox.polyfill.btoa=function(string){var binary='',ret='';String(string).split('').forEach(function(char){binary+=Ox.pad(char.charCodeAt(0).toString(2),'left',8,'0');});binary=Ox.pad(binary,Math.ceil(binary.length/6)*6,'0');while(binary){ret+=chars[parseInt(binary.slice(0,6),2)];binary=binary.slice(6);}
|
|||
|
|
return Ox.pad(ret,Math.ceil(ret.length/4)*4,'=');};Ox.polyfill.bind=function(that){if(typeof this!=='function'){throw new TypeError();}
|
|||
|
|
var args=Array.prototype.slice.call(arguments,1),fn=function(){},this_=this,ret=function(){return this_.apply(this instanceof fn?this:that||window,args.concat(Array.prototype.slice.call(arguments)));};fn.prototype=this.prototype;ret.prototype=new fn();return ret;};Ox.polyfill.every=function(iterator,that){if(this===void 0||this===null||typeof iterator!=='function'){throw new TypeError();}
|
|||
|
|
var array=Object(this),i,length=array.length>>>0,ret=true;for(i=0;i<length;i++){if(i in array&&!iterator.call(that,array[i],i,array)){ret=false;break;}}
|
|||
|
|
return ret;};Ox.polyfill.filter=function(iterator,that){if(this===void 0||this===null||typeof iterator!=='function'){throw new TypeError();}
|
|||
|
|
var array=Object(this),i,length=array.length>>>0,ret=[],value;for(i=0;i<length;i++){if(i in array&&iterator.call(that,value=array[i],i,array)){ret.push(value);}}
|
|||
|
|
return ret;};Ox.polyfill.forEach=function(iterator,that){if(this===void 0||this===null||typeof iterator!=='function'){throw new TypeError();}
|
|||
|
|
var array=Object(this),i,length=array.length>>>0;for(i=0;i<length;i++){if(i in array){iterator.call(that,array[i],i,array);}}};Ox.polyfill.indexOf=function(value){if(this===void 0||this===null){throw new TypeError();}var array=Object(this),i,length=array.length>>>0,ret=-1;for(i=0;i<length;i++){if(i in array&&array[i]===value){ret=i;break;}}
|
|||
|
|
return ret;};Ox.polyfill.isArray=function(value){return Object.prototype.toString.call(value)=='[object Array]';};Ox.polyfill.JSON=(function(){var replace={'"':'\\"','\b':'\\b','\f':'\\f','\n':'\\n','\r':'\\r','\t':'\\t','\\':'\\\\'};function quote(value){return'"'+value.split('').map(function(char){return replace[char]||char;}).join('')+'"';}
|
|||
|
|
return{parse:function parse(string){return eval('('+string+')');},stringify:function stringify(value){var ret='null',type=Ox.typeOf(value);if(type=='arguments'||type=='regexp'){ret='{}';}else if(type=='array'){ret=['[',']'].join(value.map(function(v){return stringify(v);}).join(','));}else if(type=='boolean'){ret=String(value);}else if(type=='date'){ret=Ox.splice(Ox.getISODate(value,true),19,0,'.'+String(+value).slice(-3));}else if(type=='number'){ret=isFinite(value)?String(value):'null';}else if(type=='object'){ret=['{','}'].join(Object.keys(value).map(function(k){return quote(k)+': '+stringify(value[k]);}).join(','));}else if(type=='string'){ret=quote(value);}
|
|||
|
|
return ret;}};}());Ox.polyfill.keys=function(object){if(object!==Object(object)){throw new TypeError();}
|
|||
|
|
var key,ret=[];for(key in object){Object.prototype.hasOwnProperty.call(object,key)&&ret.push(key);}
|
|||
|
|
return ret;};Ox.polyfill.lastIndexOf=function(value){if(this===void 0||this===null){throw new TypeError();}var array=Object(this),i,length=array.length>>>0,ret=-1;for(i=length-1;i>=0;i--){if(i in array&&array[i]===value){ret=i;break;}}
|
|||
|
|
return ret;};Ox.polyfill.map=function(iterator,that){if(this===void 0||this===null||typeof iterator!=='function'){throw new TypeError();}
|
|||
|
|
var array=Object(this),i,length=array.length>>>0,ret=new Array(length);for(i=0;i<length;i++){if(i in array){ret[i]=iterator.call(that,array[i],i,array);}}
|
|||
|
|
return ret;};Ox.polyfill.reduce=function(iterator,ret){if(this===void 0||this===null||typeof iterator!=='function'){throw new TypeError();}
|
|||
|
|
var array=Object(this),i,length=array.length;if(!length&&ret===void 0){throw new TypeError();}
|
|||
|
|
if(ret===void 0){ret=array[0];i=1;}
|
|||
|
|
for(i=i||0;i<length;i++){if(i in array){ret=iterator.call(void 0,ret,array[i],i,array);}}
|
|||
|
|
return ret;};Ox.polyfill.reduceRight=function(iterator,ret){if(this===void 0||this===null||typeof iterator!=='function'){throw new TypeError();}
|
|||
|
|
var array=Object(this),i,length=array.length;if(!length&&ret===void 0){throw new TypeError();}
|
|||
|
|
if(ret===void 0){ret=array[length-1];i=length-2;}
|
|||
|
|
for(i=i||length-1;i>=0;i--){if(i in array){ret=iterator.call(void 0,ret,array[i],i,array);}}
|
|||
|
|
return ret;};Ox.polyfill.some=function(iterator,that){if(this===void 0||this===null||typeof iterator!=='function'){throw new TypeError();}
|
|||
|
|
var array=Object(this),i,length=array.length>>>0,ret=false;for(i=0;i<length;i++){if(i in array&&iterator.call(that,array[i],i,array)){ret=true;break;}}
|
|||
|
|
return ret;};Ox.polyfill.trim=function(){if(this===void 0||this===null){throw new TypeError();}
|
|||
|
|
return this.replace(/^\s+|\s+$/g,'');};[[Array,['isArray']],[Array.prototype,['every','filter','forEach','indexOf','lastIndexOf','map','reduce','reduceRight','some']],[Function.prototype,['bind']],[Object,['keys']],[String.prototype,['trim']],[window,['atob','btoa','JSON']]].forEach(function(item){var object=item[0],keys=item[1];keys.forEach(function(key){if(!key in object){if(canDefineProperty){Object.defineProperty(object,key,{configurable:true,enumerable:false,writable:true,value:Ox.polyfill[key]});}else{object[key]=Ox.polyfill[key];}}});});if(window.console){if(typeof window.console.log!=='function'){log=window.console.log;window.console.log=function(){log(Array.prototype.slice.call(arguments).join(' '));};}else if(!window.console.log.apply){window.console.log=Function.prototype.bind.call(window.console.log,window.console);}}}(this));'use strict';Ox.api=function(items,options){options=options||{};var api={cache:options.cache,enums:options.enums?parseEnums(options.enums):{},geo:options.geo,map:options.map||{},sort:options.sort||[],sums:options.sums||[],unique:options.unique||'id'},fn=function(options,callback){var data,keys,map={},result={data:{},status:{code:200,text:'ok'}};options=options||{};if(options.query){options.query.conditions=parseConditions(options.query.conditions);result.data.items=items.filter(function(item){return testQuery(item,options.query);});}else{result.data.items=Ox.clone(items);}
|
|||
|
|
if(options.sort&&result.data.items.length>1){keys=[];options.sort=parseSort(options.sort.concat(api.sort)).filter(function(v){var ret=keys.indexOf(v.key)==-1;keys.push(v.key);return ret;});options.sort.forEach(function(v){var key=v.key;if(api.enums[key]){map[key]=function(value){return api.enums[key].indexOf(value.toLowerCase());};}else if(api.map[key]){map[key]=api.map[key];}});if(options.keys||options.positions){result.data.items=sortBy(result.data.items,options.sort,map,options.query);}}
|
|||
|
|
if(options.positions){data={positions:{}};options.positions.forEach(function(id){data.positions[id]=Ox.indexOf(result.data.items,function(item){return item[api.unique]==id;});});result.data=data;}else if(!options.keys){data={};api.sums.forEach(function(key){data[key]=result.data.items.map(function(item){return item[key];});data[key]=Ox.isString(data[key][0])?Ox.unique(data[key]).length:Ox.sum(data[key]);});data.items=result.data.items.length;if(api.geo){data.area=data.items==0?{south:-Ox.MAX_LATITUDE,west:-179,north:Ox.MAX_LATITUDE,east:179}:result.data.items.reduce(function(prev,curr){return{south:Math.min(prev.south,curr.south),west:Math.min(prev.west,curr.west),north:Math.max(prev.north,curr.north),east:Math.max(prev.east,curr.east)};},{south:Ox.MAX_LATITUDE,west:180,north:-Ox.MAX_LATITUDE,east:-180});}
|
|||
|
|
result.data=data;}else{if(!Ox.isEmpty(options.keys)){if(options.keys.indexOf(api.unique)==-1){options.keys.push(api.unique);}
|
|||
|
|
result.data.items=result.data.items.map(function(item){var ret={};options.keys.forEach(function(key){ret[key]=item[key];});return ret;});}
|
|||
|
|
if(options.range){result.data.items=result.data.items.slice(options.range[0],options.range[1]);}}
|
|||
|
|
callback&&callback(result);return result;},ret=Ox.extend(api.cache?Ox.cache(fn,{async:true}):fn,{update:function(updatedItems){items=updatedItems;api.cache&&ret.clear();sortBy.clear();return ret;}}),sortBy=Ox.cache(function sortBy(array,by,map,query){return Ox.sortBy(array,by,map);},{key:function(args){return JSON.stringify([args[1],args[3]]);}});function parseEnums(enums){return Ox.map(enums,function(values){return values.map(function(value){return value.toLowerCase();});});}
|
|||
|
|
function parseConditions(conditions){return conditions.map(function(condition){var key=condition.key,operator=condition.operator,values=Ox.makeArray(condition.value);if(condition.conditions){condition.conditions=parseConditions(condition.conditions);}else{values=values.map(function(value){if(Ox.isString(value)){value=value.toLowerCase();}
|
|||
|
|
if(api.enums[key]&&(operator.indexOf('<')>-1||operator.indexOf('>')>-1)){value=api.enums[key].indexOf(value);}
|
|||
|
|
return value;});condition.value=Ox.isArray(condition.value)?values:values[0];}
|
|||
|
|
return condition;});}
|
|||
|
|
function parseSort(sort){return sort.map(function(sort){return Ox.isString(sort)?{key:sort.replace(/^[\+\-]/,''),operator:sort[0]=='-'?'-':'+'}:sort;});}
|
|||
|
|
function testCondition(item,condition){var key=condition.key,operator=condition.operator.replace('!',''),value=condition.value,not=condition.operator[0]=='!',itemValue=item[key],test={'=':function(a,b){return Ox.isArray(b)?a>=b[0]&&a<b[1]:Ox.isArray(a)?a.some(function(value){return value.indexOf(b)>-1;}):Ox.isString(a)?a.indexOf(b)>-1:a===b;},'==':function(a,b){return Ox.isArray(a)?a.some(function(value){return value===b;}):a===b;},'<':function(a,b){return a<b;},'<=':function(a,b){return a<=b;},'>':function(a,b){return a>b;},'>=':function(a,b){return a>=b;},'^':function(a,b){return Ox.startsWith(a,b);},'$':function(a,b){return Ox.endsWith(a,b);}};if(Ox.isString(itemValue)){itemValue=itemValue.toLowerCase();}else if(Ox.isArray(itemValue)&&Ox.isString(itemValue[0])){itemValue=itemValue.map(function(value){return value.toLowerCase();});}
|
|||
|
|
if(api.enums[key]&&(operator.indexOf('<')>-1||operator.indexOf('>')>-1)){itemValue=api.enums[key].indexOf(itemValue);}
|
|||
|
|
return test[operator](itemValue,value)==!not;}
|
|||
|
|
function testQuery(item,query){var match=true;Ox.forEach(query.conditions,function(condition){match=(condition.conditions?testQuery:testCondition)(item,condition);if((query.operator=='&'&&!match)||(query.operator=='|'&&match)){return false;}});return match;}
|
|||
|
|
return ret;};Ox.compact=function(array){return array.filter(function(value){return value!=null;});};Ox.find=function(array,string,leading){var matches=[[],[]];string=string.toLowerCase();array.forEach(function(value){var lowerCase=value.toLowerCase(),index=lowerCase.indexOf(string);index>-1&&matches[index==0?0:1][lowerCase==string?'unshift':'push'](value);});return leading?matches[0]:matches[0].concat(matches[1]);};Ox.flatten=function(array){var ret=[];array.forEach(function(value){if(Ox.isArray(value)){ret=ret.concat(Ox.flatten(value));}else{ret.push(value);}});return ret;};Ox.getIndex=function(array,key,value){return Ox.indexOf(array,function(obj){return obj[key]===value;});};Ox.getIndexById=function(array,id){return Ox.getIndex(array,'id',id);};Ox.getObject=function(array,key,value){var index=Ox.getIndex(array,key,value);return index>-1?array[index]:null;};Ox.getObjectById=function(array,id){return Ox.getObject(array,'id',id);};Ox.last=function(array,value){var ret;if(arguments.length==1){ret=array[array.length-1];}else{array[array.length-1]=value;ret=array;}
|
|||
|
|
return ret;};Ox.makeArray=function(value){var ret,type=Ox.typeOf(value);if(type=='arguments'||type=='nodelist'){ret=Ox.slice(value);}else if(type=='array'){ret=value;}else{ret=[value];}
|
|||
|
|
return ret;};Ox.nextValue=function(array,value,direction){var found=false,nextValue;direction=direction||1;direction==-1&&array.reverse();Ox.forEach(array,function(v){if(direction==1?v>value:v<value){nextValue=v;found=true;return false;}});direction==-1&&array.reverse();if(!found){nextValue=array[direction==1?0:array.length-1];}
|
|||
|
|
return nextValue;};Ox.range=function(){var array=[];Ox.loop.apply(null,Ox.slice(arguments).concat(function(index){array.push(index);}));return array;};(function(){var getSortValue=Ox.cache(function getSortValue(value){var sortValue=value;function trim(value){return value.replace(/^\W+(?=\w)/,'');}
|
|||
|
|
if(Ox.isEmpty(value)||Ox.isNull(value)||Ox.isUndefined(value)){sortValue=null;}else if(Ox.isString(value)){sortValue=trim(value.toLowerCase());Ox.forEach(['a','an','the'],function(article){if(new RegExp('^'+article+' ').test(sortValue)){sortValue=trim(sortValue.slice(article.length+1))
|
|||
|
|
+', '+sortValue.slice(0,article.length);return false;}});sortValue=sortValue.replace(/(\d),(?=(\d{3}))/g,'$1').replace(/\d+/g,function(match){return Ox.pad(match,'left',64,'0');});}
|
|||
|
|
return sortValue;},{key:function(args){return Ox.typeOf(args[0])+' '+args[0];}});Ox.sort=function(array,map){return array.sort(function(a,b){a=getSortValue(map?map(a):a);b=getSortValue(map?map(b):b);return a<b?-1:a>b?1:0;});};Ox.sortBy=function(array,by,map){var sortValues={};by=Ox.makeArray(by).map(function(value){return Ox.isString(value)?{key:value.replace(/^[\+\-]/,''),operator:value[0]=='-'?'-':'+'}:value;});map=map||{};return array.sort(function(a,b){var aValue,bValue,index=0,key,ret=0;while(ret==0&&index<by.length){key=by[index].key;aValue=getSortValue(map[key]?map[key](a[key],a):a[key]);bValue=getSortValue(map[key]?map[key](b[key],b):b[key]);if((aValue===null)!=(bValue===null)){ret=aValue===null?1:-1;}else if(aValue<bValue){ret=by[index].operator=='+'?-1:1;}else if(aValue>bValue){ret=by[index].operator=='+'?1:-1;}else{index++;}}
|
|||
|
|
return ret;});};}());Ox.unique=function(array){return Ox.filter(array,function(value,index){return array.indexOf(value)==index;});};Ox.zip=function(){var args=arguments.length==1?arguments[0]:Ox.slice(arguments),array=[];args[0].forEach(function(value,index){array[index]=[];args.forEach(function(value){array[index].push(value[index]);});});return array;};'use strict';Ox.char=String.fromCharCode;Ox.clean=function(string){return Ox.filter(Ox.map(string.split('\n'),function(string){return string.replace(/\s+/g,' ').trim()||'';})).join('\n');};Ox.codePointAt=function(string,index){var first,length=string.length,ret,second;if(index>=0&&index<length){first=string.charCodeAt(index);if(first<0xD800||first>0xDBFF||index==length-1){ret=first;}else{second=string.charCodeAt(index+1);ret=second<0xDC00||second>0xDFFF?first:((first-0xD800)*0x400)+(second-0xDC00)+0x10000;}}
|
|||
|
|
return ret;};Ox.endsWith=function(string,substring){string=string.toString();substring=substring.toString();return string.slice(string.length-substring.length)==substring;};Ox.fromCodePoint=function(){var ret='';Ox.forEach(arguments,function(number){if(number<0||number>0x10FFFF||!Ox.isInt(number)){throw new RangeError();}
|
|||
|
|
if(number<0x10000){ret+=String.fromCharCode(number);}else{number-=0x10000;ret+=String.fromCharCode((number>>10)+0xD800)
|
|||
|
|
+String.fromCharCode((number%0x400)+0xDC00);}});return ret;};Ox.isValidEmail=function(string){return!!/^[0-9A-Z\.\+\-_]+@(?:[0-9A-Z\-]+\.)+[A-Z]{2,64}$/i.test(string);};Ox.pad=function(string,position,length,padding){var hasPosition=Ox.isString(arguments[1]),isNumber=Ox.isNumber(arguments[0]),last=Ox.last(arguments);position=hasPosition?arguments[1]:isNumber?'left':'right';length=Math.max(hasPosition?arguments[2]:arguments[1],0);padding=Ox.isString(last)?last:isNumber&&position=='left'?'0':' ';string=string.toString();padding=Ox.repeat(padding,length-string.length);return position=='left'?(padding+string).slice(-length):(string+padding).slice(0,length);};Ox.parseDuration=function(string){return string.split(':').reverse().slice(0,4).reduce(function(p,c,i){return p+(parseFloat(c)||0)*(i==3?86400:Math.pow(60,i));},0);};Ox.parsePath=function(string){var matches=/^(.+\/)?(.+?(\..+)?)?$/.exec(string);return{pathname:matches[1]||'',filename:matches[2]||'',extension:matches[3]?matches[3].slice(1):''};};Ox.parseSRT=function(string,fps){return string.replace(/\r\n/g,'\n').trim().split('\n\n').map(function(block){var lines=block.split('\n'),points;if(lines.length<3){Ox.Log('Core','skip invalid srt block',lines);return{};}
|
|||
|
|
lines.shift();points=lines.shift().split(' --> ').map(function(point){return point.replace(',',':').split(':').reduce(function(previous,current,index){return previous+parseInt(current,10)*[3600,60,1,0.001][index];},0);});if(fps){points=points.map(function(point){return Math.round(point*fps)/fps;});}
|
|||
|
|
return{'in':points[0],out:points[1],text:lines.join('\n')};}).filter(function(block){return!Ox.isEmpty(block);});};Ox.parseURL=(function(){var a=document.createElement('a'),keys=['hash','host','hostname','origin','pathname','port','protocol','search'];return function(string){var ret={};a.href=string;keys.forEach(function(key){ret[key]=a[key];});return ret;};}());Ox.parseUserAgent=function(userAgent){var aliases={browser:{'Firefox':/(Fennec|Firebird|Iceweasel|Minefield|Namoroka|Phoenix|SeaMonkey|Shiretoko)/},system:{'BSD':/(FreeBSD|NetBSD|OpenBSD)/,'Linux':/(CrOS|MeeGo|webOS)/,'Unix':/(AIX|HP-UX|IRIX|SunOS)/}},names={browser:{'chromeframe':'Chrome Frame','MSIE':'Internet Explorer'},system:{'CPU OS':'iOS','iPhone OS':'iOS','Macintosh':'Mac OS X'}},regexps={browser:[/(Camino)\/(\d+)/,/(chromeframe)\/(\d+)/,/(Edge)\/(\d+)/,/(Chrome)\/(\d+)/,/(Epiphany)\/(\d+)/,/(Firefox)\/(\d+)/,/(Galeon)\/(\d+)/,/(Googlebot)\/(\d+)/,/(Konqueror)\/(\d+)/,/(MSIE) (\d+)/,/(Netscape)\d?\/(\d+)/,/(NokiaBrowser)\/(\d+)/,/(Opera) (\d+)/,/(Opera)\/.+Version\/(\d+)/,/(YandexBot)\/(\d+)/,/(YandexMobileBot)\/(\d+)/,/Version\/(\d+).+(Safari)/],system:[/(Android) (\d+)/,/(BeOS)/,/(BlackBerry) (\d+)/,/(Darwin)/,/(BSD) (FreeBSD|NetBSD|OpenBSD)/,/(CPU OS) (\d+)/,/(iPhone OS) (\d+)/,/(Linux).+(CentOS|CrOS|Debian|Fedora|Gentoo|Mandriva|MeeGo|Mint|Red Hat|SUSE|Ubuntu|webOS)/,/(CentOS|CrOS|Debian|Fedora|Gentoo|Mandriva|MeeGo|Mint|Red Hat|SUSE|Ubuntu|webOS).+(Linux)/,/(Linux)/,/(Mac OS X) (10.\d+)/,/(Mac OS X)/,/(Macintosh)/,/(SymbianOS)\/(\d+)/,/(SymbOS)/,/(OS\/2)/,/(Unix) (AIX|HP-UX|IRIX|SunOS)/,/(Unix)/,/(Windows) (NT \d\.\d)/,/(Windows) (95|98|2000|2003|ME|NT|XP)/,/(Windows).+(Win 9x 4\.90)/,/(Windows).+(Win9\d)/,/(Windows).+(WinNT4.0)/]},versions={browser:{},system:{'10.0':'10.0 (Cheetah)','10.1':'10.1 (Puma)','10.2':'10.2 (Jaguar)','10.3':'10.3 (Panther)','10.4':'10.4 (Tiger)','10.5':'10.5 (Leopard)','10.6':'10.6 (Snow Leopard)','10.7':'10.7 (Lion)','10.8':'10.8 (Mountain Lion)','10.9':'10.9 (Mavericks)','10.10':'10.10 (Yosemite)','10.11':'10.11 (El Capitan)','10.12':'10.12 (Sierra)','10.13':'10.13 (High Sierra)','CrOS':'Chrome OS','NT 4.0':'NT 4.0 (Windows NT)','NT 4.1':'NT 4.1 (Windows 98)','Win 9x 4.90':'NT 4.9 (Windows ME)','NT 5.0':'NT 5.0 (Windows 2000)','NT 5.1':'NT 5.1 (Windows XP)','NT 5.2':'NT 5.2 (Windows 2003)','NT 6.0':'NT 6.0 (Windows Vista)','NT 6.1':'NT 6.1 (Windows 7)','NT 6.2':'NT 6.2 (Windows 8)','NT 6.3':'NT 6.3 (Windows 8.1)','NT 6.4':'NT 6.4 (Windows 10)','95':'NT 4.0 (Windows 95)','NT':'NT 4.0 (Windows NT)','98':'NT 4.1 (Windows 98)','ME':'NT 4.9 (Windows ME)','2000':'NT 5.0 (Windows 2000)','2003':'NT 5.2 (Windows 2003)','XP':'NT 5.1 (Windows XP)','Win95':'NT 4.0 (Windows 95)','WinNT4.0':'NT 4.0 (Windows NT)','Win98':'NT 4.1 (Windows 98)'}},userAgentData={};Ox.forEach(regexps,function(regexps,key){userAgentData[key]={name:'',string:'',version:''};Ox.forEach(aliases[key],function(regexp,alias){userAgent=userAgent.replace(regexp,key=='browser'?alias:alias+' $1');});Ox.forEach(regexps,function(regexp){var matches=userAgent.match(regexp),name,string,swap,version;if(matches){matches[2]=matches[2]||'';swap=matches[1].match(/^\d/)||matches[2]=='Linux';name=matches[swap?2:1];version=matches[swap?1:2].replace('_','.');name=names[key][name]||name,version=versions[key][version]||version;string=name;if(version){string+=' '+(['BSD','Linux','Unix'].indexOf(name)>-1?'('+version+')':version);}
|
|||
|
|
userAgentData[key]={name:names[name]||name,string:string,version:versions[version]||version};return false;}});});return userAgentData;};Ox.repeat=function(value,times){var ret;if(Ox.isArray(value)){ret=[];Ox.loop(times,function(){ret=ret.concat(value);});}else{ret=times>=1?new Array(times+1).join(value.toString()):'';}
|
|||
|
|
return ret;};Ox.splice=function(string,index,remove){var array=string.split('');Array.prototype.splice.apply(array,Ox.slice(arguments,1));return array.join('');};Ox.startsWith=function(string,substring){string=string.toString();substring=substring.toString();return string.slice(0,substring.length)==substring;};Ox.toCamelCase=function(string){return string.replace(/[\-\/_][a-z]/g,function(string){return string[1].toUpperCase();});};Ox.toDashes=function(string){return string.replace(/[A-Z]/g,function(string){return'-'+string.toLowerCase();});};Ox.toSlashes=function(string){return string.replace(/[A-Z]/g,function(string){return'/'+string.toLowerCase();});};Ox.toTitleCase=function(string){return string.split(' ').map(function(value){var substring=value.slice(1),lowercase=substring.toLowerCase();if(substring==lowercase){value=value.slice(0,1).toUpperCase()+lowercase;}
|
|||
|
|
return value;}).join(' ');};Ox.toUnderscores=function(string){return string.replace(/[A-Z]/g,function(string){return'_'+string.toLowerCase();});};Ox.truncate=function(string,position,length,padding){var hasPosition=Ox.isString(arguments[1]),last=Ox.last(arguments);position=hasPosition?arguments[1]:'right';length=hasPosition?arguments[2]:arguments[1];padding=Ox.isString(last)?last:'…';if(string.length>length){if(position=='left'){string=padding
|
|||
|
|
+string.slice(padding.length+string.length-length);}else if(position=='center'){string=string.slice(0,Math.ceil((length-padding.length)/2))
|
|||
|
|
+padding
|
|||
|
|
+string.slice(-Math.floor((length-padding.length)/2));}else if(position=='right'){string=string.slice(0,length-padding.length)+padding;}}
|
|||
|
|
return string;};Ox.words=function(string){var array=string.toLowerCase().split(/\b/),length=array.length,startsWithWord=/\w/.test(array[0]);array.forEach(function(v,i){if(i>0&&i<length-1&&(v=='-'||v=='\'')){array[i+1]=array[i-1]+array[i]+array[i+1];array[i-1]=array[i]='';}});array=array.filter(function(v){return v.length;});return array.filter(function(v,i){return i%2==!startsWithWord;});};Ox.wordwrap=function(string,length){var balanced,lines,max,newline,words;string=String(string);length=length||80;balanced=Ox.isBoolean(arguments[2])?arguments[2]:Ox.isBoolean(arguments[3])?arguments[3]:false;newline=Ox.isString(arguments[2])?arguments[2]:Ox.isString(arguments[3])?arguments[3]:'\n';words=string.split(' ');if(balanced){lines=Ox.wordwrap(string,length,newline).split(newline);if(lines.length>1){max=Ox.max(words.map(function(word){return word.length;}));while(length>max){if(Ox.wordwrap(string,--length,newline).split(newline).length>lines.length){length++;break;}}}}
|
|||
|
|
lines=[''];words.forEach(function(word){var index;if((lines[lines.length-1]+word).length<=length){lines[lines.length-1]+=word+' ';}else{if(word.length<=length){lines.push(word+' ');}else{index=length-lines[lines.length-1].length;lines[lines.length-1]+=word.slice(0,index);while(index<word.length){lines.push(word.substr(index,length));index+=length;}
|
|||
|
|
lines[lines.length-1]+=' ';}}});return lines.join(newline).trim();};'use strict';Ox.checkType=function(value,type){if(!Ox.contains(Ox.makeArray(type),Ox.typeOf(value))){throw new TypeError();}};Ox.isArguments=function(value){return Ox.typeOf(value)=='arguments';};Ox.isArray=function(value){return Ox.typeOf(value)=='array';};Ox.isBoolean=function(value){return Ox.typeOf(value)=='boolean';};Ox.isDate=function(value){return Ox.typeOf(value)=='date';};Ox.isElement=function(value){return Ox.endsWith(Ox.typeOf(value),'element');};Ox.isEmpty=function(value){return Ox.len(value)===0;};Ox.isEqual=function(a,b){var ret=false,type=Ox.typeOf(a);if(a===b){ret=a!==0||1/a===1/b;}else if(type==Ox.typeOf(b)){if(a==b||a!==a){ret=true;}else if(type=='date'){ret=+a==+b;}else if(type=='element'){ret=a.isEqualNode(b);}else if(type=='regexp'){ret=a.toString()==b.toString();}else if((type=='arguments'||type=='array'||type=='object')&&Ox.len(a)==Ox.len(b)){ret=true;Ox.forEach(a,function(value,key){ret=Ox.isEqual(value,b[key]);return ret;});}}
|
|||
|
|
return ret;};Ox.isError=function(value){return Ox.typeOf(value)=='error';};Ox.isFunction=function(value){return Ox.typeOf(value)=='function';};Ox.isInfinity=function(value){return Ox.typeOf(value)=='number'&&!isFinite(value)&&!Ox.isNaN(value);};Ox.isInt=function(value){return isFinite(value)&&value===Math.floor(value);};Ox.isInvalidDate=function(value){return Ox.isDate(value)&&Ox.isNaN(value.getTime());};Ox.isNaN=function(value){return value!==value;};Ox.isNodeList=function(value){return Ox.typeOf(value)=='nodelist';};Ox.isNull=function(value){return Ox.typeOf(value)=='null';};Ox.isNumber=function(value){return Ox.typeOf(value)=='number';};Ox.isObject=function(value){return Ox.typeOf(value)=='object';};Ox.isPrimitive=function(value){return Ox.contains(['boolean','null','number','string','undefined'],Ox.typeOf(value));};Ox.isRegExp=function(value){return Ox.typeOf(value)=='regexp';};Ox.isString=function(value){return Ox.typeOf(value)=='string';};Ox.isUndefined=function(value){return Ox.typeOf(value)=='undefined';};Ox.isValidDate=function(value){return Ox.isDate(value)&&!Ox.isNaN(value.getTime());};Ox.typeOf=function(value){return Object.prototype.toString.call(value).slice(8,-1).toLowerCase();};if(Ox.typeOf((function(){return arguments;}()))!='arguments'||Ox.typeOf(document.getElementsByTagName('a'))!='nodelist'||Ox.typeOf(null)!='null'||Ox.typeOf(window)!='global'||Ox.typeOf()!='undefined'){Ox.typeOf=function(value){var type=Object.prototype.toString.call(value).slice(8,-1).toLowerCase();if(value===null){type='null';}else if(value===void 0){type='undefined';}else if(value===window){type='global';}else if(type=='object'&&typeof value.callee=='function'){type='arguments';}else if(type=='htmlcollection'||(type=='object'&&typeof value.item!='undefined'&&typeof value.length=='number')){type='nodelist';}
|
|||
|
|
return type;};}
|
|||
|
|
'use strict';Ox.avg=function(collection){return Ox.sum(collection)/Ox.len(collection);};Ox.clone=function(collection,deep){var ret,type=Ox.typeOf(collection);if(type!='array'&&type!='object'){ret=collection;}else if(deep){ret=type=='array'?[]:{};Ox.forEach(collection,function(value,key){type=Ox.typeOf(value);ret[key]=type=='array'||type=='object'?Ox.clone(value,true):value;});}else{ret=type=='array'?collection.slice():Ox.extend({},collection);}
|
|||
|
|
return ret;};Ox.contains=function(collection,value){var type=Ox.typeOf(collection);return(type=='nodelist'||type=='object'?Ox.values(collection):collection).indexOf(value)>-1;};Ox.count=function(collection,value){var count={};Ox.forEach(collection,function(value){count[value]=(count[value]||0)+1;});return value?count[value]||0:count;};Ox.every=function(collection,iterator,that){iterator=iterator||Ox.identity;return Ox.forEach(collection,function(value,key,collection){return!!iterator.call(that,value,key,collection);})==Ox.len(collection);};Ox.filter=function(collection,iterator,that){var ret,type=Ox.typeOf(collection);iterator=iterator||Ox.identity;if(type=='object'||type=='storage'){ret={};Ox.forEach(collection,function(value,key){if(iterator.call(that,value,key,collection)){ret[key]=value;}});}else{ret=Ox.slice(collection).filter(iterator,that);if(type=='string'){ret=ret.join('');}}
|
|||
|
|
return ret;};Ox.forEach=function(collection,iterator,that){var i=0,key,type=Ox.typeOf(collection);if(type=='object'||type=='storage'){for(key in collection){if(Ox.hasOwn(collection,key)&&iterator.call(that,collection[key],key,collection)===false){break;}
|
|||
|
|
i++;}}else{collection=Ox.slice(collection);for(i=0;i<collection.length;i++){if(i in collection&&iterator.call(that,collection[i],i,collection)===false){break;}}}
|
|||
|
|
return i;};Ox.indexOf=function(collection,test){var index=Ox.forEach(collection,function(value){return!test(value);});return Ox.isObject(collection)?Object.keys(collection)[index]||null:index==collection.length?-1:index;};Ox.indicesOf=function(collection,test){var ret=[];Ox.forEach(collection,function(value,index){test(value)&&ret.push(index);});return ret;};Ox.len=function(collection){var ret,type=Ox.typeOf(collection);if(type=='arguments'||type=='array'||type=='nodelist'||type=='string'){ret=collection.length;}else if(type=='object'||type=='storage'){ret=Object.keys(collection).length;}
|
|||
|
|
return ret;};Ox.map=function(collection,iterator,that){var ret,type=Ox.typeOf(collection);if(type=='object'||type=='storage'){ret={};Ox.forEach(collection,function(value,key){ret[key]=iterator.call(that,value,key,collection);});}else{ret=Ox.slice(collection).map(iterator);if(type=='string'){ret=ret.join('');}}
|
|||
|
|
return ret;};Ox.max=function(collection){var ret,values=Ox.values(collection);if(values.length<Ox.STACK_LENGTH){ret=Math.max.apply(null,values);}else{ret=values.reduce(function(previousValue,currentValue){return Math.max(previousValue,currentValue);},-Infinity);}
|
|||
|
|
return ret;};Ox.min=function(collection){var ret,values=Ox.values(collection);if(values.length<Ox.STACK_LENGTH){ret=Math.min.apply(null,values);}else{ret=values.reduce(function(previousValue,currentValue){return Math.min(previousValue,currentValue);},Infinity);}
|
|||
|
|
return ret;};Ox.numberOf=function(collection,test){return Ox.len(Ox.filter(collection,test));};Ox.remove=function(collection,element){var ret,key;if(Ox.isArray(collection)){key=collection.indexOf(element);if(key>-1){ret=collection.splice(key,1)[0];}}else{key=Ox.keyOf(collection,element);if(key){ret=collection[key];delete collection[key];}}
|
|||
|
|
return ret;};Ox.reverse=function(collection){return Ox.isArray(collection)?Ox.clone(collection).reverse():collection.toString().split('').reverse().join('');};Ox.shuffle=function(collection){var keys,ret,type=Ox.typeOf(collection),values;if(type=='object'||type=='storage'){keys=Object.keys(collection);values=Ox.shuffle(Ox.values(collection));ret={};keys.forEach(function(key,index){ret[key]=values[index];});}else{ret=[];Ox.slice(collection).forEach(function(value,index){var random=Math.floor(Math.random()*(index+1));ret[index]=ret[random];ret[random]=value;});if(type=='string'){ret=ret.join('');}}
|
|||
|
|
return ret;};Ox.slice=Ox.toArray=function(collection,start,stop){return Array.prototype.slice.call(collection,start,stop);};if(Ox.slice([0]).length==0||Ox.slice('0')[0]===null||Ox.slice('0')[0]===void 0||!(function(){try{return Ox.slice(document.getElementsByTagName('a'));}catch(error){}}())){Ox.slice=Ox.toArray=function(collection,start,stop){var args=stop===void 0?[start]:[start,stop],array=[],index,length,ret;if(Ox.typeOf(collection)=='string'){collection=collection.split('');}
|
|||
|
|
try{ret=Array.prototype.slice.apply(collection,args);}catch(error){length=collection.length;for(index=0;index<length;index++){array[index]=collection[index];}
|
|||
|
|
ret=Array.prototype.slice.apply(array,args);}
|
|||
|
|
return ret;};}
|
|||
|
|
Ox.some=function(collection,iterator,that){iterator=iterator||Ox.identity;return Ox.forEach(collection,function(value,key,collection){return!iterator.call(that,value,key,collection);})<Ox.len(collection);};Ox.sum=function(collection){var ret=0;collection=arguments.length>1?Ox.slice(arguments):collection;Ox.forEach(collection,function(value){value=+value;ret+=isFinite(value)?value:0;});return ret;};Ox.values=function(collection){var ret,type=Ox.typeOf(collection);if(type=='array'||type=='nodelist'){ret=Ox.slice(collection);}else if(type=='object'||type=='storage'){ret=[];Ox.forEach(collection,function(value){ret.push(value);});}else if(type=='string'){ret=collection.split('');}
|
|||
|
|
return ret;};Ox.walk=function(collection,iterator,that,keys){keys=keys||[];Ox.forEach(collection,function(value,key){var keys_=keys.concat(key);iterator.call(that,value,keys_,collection);Ox.walk(collection[key],iterator,that,keys_);});};'use strict';Ox.acosh=function(x){return Math.log(x+Math.sqrt(x*x-1));};Ox.asinh=function(x){return Math.log(x+Math.sqrt(x*x+1));};Ox.atanh=function(x){return 0.5*Math.log((1+x)/(1-x));};Ox.cosh=function(x){return(Math.exp(x)+Math.exp(-x))/2;};Ox.deg=function(rad){return rad*180/Math.PI;};Ox.hypot=function(){return Math.sqrt(Ox.slice(arguments).reduce(function(sum,number){return sum+number*number;},0));};Ox.limit=function(){var number=arguments[0],min=arguments.length==3?arguments[1]:-Infinity,max=arguments[arguments.length-1];return Math.min(Math.max(number,min),max);};Ox.log=function(number,base){return Math.log(number)/Math.log(base||Math.E);};Ox.mod=function(number,by){return(number%by+by)%by;};Ox.rad=function(deg){return deg*Math.PI/180;};Ox.random=function(){var min=arguments.length==2?arguments[0]:0,max=arguments.length?Ox.last(arguments):2;return min+Math.floor(Math.random()*(max-min));};Ox.round=function(number,decimals){var pow=Math.pow(10,decimals||0);return Math.round(number*pow)/pow;};Ox.sign=function(x){x=+x;return x!==x||x===0?x:x<0?-1:1;};Ox.sinh=function(x){return(Math.exp(x)-Math.exp(-x))/2;};Ox.splitInt=function(number,by){var div=Math.floor(number/by),mod=number%by;return Ox.range(by).map(function(i){return div+(i>by-1-mod);});};Ox.tanh=function(x){return(Math.exp(x)-Math.exp(-x))/(Math.exp(x)+Math.exp(-x));};Ox.trunc=function(x){return~~x;};'use strict';(function(){function asyncMap(forEach,collection,iterator,that,callback){var type=Ox.typeOf(collection),results=type=='object'?{}:[];callback=Ox.last(arguments);that=arguments.length==5?that:null;forEach(collection,function(value,key,collection,callback){iterator(value,key,collection,function(value){results[key]=value;callback();});},that,function(){callback(type=='string'?results.join(''):results);});}
|
|||
|
|
Ox.asyncMap=function(array,iterator,that,callback){array=Ox.makeArray(array);callback=Ox.last(arguments);that=arguments.length==4?that:null;if(array.some(Ox.isArray)){Ox.serialMap(array,function(value,key,array,callback){Ox.parallelMap(Ox.makeArray(value),iterator,callback);},callback);}else{Ox.parallelMap(array,iterator,callback);}};Ox.nonblockingForEach=function(collection,iterator,that,callback,ms){var i=0,keys,last=Ox.last(arguments),n,time,type=Ox.typeOf(collection);callback=Ox.isFunction(last)?last:arguments[arguments.length-2];collection=type=='array'||type=='object'?collection:Ox.slice(collection);keys=type=='object'?Object.keys(collection):Ox.range(collection.length);ms=ms||1000;n=Ox.len(collection);that=arguments.length==5||(arguments.length==4&&Ox.isFunction(last))?that:null;time=+new Date();iterate();function iterate(){Ox.forEach(keys.slice(i),function(key){if(key in collection){if(iterator.call(that,collection[key],key,collection)===false){i=n;return false;}}
|
|||
|
|
i++;if(+new Date()>=time+ms){return false;}});if(i<n){setTimeout(function(){time=+new Date();iterate();},1);}else{callback();}}};Ox.nonblockingMap=function(collection,iterator,that,callback,ms){var last=Ox.last(arguments),type=Ox.typeOf(collection),results=type=='object'?{}:[];callback=Ox.isFunction(last)?last:arguments[arguments.length-2];that=arguments.length==5||(arguments.length==4&&Ox.isFunction(last))?that:null;Ox.nonblockingForEach(collection,function(value,key,collection){results[key]=iterator.call(that,value,key,collection);},function(){callback(type=='string'?results.join(''):results);},ms);};Ox.parallelForEach=function(collection,iterator,that,callback){var i=0,n,type=Ox.typeOf(collection);callback=callback||(arguments.length==3?arguments[2]:Ox.noop);collection=type=='array'||type=='object'?collection:Ox.slice(collection);n=Ox.len(collection);that=arguments.length==4?that:null;Ox.forEach(collection,function(value,key,collection){iterator.call(that,value,key,collection,function(){++i==n&&callback();});});};Ox.parallelMap=function(){asyncMap.apply(null,[Ox.parallelForEach].concat(Ox.slice(arguments)));};Ox.serialForEach=function(collection,iterator,that,callback){var i=0,keys,n,type=Ox.typeOf(collection);callback=callback||(arguments.length==3?arguments[2]:Ox.noop);collection=type=='array'||type=='object'?collection:Ox.slice(collection);keys=type=='object'?Object.keys(collection):Ox.range(collection.length);n=Ox.len(collection);that=arguments.length==4?that:null;iterate();function iterate(value){if(value!==false){if(keys[i]in collection){iterator.call(that,collection[keys[i]],keys[i],collection,++i<n?iterate:callback);}else{++i<n?iterate():callback();}}else{callback();}}};Ox.serialMap=function(collection,iterator,that,callback){asyncMap.apply(null,[Ox.serialForEach].concat(Ox.slice(arguments)));};}());'use strict';Ox.hsl=function(rgb){var hsl=[0,0,0],max,min;if(arguments.length==3){rgb=Ox.slice(arguments);}
|
|||
|
|
rgb=Ox.clone(rgb).map(function(value){return value/255;});max=Ox.max(rgb);min=Ox.min(rgb);hsl[2]=0.5*(max+min);if(max==min){hsl[0]=0;hsl[1]=0;}else{if(max==rgb[0]){hsl[0]=(60*(rgb[1]-rgb[2])/(max-min)+360)%360;}else if(max==rgb[1]){hsl[0]=60*(rgb[2]-rgb[0])/(max-min)+120;}else if(max==rgb[2]){hsl[0]=60*(rgb[0]-rgb[1])/(max-min)+240;}
|
|||
|
|
if(hsl[2]<=0.5){hsl[1]=(max-min)/(2*hsl[2]);}else{hsl[1]=(max-min)/(2-2*hsl[2]);}}
|
|||
|
|
return hsl;};Ox.rgb=function(hsl){var rgb=[0,0,0],v1,v2,v3;if(arguments.length==3){hsl=Ox.slice(arguments);}
|
|||
|
|
hsl=Ox.clone(hsl);hsl[0]/=360;if(hsl[1]==0){rgb=[hsl[2],hsl[2],hsl[2]];}else{if(hsl[2]<0.5){v2=hsl[2]*(1+hsl[1]);}else{v2=hsl[1]+hsl[2]-(hsl[1]*hsl[2]);}
|
|||
|
|
v1=2*hsl[2]-v2;rgb.forEach(function(v,i){v3=hsl[0]+(1-i)*1/3;if(v3<0){v3++;}else if(v3>1){v3--;}
|
|||
|
|
if(v3<1/6){rgb[i]=v1+((v2-v1)*6*v3);}else if(v3<0.5){rgb[i]=v2;}else if(v3<2/3){rgb[i]=v1+((v2-v1)*6*(2/3-v3));}else{rgb[i]=v1;}});}
|
|||
|
|
return rgb.map(function(value){return Math.round(value*255);});};Ox.toHex=function(rgb){return rgb.map(function(value){return Ox.pad(value.toString(16).toUpperCase(),'left',2,'0');}).join('');};Ox.toRGB=function(hex){return Ox.range(3).map(function(index){return parseInt(hex.substr(index*2,2),16);});};'use strict';Ox.AMPM=['AM','PM'];Ox.BASE_32_ALIASES={'I':'1','L':'1','O':'0','U':'V'},Ox.BASE_32_DIGITS='0123456789ABCDEFGHJKMNPQRSTVWXYZ';Ox.BCAD=['BC','AD'];Ox.EARTH_RADIUS=6378137;Ox.EARTH_CIRCUMFERENCE=2*Math.PI*Ox.EARTH_RADIUS;Ox.EARTH_SURFACE=4*Math.PI*Math.pow(Ox.EARTH_RADIUS,2);Ox.HTML_ENTITIES={'"':'"','&':'&',"'":''','<':'<','>':'>'};Ox.KEYS={0:'section',8:'backspace',9:'tab',12:'clear',13:'enter',16:'shift',17:'control',18:'alt',20:'capslock',27:'escape',32:'space',33:'pageup',34:'pagedown',35:'end',36:'home',37:'left',38:'up',39:'right',40:'down',45:'insert',46:'delete',47:'help',48:'0',49:'1',50:'2',51:'3',52:'4',53:'5',54:'6',55:'7',56:'8',57:'9',65:'a',66:'b',67:'c',68:'d',69:'e',70:'f',71:'g',72:'h',73:'i',74:'j',75:'k',76:'l',77:'m',78:'n',79:'o',80:'p',81:'q',82:'r',83:'s',84:'t',85:'u',86:'v',87:'w',88:'x',89:'y',90:'z',91:'meta.left',92:'meta.right',93:'meta.right',96:'0.numpad',97:'1.numpad',98:'2.numpad',99:'3.numpad',100:'4.numpad',101:'5.numpad',102:'6.numpad',103:'7.numpad',104:'8.numpad',105:'9.numpad',106:'asterisk.numpad',107:'plus.numpad',109:'minus.numpad',108:'enter.numpad',110:'dot.numpad',111:'slash.numpad',112:'f1',113:'f2',114:'f3',115:'f4',116:'f5',117:'f6',118:'f7',119:'f8',120:'f9',121:'f10',122:'f11',123:'f12',124:'f13',125:'f14',126:'f15',127:'f16',128:'f17',129:'f18',130:'f19',131:'f20',144:'numlock',145:'scrolllock',186:'semicolon',187:'equal',188:'comma',189:'minus',190:'dot',191:'slash',192:'backtick',219:'openbracket',220:'backslash',221:'closebracket',222:'quote',224:'meta'};Ox.LOCALE='en';Ox.LOCALE_NAMES={'ar':'العربية','de':'Deutsch','el':'Ελληνικά','en':'English','fr':'Français','hi':'हिन्दी'};Ox.LOCALES={"Geo":["de","ar"],"Ox":["de","el","hi","ar"],"UI":["de","el","hi","ar"]};Ox.MAX_LATITUDE=Ox.deg(Math.atan(Ox.sinh(Math.PI)));Ox.MIN_LATITUDE=-Ox.MAX_LATITUDE;Ox.MODIFIER_KEYS={altKey:'alt',ctrlKey:'control',shiftKey:'shift',metaKey:'meta'};Ox.MONTHS=['January','February','March','April','May','June','July','August','September','October','November','December'];Ox.SHORT_MONTHS=Ox.MONTHS.map(function(val){return val.slice(0,3);});Ox.PATH=(function(){var index,regexp=/Ox\.js(\?.+|)$/,scripts=document.getElementsByTagName('script'),src;for(index=scripts.length-1;index>=0;index--){src=scripts[index].src;if(regexp.test(src)){return src.replace(regexp,'');}}}());Ox.MODE=Ox.PATH.slice(0,-1).split('/').pop();Ox.PREFIXES=['','K','M','G','T','P'];Ox.SEASONS=['Winter','Spring','Summer','Fall'];Ox.STACK_SIZE=65536;Ox.SYMBOLS={dollar:'\u0024',cent:'\u00A2',pound:'\u00A3',currency:'\u00A4',yen:'\u00A5',bullet:'\u2022',ellipsis:'\u2026',permille:'\u2030',colon:'\u20A1',cruzeiro:'\u20A2',franc:'\u20A3',lira:'\u20A4',naira:'\u20A6',peseta:'\u20A7',won:'\u20A9',sheqel:'\u20AA',dong:'\u20AB',euro:'\u20AC',kip:'\u20AD',tugrik:'\u20AE',drachma:'\u20AF',peso:'\u20B1',guarani:'\u20B2',austral:'\u20B3',hryvnia:'\u20B4',cedi:'\u20B5',tenge:'\u20B8',rupee:'\u20B9',celsius:'\u2103',fahrenheit:'\u2109',pounds:'\u2114',ounce:'\u2125',ohm:'\u2126',kelvin:'\u212A',angstrom:'\u212B',info:'\u2139',arrow_left:'\u2190',arrow_up:'\u2191',arrow_right:'\u2192',arrow_down:'\u2193',home:'\u2196',end:'\u2198','return':'\u21A9',redo:'\u21BA',undo:'\u21BB',page_up:'\u21DE',page_down:'\u21DF',tab:'\u21E5',shift:'\u21E7',capslock:'\u21EA',infinity:'\u221E',control:'\u2303',command:'\u2318',enter:'\u2324',alt:'\u2325','delete':'\u2326',clear:'\u2327',backspace:'\u232B',option:'\u2387',navigate:'\u2388',escape:'\u238B',eject:'\u23CF',space:'\u2423',triangle_up:'\u25B2',triangle_right:'\u25BA',triangle_down:'\u25BC',select:'\u25BE',triangle_left:'\u25C0',diamond:'\u25C6',black_star:'\u2605',white_star:'\u2606',burn:'\u2622',sound:'\u266B',trash:'\u267A',flag:'\u2691',anchor:'
|
|||
|
|
function normalizeEvents(args){var ret={};Ox.forEach(Ox.makeObject(args),function(callback,event){if(Ox.contains(mousewheelEvents,event)){originalMousewheelEvents.forEach(function(event){ret[event]=callback;});}else{ret[event]=callback;}});return ret;}
|
|||
|
|
return elements.length?Ox.extend(Ox.zipObject(Ox.range(elements.length),elements),{add:function add($other){elements=Ox.unique(elements.concat($other.elements()));this.length=elements.length;return this;},addClass:function addClass(string){string=Ox.clean(string);elements.forEach(function(element){element.className=Ox.unique(((element.className?element.className+' ':'')+string).split(' ')).join(' ');});return this;},append:function append(){var $others=Ox.slice(arguments);elements.forEach(function(element){$others.forEach(function($other){getElements($other).forEach(function(otherElement){element.appendChild(otherElement);});});});return this;},appendTo:function appendTo($other){getElements($other).forEach(function(otherElement){elements.forEach(function(element){otherElement.appendChild(element);});});return this;},attr:function attr(){var args=arguments,ret;if(args.length==1&&Ox.isString(args[0])){ret=this[0].getAttribute?this[0].getAttribute(args[0]):void 0;return ret===null?void 0:ret;}else{args=Ox.makeObject(args);elements.forEach(function(element){Ox.forEach(args,function(value,key){if(element.setAttribute&&!Ox.contains([false,null,void 0],value)){element.setAttribute(key,value);}});});return this;}},children:function children(selector){var children=Ox.unique(Ox.flatten(elements.map(function(element){return Ox.slice(element.childNodes);})));return Ox.$(selector?children.filter(function(child){return Ox.$(child).is(selector);}):children);},css:function css(){var args=arguments;if(args.length==1&&Ox.isString(args[0])){return elements[0].style[args[0]];}else{elements.forEach(function(element){Ox.forEach(Ox.makeObject(args),function(value,key){element.style[key]=value;});});return this;}},data:function data(){var args;if(arguments.length==1&&Ox.isString(arguments[0])){return element.getAttribute('data-'+arguments[0]);}else{args=Ox.makeObject(arguments);elements.forEach(function(element){Ox.forEach(args,function(value,key){element.setAttribute('data-'+key,value);});});return this;}},elements:elements,eq:function eq(){var that=this;Ox.loop(1,this.length,function(index){delete that[index];});this.elements=[this.elements[index]];this.length=1;return this;},empty:function empty(){return this.html('');},every:function every(){return Array.prototype.every.apply(elements,arguments);},filter:function filter(){return Array.prototype.filter.apply(elements,arguments);},find:function find(selector){return Ox.$(Ox.unique(Ox.flatten(elements.map(function(element){return Ox.slice(element.querySelectorAll(selector||'*'));}))));},forEach:function forEach(){Array.prototype.forEach.apply(elements,arguments);return this;},hasClass:function hasClass(string){return elements.some(function(element){return Ox.contains(element.className.split(' '),string);});},height:function height(){return elements[0][elements[0]==document?'height':elements[0]==window?'innerHeight':'offsetHeight'];},hide:function hide(){previousDisplay=this.css('display');return this.css({display:'none'});},html:function html(string){var html='';if(arguments.length==0){elements.forEach(function(element){html+=element.innerHTML;})
|
|||
|
|
return html;}else{elements.forEach(function(element){element.innerHTML=string;});return this;}},insertAfter:function insertAfter($other){var nextSibling=$other[0].nextSibling;elements.forEach(function(element){$other[0].parentNode.insertBefore(element,nextSibling);})
|
|||
|
|
return this;},insertBefore:function insertBefore($other){elements.forEach(function(element){$other[0].parentNode.insertBefore(element,$other[0]);});return this;},is:function is(selector){return elements.some(function(element){var parent=element.parentNode;if(!parent){parent=document.createElement('div');parent.appendChild(element);}
|
|||
|
|
return Ox.contains(parent.querySelectorAll(selector),element);});},length:elements.length,map:function map(){return Array.prototype.map.apply(elements,arguments);},next:function next(){return Ox.$(Ox.unique(Ox.filter(elements.map(function(element){return element.nextSibling;}))));},nextAll:function nextAll(){var siblings=[];elements.forEach(function(element){var sibling=element;while(true){sibling=sibling.nextSibling;if(!sibling){break;}
|
|||
|
|
siblings.push(sibling);}});return Ox.$(Ox.unique(siblings));},off:function off(event,callback){var args=normalizeEvents(arguments);elements.forEach(function(element){Ox.forEach(args,function(callback,event){if(callback){element.removeEventListener(event,callback,false);}else{element['on'+event]=null;}});});return this;},on:function on(){var args=normalizeEvents(arguments);elements.forEach(function(element){Ox.forEach(args,function(callback,event){element.addEventListener(event,callback,false);});});return this;},one:function one(events){var args=Ox.slice(arguments),that=this;Ox.forEach(normalizeEvents(arguments),function(callback,event){that.on(event,function fn(){that.off(event,fn);return callback.apply(that,args);});});return this;},parent:function parent(){return Ox.$(Ox.unique(Ox.compact(elements.map(function(element){return element.parentNode;}))));},parents:function parents(selector){var parents=[];Ox.reverse(elements).forEach(function(element){var parent=element;while(true){parent=parent.parentNode;if(!parent||parent==document){break;}
|
|||
|
|
parents.unshift(parent);}});parents=Ox.unique(parents);return Ox.$(selector?parents.filter(function(parent){return Ox.$(parent).is(selector);}):parents);},prepend:function prepend(){var $others=Ox.slice(arguments).reverse();elements.forEach(function(element){var parent=element.parentNode;$others.forEach(function($other){getElements($other).forEach(function(otherElement){parent.insertBefore(otherElement,parent.firstChild);});});});return this;},prependTo:function prependTo($other){getElements($other).forEach(function(otherElement){var firstChild=otherElement.firstChild
|
|||
|
|
elements.forEach(function(element){otherElement.insertBefore(element,firstChild);});});return this;},prev:function prev(){return Ox.$(Ox.unique(Ox.filter(elements.map(function(element){return element.previousSibling;}))));},prevAll:function prevAll(){var siblings=[];Ox.reverse(elements).forEach(function(element){var sibling=element;while(true){sibling=sibling.previousSibling;if(!sibling){break;}
|
|||
|
|
siblings.unshift(sibling);}});return Ox.$(Ox.unique(siblings));},reduce:function reduce(){return Array.prototype.reduce.apply(elements,arguments);},remove:function remove(){elements.forEach(function(element){if(element.parentNode){element.parentNode.removeChild(element);}});return this;},removeAttr:function removeAttr(){var keys=Ox.makeArray(arguments);elements.forEach(function(element){keys.forEach(function(key){element.removeAttribute(key);});});return this;},removeClass:function removeClass(string){var classNames=Ox.clean(string).split(' ');elements.forEach(function(element){element.className=element.className.split(' ').filter(function(className){return!Ox.contains(classNames,className)}).join(' ');});return this;},replace:function replace($other){getElements($other).forEach(function(otherElement){var parent=otherElement.parentNode,sibling=otherElement.nextSibling;if(parent){parent.removeChild(otherElement);elements.forEach(function(element){parent.insertBefore(element,sibling)});}});return this;},replaceWith:function replaceWith($other){elements.forEach(function(element){var parent=element.parentNode,sibling=element.nextSibling;if(parent){parent.removeChild(element);getElements($other).forEach(function(otherElement){parent.insertBefore(otherElement,sibling);});}});return this;},show:function show(){return this.css({display:previousDisplay||'block'});},siblings:function siblings(selector){var siblings=Ox.unique(elements.map(function(element){return Ox.filter(element.parentNode.childNodes,function(sibling){return sibling!==element;});}));return Ox.$(selector?siblings.filter(function(sibling){return Ox.$(sibling).is(selector);}):siblings);},some:function some(){return Array.prototype.some.apply(elements,arguments);},text:function text(string){var text='';if(arguments.length==0){elements.forEach(function(element){text+=Ox.isString(element.textContent)?element.textContent:element.innerText;});return text;}else{elements.forEach(function(element){element.empty();element.appendChild(document.createTextNode(string));});return this;}},toggle:function toggle(){return this[Ox.$(element).css('display')=='none'?'show':'hide']();},toggleClass:function toggleClass(string){elements.forEach(function(element){var $element=Ox.$(element);$element[$element.hasClass(string)?'removeClass':'addClass'](string);})
|
|||
|
|
return this;},trigger:function trigger(event){elements.forEach(function(element){var e=document.createEvent('MouseEvents');e.initEvent(event,true,true);element.dispatchEvent(e);});return this;},val:function val(value){var ret;if(arguments.length==0){return elements[0].value;}else{elements.forEach(function(element){element.value=value;});return this;}},width:function width(){return elements[0][elements[0]==document?'width':elements[0]==window?'innerWidth':'offsetWidth'];}}):null;};Ox.canvas=function(){var c={},isImage=arguments.length==1,image=isImage?arguments[0]:{width:arguments[0],height:arguments[1]};c.context=(c.canvas=Ox.$('<canvas>').attr({width:image.width,height:image.height})[0]).getContext('2d');isImage&&c.context.drawImage(image,0,0);c.data=(c.imageData=c.context.getImageData(0,0,image.width,image.height)).data;return c;};Ox.documentReady=(function(){var callbacks=[];document.onreadystatechange=window.onload=function(){if(document.readyState=='complete'){callbacks.forEach(function(callback){callback();});document.onreadystatechange=window.onload=null;}};return function(callback){if(document.readyState=='complete'){callback();return true;}else{callbacks.push(callback);return false;}};}());'use strict';Ox.getDateInWeek=function(date,weekday,utc){date=Ox.makeDate(date);var sourceWeekday=Ox.getISODay(date,utc),targetWeekday=Ox.isNumber(weekday)?weekday:Ox.indexOf(Ox.WEEKDAYS,function(v){return v.slice(0,3)==weekday.slice(0,3);})+1;return Ox.setDate(date,Ox.getDate(date,utc)-sourceWeekday+targetWeekday,utc);};Ox.getDayOfTheYear=function(date,utc){date=Ox.makeDate(date);var month=Ox.getMonth(date,utc),year=Ox.getFullYear(date,utc);return Ox.sum(Ox.range(month).map(function(i){return Ox.getDaysInMonth(year,i+1);}))+Ox.getDate(date,utc);};Ox.getDaysInMonth=function(year,month){year=Ox.makeYear(year);month=Ox.isNumber(month)?month:Ox.indexOf(Ox.MONTHS,function(v){return v.slice(0,3)==month.slice(0,3);})+1;return new Date(year,month,0,1).getDate();};Ox.getDaysInYear=function(year,utc){return 365+Ox.isLeapYear(Ox.makeYear(year,utc));};Ox.getFirstDayOfTheYear=function(date,utc){date=Ox.makeDate(date);date=Ox.setMonth(date,0,utc);date=Ox.setDate(date,1,utc);return Ox.getDay(date,utc);};Ox.getISODate=function(date,utc){return Ox.formatDate(Ox.makeDate(date),'%FT%TZ',utc);};Ox.getISODay=function(date,utc){return Ox.getDay(Ox.makeDate(date),utc)||7;};Ox.getISOWeek=function(date,utc){date=Ox.makeDate(date);return Math.floor((Ox.getDayOfTheYear(Ox.setDate(date,Ox.getDate(date,utc)-Ox.getISODay(date,utc)+4,utc),utc)-1)/7)+1;};Ox.getISOYear=function(date,utc){date=Ox.makeDate(date);return Ox.getFullYear(Ox.setDate(date,Ox.getDate(date,utc)-Ox.getISODay(date,utc)+4,utc));};Ox.getTime=function(utc){return+new Date()-(utc?Ox.getTimezoneOffset():0);};Ox.getTimezoneOffset=function(date){return Ox.makeDate(date).getTimezoneOffset()*60000;};Ox.getTimezoneOffsetString=function(date){var offset=Ox.makeDate(date).getTimezoneOffset();return(offset<=0?'+':'-')
|
|||
|
|
+Ox.pad(Math.floor(Math.abs(offset)/60),2)
|
|||
|
|
+Ox.pad(Math.abs(offset)%60,2);};Ox.getWeek=function(date,utc){date=Ox.makeDate(date);return Math.floor((Ox.getDayOfTheYear(date,utc)
|
|||
|
|
+Ox.getFirstDayOfTheYear(date,utc)-1)/7);};Ox.isLeapYear=function(year,utc){year=Ox.makeYear(year,utc);return year%4==0&&(year%100!=0||year%400==0);};Ox.makeDate=function(date){if(Ox.isString(date)&&Ox.isInvalidDate(new Date(date))){if(/^\d{4}$/.test(date)){date+='-01-01';}else if(/^\d{4}-\d{2}$/.test(date)){date+='-01';}else if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(date)){date=date.replace(/T/,' ').replace(/Z/,'');}
|
|||
|
|
date=date.replace(/-/g,'/');}
|
|||
|
|
return Ox.isUndefined(date)?new Date():new Date(date);};Ox.makeYear=function(date,utc){return Ox.isDate(date)?Ox.getFullYear(date,utc):parseInt(date,10);};Ox.parseDate=function(string,utc){var date,defaults=[,1,1,0,0,0,0],values=/(-?\d+)-?(\d+)?-?(\d+)? ?(\d+)?:?(\d+)?:?(\d+)?\.?(\d+)?/.exec(string);if(values){values.shift();date=new Date();values=values.map(function(v,i){return v?(i==6?Ox.pad(v,3,'0'):v):defaults[i];});values[1]--;['FullYear','Month','Date','Hours','Minutes','Seconds','Milliseconds'].forEach(function(part,i){Ox['set'+part](date,values[i],utc);});}else{date=null;}
|
|||
|
|
return date;};['FullYear','Month','Date','Day','Hours','Minutes','Seconds','Milliseconds'].forEach(function(part){Ox['get'+part]=function(date,utc){return Ox.makeDate(date)['get'+(utc?'UTC':'')+part]();};Ox['set'+part]=function(date,num,utc){return(Ox.isDate(date)?date:new Date(date))['set'+(utc?'UTC':'')+part](num);};});'use strict';Ox.encodeBase26=function(number){var string='';while(number){string=String.fromCharCode(65+(number-1)%26)+string;number=Math.floor((number-1)/26);}
|
|||
|
|
return string;};Ox.decodeBase26=function(string){return string.toUpperCase().split('').reverse().reduce(function(p,c,i){return p+(c.charCodeAt(0)-64)*Math.pow(26,i);},0);};Ox.encodeBase32=function(number){return Ox.map(number.toString(32),function(char){return Ox.BASE_32_DIGITS[parseInt(char,32)];});};Ox.decodeBase32=function(string){return parseInt(Ox.map(string.toUpperCase(),function(char){var index=Ox.BASE_32_DIGITS.indexOf(Ox.BASE_32_ALIASES[char]||char);return index==-1?' ':index.toString(32);}),32);};Ox.encodeBase64=function(number){return btoa(Ox.encodeBase256(number)).replace(/=/g,'');};Ox.decodeBase64=function(string){return Ox.decodeBase256(atob(string));};Ox.encodeBase128=function(number){var string='';while(number){string=Ox.char(number&127)+string;number>>=7;}
|
|||
|
|
return string;};Ox.decodeBase128=function(string){return string.split('').reverse().reduce(function(p,c,i){return p+(c.charCodeAt(0)<<i*7);},0);};Ox.encodeBase256=function(number){var string='';while(number){string=Ox.char(number&255)+string;number>>=8;}
|
|||
|
|
return string;};Ox.decodeBase256=function(string){return string.split('').reverse().reduce(function(p,c,i){return p+(c.charCodeAt(0)<<i*8);},0);};Ox.encodeDeflate=function(string,callback){string=Ox.encodeUTF8(string);var length=1+string.length,c=Ox.canvas(Math.ceil(length/3),1),data,idat,pad=(3-length%3)%3;string=Ox.char(pad)+string+Ox.repeat('\u00FF',pad);Ox.loop(c.data.length,function(i){c.data[i]=i%4<3?string.charCodeAt(i-parseInt(i/4)):255;});c.context.putImageData(c.imageData,0,0);string=atob(c.canvas.toDataURL().split(',')[1]);data=string.slice(16,20)+string.slice(29,33);idat=string.slice(33,-12);while(idat){length=idat.slice(0,4);data+=length+idat.slice(8,12+(length=Ox.decodeBase256(length)));idat=idat.slice(12+length);}
|
|||
|
|
callback&&callback(data);return data;};Ox.decodeDeflate=function(string,callback){var image=new Image(),data='\u0089PNG\r\n\u001A\n\u0000\u0000\u0000\u000DIHDR'
|
|||
|
|
+string.slice(0,4)+'\u0000\u0000\u0000\u0001'
|
|||
|
|
+'\u0008\u0006\u0000\u0000\u0000'+string.slice(4,8),idat=string.slice(8),length;function error(){throw new RangeError('Deflate codec can\'t decode data.');}
|
|||
|
|
while(idat){length=idat.slice(0,4);data+=length+'IDAT'+idat.slice(4,8+(length=Ox.decodeBase256(length)));idat=idat.slice(8+length);}
|
|||
|
|
data+='\u0000\u0000\u0000\u0000IEND\u00AE\u0042\u0060\u0082';image.onload=function(){string=Ox.slice(Ox.canvas(image).data).map(function(value,index){return index%4<3?Ox.char(value):'';}).join('');try{string=Ox.decodeUTF8(string.slice(1,-string.charCodeAt(0)||void 0));}catch(e){error();}
|
|||
|
|
callback(string);};image.onerror=error;image.src='data:image/png;base64,'+btoa(data);};(function(){function replace(string){return string.toString().replace(/%(?![0-9A-Fa-f]{2})/g,'%25').replace(/(%[0-9A-Fa-f]{2})+/g,function(match){var hex=match.split('%').slice(1),ret;Ox.forEach(Ox.range(1,hex.length+1),function(length){var string=Ox.range(length).map(function(i){return Ox.char(parseInt(hex[i],16));}).join('');try{Ox.decodeUTF8(string);ret=match.slice(0,length*3)
|
|||
|
|
+replace(match.slice(length*3));return false;}catch(e){}});return ret||'%25'+hex[0]+replace(match.slice(3));});}
|
|||
|
|
Ox.decodeURI=function(string){return decodeURI(replace(string));};Ox.decodeURIComponent=function(string){return decodeURIComponent(replace(string));};}());Ox.encodeUTF8=function(string){return Ox.map(string,function(char){var code=char.charCodeAt(0),string='';if(code<128){string=char;}else if(code<2048){string=String.fromCharCode(code>>6|192)
|
|||
|
|
+String.fromCharCode(code&63|128);}else{string=String.fromCharCode(code>>12|224)
|
|||
|
|
+String.fromCharCode(code>>6&63|128)
|
|||
|
|
+String.fromCharCode(code&63|128);}
|
|||
|
|
return string;});};Ox.decodeUTF8=function(string){var code,i=0,length=string.length,ret='';function error(byte,position){throw new RangeError('UTF-8 codec can\'t decode byte 0x'+byte.toString(16).toUpperCase()+' at position '+position);}
|
|||
|
|
while(i<length){code=[string.charCodeAt(i),string.charCodeAt(i+1),string.charCodeAt(i+2)];if(code[0]<128){ret+=string[i];i++;}else if(code[0]>=192&&code[0]<240&&i<length-(code[0]<224?1:2)){if(code[1]>=128&&code[1]<192){if(code[0]<224){ret+=String.fromCharCode((code[0]&31)<<6|code[1]&63);i+=2;}else if(code[2]>=128&&code[2]<192){ret+=String.fromCharCode((code[0]&15)<<12|(code[1]&63)<<6|code[2]&63);i+=3;}else{error(code[2],i+2);}}else{error(code[1],i+1);}}else{error(code[0],i);}}
|
|||
|
|
return ret;};'use strict';Ox.formatArea=function(number,decimals){var k=number>=1000000?'k':'';decimals=Ox.isUndefined(decimals)?8:decimals;return Ox.formatNumber((k?number/1000000:number).toPrecision(decimals))+' '+k+'m\u00B2';};Ox.formatCount=function(number,singular,plural){plural=(plural||singular+'s')+(number===2?'{2}':'');return(number===0?Ox._('no'):Ox.formatNumber(number))
|
|||
|
|
+' '+Ox._(number===1?singular:plural);};Ox.formatCurrency=function(number,string,decimals){return string+Ox.formatNumber(number,decimals);};(function(){var format=[['%',function(){return'%{%}';}],['c',function(){return'%D %r';}],['D',function(){return'%m/%d/%y';}],['ED',function(){return'%ES %T';}],['Ed',function(){return'%ES %R';}],['EL',function(){return Ox._('%A, %B %e, %Y');}],['El',function(){return Ox._('%B %e, %Y');}],['EM',function(){return Ox._('%a, %b %e, %Y');}],['Em',function(){return Ox._('%b %e, %Y');}],['ES',function(){return Ox._('%m/%d/%Y');}],['Es',function(){return Ox._('%m/%d/%y');}],['ET',function(){return Ox._('%I:%M:%S %p');}],['Et',function(){return Ox._('%I:%M %p');}],['F',function(){return'%Y-%m-%d';}],['h',function(){return'%b';}],['R',function(){return'%H:%M';}],['r',function(){return'%I:%M:%S %p';}],['T',function(){return'%H:%M:%S';}],['v',function(){return'%e-%b-%Y';}],['\\+',function(){return'%a %b %e %H:%M:%S %Z %Y';}],['A',function(date,utc){return Ox._(Ox.WEEKDAYS[(Ox.getDay(date,utc)+6)%7]);}],['a',function(date,utc){return Ox._(Ox.SHORT_WEEKDAYS[(Ox.getDay(date,utc)+6)%7]);}],['B',function(date,utc){return Ox._(Ox.MONTHS[Ox.getMonth(date,utc)]);}],['b',function(date,utc){return Ox._(Ox.SHORT_MONTHS[Ox.getMonth(date,utc)]);}],['C',function(date,utc){return Math.floor(Ox.getFullYear(date,utc)/100).toString();}],['d',function(date,utc){return Ox.pad(Ox.getDate(date,utc),2);}],['e',function(date,utc){return Ox.pad(Ox.getDate(date,utc),2,' ');}],['G',function(date,utc){return Ox.getISOYear(date,utc);}],['g',function(date,utc){return Ox.getISOYear(date,utc).toString().slice(-2);}],['H',function(date,utc){return Ox.pad(Ox.getHours(date,utc),2);}],['I',function(date,utc){return Ox.pad((Ox.getHours(date,utc)+11)%12+1,2);}],['j',function(date,utc){return Ox.pad(Ox.getDayOfTheYear(date,utc),3);}],['k',function(date,utc){return Ox.pad(Ox.getHours(date,utc),2,' ');}],['l',function(date,utc){return Ox.pad(((Ox.getHours(date,utc)+11)%12+1),2,' ');}],['M',function(date,utc){return Ox.pad(Ox.getMinutes(date,utc),2);}],['m',function(date,utc){return Ox.pad((Ox.getMonth(date,utc)+1),2);}],['p',function(date,utc){return Ox._(Ox.AMPM[Math.floor(Ox.getHours(date,utc)/12)]);}],['Q',function(date,utc){return Math.floor(Ox.getMonth(date,utc)/4)+1;}],['S',function(date,utc){return Ox.pad(Ox.getSeconds(date,utc),2);}],['s',function(date,utc){return Math.floor((+date-(utc?Ox.getTimezoneOffset(date):0))/1000);}],['U',function(date,utc){return Ox.pad(Ox.getWeek(date,utc),2);}],['u',function(date,utc){return Ox.getISODay(date,utc);}],['V',function(date,utc){return Ox.pad(Ox.getISOWeek(date,utc),2);}],['W',function(date,utc){return Ox.pad(Math.floor((Ox.getDayOfTheYear(date,utc)
|
|||
|
|
+(Ox.getFirstDayOfTheYear(date,utc)||7)-2)/7),2);}],['w',function(date,utc){return Ox.getDay(date,utc);}],['X',function(date,utc){var y=Ox.getFullYear(date,utc);return Math.abs(y)+' '+Ox._(Ox.BCAD[y<0?0:1]);}],['x',function(date,utc){var y=Ox.getFullYear(date,utc);return Math.abs(y)+(y<1000?' '+Ox._(Ox.BCAD[y<0?0:1]):'');}],['Y',function(date,utc){return Ox.getFullYear(date,utc);}],['y',function(date,utc){return Ox.getFullYear(date,utc).toString().slice(-2);}],['Z',function(date,utc){return utc?'UTC':(date.toString().split('(')[1]||'').replace(')','');}],['z',function(date,utc){return utc?'+0000':Ox.getTimezoneOffsetString(date);}],['n',function(){return'\n';}],['t',function(){return'\t';}],['\\{%\\}',function(){return'%';}]].map(function(value){return[new RegExp('%'+value[0],'g'),value[1]];});Ox.formatDate=function(date,string,utc){if(date===''){return'';}
|
|||
|
|
date=Ox.makeDate(date);format.forEach(function(value){string=string.replace(value[0],function(){return value[1](date,utc);});});return string;};}());Ox.formatDateRange=function(start,end,utc){end=end||Ox.formatDate(new Date(),'%Y-%m-%d');var isOneUnit=false,range=[start,end],strings,dates=range.map(function(str){return Ox.parseDate(str,utc);}),parts=range.map(function(str){var parts=Ox.compact(/(-?\d+)-?(\d+)?-?(\d+)? ?(\d+)?:?(\d+)?:?(\d+)?/.exec(str));parts.shift();return parts.map(function(part){return parseInt(part,10);});}),precision=parts.map(function(parts){return parts.length;}),y=parts[0][0]<0?'%X':'%Y',formats=[y,'%B '+y,'%a, %b %e, '+y,'%a, %b %e, '+y+', %H:%M','%a, %b %e, '+y+', %H:%M','%a, %b %e, '+y+', %H:%M:%S',];if(precision[0]==precision[1]){isOneUnit=true;Ox.loop(precision[0],function(i){if((i<precision[0]-1&&parts[0][i]!=parts[1][i])||(i==precision[0]-1&&parts[0][i]!=parts[1][i]-1)){isOneUnit=false;return false;}});}
|
|||
|
|
if(isOneUnit){strings=[Ox.formatDate(dates[0],formats[precision[0]-1],utc)];}else{strings=[Ox.formatDate(dates[0],formats[precision[0]-1],utc),Ox.formatDate(dates[1],formats[precision[1]-1],utc)];if(parts[0][0]==parts[1][0]&&precision[0]<=3&&precision[1]<=3){strings[0]=Ox.formatDate(dates[0],formats[precision[0]-1].replace(new RegExp(',? '+y),''),utc);}
|
|||
|
|
if(parts[0][0]==parts[1][0]&&parts[0][1]==parts[1][1]&&parts[0][2]==parts[1][2]){strings[1]=strings[1].split(', ').pop();}}
|
|||
|
|
return strings.join(' - ').replace(/ /g,' ');};Ox.formatDateRangeDuration=function(start,end,utc){end=end||Ox.formatDate(new Date(),'%Y-%m-%d');var date=Ox.parseDate(start,utc),dates=[start,end].map(function(string){return Ox.parseDate(string,utc);}),keys=['year','month','day','hour','minute','second'],parts=['FullYear','Month','Date','Hours','Minutes','Seconds'],values=[];date&&keys.forEach(function(key,i){while(true){if(key=='month'){var day=Ox.getDate(date,utc);Ox.setDate(date,Math.min(day,Ox.getDaysInMonth(Ox.getFullYear(date,utc),Ox.getMonth(date,utc)+2,utc)),utc);}
|
|||
|
|
Ox['set'+parts[i]](date,Ox['get'+parts[i]](date,utc)+1,utc);if(date<=dates[1]){values[i]=(values[i]||0)+1;}else{Ox['set'+parts[i]](date,Ox['get'+parts[i]](date,utc)-1,utc);key=='month'&&Ox.setDate(date,day,utc);break;}}});return Ox.filter(Ox.map(values,function(value,i){return value?value+' '+keys[i]+(value>1?'s':''):'';})).join(' ');};Ox.formatDegrees=function(degrees,mode){var days=0,seconds=Math.round(Math.abs(degrees)*3600),sign=degrees<0?'-':'',array=Ox.formatDuration(seconds).split(':');if(array.length==4){days=parseInt(array.shift(),10);}
|
|||
|
|
array[0]=days*24+parseInt(array[0],10);return(!mode?sign:'')
|
|||
|
|
+array[0]+'°'+array[1]+"'"+array[2]+'"'
|
|||
|
|
+(mode=='lat'?(degrees<0?'S':'N'):mode=='lng'?(degrees<0?'W':'E'):'');};Ox.formatDimensions=Ox.formatResolution=function(array,string){return array.map(function(value){return Ox.formatNumber(value);}).join(' × ')+(string?' '+string:'');};Ox.formatDuration=function(seconds){var last=Ox.last(arguments),format=last=='short'||last=='long'?last:'none',decimals=Ox.isNumber(arguments[1])?arguments[1]:0,seconds=Ox.round(Math.abs(seconds),decimals),values=[Math.floor(seconds/31536000),Math.floor(seconds%31536000/86400),Math.floor(seconds%86400/3600),Math.floor(seconds%3600/60),Ox.formatNumber(seconds%60,decimals)],string=format=='short'?['y','d','h','m','s']:format=='long'?['year','day','hour','minute','second']:[],pad=[values[0].toString().length,values[0]?3:values[1].toString().length,2,2,decimals?decimals+3:2];while(!values[0]&&values.length>(format=='none'?3:1)){values.shift();string.shift();pad.shift();}
|
|||
|
|
return Ox.filter(Ox.map(values,function(value,index){var ret;if(format=='none'){ret=Ox.pad(value,'left',pad[index],'0');}else if(Ox.isNumber(value)?value:parseFloat(value)){ret=value+(format=='long'?' ':'')+Ox._(string[index]+(format=='long'?(value==1?'':value==2?'s{2}':'s'):''));}else{ret='';}
|
|||
|
|
return ret;})).join(format=='none'?':':' ');};Ox.formatISBN=function(isbn,length,dashes){var ret='';function getCheckDigit(isbn){var mod=isbn.length==10?11:10
|
|||
|
|
return(Ox.mod(mod-Ox.sum(isbn.slice(0,-1).split('').map(function(digit,index){return isbn.length==10?parseInt(digit)*(10-index):parseInt(digit)*(index%2==0?1:3);})),mod)+'').replace('10','X');}
|
|||
|
|
isbn=isbn.toUpperCase().replace(/[^\dX]/g,'');if(isbn.length==10){isbn=isbn.slice(0,-1).replace(/\D/g,'')+isbn.slice(-1);}
|
|||
|
|
if((isbn.length==10||isbn.length==13)&&isbn.slice(-1)==getCheckDigit(isbn)){if(isbn.length==length){ret=isbn}else if(isbn.length==10||isbn.slice(0,3)=='978'){isbn=isbn.length==10?'978'+isbn:isbn.slice(3);ret=isbn.slice(0,-1)+getCheckDigit(isbn);}}
|
|||
|
|
return dashes?[ret.slice(-13,-10),ret.slice(-10,-9),ret.slice(-9,-6),ret.slice(-6,-1),ret.slice(-1)].join('-').replace(/^-+/,''):ret;};Ox.formatNumber=function(number,decimals){var array=[],abs=Math.abs(number),split=abs.toFixed(decimals).split('.');while(split[0]){array.unshift(split[0].slice(-3));split[0]=split[0].slice(0,-3);}
|
|||
|
|
split[0]=array.join(Ox._(','));return(number<0?'-':'')+split.join(Ox._('.'));};Ox.formatOrdinal=function(number){var string=Ox.formatNumber(number),length=string.length,last=string[length-1],ten=length>1&&string[length-2]=='1',twenty=length>1&&!ten;if(last=='1'&&!ten){string+=Ox._('st'+(twenty?'{21}':''));}else if(last=='2'&&!ten){string+=Ox._('nd'+(twenty?'{22}':''));}else if(last=='3'&&!ten){string+=Ox._('rd'+(twenty?'{23}':''));}else{string+=Ox._('th'+(Ox.contains('123',last)&&ten?'{1'+last+'}':''));}
|
|||
|
|
return string;};Ox.formatPercent=function(number,total,decimals){return Ox.formatNumber(number/total*100,decimals)+Ox._('%');};Ox.formatRoman=function(number){var string='';Ox.forEach({M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},function(value,roman){while(number>=value){string+=roman;number-=value;}});return string;};Ox.formatSRT=function(subtitles){return'\ufeff'+Ox.sortBy(subtitles,['in','out']).map(function(subtitle,index){return[index+1,['in','out'].map(function(key){return Ox.formatDuration(subtitle[key],3).replace('.',',');}).join(' --> '),subtitle['text']].join('\r\n')}).join('\r\n\r\n')+'\r\n\r\n';};Ox.formatString=function(string,collection,keepUnmatched){return string.replace(/\{([^}]+)\}/g,function(string,match){var key,keys=match.replace(/\\\./g,'\n').split('.').map(function(key){return key.replace(/\n/g,'.');}),value=collection||{};while(keys.length){key=keys.shift();if(value[key]){value=value[key];}else{value=null;break;}}
|
|||
|
|
return value!==null?value:keepUnmatched?'{'+match+'}':'';});};Ox.formatUnit=function(number,string,decimals){return Ox.formatNumber(number,decimals)
|
|||
|
|
+(/^[:%]/.test(string)?'':' ')+string;};Ox.formatValue=function(number,string,bin){var base=bin?1024:1000,length=Ox.PREFIXES.length,ret;Ox.forEach(Ox.PREFIXES,function(prefix,index){if(number<Math.pow(base,index+1)||index==length-1){ret=Ox.formatNumber(number/Math.pow(base,index),index?index-1:0)+' '+prefix+(prefix&&bin?'i':'')+string;return false;}});return ret;};'use strict';(function(){function deg(point){return Ox.map(point,function(val){return Ox.mod(Ox.deg(val)+180,360)-180;});}
|
|||
|
|
function rad(point){return Ox.map(point,function(val){return Ox.rad(val);});}
|
|||
|
|
function splitArea(area){return Ox.crossesDateline(area.sw,area.ne)?[{sw:area.sw,ne:{lat:area.ne.lat,lng:180}},{sw:{lat:area.sw.lat,lng:-180},ne:area.ne}]:[area];}
|
|||
|
|
Ox.crossesDateline=function(pointA,pointB){return pointA.lng>pointB.lng;};Ox.getArea=function(pointA,pointB){if(Ox.crossesDateline(pointA,pointB)){pointB.lng+=360;}
|
|||
|
|
pointA=rad(pointA);pointB=rad(pointB);return Math.pow(Ox.EARTH_RADIUS,2)*Math.abs(Math.sin(pointA.lat)-Math.sin(pointB.lat))*Math.abs(pointA.lng-pointB.lng);};Ox.getAverageBearing=function(bearingA,bearingB){return Ox.mod((bearingA+bearingB)/2+(Math.abs(bearingA-bearingB)>180?180:0),360);};Ox.getBearing=function(pointA,pointB){pointA=rad(pointA);pointB=rad(pointB);var x=Math.cos(pointA.lat)*Math.sin(pointB.lat)
|
|||
|
|
-Math.sin(pointA.lat)*Math.cos(pointB.lat)*Math.cos(pointB.lng-pointA.lng),y=Math.sin(pointB.lng-pointA.lng)*Math.cos(pointB.lat);return(Ox.deg(Math.atan2(y,x))+360)%360;};Ox.getBearingDifference=function(bearingA,bearingB){var difference=Math.abs(bearingA-bearingB);return difference>180?360-difference:difference;};Ox.getCenter=function(pointA,pointB){pointA=rad(pointA);pointB=rad(pointB);var x=Math.cos(pointB.lat)*Math.cos(pointB.lng-pointA.lng),y=Math.cos(pointB.lat)*Math.sin(pointB.lng-pointA.lng),d=Math.sqrt(Math.pow(Math.cos(pointA.lat)+x,2)+Math.pow(y,2)),lat=Math.atan2(Math.sin(pointA.lat)+Math.sin(pointB.lat),d),lng=pointA.lng+Math.atan2(y,Math.cos(pointA.lat)+x);return deg({lat:lat,lng:lng});};Ox.getCircle=function(center,radius,precision){return Ox.range(0,360,360/Math.pow(2,precision)).map(function(bearing){return Ox.getPoint(center,radius,bearing);});};Ox.getClosestBearing=function(bearing,bearings){var differences=bearings.map(function(bearing_){return getBearingDifference(bearing,bearing_);});return bearings[differences.indexOf(Ox.min(differences))];};Ox.getDegreesPerMeter=function(lat){return 360/Ox.EARTH_CIRCUMFERENCE/Math.cos(lat*Math.PI/180);};Ox.getDistance=function(pointA,pointB){pointA=rad(pointA);pointB=rad(pointB);return Math.acos(Math.sin(pointA.lat)*Math.sin(pointB.lat)
|
|||
|
|
+Math.cos(pointA.lat)*Math.cos(pointB.lat)*Math.cos(pointB.lng-pointA.lng))*Ox.EARTH_RADIUS;};Ox.getLatLngByXY=function(xy){function getValue(value){return(value-0.5)*2*Math.PI;}
|
|||
|
|
return{lat:-Ox.deg(Math.atan(Ox.sinh(getValue(xy.y)))),lng:Ox.deg(getValue(xy.x))};};Ox.getLine=function(pointA,pointB,precision){var line=[pointA,pointB],points;while(precision>0){points=[line[0]];Ox.loop(line.length-1,function(i){points.push(Ox.getCenter(line[i],line[i+1]),line[i+1]);});line=points;precision--;}
|
|||
|
|
return line;};Ox.getMetersPerDegree=function(lat){return Math.cos(lat*Math.PI/180)*Ox.EARTH_CIRCUMFERENCE/360;};Ox.getPoint=function(point,distance,bearing){var pointB={};point=rad(point);distance/=Ox.EARTH_RADIUS;bearing=Ox.rad(bearing);pointB.lat=Math.asin(Math.sin(point.lat)*Math.cos(distance)
|
|||
|
|
+Math.cos(point.lat)*Math.sin(distance)*Math.cos(bearing));pointB.lng=point.lng+Math.atan2(Math.sin(bearing)*Math.sin(distance)*Math.cos(point.lat),Math.cos(distance)-Math.sin(point.lat)*Math.sin(pointB.lat));return deg(pointB);};Ox.getXYByLatLng=function(latlng){function getValue(value){return value/(2*Math.PI)+0.5;}
|
|||
|
|
return{x:getValue(Ox.rad(latlng.lng)),y:getValue(Ox.asinh(Math.tan(Ox.rad(-latlng.lat))))};};Ox.isPolar=function(point){return point.lat<Ox.MIN_LATITUDE||point.lat>Ox.MAX_LATITUDE;};Ox.containsArea=function(areaA,areaB){var areas=[areaA,areaB].map(splitArea),ret;function contains(areaA,areaB){return areaA.sw.lat<=areaB.sw.lat&&areaA.sw.lng<=areaB.sw.lng&&areaA.ne.lat>=areaB.ne.lat&&areaA.ne.lng>=areaB.ne.lng;}
|
|||
|
|
Ox.forEach(areas[1],function(area1){Ox.forEach(areas[0],function(area0){ret=contains(area0,area1);return!ret;});return ret;});return ret;};Ox.intersectAreas=function(areas){var intersections,ret;areas=areas.map(splitArea);ret=areas[0];function intersect(areaA,areaB){return areaA.sw.lat>areaB.ne.lat||areaA.sw.lng>areaB.ne.lng||areaA.ne.lat<areaB.sw.lat||areaA.ne.lng<areaB.sw.lng?null:{sw:{lat:Math.max(areaA.sw.lat,areaB.sw.lat),lng:Math.max(areaA.sw.lng,areaB.sw.lng)},ne:{lat:Math.min(areaA.ne.lat,areaB.ne.lat),lng:Math.min(areaA.ne.lng,areaB.ne.lng)}};}
|
|||
|
|
Ox.forEach(areas.slice(1),function(parts){if(ret.length==1&&parts.length==1){ret=intersect(ret[0],parts[0]);}else{intersections=Ox.compact(ret.map(function(part){return Ox.intersectAreas(parts.concat(part));}));ret=intersections.length==0?null:Ox.joinAreas(intersections);}
|
|||
|
|
if(ret===null){return false;}else{ret=splitArea(ret);}});return ret?Ox.joinAreas(ret):null;};Ox.joinAreas=function(areas){var ret=areas[0],gaps=[{sw:{lat:-90,lng:ret.ne.lng},ne:{lat:90,lng:ret.sw.lng}}];function containsGaps(area){return Ox.getIndices(gaps,function(gap){return Ox.containsArea({sw:{lat:-90,lng:area.sw.lng},ne:{lat:90,lng:area.ne.lng}},gap);});}
|
|||
|
|
function intersectsWithGaps(area){var ret={};gaps.forEach(function(gap,i){var intersection=Ox.intersectAreas([area,gap]);if(intersection){ret[i]=intersection;}});return ret;}
|
|||
|
|
function isContainedInGap(area){var ret=-1;Ox.forEach(gaps,function(gap,i){if(Ox.containsArea(gap,area)){ret=i;return false;}});return ret;}
|
|||
|
|
areas.slice(1).forEach(function(area){var index,indices,intersections;if(area.sw.lat<ret.sw.lat){ret.sw.lat=area.sw.lat;}
|
|||
|
|
if(area.ne.lat>ret.ne.lat){ret.ne.lat=area.ne.lat;}
|
|||
|
|
index=isContainedInGap(area);if(index>-1){gaps.push({sw:gaps[index].sw,ne:{lat:90,lng:area.sw.lng}});gaps.push({sw:{lat:-90,lng:area.ne.lng},ne:gaps[index].ne});gaps.splice(index,1);}else{indices=containsGaps(area);Ox.reverse(indices).forEach(function(index){gaps.splice(index,1);});intersections=intersectsWithGaps(area);Ox.forEach(intersections,function(intersection,index){gaps[index]={sw:{lat:-90,lng:gaps[index].sw.lng==intersection.sw.lng?intersection.ne.lng:gaps[index].sw.lng},ne:{lat:90,lng:gaps[index].ne.lng==intersection.ne.lng?intersection.sw.lng:gaps[index].ne.lng}};});}});if(gaps.length==0){ret.sw.lng=-180;ret.ne.lng=180;}else{gaps.sort(function(a,b){return(b.ne.lng
|
|||
|
|
+(Ox.crossesDateline(b.sw,b.ne)?360:0)
|
|||
|
|
-b.sw.lng)-(a.ne.lng
|
|||
|
|
+(Ox.crossesDateline(a.sw,a.ne)?360:0)
|
|||
|
|
-a.sw.lng);});ret.sw.lng=gaps[0].ne.lng;ret.ne.lng=gaps[0].sw.lng;}
|
|||
|
|
return ret;};}());'use strict';(function(){var defaultTags=[{'name':'b'},{'name':'bdi'},{'name':'code'},{'name':'em'},{'name':'i'},{'name':'q'},{'name':'s'},{'name':'span'},{'name':'strong'},{'name':'sub'},{'name':'sup'},{'name':'u'},{'name':'blockquote'},{'name':'cite'},{'name':'div','optional':['style'],'validate':{'style':/^direction: rtl$/}},{'name':'h1'},{'name':'h2'},{'name':'h3'},{'name':'h4'},{'name':'h5'},{'name':'h6'},{'name':'p'},{'name':'pre'},{'name':'li'},{'name':'ol'},{'name':'ul'},{'name':'dl'},{'name':'dt'},{'name':'dd'},{'name':'table'},{'name':'tbody'},{'name':'td'},{'name':'tfoot'},{'name':'th'},{'name':'thead'},{'name':'tr'},{'name':'[]'},{'name':'a','required':['href'],'optional':['target'],'validate':{'href':/^((https?:\/\/|\/|mailto:).*?)/,'target':/^_blank$/}},{'name':'br'},{'name':'iframe','optional':['width','height'],'required':['src'],'validate':{'width':/^\d+$/,'height':/^\d+$/,'src':/^((https?:\/\/|\/).*?)/}},{'name':'img','optional':['width','height'],'required':['src'],'validate':{'width':/^\d+$/,'height':/^\d+$/,'src':/^((https?:\/\/|\/).*?)/},},{'name':'figure'},{'name':'figcaption'}],htmlEntities={'"':'"','&':'&',"'":''','<':'<','>':'>'},regexp={entity:/&[^\s]+?;/g,html:/[<&]/,tag:new RegExp('<\\/?('+['a','b','br','code','i','s','span','u'].join('|')+')\\/?>','gi')},salt=Ox.range(2).map(function(){return Ox.range(16).map(function(){return Ox.char(65+Ox.random(26));}).join('');});function addLinks(string,obfuscate){return string.replace(/\b((https?:\/\/|www\.).+?)([.,:;!?)\]]*?(\s|$))/gi,function(match,url,prefix,end){prefix=prefix.toLowerCase()=='www.'?'http://':'';return Ox.formatString('<a href="{prefix}{url}">{url}</a>{end}',{end:end,prefix:prefix,url:url});}).replace(/\b([0-9A-Z.+\-_]+@(?:[0-9A-Z\-]+\.)+[A-Z]{2,6})\b/gi,obfuscate?function(match,mail){return Ox.encodeEmailAddress(mail);}:'<a href="mailto:$1">$1</a>');}
|
|||
|
|
function decodeHTMLEntities(string){return string.replace(new RegExp('('+Ox.values(htmlEntities).join('|')+')','g'),function(match){return Ox.keyOf(htmlEntities,match);}).replace(/&#([0-9A-FX]+);/gi,function(match,code){return Ox.char(/^X/i.test(code)?parseInt(code.slice(1),16):parseInt(code,10));});}function splitHTMLTags(string,ignore){var isTag=false,ret=[''];ignore=ignore||[];Ox.forEach(string,function(char,i){if(!isTag&&char=='<'&&ignore.indexOf(i)==-1){isTag=true;ret.push('');}
|
|||
|
|
ret[ret.length-1]+=char;if(isTag&&char=='>'){isTag=false;ret.push('');}});return ret;}
|
|||
|
|
Ox.addLinks=function(string,isHTML){var isLink=false;return isHTML?splitHTMLTags(string).map(function(string,i){var isTag=i%2;if(isTag){if(/^<a/.test(string)){isLink=true;}else if(/^<\/a/.test(string)){isLink=false;}}
|
|||
|
|
return isTag||isLink?string:addLinks(string);}).join(''):Ox.normalizeHTML(addLinks(string));};Ox.encodeEmailAddress=function(address,text){var parts=['mailto:'+address,text||address].map(function(part){return Ox.map(part,function(char){var code=char.charCodeAt(0);return char==':'?':':'&#'
|
|||
|
|
+(Math.random()<0.5?code:'x'+code.toString(16))
|
|||
|
|
+';';});});return'<a href="'+parts[0]+'">'+parts[1]+'</a>';};Ox.encodeHTMLEntities=function(string,encodeAll){return Ox.map(String(string),function(char){var code=char.charCodeAt(0);if(code<128){char=char in htmlEntities?htmlEntities[char]:char;}else if(encodeAll){char='&#x'
|
|||
|
|
+Ox.pad(code.toString(16).toUpperCase(),'left',4,'0')
|
|||
|
|
+';';}
|
|||
|
|
return char;});};Ox.decodeHTMLEntities=function(string,decodeAll){return decodeAll?Ox.decodeHTMLEntities(Ox.normalizeHTML(string)):decodeHTMLEntities(string);};Ox.highlight=function(string,query,classname,isHTML){if(!query){return string;}
|
|||
|
|
var cursor=0,entities=[],matches=[],offset=0,re=Ox.isRegExp(query)?query:new RegExp(Ox.escapeRegExp(query),'gi'),span=['<span class="'+classname+'">','</span>'],tags=[];function insert(array){array.forEach(function(v){string=Ox.splice(string,v.position,v.length,v.value);matches.forEach(function(match){if(v.position<match.position){match.position+=v.value.length-v.length;}else if(v.position<match.position+match.value.length){match.value=Ox.splice(match.value,v.position-match.position,v.length,v.value);}});});}
|
|||
|
|
if(isHTML&®exp.html.test(string)){string=string.replace(regexp.tag,function(value,tag,position){tags.push({length:0,position:position,value:value});return'';}).replace(regexp.entity,function(value,position){var ret=Ox.decodeHTMLEntities(value,true);entities.push({length:ret.length,position:position,value:value});return ret;});splitHTMLTags(string,entities.map(function(entity){var ret=entity.position+offset;offset+=entity.length-entity.value.length;return ret;})).forEach(function(v,i){if(i%2==0){v.replace(re,function(value,position){matches.push({position:cursor+position,value:value});});}
|
|||
|
|
cursor+=v.length;});insert(entities);insert(tags);matches.reverse().forEach(function(match){string=Ox.splice(string,match.position,match.value.length,span.join(match.value));});if(matches.length&&tags.length){string=Ox.normalizeHTML(string);}}else{string=Ox.encodeHTMLEntities(string.replace(re,function(value){matches.push(span.join(Ox.encodeHTMLEntities(value)));return salt.join(matches.length-1);}));matches.forEach(function(match,i){string=string.replace(new RegExp(salt.join(i)),match);});}
|
|||
|
|
return string;};Ox.normalizeHTML=function(html){return regexp.html.test(html)?Ox.$('<div>').html(html).html():html;};Ox.parseMarkdown=function(string){var array=[];return string.replace(/\r\n/g,'\n').replace(/\r/g,'\n').replace(/(?:^|\n)```(.*)\n([^`]+)\n```/g,function(match,classname,code){array.push('<pre><code'
|
|||
|
|
+(classname?' class="'+classname+'"':'')+'>'
|
|||
|
|
+code.trim().replace(/</g,'<')+'\n</code></pre>');return salt.join(array.length-1);}).replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(match,prev,backticks,code,next){array.push(prev+'<code>'
|
|||
|
|
+code.trim().replace(/</g,'<')+'</code>');return salt.join(array.length-1);}).replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,'<strong>$2</strong>').replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,'<em>$2</em>').replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,function(match,all,text,id,url,rest,quote,title){return'<a href="'+Ox.encodeHTMLEntities(url)+'"'+(title?' title="'+Ox.encodeHTMLEntities(title)+'"':'')+'>'+text+'</a>';}).replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'<a href=\"$1\">$1</a>').replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(match,mail){return Ox.encodeEmailAddress(mail);}).replace(/\n\n/g,'<br><br>').replace(new RegExp(salt.join('(\\d+)'),'g'),function(match,index){return array[parseInt(index)];});};Ox.sanitizeHTML=function(html,tags,globalAttributes){tags=tags||defaultTags;globalAttributes=globalAttributes||[];var escaped={},level=0,matches=[],selfClosingTags=['img','br'],validAttributes={},requiredAttributes={},validate={},validTags=tags.map(function(tag){validAttributes[tag.name]=globalAttributes.concat(tag.required||[]).concat(tag.optional||[]);requiredAttributes[tag.name]=tag.required||[];validate[tag.name]=tag.validate||{};return tag.name;});if(Ox.contains(validTags,'[]')){html=html.replace(/\[((\/|https?:\/\/|mailto:).+?) (.+?)\]/gi,'<a href="$1">$3</a>');validTags=validTags.filter(function(tag){return tag!='[]';});}
|
|||
|
|
html=splitHTMLTags(html).map(function(string,i){var attrs={},attrMatch,attrRegexp=/([^=\ ]+)="([^"]+)"/g,attrString,isClosing,isTag=i%2,isValid=true,tag,tagMatch,tagRegexp=/<(\/)?([^\ \/]+)(.*?)(\/)?>/g;if(isTag){tagMatch=tagRegexp.exec(string);if(tagMatch){isClosing=!Ox.isUndefined(tagMatch[1]);tag=tagMatch[2];attrString=tagMatch[3].trim();while(attrMatch=attrRegexp.exec(attrString)){if(validAttributes[tag]&&Ox.contains(validAttributes[tag],attrMatch[1])){attrs[attrMatch[1]]=attrMatch[2];}}
|
|||
|
|
if(!isClosing&&!Ox.contains(selfClosingTags,tag)){level++;}
|
|||
|
|
if(!Ox.contains(validTags,tag)||(attrString.length&&Ox.isEmpty(attrs))){isValid=false;}else if(!isClosing&&requiredAttributes[tag]){requiredAttributes[tag].forEach(function(attr){if(Ox.isUndefined(attrs[attr])){isValid=false;}});}
|
|||
|
|
if(isValid&&!Ox.isEmpty(attrs)){Ox.forEach(attrs,function(value,key){if(!Ox.isUndefined(validate[tag][key])&&!validate[tag][key].exec(value)){isValid=false;return false;}});}
|
|||
|
|
if(isValid&&isClosing){isValid=!escaped[level];}else{escaped[level]=!isValid;}
|
|||
|
|
if(isClosing){level--;}
|
|||
|
|
if(isValid){return'<'
|
|||
|
|
+(isClosing?'/':'')
|
|||
|
|
+tag
|
|||
|
|
+(!isClosing&&!Ox.isEmpty(attrs)?' '+Ox.values(Ox.map(attrs,function(value,key){return key+'="'+value+'"';})).join(' '):'')
|
|||
|
|
+'>';}}}
|
|||
|
|
return Ox.encodeHTMLEntities(Ox.decodeHTMLEntities(string));}).join('');html=Ox.addLinks(html,true);html=html.replace(/\n\n/g,'<br/><br/>');return Ox.normalizeHTML(html);};Ox.stripTags=function(string){return string.replace(/<.*?>/g,'');};}());'use strict';Ox.oshash=function(file,callback){var hash=fromString(file.size.toString());read(0);function add(A,B){var a,b,c,d;d=A[3]+B[3];c=A[2]+B[2]+(d>>16);d&=0xffff;b=A[1]+B[1]+(c>>16);c&=0xffff;a=A[0]+B[0]+(b>>16);b&=0xffff;a&=0xffff;return[a,b,c,d];}
|
|||
|
|
function fromData(s,offset){offset=offset||0;return[s.charCodeAt(offset+6)+(s.charCodeAt(offset+7)<<8),s.charCodeAt(offset+4)+(s.charCodeAt(offset+5)<<8),s.charCodeAt(offset+2)+(s.charCodeAt(offset+3)<<8),s.charCodeAt(offset+0)+(s.charCodeAt(offset+1)<<8)];}
|
|||
|
|
function fromString(str){var base=10,blen=1,i,num,pos,r=[0,0,0,0];for(pos=0;pos<str.length;pos++){num=parseInt(str.charAt(pos),base);i=0;do{while(i<blen){num+=r[3-i]*base;r[3-i++]=(num&0xFFFF);num>>>=16;}
|
|||
|
|
if(num){blen++;}}while(num);}
|
|||
|
|
return r;}
|
|||
|
|
function hex(h){return(Ox.pad(h[0].toString(16),'left',4,'0')
|
|||
|
|
+Ox.pad(h[1].toString(16),'left',4,'0')
|
|||
|
|
+Ox.pad(h[2].toString(16),'left',4,'0')
|
|||
|
|
+Ox.pad(h[3].toString(16),'left',4,'0')).toLowerCase();}
|
|||
|
|
function read(offset,last){var blob,block=65536,length=8,reader=new FileReader();reader.onload=function(data){var s=data.target.result,s_length=s.length-length,i;for(i=0;i<=s_length;i+=length){hash=add(hash,fromData(s,i));}
|
|||
|
|
if(file.size<block||last){callback(hex(hash));}else{read(file.size-block,true);}};if(file.mozSlice){blob=file.mozSlice(offset,offset+block);}else if(file.webkitSlice){blob=file.webkitSlice(offset,offset+block);}else{blob=file.slice(offset,offset+block);}
|
|||
|
|
reader.readAsBinaryString(blob);}};Ox.SHA1=function(msg){function rotate_left(n,s){var t4=(n<<s)|(n>>>(32-s));return t4;};function cvt_hex(val){var str="";var i;var v;for(i=7;i>=0;i--){v=(val>>>(i*4))&0x0f;str+=v.toString(16);}
|
|||
|
|
return str;};var blockstart;var i,j;var W=new Array(80);var H0=0x67452301;var H1=0xEFCDAB89;var H2=0x98BADCFE;var H3=0x10325476;var H4=0xC3D2E1F0;var A,B,C,D,E;var temp;msg=Ox.encodeUTF8(msg);var msg_len=msg.length;var word_array=new Array();for(i=0;i<msg_len-3;i+=4){j=msg.charCodeAt(i)<<24|msg.charCodeAt(i+1)<<16|msg.charCodeAt(i+2)<<8|msg.charCodeAt(i+3);word_array.push(j);}
|
|||
|
|
switch(msg_len%4){case 0:i=0x080000000;break;case 1:i=msg.charCodeAt(msg_len-1)<<24|0x0800000;break;case 2:i=msg.charCodeAt(msg_len-2)<<24|msg.charCodeAt(msg_len-1)<<16|0x08000;break;case 3:i=msg.charCodeAt(msg_len-3)<<24|msg.charCodeAt(msg_len-2)<<16|msg.charCodeAt(msg_len-1)<<8|0x80;break;}
|
|||
|
|
word_array.push(i);while((word_array.length%16)!=14){word_array.push(0);}
|
|||
|
|
word_array.push(msg_len>>>29);word_array.push((msg_len<<3)&0x0ffffffff);for(blockstart=0;blockstart<word_array.length;blockstart+=16){for(i=0;i<16;i++){W[i]=word_array[blockstart+i];}
|
|||
|
|
for(i=16;i<=79;i++){W[i]=rotate_left(W[i-3]^W[i-8]^W[i-14]^W[i-16],1);}
|
|||
|
|
A=H0;B=H1;C=H2;D=H3;E=H4;for(i=0;i<=19;i++){temp=(rotate_left(A,5)+((B&C)|(~B&D))+E+W[i]+0x5A827999)&0x0ffffffff;E=D;D=C;C=rotate_left(B,30);B=A;A=temp;}
|
|||
|
|
for(i=20;i<=39;i++){temp=(rotate_left(A,5)+(B^C^D)+E+W[i]+0x6ED9EBA1)&0x0ffffffff;E=D;D=C;C=rotate_left(B,30);B=A;A=temp;}
|
|||
|
|
for(i=40;i<=59;i++){temp=(rotate_left(A,5)+((B&C)|(B&D)|(C&D))+E+W[i]+0x8F1BBCDC)&0x0ffffffff;E=D;D=C;C=rotate_left(B,30);B=A;A=temp;}
|
|||
|
|
for(i=60;i<=79;i++){temp=(rotate_left(A,5)+(B^C^D)+E+W[i]+0xCA62C1D6)&0x0ffffffff;E=D;D=C;C=rotate_left(B,30);B=A;A=temp;}
|
|||
|
|
H0=(H0+A)&0x0ffffffff;H1=(H1+B)&0x0ffffffff;H2=(H2+C)&0x0ffffffff;H3=(H3+D)&0x0ffffffff;H4=(H4+E)&0x0ffffffff;}
|
|||
|
|
var temp=cvt_hex(H0)+cvt_hex(H1)+cvt_hex(H2)+cvt_hex(H3)+cvt_hex(H4);return temp.toLowerCase();}
|
|||
|
|
'use strict';Ox.doc=(function(){var re={item:/^(.+?)\s+<(.+?)>\s+(.+?)$/,multiline:/^\/\*\@.*?\n([\w\W]+)\n.*?\@?\*\/$/,script:/\n(\s*<script>s*\n[\w\W]+\n\s*<\/script>s*)/g,signature:/^(\(.*?\))\s+\->(.*)/,singleline:/^\/\/@\s*(.*?)\s*$/,test:/\n(\s*> .+\n.+?)/g,},types={a:'array',b:'boolean',d:'date',e:'error',f:'function',g:'arguments',h:'htmlelement','l':'nodelist',n:'number',o:'object',r:'regexp',s:'string',u:'undefined','w':'window','*':'any','+':'other','!':'event'};function addInheritedProperties(items){var constructors=getConstructors(items),instances={},nodes={};function hasProperty(item,property){var properties=item.properties||[],inheritedproperties=item.inheritedproperties?item.inheritedproperties.map(function(v){return v.properties;}):[];return Ox.contains(properties.concat(inheritedproperties).map(function(property){return property.name;}),property.name);}
|
|||
|
|
constructors.forEach(function(constructor){var instance=Ox.last(constructor.returns);instances[constructor.name]=instance;nodes[constructor.name]=instance['class'];});Ox.forEach(getChains(nodes),function(chain,childName){var child=instances[childName];chain.forEach(function(parentName){var parent=instances[parentName]||Ox.last(items[Ox.indexOf(items,function(item){return item.name==parentName;})].returns);['properties','events'].forEach(function(key){parent[key]&&parent[key].forEach(function(value){var key_='inherited'+key;if(key=='events'||!hasProperty(child,value)){if(!child[key_]){child[key_]=[];}
|
|||
|
|
if(!child[key_].some(function(v){return v.name==parentName;})){child[key_].push(Ox.extend({name:parentName},key,[]));}
|
|||
|
|
Ox.last(child[key_])[key].push(value);}});});});});return items;}
|
|||
|
|
function decodeLinebreaks(match,submatch){return(submatch||match).replace(/\u21A9/g,'\n');}
|
|||
|
|
function encodeLinebreaks(match,submatch){return'\n'+(submatch||match).replace(/\n/g,'\u21A9');}
|
|||
|
|
function getChains(nodes){var chains={},sorted=[],visited=[];function visit(name,stack){stack=stack||[];if(Ox.contains(stack,name)){throw new Error('Circular dependency: '+name+' <-> '+Ox.last(stack));}
|
|||
|
|
if(!Ox.contains(visited,name)){visited.push(name);stack.push(name);Ox.forEach(nodes,function(parent,name_){parent==name&&visit(name_,stack);});sorted.unshift(name);}}
|
|||
|
|
Ox.forEach(nodes,function(parent,name){visit(name);});sorted.forEach(function(name){chains[name]=[nodes[name]].concat(chains[nodes[name]]||[]);});return chains;}
|
|||
|
|
function getConstructors(items){var constructors=[];items.forEach(function(item){if(item.returns){Ox.forEach(item.returns,function(v){if(v['class']){constructors.push(item);return false;}});}
|
|||
|
|
['arguments','properties','returns'].forEach(function(key){if(item[key]){constructors.concat(getConstructors(item[key]));}});});return constructors;}
|
|||
|
|
function getIndent(string){var indent=-1;while(string[++indent]==' '){}
|
|||
|
|
return indent;}
|
|||
|
|
function parseItem(string){var matches=re.item.exec(string);return matches&&(matches[2].indexOf('/')==-1||'\'"'.indexOf(matches[2].slice(-2,-1))>-1)?Ox.extend(parseName(matches[1]),parseTypes(matches[2]),{summary:matches[3].trim()}):null;}
|
|||
|
|
function parseName(string){var matches=re.signature.exec(string);return matches?{signature:matches[1],name:matches[2].trim()}:{name:string};}
|
|||
|
|
function parseNode(node){var item=parseItem(node.line),order=[];item.name=item.name.replace(/^\./,'');node.nodes&&node.nodes.forEach(function(node){var key,line=node.line,subitem;if(!/^#/.test(node.line)){if(/^<script>/.test(line)){item.tests=[parseScript(line)];}else if(/^>/.test(line)){item.tests=item.tests||[];item.tests.push(parseTest(line));}else if((subitem=parseItem(line))){if(subitem.signature){item.returns=item.returns||[];item.returns.push(parseNode(node));order.push('returns');}else if(subitem.types[0]=='event'){item.events=item.events||[];item.events.push(parseNode(node));}else{key=item.types[0]=='function'&&!/^\./.test(subitem.name)?'arguments':'properties';item[key]=item[key]||[];item[key].push(parseNode(node));order.push(key);}}else{item.description=item.description?item.description+' '+line:line;}}});item.summary=Ox.parseMarkdown(item.summary);if(item.description){item.description=Ox.parseMarkdown(item.description);}
|
|||
|
|
if(item.types[0]=='function'){item.order=Ox.unique(order);}
|
|||
|
|
return item;}
|
|||
|
|
function parseScript(string){var lines=decodeLinebreaks(string).split('\n'),indent=getIndent(lines[1]);return{statement:lines.slice(1,-1).map(function(line,i){return line.slice(indent);}).join('\n')};}
|
|||
|
|
function parseSource(source,file){var blocks=[],items=[],section='',tokens=[];Ox.tokenize(source).forEach(function(token){var match;if(token.type=='comment'&&(match=re.multiline.exec(token.value)||re.singleline.exec(token.value))){blocks.push(match[1]);tokens.push([]);}else if(tokens.length){tokens[tokens.length-1].push(token);}});blocks.forEach(function(block,i){var item,lastItem,lastToken,lines=block.replace(re.script,encodeLinebreaks).replace(re.test,encodeLinebreaks).split('\n'),parent,tree=parseTree(lines);if(re.item.test(tree.line)){item=parseNode(tree);item.file=file||'';if(section){item.section=section;}
|
|||
|
|
if(/^[A-Z]/.test(item.name)){item.source=parseTokens(tokens[i]);item.line=item.source[0].line;items.push(item);}else{item.name=item.name.replace(/^\./,'');lastItem=Ox.last(items);parent=lastItem.types[0]=='function'&&lastItem.returns&&lastItem.returns[0].types[0]=='object'?lastItem.returns[0]:lastItem;parent.properties=parent.properties||[];parent.properties.push(item);if(parent.order&&!Ox.contains(parent.order,'properties')){parent.order.push('properties');}
|
|||
|
|
lastToken=Ox.last(lastItem.source);lastItem.source=lastItem.source.concat({column:lastToken.column+lastToken.value.length,line:lastToken.line,type:'linebreak',value:'\n'},parseTokens(tokens[i],true));}}else{section=tree.line;}});return items;}
|
|||
|
|
function parseTest(string){var lines=decodeLinebreaks(string).split('\n ');return{statement:lines[0].slice(2),expected:lines[1].trim()};}
|
|||
|
|
function parseTokens(tokens,includeLeading){var start=0,stop=tokens.length,types=['linebreak','whitespace'];if(includeLeading){while(tokens[start].type=='whitespace'){start++;}}else{while(types.indexOf(tokens[start].type)>-1){start++;}
|
|||
|
|
while(start&&tokens[start-1].type=='whitespace'){start--;}}
|
|||
|
|
while(stop>start&&types.indexOf(tokens[stop-1].type)>-1){stop--;}
|
|||
|
|
return tokens.slice(start,stop);}
|
|||
|
|
function parseTree(lines){var branches=[],indent,node={line:lines.shift().trim()};if(lines.length){indent=getIndent(lines[0]);lines.forEach(function(line){if(getIndent(line)==indent){branches.push([line]);}else{branches[branches.length-1].push(line);}});node.nodes=branches.map(function(lines){return parseTree(lines);});}
|
|||
|
|
return node;}
|
|||
|
|
function parseTypes(string){var array,isArray,ret={types:[]},type;if('\'"'.indexOf(string.slice(-2,-1))==-1){array=string.split(':');string=array[0];if(array.length==2){ret['class']=array[1];}}
|
|||
|
|
string.split('|').forEach(function(string){var unwrapped=unwrap(string);if(unwrapped in types){ret.types.push(wrap(types[unwrapped]));}else if((type=Ox.filter(Ox.values(types),function(type){return Ox.startsWith(type,unwrapped);})).length){ret.types.push(wrap(type[0]));}else{ret['default']=string;}});function unwrap(string){return(isArray=/^\[.+\]$/.test(string))?string.slice(1,-1):string;}
|
|||
|
|
function wrap(string){return isArray?'['+string+'s'+']':string;}
|
|||
|
|
return ret;}
|
|||
|
|
return function(argument,callback){var counter=0,items=[],ret;if(arguments.length==1){ret=addInheritedProperties(parseSource(argument));}else{argument=Ox.makeArray(argument);argument.forEach(function(file){Ox.get(file,function(source){items=items.concat(parseSource(source,file.split('?')[0]));if(++counter==argument.length){callback(addInheritedProperties(items));}});});}
|
|||
|
|
return ret;};}());Ox.identify=(function(){var identifiers={constant:['E','LN2','LN10','LOG2E','LOG10E','PI','SQRT1_2','SQRT2','MAX_VALUE','MIN_VALUE','NEGATIVE_INFINITY','POSITIVE_INFINITY'],keyword:['break','case','catch','class','const','continue','debugger','default','delete','do','else','enum','export','extends','false','finally','for','function','if','implements','import','in','instanceof','interface','let','module','new','null','package','private','protected','public','return','super','switch','static','this','throw','true','try','typeof','var','void','yield','while','with'],method:['concat','every','filter','forEach','join','lastIndexOf','indexOf','isArray','map','pop','push','reduce','reduceRight','reverse','shift','slice','some','sort','splice','unshift','getDate','getDay','getFullYear','getHours','getMilliseconds','getMinutes','getMonth','getSeconds','getTime','getTimezoneOffset','getUTCDate','getUTCDay','getUTCFullYear','getUTCHours','getUTCMilliseconds','getUTCMinutes','getUTCMonth','getUTCSeconds','now','parse','setDate','setFullYear','setHours','setMilliseconds','setMinutes','setMonth','setSeconds','setTime','setUTCDate','setUTCFullYear','setUTCHours','setUTCMilliseconds','setUTCMinutes','setUTCMonth','setUTCSeconds','toDateString','toJSON','toLocaleDateString','toLocaleString','toLocaleTimeString','toTimeString','toUTCString','UTC','apply','bind','call','isGenerator','parse','stringify','abs','acos','asin','atan','atan2','ceil','cos','exp','floor','log','max','min','pow','random','round','sin','sqrt','tan','toExponential','toFixed','toLocaleString','toPrecision','create','defineProperty','defineProperties','freeze','getOwnPropertyDescriptor','getOwnPropertyNames','getPrototypeOf','hasOwnProperty','isExtensible','isFrozen','isPrototypeOf','isSealed','keys','preventExtensions','propertyIsEnumerable','seal','toLocaleString','toString','valueOf','exec','test','charAt','charCodeAt','concat','fromCharCode','indexOf','lastIndexOf','localeCompare','match','replace','search','slice','split','substr','substring','toLocaleLowerCase','toLocaleUpperCase','toLowerCase','toUpperCase','trim','addEventListener','alert','atob','blur','btoa','clearInterval','clearTimeout','close','confirm','dispatchEvent','escape','find','focus','getComputedStyle','getSelection','moveBy','moveTo','open','postMessage','print','prompt','removeEventListener','resizeBy','resizeTo','scroll','scrollBy','scrollTo','setCursor','setInterval','setTimeout','stop','unescape'],object:['Array','Boolean','Date','decodeURI','decodeURIComponent','encodeURI','encodeURIComponent','Error','eval','EvalError','Function','Infinity','isFinite','isNaN','JSON','Math','NaN','Number','Object','parseFloat','parseInt','RangeError','ReferenceError','RegExp','String','SyntaxError','TypeError','undefined','URIError','window'],property:['constructor','length','prototype','global','ignoreCase','lastIndex','multiline','source','applicationCache','closed','console','content','crypto','defaultStatus','document','frameElement','frames','history','innerHeight','innerWidth','length','location','locationbar','localStorage','menubar','name','navigator','opener','outerHeight','outerWidth','pageXOffset','pageYOffset','parent','personalbar','screen','screenX','screenY','scrollbars','scrollX','scrollY','self','sessionStorage','status','statusbar','toolbar','top']};return function(identifier){var ret;if(identifiers.keyword.indexOf(identifier)>-1){ret='keyword';}else{ret='identifier';Ox.forEach(identifiers,function(words,type){if(words.indexOf(identifier)>-1){ret=type;return false;}});}
|
|||
|
|
return ret;};}());Ox.minify=function(){if(arguments.length==1){return minify(arguments[0]);}else{Ox.get(arguments[0],function(source){arguments[1](minify(source));});}
|
|||
|
|
function minify(source){var tokens=Ox.tokenize(source),length=tokens.length,ret='';tokens.forEach(function(token,i){var next,nextToken,prevToken;if(['linebreak','whitespace'].indexOf(token.type)>-1){prevToken=i==0?null:tokens[i-1];next=i+1;while(next<length&&['comment','linebreak','whitespace'].indexOf(tokens[next].type)>-1){next++;}
|
|||
|
|
nextToken=next==length?null:tokens[next];}
|
|||
|
|
if(token.type=='linebreak'){if(prevToken&&nextToken&&(['identifier','number','string'].indexOf(prevToken.type)>-1||['++','--',')',']','}'].indexOf(prevToken.value)>-1)&&(['identifier','number','string'].indexOf(nextToken.type)>-1||['+','-','++','--','~','!','(','[','{'].indexOf(nextToken.value)>-1)){ret+='\n';}}else if(token.type=='whitespace'){if(prevToken&&nextToken&&((['identifier','number'].indexOf(prevToken.type)>-1&&['identifier','number'].indexOf(nextToken.type)>-1)||(['+','-','++','--'].indexOf(prevToken.value)>-1&&['+','-','++','--'].indexOf(nextToken.value)>-1))){ret+=' ';}}else if(token.type!='comment'){ret+=token.value;}});return ret;}};Ox.test=function(argument,callback){function runTests(items){var id=Ox.uid(),regexp=/(.+Ox\.test\()/,results=[];Ox.test.data[id]={callback:callback,done:false,results:results,tests:{}};items.forEach(function(item){item.tests&&item.tests.some(function(test){return test.expected;})&&item.tests.forEach(function(test){var actual,statement=test.statement,isAsync=regexp.test(statement);if(isAsync){Ox.test.data[id].tests[test.statement]={expected:test.expected,name:item.name,section:item.section};statement=statement.replace(regexp,"$1'"+statement.replace(/'/g,"\\'")+"', ");}
|
|||
|
|
Ox.Log('TEST',statement);actual=eval(statement);if(!isAsync&&test.expected){Ox.test.data[id].results.push({actual:stringifyResult(actual),expected:test.expected,name:item.name,section:item.section,statement:statement,passed:Ox.isEqual(actual,eval('('+test.expected+')'))});}});});Ox.test.data[id].done=true;if(Ox.isEmpty(Ox.test.data[id].tests)){callback(Ox.test.data[id].results);delete Ox.test.data[id];}}
|
|||
|
|
function stringifyResult(result){return Ox.isEqual(result,-0)?'-0':Ox.isNaN(result)?'NaN':Ox.isUndefined(result)?'undefined':JSON.stringify(result);}
|
|||
|
|
if(arguments.length==2){if(Ox.typeOf(argument)=='string'&&Ox.contains(argument,'\n')){runTests(Ox.doc(argument));}else{argument=Ox.makeArray(argument);if(Ox.typeOf(argument[0])=='string'){Ox.doc(argument,runTests);}else{runTests(argument);}}}else{var statement=arguments[0],actual=arguments[1],expected=arguments[2],id,test;Ox.forEach(Ox.test.data,function(v,k){if(v.tests[statement]){id=k;test=v.tests[statement];return false;}});Ox.test.data[id].results.push(Ox.extend(test,{actual:stringifyResult(actual),statement:statement,passed:Ox.isEqual(actual,expected)}));delete Ox.test.data[id].tests[statement];if(Ox.test.data[id].done&&Ox.isEmpty(Ox.test.data[id].tests)){Ox.test.data[id].callback(Ox.test.data[id].results);delete Ox.test.data[id];}}};Ox.test.data={};Ox.tokenize=(function(){var comment=['//','/*'],identifier='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',linebreak='\n\r',number='0123456789',operator=['+','-','*','/','%','++','--','=','+=','-=','*=','/=','%=','&=','|=','^=','<<=','>>=','>>>=','&','|','^','~','<<','>>','>>>','==','!=','===','!==','>','>=','<','<=','?',':','(',')','[',']','{','}','&&','||','!','.',',',';'],regexp='abcdefghijklmnopqrstuvwxyz',string='\'"',whitespace=' \t';function isRegExp(tokens){var i=tokens.length-1,isRegExp,token
|
|||
|
|
while(i>=0&&['comment','linebreak','whitespace'].indexOf(tokens[i].type)>-1){i--;}
|
|||
|
|
if(i==-1){isRegExp=true;}else{token=tokens[i];isRegExp=(token.type=='identifier'&&Ox.identify(token.value)=='keyword'&&['false','null','true'].indexOf(token.value)==-1)||(token.type=='operator'&&['++','--',')',']','}'].indexOf(token.value)==-1);}
|
|||
|
|
return isRegExp;}
|
|||
|
|
return function(source){var char,column=1,cursor=0,delimiter,length=source.length,line=1,lines,next,tokens=[],start,type,value;source=source.replace(/\r\n/g,'\n').replace(/\r/g,'\n');while(cursor<length){start=cursor;char=source[cursor];if(comment.indexOf(delimiter=char+source[cursor+1])>-1){type='comment';++cursor;while(char=source[++cursor]){if(delimiter=='//'&&char=='\n'){break;}else if(delimiter=='/*'&&char+source[cursor+1]=='*/'){cursor+=2;break;}}}else if(identifier.indexOf(char)>-1){type='identifier';while((identifier+number).indexOf(source[++cursor])>-1){}}else if(linebreak.indexOf(char)>-1){type='linebreak';while(linebreak.indexOf(source[++cursor])>-1){}}else if(number.indexOf(char)>-1||char=='.'&&number.indexOf(source[cursor+1])>-1){type='number';while((number+'.abcdefxABCDEFX+-').indexOf(source[++cursor])>-1){if(source[cursor-1]!='e'&&source[cursor-1]!='E'&&(source[cursor]=='+'||source[cursor]=='-')){break;}}}else if(char=='/'&&isRegExp(tokens)){type='regexp';while((char=source[++cursor])!='/'&&cursor<length){char=='\\'&&++cursor;}
|
|||
|
|
while(regexp.indexOf(source[++cursor])>-1){}}else if(operator.indexOf(char)>-1){type='operator';while(operator.indexOf(char+=source[++cursor])>-1&&cursor<length){}}else if(string.indexOf(delimiter=char)>-1){type='string';while((char=source[++cursor])!=delimiter&&cursor<length){char=='\\'&&++cursor;}
|
|||
|
|
++cursor;}else if(whitespace.indexOf(char)>-1){type='whitespace';while(whitespace.indexOf(source[++cursor])>-1){}}else{type='error';++cursor;}
|
|||
|
|
value=source.slice(start,cursor);if(type=='error'&&tokens.length&&tokens[tokens.length-1].type=='error'){tokens[tokens.length-1].value+=value;}else{tokens.push({column:column,line:line,type:type,value:value});}
|
|||
|
|
if(type=='comment'){lines=value.split('\n');column=lines[lines.length-1].length;line+=lines.length-1;}else if(type=='linebreak'){column=1;line+=value.length;}else{column+=value.length;}}
|
|||
|
|
return tokens;};}());'use strict';(function(){var log,translations={};Ox.getLocale=function(){return Ox.LOCALE;};Ox.setLocale=function(locale,url,callback){var isValidLocale=Ox.contains(Object.keys(Ox.LOCALE_NAMES),locale),urls=[];if(arguments.length==2){callback=arguments[1];url=null;}
|
|||
|
|
if(isValidLocale){Ox.LOCALE=locale;if(locale=='en'){translations={};}else{translations={};Ox.forEach(Ox.LOCALES,function(locales,module){if((module=='Ox'||Ox.load[module])&&Ox.contains(locales,locale)){urls.push([Ox.PATH+module+'/json/locale.'
|
|||
|
|
+locale+'.json']);}});}
|
|||
|
|
url&&Ox.makeArray(url).forEach(function(value){urls.push(Ox.makeArray(value));});if(urls.length){Ox.getJSON(urls,function(data){Ox.forEach(data,function(values,url){Ox.extend(translations,values);});callback(true);})}else{callback(true);}}else{callback(false);}};Ox._=function(value,options){var translation=translations[value];log&&log(value,translation);translation=translation||value||'';return Ox.formatString(translation,options);};Ox._.log=function(callback){log=callback;};})();'use strict';Ox.extend=function(object){var args=Ox.slice(arguments,1);if(!Ox.isObject(args[0])){args=[Ox.makeObject(args)];}
|
|||
|
|
Ox.forEach(args,function(arg){Ox.forEach(arg,function(value,key){object[key]=value;});});return object;};Ox.getset=function(object,args,callback,that){var object_=Ox.clone(object),ret;if(args.length==0){ret=object_;}else if(args.length==1&&!Ox.isObject(args[0])){ret=Ox.clone(object[args[0]]);}else{args=Ox.makeObject(args);object=Ox.extend(object,args);Ox.forEach(args,function(value,key){if(!object_||!Ox.isEqual(object_[key],value)){callback&&callback(key,value);}});ret=that;}
|
|||
|
|
return ret;};Ox.hasOwn=function(object,value){return Object.prototype.hasOwnProperty.call(object,value);};Ox.keyOf=function(object,value){var key;Ox.forEach(object,function(v,k){if(v===value){key=k;return false;}});return key;};Ox.makeObject=function(array){var ret={};if(Ox.isObject(array[0])){ret=array[0];}else if(array.length){ret[array[0]]=array[1];}
|
|||
|
|
return ret;};Ox.methods=function(object,includePrototype){var key,keys;if(includePrototype){keys=[];for(var key in object){keys.push(key);}}else{keys=Object.keys(object);}
|
|||
|
|
return keys.filter(function(key){return Ox.isFunction(object[key]);}).sort();};Ox.serialize=function(object,isJSON){var ret=[];Ox.forEach(object,function(value,key){var value;if(isJSON){try{value=JSON.stringify(value);}catch(e){}}
|
|||
|
|
if(!Ox.isEmpty(value)&&!Ox.isNull(value)&&!Ox.isUndefined(value)){ret.push(key+'='+value);}});return ret.join('&');};Ox.unserialize=function(string,isJSON){var ret={};Ox.filter(string.split('&')).forEach(function(value){var array=value.split('=');if(array[1]){if(isJSON){try{ret[array[0]]=JSON.parse(array[1]);}catch(e){ret[array[0]]=array[1];}}else{ret[array[0]]=array[1];}}});return ret;};Ox.zipObject=function(keys,values){var object={};keys=Ox.makeArray(keys);values=Ox.makeArray(values);keys.forEach(function(key,index){object[key]=values[index];});return object;};Ox.escapeRegExp=function(string){return(string+'').replace(/([\/\\^$*+?.\-|(){}[\]])/g,'\\$1');};'use strict';Ox.get=function(url,callback){var request=new XMLHttpRequest();request.open('GET',url,true);request.onreadystatechange=function(){if(request.readyState==4){if(request.status==200){callback(request.responseText,null);}else{callback(null,{code:request.status,text:request.statusText});}}};request.send();};Ox.getAsync=function(urls,get,callback){urls=Ox.makeArray(urls);var errors={},i=0,n=urls.length,results={};function done(){callback&&callback(filter(results),filter(errors));}
|
|||
|
|
function extend(object,value,urls){value!==null&&Ox.extend.apply(null,[object].concat(urls.length===1?[urls[0],value]:[value]));}
|
|||
|
|
function filter(object){return n==1?object[urls[0]]:Ox.filter(object,function(value){return value!==null;});}
|
|||
|
|
function getParallel(){urls.forEach(function(url){get(url,function(result,error){results[url]=result;errors[url]=error;++i==n&&done();});});}
|
|||
|
|
function getSerial(){var url=urls.shift();Ox.getAsync(url,get,function(result,error){extend(results,result,url);extend(errors,error,url);urls.length?getSerial():done();});}
|
|||
|
|
urls.some(Ox.isArray)?getSerial():getParallel();};(function(){var cache={},head=document.head||document.getElementsByTagName('head')[0]||document.documentElement;function getFile(type,url,callback){var element,tagValue,typeValue,urlKey;if(!cache[url]){if(!type){type=Ox.parseURL(url).pathname.split('.').pop();type=type=='css'?'stylesheet':type=='js'?'script':'image';}
|
|||
|
|
if(type=='image'){element=new Image();element.onerror=onError;element.onload=onLoad;element.src=url;}else{tagValue=type=='script'?'script':'link';typeValue=type=='script'?'text/javascript':'text/css';urlKey=type=='script'?'src':'href';if(Ox.some(document.getElementsByTagName(tagValue),function(element){return element[urlKey]==url;})){onLoad();}else{element=document.createElement(tagValue);element.onerror=onError;element.onload=element.onreadystatechange=onLoad;element.type=typeValue;element[urlKey]=url;if(type=='stylesheet'){element.rel='stylesheet';}
|
|||
|
|
head.appendChild(element);}
|
|||
|
|
if(type=='stylesheet'){waitForCSS();}}}else{callback(cache[url],null);}
|
|||
|
|
function onError(){callback(null,{code:404,text:'Not Found'});}
|
|||
|
|
function onLoad(){if(!this||!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){cache[url]=type=='image'?this:true;callback(cache[url],null);}}
|
|||
|
|
function waitForCSS(){var error=false;try{element.sheet.cssRule;}catch(e){error=true;setTimeout(function(){waitForCSS();},25);}
|
|||
|
|
!error&&onLoad();}}
|
|||
|
|
function getFiles(type,urls,callback){Ox.getAsync(urls,function(url,callback){getFile(type,url,callback);},callback);}
|
|||
|
|
Ox.getFile=function(url,callback){getFiles(null,url,callback);};Ox.getImage=function(url,callback){getFiles('image',url,callback);};Ox.getScript=function(url,callback){getFiles('script',url,callback);};Ox.getStylesheet=function(url,callback){getFiles('stylesheet',url,callback);};}());Ox.getJSON=function(url,callback,isJSONC){var urls=Ox.makeArray(url);Ox.getAsync(urls,function(url,callback){Ox.get(url,function(data,error){callback(JSON.parse(isJSONC?Ox.minify(data||''):data),error);});},callback);};Ox.getJSONC=function(url,callback){Ox.getJSON(url,callback,true);};Ox.getJSONP=function(url,callback){var urls=Ox.makeArray(url);Ox.getAsync(urls,function(url,callback){var id='callback'+Ox.uid();Ox.getJSONP[id]=function(data){delete Ox.getJSONP[id];callback(data,null);};Ox.$('body').append(Ox.$('<script>').attr({'src':url.replace('{callback}','Ox.getJSONP.'+id),'type':'text/javascript'}));},callback);};Ox.post=function(url,data,callback){var request=new XMLHttpRequest();request.open('post',url,true);request.onreadystatechange=function(){if(request.readyState==4){if(request.status==200){callback(request.responseText,null);}else{callback(null,{code:request.status,text:request.statusText});}}};request.send(data);};'use strict';Ox.getVideoFormat=function(formats){var aliases={mp4:'h264',m4v:'h264',ogv:'ogg'},tests={h264:'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',ogg:'video/ogg; codecs="theora, vorbis"',webm:'video/webm; codecs="vp8, vorbis"'},userAgent=navigator.userAgent.toLowerCase(),video=document.createElement('video'),videoFormat;Ox.forEach(formats,function(format){var alias=aliases[format]||format;if(video.canPlayType&&video.canPlayType(tests[alias]).replace('no','')){if(!(alias=='webm'&&/safari/.test(userAgent)&&!/chrome/.test(userAgent)&&!/linux/.test(userAgent))){videoFormat=format;return false;}}});return videoFormat;};Ox.getVideoInfo=Ox.queue(function(url,callback){Ox.Log('VIDEO','getVideoInfo',url);var video=document.createElement('video');video.addEventListener('loadedmetadata',function(event){Ox.Log('VIDEO','getVideoInfo done',url);var info={duration:this.duration,widht:this.videoWidth,height:this.videoHeight,};this.src='';Ox.$(video).remove();video=null;callback(info);});video.preload='metadata';video.src=url;video.style.display='none';Ox.$body.append(video);},4);
|