$util = {
/**
* 유형 감지
*/
유형 : function(obj){
var rep = /[객체(w )]/i;
var str = Object.prototype.toString.call(obj).toLowerCase();
str.match(rep);
return RegExp.$1;
},
/**
* 전체 복사
*/
$unlink :function (객체){
var unlinked;
스위치 ($type(객체)){
케이스 '객체':
unlinked = {};
for (var p in object) {
unlinked[p] = $unlink(object[p]);
}
break;
'배열':
연결 해제됨 = [];
for (var i = 0, l = object.length; i < l; i ) {
unlinked[i] = $unlink(object[i]);
}
휴식;
기본값: 객체 반환;
}
연결 해제된 반환;
},
/**
*돔 관련 운영
*/
dom:{
$: 함수(id) {
return document.getElementById(id);
},
getStyle: function(obj, prop) {
var style = obj.currentStyle || window.getCompulatedStyle(obj, '');
if (obj.style.filter) {
return obj.style.filter.match(/d /g)[0];
}
return style[prop];
},
setStyle: function(obj, prop, val) {
스위치(prop) {
케이스 '불투명도':
if($util.client .browser.ie){
obj.style.filter = 'alpha(' prop '=' val*100 ')'
}else{
obj.style[prop] = val;
}
break;
기본값:
obj.style[prop] = val 'px';
break;
}
},
setStyles: function(obj, props) {
for (props의 var prop) {
스위치(prop) {
케이스 '불투명도':<> if($util.client. browser.ie){
obj.style.filter = 'alpha(' prop '=' props[prop] ')'
}else{
obj.style[prop] = 소품[prop];
}
break;
기본값:
obj.style[prop] = props[prop] 'px';
휴식;
}
}
}
},
/**
*이벤트 이벤트 관련
*/
evt : {
addEvent : function(oTarget, sEventType, fnHandler) {
if (oTarget.addEventListener) {
o타겟. addEventListener(sEventType, fnHandler, false);
} else if (oTarget.attachEvent) {
oTarget.attachEvent("on" sEventType, fnHandler);
} else {
oTarget["on" sEventType] = fnHandler;
}
},
rmEvent : function RemoveEventHandler (oTarget, sEventType, fnHandler) {
if (oTarget.removeEventListener) {
oTarget.removeEventListener(sEventType, fnHandler, false);
} else if (oTarget.detachEvent) {
oTarget.detachEvent("on" sEventType, fnHandler);
} else { oTarget["on" sEventType] = null;
}
}
},
/**
*Ajax 비동기 로딩
*/
ajax : {
요청:함수(옵션) {
var xhr, res;
var url = options.url,
맥락 = options.context,
성공 = options.success,
type = options.type,
데이터 유형 =
async = options.async,
보내기 = options.send,
헤더 = options.headers;
시도 {
xhr = new XMLHttpRequest();
} catch(e ) {
시도해 보세요 {
xhr = new ActiveXObject(' MSXML2.XMLHTTP');
} catch(e) {
xhr = new ActiveXObject('Microsoft.XMLHTTP');
}
}
xhr.onreadystatechange = 기능( ) {
if (xhr.readyState == 4 && xhr.status == 200) {
res = xhr.responseText;
성공(res);
}
}
xhr.open(type, url, async);
xhr.send(send);
}
},
/**
*어레이 어레이 관련
*/
배열 : {
minIndex : 함수(ary){
return Math.min.apply(null,ary);
},
최대 항목 : 함수(ary){
return Math.max.apply(null,ary);
}
},
/**
*Client 客户端检测
*/
client : function(){
// 浏览器渲染引擎 engines
var engine = {
ie: 0,
gecko: 0,
webkit: 0,
khtml: 0,
opera: 0,
//complete version
ver: null
};
// 浏览器
var browser = {
//browsers
ie: 0,
firefox: 0,
safari: 0,
konq: 0,
opera: 0,
chrome: 0,
//specific version
ver: null
};
// 客户端平台platform/device/OS
var system = {
win: false,
mac: false,
x11: false,
//移动设备
iphone: false,
ipod: false,
ipad: false,
ios: false,
android: false,
nokiaN: false,
winMobile: false,
//game systems
wii: false,
ps: false
};
// 检测浏览器引擎
var ua = navigator.userAgent;
if (window.opera){
engine.ver = browser.ver = window.opera.version();
engine.opera = browser.opera =parseFloat(engine.ver);
} else if (/AppleWebKit/(S )/.test(ua)){
engine.ver = RegExp["$1"];
engine.webkit =parseFloat(engine.ver);
//Chrome인지 Safari인지 확인
if (/Chrome/(S )/.test(ua)){
browser.ver = RegExp["$1"];
browser.chrome =parseFloat(browser.ver);
} else if (/Version/(S )/.test(ua)){
browser.ver = RegExp["$1"];
browser.safari = parseFloat(browser.ver);
} else {
//대략적인 버전
var safariVersion = 1;
if (engine.webkit < 00){
safariVersion = 1;
} else if (engine.webkit < 312){
safariVersion = 1.2;
} else if (engine.webkit < 412){
safariVersion = 1.3;
} else {
safariVersion = 2;
}
browser.safari = browser.ver = safariVersion;
}
} else if (/KHTML/(S )/.test(ua) || /Konqueror/([^;] )/.test(ua)){
engine.ver = 브라우저 .ver = RegExp["$1"];
engine.khtml = browser.konq =parseFloat(engine.ver);
} else if (/rv:([^)] )) Gecko/d{8 }/.test(ua)){
engine.ver = RegExp["$1"];
engine.gecko =parseFloat(engine.ver);
//Firefox인지 확인
if (/Firefox/(S )/.test(ua)){
browser.ver = RegExp["$1"];
browser.firefox = parseFloat(browser.ver);<🜜> }
} else if (/MSIE ([^;] )/.test(ua)){
engine.ver = browser.ver = RegExp["$1"];
engine.ie = 브라우저. 즉 =parseFloat(engine.ver);
}
//detect browsers
browser.ie = engine.ie;
browser.opera = engine.opera;
//detect platform
var p = navigator.platform;
system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
//Windows 운영 체제 감지
if (system.win){
if (/Win(?:dows )?([^do]{2})s?(d .d )?/ .test(ua)){
if (RegExp["$1"] == "NT"){
스위치(RegExp["$2"]){
케이스 "5.0":
시스템 .win = "2000";
break;
사례 "5.1":
system.win = "XP" ;
break;
사례 "6.0":
system.win = "Vista";
break;
사례 "6.1":
system.win = "7";
break;
기본값:
system.win = "NT";
휴식;
}
} else if (RegExp["$1"] == "9x"){
시스템 .win = "ME";
} else {
system.win = RegExp[ "$1"];
}
}
}
//모바일 기기
system.iphone = ua.indexOf("iPhone") > -1;
system.ipod = ua.indexOf("iPod") > -1;
system.ipad = ua.indexOf("iPad") > -1;
system.nokiaN = ua.indexOf("NokiaN") > -1;
//windows mobile
if (system.win == "CE"){
system.winMobile = system.win;
} else if (system.win == "Ph"){
if(/Windows Phone OS (\d+.\d+)/.test(ua)){;
system.win = "Phone";
system.winMobile = parseFloat(RegExp["$1"]);
}
}
//determine iOS version
if (system.mac && ua.indexOf("Mobile") > -1){
if (/CPU (?:iPhone )?OS (\d+_\d+)/.test(ua)){
system.ios = parseFloat(RegExp.$1.replace("_", "."));
} else {
system.ios = 2; //can't really detect - so guess
}
}
//determine Android version
if (/Android (\d+\.\d+)/.test(ua)){
system.android = parseFloat(RegExp.$1);
}
//gaming systems
system.wii = ua.indexOf("Wii") > -1;
system.ps = /playstation/i.test(ua);
//return it
return {
engine: engine,
browser: browser,
system: system
};
}(),
/**
*트윈 완화 관련
*/
트윈: {
선형: 함수(t, b, c, d) {
return c * t / d b;
},
쿼드: {
easyIn: function(t, b, c, d) {
return c * (t /= d) * t b;
},
easyOut: 함수(t, b, c, d) {
return - c * (t /= d) * (t - 2) b;
},
easyInOut: 함수(t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t b;
return - c / 2 * ((--t) * (t - 2) - 1) b;
}
},
큐빅: {
easyIn: function(t, b, c, d) {
return c * (t /= d) * t * t b;
},
easyOut: function(t, b, c, d) {
return c * ((t = t / d - 1) * t * t 1) b;
},
easyInOut: function(t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t b;
return c / 2 * ((t -= 2) * t * t 2) b;
}
},
쿼트: {
easyIn: function(t, b , 씨, d) {
return c * (t /= d) * t * t * t b;
},
easyOut: function(t, b, c, d) {
return - c * ((t = t / d - 1) * t * t * t - 1) b;
},
easyInOut: function(t, b, c, d) {
if ((t / = d / 2) < 1) 반환 c / 2 * t * t * t * t b;
반환 - c / 2 * ((t -= 2) * t * t * t - 2) b;
}
} ,
Quint: {
easyIn: function(t, b, c, d) {
return c * (t /= d) * t * t * t * t b;
},
easyOut: function(t, b, c, d) {
return c * ((t = t / d - 1) * t * t * t * t 1) b;
},
easyInOut: function(t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t b;
c / 2 * ((t -= 2) * t * t * t * t 2) b;
}
},
사인: {
: 함수(t, b, c, d) {
return - c * Math.cos(t / d * (Math.PI / 2)) c b;
},
easyOut: function(t, b, c, d) {
return c * Math.sin(t / d * (Math.PI / 2)) b;
},
easyInOut: function(t, b, c, d) {
return -c / 2 * (Math.cos (Math.pi * t / d) -1) b;
} <🎜}, <🎜 엑스포 : {
easein : function (t, b , c, d) {
반환(t == 0) ? b: c * Math.pow(2, 10 * (t / d - 1)) b;
},
easyOut: function(t, b, c, d) {
return (t = =디) ? b c: c * ( - Math.pow(2, -10 * t / d) 1) b;
},
easyInOut: function(t, b, c, d) {
if (t == 0) return b;
if (t == d) return b c;
if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) b;
반환 c / 2 * ( - Math.pow(2, -10 * --t) 2) b;
}
},
원: {
easyIn: function(t, b, c, d) {
return - c * (Math.sqrt(1 - (t /= d) * t) - 1) b;
},
easyOut: function(t, b, c, d) {
return c * Math.sqrt(1 - (t = t / d - 1) * t) b;
},
easyInOut : function(t, b, c, d) {
if ((t /= d / 2) < 1) return - c / 2 * (Math.sqrt(1 - t * t) - 1) b ;
반환 c / 2 * (Math.sqrt(1 - (t -= 2) * t) 1) b;
}
},
탄력적: {
easyIn: function(t, b, c, d, a, p) {
if (t == 0) return b;
if ((t /= d ) == 1) return b c;
if (!p) p = d * .3;
if (!a || a < Math.abs(c)) {
a = c;
var s = p / 4;
} else var s = p / (2 * Math.PI) * Math.asin(c / a);
return - (a * Math.pow(2 , 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) b;
},
easyOut: function(t, b, c, d, a, p) {
if (t == 0) return b;
if ((t /= d) == 1) return b c;
if (!p) p = d * .3;
if (!a || a < Math.abs(c)) {
a = c;
var s = p / 4;
} else var s = p / (2 * Math.PI) * Math.asin(c / a);
return (a * Math.pow(2, -10 * t) * Math.sin((t * d - s ) * (2 * Math.PI) / p) c b);
},
easyInOut: function(t, b, c, d, a, p) {
if (t == 0) return b;
if ((t /= d / 2) == 2) return b c;
if (!p) p = d * (.3 * 1.5);
if (!a | | < Math.abs(c)) {
a = c;
var s = p / 4;
} else var s = p / (2 * Math.PI) * Math.asin(c / a );
if (t < 1) return - .5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) b;
return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math .pi) / p) * .5 c b;
} <🎜} <🎜}, back : {
easein : function (t, b, c, d, s) {<× if (s == 정의되지 않음) s = 1.70158;
return c * (t /= d) * t * ((s 1) * t - s) b;
},
easyOut: function(t, b, c, d, s) {
if (s == undefine) s = 1.70158;
return c * ((t = t / d - 1) * t * ((s 1) * t s) 1) b;
},
easyInOut: function(t, b, c, d, s) {
if (s == 정의되지 않음) s = 1.70158 ;
if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) 1) * t - s)) b;
c / 2 * ((t -= 2) * t * (((s *= (1.525)) 1) * t s) 2) b;
}
},
바운스: {
easyIn: function(t, b, c, d) {
return c - Tween.Bounce.easeOut(d - t, 0, c, d) b;
},
easyOut: function(t, b, c, d) {
if ((t /= d) < (1 / 2.75)) {
return c * (7.5625 * t * t) b;
} else if (t < (2 / 2.75)) {
return c * (7.5625 * (t -= (1.5 / 2.75)) * t .75) b;
} else if (t < ( 2.5 / 2.75)) {
return c * (7.5625 * (t -= (2.25 / 2.75)) * t .9375) b;
} else {
c * (7.5625 * (t - = (2.625 / 2.75)) * t .984375) b;
}
},
easyInOut: function(t, b, c, d) if (t < d / 2) return Tween.Bounce.easeIn(t * 2, 0, c, d) * .5 b;
그렇지 않으면 Tween.Bounce.easeOut(t * 2 - d, 0, c, d) *를 반환합니다. .5 c * .5 b;
}
}
}
}
하측면是个应용: