//디바이스타입 파악을 위한 변수
var MOBILE_USER_AGENT_PREFIXES = [ "w3c ", "w3c-", "acs-", "alav",
"alca", "amoi", "audi", "avan", "benq", "bird", "blac", "blaz", "brew",
"cell", "cldc", "cmd-", "dang", "doco", "eric", "hipt", "htc_", "inno",
"ipaq", "ipod", "jigs", "kddi", "keji", "leno", "lg-c", "lg-d", "lg-g",
"lge-", "lg/u", "maui", "maxo", "midp", "mits", "mmef", "mobi", "mot-",
"moto", "mwbp", "nec-", "newt", "noki", "palm", "pana", "pant", "phil",
"play", "port", "prox", "qwap", "sage", "sams", "sany", "sch-", "sec-",
"send", "seri", "sgh-", "shar", "sie-", "siem", "smal", "smar", "sony",
"sph-", "symb", "t-mo", "teli", "tim-", "tosh", "tsm-", "upg1", "upsi",
"vk-v", "voda", "wap-", "wapa", "wapi", "wapp", "wapr", "webc", "winw",
"winw", "xda ", "xda-" ];
var MOBILE_USER_AGENT_KEYWORDS = [ "blackberry", "webos", "ipod",
"lge vx", "midp", "maemo", "mmp", "netfront", "hiptop", "nintendo DS",
"novarra", "openweb", "opera mobi", "opera mini", "palm", "psp",
"phone", "smartphone", "symbian", "up.browser", "up.link", "wap",
"windows ce" ];
var TABLET_USER_AGENT_KEYWORDS = [ "ipad", "playbook", "hp-tablet" ];
//디바이스타입 파악
// @returns NORMAL(PC), MOBILE, TABLET
function getDeviceType() {
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent != null && userAgent.length > 0) {
var tUserAgent = userAgent.slice(0, 4);
for ( var i = 0; i < MOBILE_USER_AGENT_PREFIXES.length; i++) {
if (tUserAgent.indexOf(MOBILE_USER_AGENT_PREFIXES[i], 0) != -1) {
return 'MOBILE';
}
}
}
for ( var i = 0; i < MOBILE_USER_AGENT_KEYWORDS.length; i++) {
if (userAgent.indexOf(MOBILE_USER_AGENT_KEYWORDS[i], 0) != -1) {
return 'MOBILE';
}
}
for ( var ii = 0; ii < TABLET_USER_AGENT_KEYWORDS.length; ii++) {
if (userAgent.indexOf(TABLET_USER_AGENT_KEYWORDS[ii], 0) != -1) {
return 'TABLET';
}
}
if (userAgent.indexOf("android") != -1 && userAgent.indexOf("mobile") != -1) {
return 'MOBILE';
} else if (userAgent.indexOf("android") != -1
&& userAgent.indexOf("mobile") == -1) {
return 'TABLET';
}
return 'NORMAL';
}
//Parameters를 parsing
// @returns (JSON) parameters
function getBroadCastParam(){
var param ={};
var varName = '';
var value = '';
var nowAddress = decodeURIComponent(location.href);
var parameters = '';
if(nowAddress.indexOf('?') != -1){
parameters = (nowAddress.slice(nowAddress.indexOf('?')+1,nowAddress.length)).split('&');
for(var i = 0 ; i < parameters.length ; i++) {
varName = parameters[i].split('=')[0];
value = parameters[i].split('=')[1];
param[varName] = value;
}
}
param["deviceType"] = getDeviceType();
param["proxyPage"] = "Y";
return param;
}
/* ★사용법★*/
var param = getBroadCastParam();
if (param["deviceType"] != 'MOBILE') {
param["deviceType"] = 'NORMAL';
}