_K={};
_K.handler = function() {
var _handlers = [];
var _find = function(_param) {
var _len=_handlers.length;
if(_len == 0) {
return -1;
}else{
var _d = -1;
for(var i=0;i<_len;i++){
var _handler=_handlers[i];
if(_handler.elm==_param.elm&&_handler.type==_param.type&&_handler.func==_param.func){
_d = i;
}
}
return _d;
}
};
return {
add : function(_elm, _type, _this, _func) {
var _param = {
'elm':_elm,
'type':_type,
'func':_func
};
if(_find(_param)!=-1)return;
var _wrapper = function(event) {
return _func.call(_this, event)
};
_elm.addEventListener(_type, _wrapper, false);
_param.wrapper=_wrapper;
_handlers.push(_param);
},
remove : function(_elm, _type,_func) {
var _param = {
'elm':_elm,
'type':_type,
'func':_func
};
var _i = _find(_param);
if(_i==-1){
return;
}else{
var _wrapper = _handlers[_i].wrapper;
_elm.removeEventListener(_type,_wrapper, false);
_handlers.splice(_i,1);
}
},
list:function(){
return _handlers;
}
}
}();
_K.LoadScript=function(_data){
this.head=document.getElementsByTagName('head')[0];
this.script=document.createElement('script');
this.data=_data;
};
_K.LoadScript.prototype.append=function(){
var _src=(_K._STATIC_.CACHE)?this.data.src+'?ver='+ new Date().getMilliseconds():this.data.src;
this.script.src=_src;
this.script.type="text/javascript";
this.head.appendChild(this.script);
};
_K.Meta=function(){
this.head=document.getElementsByTagName('head')[0];
};
_K.Meta.prototype.viewportCreater=function(){
var _viewport = document.createElement('meta');
_viewport.name="viewport";
_viewport.content="width = 480,initial-scale=1,user-scalable=no";
_viewport.id='_K.viewport:'+new Date().getMilliseconds();
this.head.appendChild(_viewport);
};
_K.Css=function(_event){
this.head=document.getElementsByTagName('head')[0];
this.width=window.innerWidth;
this.height=window.innerHeight;
this.orientation=(this.width>this.height)?'landscape':'portrait';
this.dump=document.getElementById('dump0');
this.resize(_event);
_K.handler.add(window,'resize',this,this.resize);
};
_K.Css.prototype.resize=function(event){
var _documentWidth=document.documentElement.scrollWidth;
var _documentHeight=document.documentElement.scrollHeight;
var _span = document.createElement('span');
_span.innerHTML=event.type+' /width:'+window.innerWidth+' /height:'+window.innerHeight+'<br />';
_span.innerHTML+='documentWidth:'+_documentWidth+' /documentHeight:'+_documentHeight+'<br />';
_span.innerHTML+='orientation:'+window.orientation+'<br />';
this.dump.appendChild(_span);
}
_K.load=function(_event){
_css=new _K.Css(_event);
};
_K._STATIC_={
CACHE:true
};
(function(){
var _meta = new _K.Meta();
_meta.viewportCreater();
window.addEventListener('load',_K.load,false);
})();