/* * Copyright (c) 2008 COOPS. All rights reserved. * * This software is the confidential and proprietary information of COOPS. * You shall not disclose such Confidential Information and shall use it * only in accordance with the terms of the license agreement you entered into * with COOPS. */ /** *
  • Business Group : Java Script Util
  • *
  • Sub Business Group : Java Script Map Object
  • *
  • Description : Java Script Map Object
  • *
  • Developer : Son JungHwan & 김현수
  • *
  • Date : 2008. 04. 08
  • */ function SMap() { this.key = new Array(); this.value = new Array(); this.array = new Array(); } /** *
     *   Function : Map Object put
     *   Date : 2008. 04. 08
     * 
    * * @param key * value */ SMap.prototype.put = function(key, value) { var idx = this.containsKey(key); if ( idx == -1 ) { this.key.push(key); this.value.push(value); this.array[key] = value; } else { this.value[idx] = value; this.array[key] = value; } } /** *
     *   Function : Map Object get value using key
     *   Date : 2008. 04. 08
     * 
    * * @param key * @return value */ SMap.prototype.get = function(key) { return this.array[key]; } /** *
     *   Function : Map Object remove value using key
     *   Date : 2008. 04. 08
     * 
    * * @param key * @return 1 : success * -1 : key is not exist */ SMap.prototype.remove = function(key) { var idx = this.containsKey(key); var mapArray = new Array(); if ( idx == -1 ) { return -1; } else { this.key.splice(idx,1); this.value.splice(idx,1); for ( i = 0; i < this.key.length; i++ ) { mapArray[this.key[i]] = this.key[i]; } this.array = mapArray; return 1; } } /** *
     *   Function : Map Object get size
     *   Date : 2008. 04. 08
     * 
    * * @return value */ SMap.prototype.size = function() { return this.key.length; } /** *
     *   Function : Map Object key Existence
     *   Date : 2008. 04. 08
     * 
    * * @param key * @return idx : key's index * -1 : key is not exist */ SMap.prototype.containsKey = function(key) { var idx = -1; for ( i=0; i < this.size(); i++ ) { if ( this.key[i] == key ) { idx = i; } } return idx; } /** *
     *   Function : Map Object get key using index
     *   Date : 2008. 04. 08
     * 
    * * @param idx * @return key */ SMap.prototype.getKey = function(idx) { return this.key[idx]; } /** *
     *   Function : Map Object get value using index
     *   Date : 2008. 04. 08
     * 
    * * @param idx * @return value */ SMap.prototype.getWithIdx = function(idx) { return this.value[idx]; } function SNavigation(nPage){ this.nPage = nPage; this.path = window.location.pathname + "?nPage=" + this.nPage; } /** *
     *   Function : p_로 시작하는 파라미터 값을 가져온다.
     *   Date : 2008. 04. 08
     * 
    * * @return p_parameters */ SNavigation.prototype.getP_parameters = function(){ var p_parameters= ""; var targetTags = document.getElementsByTagName("input"); for ( var i = 0; i < targetTags.length; i++ ) { var key = targetTags[i].name; if ( key && key.substring(0, 2) == "p_" && targetTags[i].value != null && targetTags[i].value != "" ) { p_parameters += "&" + key + "=" + targetTags[i].value; } } targetTags = document.getElementsByTagName("select"); for ( var i = 0; i < targetTags.length; i++ ) { var key = targetTags[i].name; if ( key && key.substring(0, 2) == "p_" && targetTags[i].value != null && targetTags[i].value != "" ) { p_parameters += "&" + key + "=" + targetTags[i].value; } } return p_parameters; } SNavigation.prototype.move = function(){ new SLink(this.path).move(); } /** *
     *   Function : 페이지 이동의 링크의 파라미터를 관리한다.
     *   Date : 2008. 04. 23
     * 
    * * @param path */ function SLink(path){ this.path = path; this.map = new SMap(); } /** *
     *   Function : p_로 시작하는 파라미터 값을 가져온다.
     *   Date : 2008. 04. 23
     * 
    * */ SLink.prototype.move = function(){ var pathPameter; var pathParamList; if ( this.path.indexOf('?', 0) != -1 ) { pathPameter = this.path.substring(this.path.indexOf('?', 0) + 1, this.path.length); pathParamList = pathPameter.split('&', pathPameter.length); } if ( pathParamList != null && pathParamList.length != 0) { var realPath = this.path.substring(0, this.path.indexOf('?', 0)); var p_Param = this.getP_parameters(); var p_PramList = p_Param.split('&', p_Param.length); var p_Map = new SMap(); for (var i = 0; i < p_PramList.length ; i++ ) { var strKey = p_PramList[i].substring(0, p_PramList[i].indexOf('=', 0)); var strValue = p_PramList[i].substring(p_PramList[i].indexOf('=', 0) + 1 , p_PramList[i].length); if ( strValue != null && strValue != "" ) { p_Map.put(strKey, strValue); } } for (var i = 0; i < pathParamList.length; i ++ ) { var strKey1 = pathParamList[i].substring(0, pathParamList[i].indexOf('=', 0)); var strValue1 = pathParamList[i].substring(pathParamList[i].indexOf('=', 0) + 1 , pathParamList[i].length); p_Map.put(strKey1, strValue1); } var mapKeySet = p_Map.key; var realPram; for ( var i = 0; i < mapKeySet.length ; i++ ) { if ( i == 0 ) { realPram = "?" + mapKeySet[i] + "=" + encodeURI(p_Map.get(mapKeySet[i])); } else { realPram += "&" + mapKeySet[i] + "=" + encodeURI(p_Map.get(mapKeySet[i])); } } window.location = realPath + realPram; } else { window.location = this.path + this.getP_parameters(); } } /** *
     *   Function : p_로 시작하는 파라미터 값을 가져온다.
     *   Date : 2008. 04. 23
     * 
    * * @return p_parameters */ SLink.prototype.getP_parameters = function(){ //return 될 파라미터 변수 var parameter = ""; //url의 파라미터 주소 var loc = window.location.toString(); //loc의 값에 ? 포함될 경우 if ( loc.indexOf('?',0) != -1 ) { loc = loc.substring(loc.indexOf('?',0) + 1, loc.length); var keyList = loc.split('&', loc.length); for (var i = 0 ; i < keyList.length ; i++ ) { var key = keyList[i]; key = key.substring(0, key.indexOf('=',0)); if (key.indexOf('p_',0) != -1 || key.indexOf('nPage',0) != -1 ) { var keyStirng = keyList[i].substring(0 ,keyList[i].indexOf('=', 0)); if (this.map.containsKey(keyStirng) == -1) { parameter += "&" + keyList[i]; this.map.put(keyStirng, keyList[i]); } }else if (key == ("menuId") || key == ("clonId")){ var keyStirng = keyList[i].substring(0 ,keyList[i].indexOf('=', 0)); if (this.map.containsKey(keyStirng) == -1) { parameter += "&" + keyList[i]; this.map.put(keyStirng, keyList[i]); } } } if ( this.path.indexOf('?', 0) == -1 && parameter.length != 0) { parameter = "?" + parameter.substring(1,parameter.length); } } else { var targetTags = document.getElementsByTagName("input"); for ( var i = 0; i < targetTags.length; i++ ) { var key = targetTags[i].name; if ( key && key.substring(0, 2) == "p_" && targetTags[i].value != null && targetTags[i].value != "" ) { if ( this.path.indexOf('?', 0) == -1) { parameter += "?" + key + "=" + targetTags[i].value; } else { parameter += "&" + key + "=" + targetTags[i].value; } }else if (key == ("menuId") || key == ("clonId")){ if ( this.path.indexOf('?', 0) == -1) { parameter += "?" + key + "=" + targetTags[i].value; this.path +=parameter; } else { parameter += "&" + key + "=" + targetTags[i].value; } } } targetTags = document.getElementsByTagName("select"); for ( var i = 0; i < targetTags.length; i++ ) { var key = targetTags[i].name; if ( key && key.substring(0, 2) == "p_" && targetTags[i].value != null && targetTags[i].value != "" ) { if ( this.path.indexOf('?', 0) == -1) { parameter += "?" + key + "=" + targetTags[i].value; } else { parameter += "&" + key + "=" + targetTags[i].value; } } } } return parameter; } /** *
     *   Function : 브라우져의 분류 코드를 반환한다.
     *   Date : 2008. 05. 14
     * 
    * * @return bsCode */ function getAppName() { var bsName = navigator.appName; var bsCode = null; if (bsName == "Microsoft Internet Explorer" ) { bsCode = 0; } else if (bsName == "Netscape" ) { bsCode = 1; } else if (bsName == "Opera" ) { bsCode = 2; } return bsCode; } function open_win (url,name,w,h){ var posx=0; var posy=0; posx = (screen.width - w)/2-1; posy = (screen.height - h)/2-1; var oWin = window.open(url, name, "scrollbars=no,width="+w+",height="+h+", top="+posy+", left="+posx ); try{ oWin.focus(); } catch(Exception){} }