1 line
2.6 KiB
JavaScript
1 line
2.6 KiB
JavaScript
function ucfirst(str){str+="";var f=str.charAt(0).toUpperCase();return f+str.substr(1)}function arrayRemove(array,element){var index=array.indexOf(element);if(index==-1){return}array.splice(index,1);return array}function json_parse(str,info){try{return JSON.parse(str)}catch(err){if(info!=undefined){}console.error("Error parsing json :: "+err+" :: "+str)}}function isOnStage(element){return $(element).closest("body").length>0}function trim(str,charlist){var whitespace,l=0,i=0;str+="";if(!charlist){whitespace=" \n\r\t\f\v \u2028\u2029 "}else{charlist+="";whitespace=charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g,"$1")}l=str.length;for(i=0;i<l;i++){if(whitespace.indexOf(str.charAt(i))===-1){str=str.substring(i);break}}l=str.length;for(i=l-1;i>=0;i--){if(whitespace.indexOf(str.charAt(i))===-1){str=str.substring(0,i+1);break}}return whitespace.indexOf(str.charAt(0))===-1?str:""}(function(){var lastTime=0;var vendors=["ms","moz","webkit","o"];for(var x=0;x<vendors.length&&!window.requestAnimationFrame;++x){window.requestAnimationFrame=window[vendors[x]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[vendors[x]+"CancelAnimationFrame"]||window[vendors[x]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame)window.requestAnimationFrame=function(callback,element){var currTime=(new Date).getTime();var timeToCall=Math.max(0,16-(currTime-lastTime));var id=window.setTimeout(function(){callback(currTime+timeToCall)},timeToCall);lastTime=currTime+timeToCall;return id};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=function(id){clearTimeout(id)}})();function guid(){function s4(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4()}function loadImage(src,callback){var img=new Image;var loaded=false;$(img).on("load",function(){if(loaded){return}loaded=true;callback(img)});img.src=src;if($(img).isLoaded()){if(!loaded){loaded=true;callback(img)}}return img}function getSVGDocument(element){var el=$(element).get(0);if(el.contentDocument){return el.contentDocument}else{var subdoc=null;try{subdoc=el.getSVGDocument()}catch(e){}return subdoc}}Object.size=function(obj){var size=0,key;for(key in obj){if(obj.hasOwnProperty(key))size++}return size};function fb(o,type){if(o==undefined){o=""}if(type==undefined){type="log"}var string="";string=JSON.stringify(o);if(window.console!=undefined){try{if(type=="log"){window.console.log(o)}else if(type=="error"){window.console.error(o)}}catch(err){}}return}function is(type,obj){var clas=Object.prototype.toString.call(obj).slice(8,-1);return obj!==undefined&&obj!==null&&clas===type} |