/** * Element Type */ ET_DYNAMIC = 0x00000001; ET_STATIC = 0x00000010; ET_PARENT_AFFECT = 0x00000100; ET_ACTIVEX = 0x00001000; /** * Element Ability */ EA_HAS_EVENT = 0x00000001; EA_ACTION = 0x00000002; EA_HAS_DOM = 0x00000020; EA_CONTROL_BASE = 0x00000100; EA_CONTROL = (EA_CONTROL_BASE | EA_HAS_EVENT); EA_HAS_FORMAT = 0x00000200; EA_HAS_TEXT = 0x00000400; EA_GROUP_BASE = 0x00001000; EA_GROUP = (EA_CONTROL | EA_GROUP_BASE); EA_PI_BASE = 0x00010000; /** * Cell Merge Flag */ CMS_NORMAL = 0; CMS_MERGED = 1; CMS_HIDE = 2; CMS_LOCK = 3; /** * control의 type * */ CON_TPYE_EDIT = 1; CON_TPYE_BUTTON = 2; CON_TPYE_VIEW = 3; /** * 한글의 완성된 형태만 체크할 때 사용 * @memberOf {TypeName} */ HANGLEREG = /[각-깋,낙-닣,닥-딯,락-맇,막-밓,박-빟,삭-싷,악-잏,작-짛,탁-팋,팍-핗,학-힣,깍-낗,딱-띻,짝-찧,빡-삫]/g; /** * EXCELLOAD 그리드를 나타냄 * @memberOf {TypeName} */ LOAD_EXCEL_GRID = ""; LOAD_EXCEL_BUTTON = ""; /** * 각 Browser에서 Event Object의 CrossBrowsing을 위하여 추가 * * @author 김지환 * @since TrustForm Soonsu 0.0.1 */ function TFEvent () { this.name; this.handler; this.propagate; this.defaultAction; }; /** * Event Button 의 값 */ TFEvent.BUTTON_LEFT = 1;//(is_ie)? 1 : 0; TFEvent.BUTTON_MIDDLE = 2;//(is_ie)? 4 : 1; TFEvent.BUTTON_RIGHT = 3;//2; /** * Event Keycode */ TFEvent.BACKSPACE = 8; TFEvent.TAB = 9; TFEvent.ENTER = 13; TFEvent.SHIFT = 16; TFEvent.CONTROL = 17; TFEvent.ALT = 18; TFEvent.PAUSE_BREAK = 19; TFEvent.CAPSLOCK = 20; TFEvent.ESC = 27; TFEvent.SPACE = 32; TFEvent.PAGEUP = 33; TFEvent.PAGEDOWN = 34; TFEvent.END = 34; TFEvent.HOME = 34; TFEvent.LEFT = 37; TFEvent.UP = 38; TFEvent.RIGHT = 39; TFEvent.DOWN = 40; TFEvent.INSERT = 45; TFEvent.DELETE = 46; TFEvent.ZERO = 48; TFEvent.ONE = 49; TFEvent.TWO = 50; TFEvent.THREE = 51; TFEvent.FOUR = 52; TFEvent.FIVE = 53; TFEvent.SIX = 54; TFEvent.SEVEN = 55; TFEvent.EIGHT = 56; TFEvent.NINE = 57; TFEvent.A = 65; TFEvent.B = 66; TFEvent.C = 67; TFEvent.D = 68; TFEvent.E = 69; TFEvent.F = 70; TFEvent.G = 71; TFEvent.H = 72; TFEvent.I = 73; TFEvent.J = 74; TFEvent.K = 75; TFEvent.L = 76; TFEvent.M = 77; TFEvent.N = 78; TFEvent.O = 79; TFEvent.P = 80; TFEvent.Q = 81; TFEvent.R = 82; TFEvent.S = 83; TFEvent.T = 84; TFEvent.U = 85; TFEvent.V = 86; TFEvent.W = 87; TFEvent.X = 88; TFEvent.Y = 89; TFEvent.Z = 90; TFEvent.F1 = 112; TFEvent.F2 = 113; TFEvent.F3 = 114; TFEvent.F4 = 115; TFEvent.F5 = 116; TFEvent.F6 = 117; TFEvent.F7 = 118; TFEvent.F8 = 119; TFEvent.F9 = 120; TFEvent.F10 = 121; TFEvent.F11 = 122; TFEvent.F12 = 123; TFEvent.TRANSLANGUAGE = 229; /** * Attribute - Style 관련 : Style 목록을 만들어 둔다. */ var STYLE_LIST = new Hashtable(); STYLE_LIST["left"] = true; STYLE_LIST["right"] = true; STYLE_LIST["top"] = true; STYLE_LIST["bottom"] = true; STYLE_LIST["width"] = true; STYLE_LIST["height"] = true; STYLE_LIST["font-family"] = true; STYLE_LIST["font-size"] = true; STYLE_LIST["font-weight"] = true; STYLE_LIST["font-style"] = true; STYLE_LIST["text-decoration"] = true; STYLE_LIST["color"] = true; STYLE_LIST["text-align"] = true; STYLE_LIST["vertical-align"] = true; STYLE_LIST["word-wrap"] = true; STYLE_LIST["line-spacing"] = true; STYLE_LIST["letter-spacing"] = true; STYLE_LIST["padding"] = true; STYLE_LIST["padding-left"] = true; STYLE_LIST["padding-top"] = true; STYLE_LIST["padding-right"] = true; STYLE_LIST["padding-bottom"] = true; STYLE_LIST["background-color"] = true; STYLE_LIST["background-image"] = true; STYLE_LIST["background-repeat"] = true; STYLE_LIST["background-position"] = true; STYLE_LIST["border-color"] = true; STYLE_LIST["border-left-color"] = true; STYLE_LIST["border-top-color"] = true; STYLE_LIST["border-right-color"] = true; STYLE_LIST["border-bottom-color"] = true; STYLE_LIST["border-width"] = true; STYLE_LIST["border-left-width"] = true; STYLE_LIST["border-top-width"] = true; STYLE_LIST["border-right-width"] = true; STYLE_LIST["border-bottom-width"] = true; STYLE_LIST["border-style"] = true; STYLE_LIST["border-left-style"] = true; STYLE_LIST["border-top-style"] = true; STYLE_LIST["border-right-style"] = true; STYLE_LIST["border-bottom-style"] = true; STYLE_LIST["margin"] = true; STYLE_LIST["margin-left"] = true; STYLE_LIST["margin-top"] = true; STYLE_LIST["margin-right"] = true; STYLE_LIST["margin-bottom"] = true; STYLE_LIST["opacity"] = true; STYLE_LIST["clip"] = true; STYLE_LIST["gradient"] = true; STYLE_LIST["cursor"] = true; STYLE_LIST["focus-rect"] = true; STYLE_LIST["unloadmark"] = true; STYLE_LIST["display"] = true; STYLE_LIST["overflow"] = true; STYLE_LIST["background-repeat"] = true; /** * Tag Name 관련 : 기본컨트롤의 TAG NAME을 목록을 만들어 둔다. */ var TAG_LIST = new Hashtable(); TAG_LIST["xhtml:body"] = true; TAG_LIST["xforms:caption"] = true; TAG_LIST["xforms:output"] = true; TAG_LIST["xforms:input"] = true; TAG_LIST["xforms:secret"] = true; TAG_LIST["xforms:select"] = true; TAG_LIST["xforms:select1"] = true; TAG_LIST["xforms:group"] = true; TAG_LIST["xforms:datagrid"] = true; TAG_LIST["xforms:textarea"] = true; TAG_LIST["xforms:treeview"] = true; TAG_LIST["xforms:calendar"] = true; TAG_LIST["xforms:table"] = true; TAG_LIST["xforms:img"] = true; TAG_LIST["xforms:shape"] = true; TAG_LIST["xforms:line"] = true; TAG_LIST["xforms:object"] = true; TAG_LIST["xforms:browser"] = true; TAG_LIST["xforms:iviewer"] = true; TAG_LIST["xforms:switch"] = true; TAG_LIST["xforms:bool"] = true; TAG_LIST["xforms:file"] = true; TAG_LIST["xforms:import"] = true; var REF_ATTRIBUTE = new Hashtable(); /** * Hashtable * * @author 김지환 * @since TrustForm Soonsu 0.0.1 */ function Hashtable () { }; /** * Collection 객체 * * @author 김지환 * @since TrustForm Soonsu 0.0.1 */ function Collection () { this.m_htCollection = new Hashtable(); this.m_arOrder = new Array(); this.length = 0; }; Collection.prototype.add = function (objKey, objValue) { if (null == this.m_htCollection[objKey]) { this.m_arOrder.push(objKey); } this.m_htCollection[objKey] = objValue; this.length = this.m_arOrder.length; }; Collection.prototype.count = function () { return this.m_arOrder.length; }; Collection.prototype.exists = function (objKey) { return (null != this.m_htCollection[objKey]); }; Collection.prototype.item = function (objKey) { if (null == this.m_arOrder[objKey]) { return this.m_htCollection[objKey]; } else { return this.m_htCollection[this.m_arOrder[objKey]]; } }; Collection.prototype.keys = function () { return this.m_arOrder; }; Collection.prototype.remove = function (objKey) { delete this.m_htCollection[objKey]; var nIndex = this.m_arOrder.find(objKey); if (0 <= nIndex) { this.m_arOrder.splice(nIndex, 1); } this.length = this.m_arOrder.length; }; Collection.prototype.removeAll = function () { for (var objKey in this.m_htCollection) { delete this.m_htCollection[objKey]; } this.m_arOrder.removeAll(); this.length = this.m_arOrder.length; }; function DOMNodeList () { //property this.length = 0; this.m_arNode = new Array(); this.m_nIterator = 0; }; DOMNodeList.prototype.add = function (objNode) { this.m_arNode.push(objNode); this.length = this.m_arNode.length; }; DOMNodeList.prototype.item = function (nIndex) { if (0 > nIndex && this.length <= nIndex) { return null; } return this.m_arNode[nIndex]; }; DOMNodeList.prototype.nextNode = function () { if (0 > this.m_nIterator && this.length <= this.m_nIterator) { return null; } return this.m_arNode[this.m_nIterator++]; }; DOMNodeList.prototype.removeNext = function () { this.m_arNode.splice(this.m_nIterator++, 1); this.length = this.m_arNode.length; }; DOMNodeList.prototype.removeAll = function () { this.m_arNode.removeAll(); this.m_nIterator = 0; this.length = this.m_arNode.length; }; DOMNodeList.prototype.reset = function () { this.m_nIterator = 0; }; /** * Array 객체에 fextractDupArr 함수를 추가한다. * 배열안의 중복된 값을 제거한다. */ Array.prototype.fextractDupArr = function () { for(var i=0; i1) { spliced = this.splice(j,1); } } } } return this; }; /** * Array 객체에 find 함수를 추가한다. * 배열에서 objValue의 index를 리턴한다. * @param objValue * @return index * * @author 김지환 */ Array.prototype.find = function (objValue) { for (var i=0; i/g,">"); strText = strText.split(" ").join(" "); strText = strText.split("\n").join("
"); strText = strText.split("\r").join(""); strText = strText.split("\t").join("       "); return strText; }; /** * String RGB색상을 반전한다. * @return */ String.prototype.invertRGB = function () { var strRGB = this; if (-1 != this.indexOf("rgb")) { var strRGBData = this.substring(this.indexOf("(")+1, this.length); var alRGBValue = strRGBData.split(/\,/g); strRGB = "#"; for (var i=0; i"); if (-1 == nIndex) { return this; } var strTag = strTag.substring(0, nIndex); strTag = strTag + " " + strAttName + "=" + "\"" + strAttValue + "\">"; return strTag; }; /** * String 객체가 비어 있는지 여부를 구한다. * @return * * @author 김지환 */ String.prototype.isEmpty = function () { if (0 < this.length) { return false; } return true; }; /** * String 객체에 Trim 함수를 추가한다. * * @author 김지환 * 수정:2011-11-14 김우겸 */ String.prototype.trim = function () { return this.replace(/^\s+/,"").replace(/\s+$/,""); }; /** * String 객체에 ReplaceAll 함수를 추가한다. * * @author 김우겸 */ String.prototype.replaceAll = function (strFindString , strChangeString) { return this.split(strFindString).join(strChangeString); }; /** * String 객체에 getByte 함수를 추가한다. * * @author 김우겸 */ String.prototype.getByte = function () { var nBytrCnt = 0; for (var nCount = 0; nCount < this.length; nCount++) { if (this.charCodeAt(nCount) > 127) { nBytrCnt += 2; } else { nBytrCnt++; } } return nBytrCnt; }; String.prototype.setByteWithStrLength = function (nByte) { var nBytrCnt = 0; var StrReturnValue = ""; for (var nCount = 0; nCount < this.length && nBytrCnt < nByte; nCount++) { if (this.charCodeAt(nCount) > 127) { nBytrCnt += 2; StrReturnValue += this.charAt(nCount); } else { nBytrCnt++; StrReturnValue += this.charAt(nCount); } } return StrReturnValue; }; String.prototype.changeExtension = function (strOldExtension, strNewExtension) { var nPosition = this.lastIndexOf('.'); if (nPosition > 0 && nPosition < this.length && strOldExtension == this.substr(nPosition + 1)) { var strNewFileName = this.substring(0, nPosition); return strNewFileName + "." + strNewExtension; } return this; }; function URIEncoder () { }; URIEncoder.encode = function (strValue, strEncoding) { strEncoding = strEncoding.toUpperCase(); if (/*defalut*/"" == strEncoding ||"UTF-8" == strEncoding || "UTF-16" == strEncoding ) { return encodeURI(strValue); } else { var objHttpClient = new HttpClient(); var strData = "encode=" + strEncoding + "&" + "value=" + encodeURI(strValue); var strResult = objHttpClient.post(__getAppName () + "/kr/comsquare/jsp/encoding.jsp", strData); if (null != strResult) { return strResult.trim(); } } return strValue; }; /** * Base64 */ function Base64 () { }; Base64.keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; Base64.encode = function (strValue) { strValue = utf16.encode(strValue); var strResult = ""; var ch1, ch2, ch3, encoded1, encoded2, encoded3, encoded4; var i = 0; while(i < strValue.length) { ch1 = strValue.charCodeAt(i++); ch2 = strValue.charCodeAt(i++); ch3 = strValue.charCodeAt(i++); encoded1 = ch1 >> 2; encoded2 = ((ch1 & 3) << 4) | (ch2 >> 4); encoded3 = ((ch2 & 15) << 2) | (ch3 >> 6); encoded4 = ch3 & 63; if (isNaN(ch2)) { encoded3 = encoded4 = 64; } else if (isNaN(ch3)) { encoded4 = 64; } strResult += Base64.keyStr.charAt(encoded1) + Base64.keyStr.charAt(encoded2) + Base64.keyStr.charAt(encoded3) + Base64.keyStr.charAt(encoded4); } return strResult; }; Base64.decode = function (strValue) { strValue = strValue.replace(/[^A-Za-z0-9\+\/\=]/g, ""); var strResult = ""; var ch1, ch2, ch3, encode1, encode2, encode3, encode4; var i=0; while (i < strValue.length) { encode1 = Base64.keyStr.indexOf(strValue.charAt(i++)); encode2 = Base64.keyStr.indexOf(strValue.charAt(i++)); encode3 = Base64.keyStr.indexOf(strValue.charAt(i++)); encode4 = Base64.keyStr.indexOf(strValue.charAt(i++)); ch1 = (encode1 << 2) | (encode2 >> 4); ch2 = ((encode2 & 15) << 4) | (encode3 >> 2); ch3 = ((encode3 & 3) << 6) | encode4; strResult += String.fromCharCode(ch1); if (encode3 != 64) { strResult += String.fromCharCode(ch2); } if (encode4 != 64) { strResult += String.fromCharCode(ch3); } } return utf16.decode(strResult); }; /** * UTF8 - URI Encoder / Decoder */ function UTF8 () { }; UTF8.encode = function (strValue) { strValue = strValue.replace(/\r\n/g,"\n"); var strUTF = ""; for (var i=0; i 127) && (chIndex < 2048)) { strUTF += String.fromCharCode((chIndex >> 6) | 192); strUTF += String.fromCharCode((chIndex & 63) | 128); } else { strUTF += String.fromCharCode((chIndex >> 12) | 224); strUTF += String.fromCharCode(((chIndex >> 6) & 63) | 128); strUTF += String.fromCharCode((chIndex & 63) | 128); } } return strUTF; }; UTF8.decode = function (strValue) { var strDecoded = ""; var i = 0; var chIndex = chIndex1 = chIndex2 = 0; while ( i < strValue.length ) { chIndex = strValue.charCodeAt(i); if (chIndex < 128) { strDecoded += String.fromCharCode(chIndex); i++; } else if((chIndex > 191) && (chIndex < 224)) { chIndex1 = strValue.charCodeAt(i+1); strDecoded += String.fromCharCode(((chIndex & 31) << 6) | (chIndex1 & 63)); i += 2; } else { chIndex1 = strValue.charCodeAt(i+1); chIndex2 = strValue.charCodeAt(i+2); strDecoded += String.fromCharCode(((chIndex & 15) << 12) | ((chIndex1 & 63) << 6) | (chIndex2 & 63)); i += 3; } } return strDecoded; }; function UTF16 () { }; UTF16.decode = function (input) { var output = [], i=0, len=input.length,value,extra; while (i < len) { value = input.charCodeAt(i++); if ((value & 0xF800) === 0xD800) { extra = input.charCodeAt(i++); if (((value & 0xFC00) !== 0xD800) || ((extra & 0xFC00) !== 0xDC00)) { throw new RangeError("UTF-16(decode): Illegal UTF-16 sequence"); } value = ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000; } output.push(value); } return output; }; UTF16.encode = function (input) { var output = [], i=0, len=input.length,value; while (i < len) { value = input[i++]; if ((value & 0xF800) === 0xD800) { throw new RangeError("UTF-16(encode): Illegal UTF-16 value"); } if (value > 0xFFFF) { value -= 0x10000; output.push(String.fromCharCode(((value >>>10) & 0x3FF) | 0xD800)); value = 0xDC00 | (value & 0x3FF); } output.push(String.fromCharCode(value)); } return output.join(""); }; /** * 좌표 객체 * @param nX * @param nY * @return * * @author 김지환 */ function Point (nX, nY) { this.m_nX = nX; this.m_nY = nY; }; Point.prototype.clone = function () { return new Point(this.m_nX, this.m_nY); }; Point.prototype.getX = function () { return this.m_nX; }; Point.prototype.setX = function (nX) { this.m_nX = nX; }; Point.prototype.getY = function () { return this.m_nY; }; Point.prototype.setY = function (nY) { this.m_nY = nY; }; /** * roundmode에 관한 수식을 연산하여 return 한다 */ function getRoundMode (strValue, strRoundMode, strRoundPosition) { var arValue = strValue.split(/\./g); var nRoundPosition = Number(strRoundPosition); if (nRoundPosition < 0 && null != arValue[1]) { // 소수점에 관한 반올림,올림,내림일때 if (Math.abs(nRoundPosition) > arValue[1].length) { // 입력한 포지션이 존재하지 않는 소수점에 위치할때 return strValue; } else { if ("round" == strRoundMode) {//반올림 if (parseInt(arValue[1].charAt(Math.abs(nRoundPosition) - 1)) > 4) { strRoundMode = "ceil"; } else { strRoundMode = "floor"; } } if ("ceil" == strRoundMode) {//올림 if (-1 == nRoundPosition ) {//소수점 첫번째 자리일 때 정수값을 +1 해준다 return String(Number(arValue[0]) + 1); } else {// 올림할 값을 구함 var strPlusValue = "0."; for (var i=0 ; i < (Math.abs(nRoundPosition) - 1); i++) { if((i + 1) == (Math.abs(nRoundPosition) - 1)) { strPlusValue += "1"; break; } else { strPlusValue += "0"; } } if ("1" == arValue[1].substring(0, Math.abs(nRoundPosition) - 1)) {//1.1 + 0.1의 값중 뒤에 쓰레기값이 존재 하는 특별한 경우 return arValue[0] + ".2"; } // 올림한 값을 더하여 return var fSubData = Number(arValue[0] + "." + arValue[1].substring(0, Math.abs(nRoundPosition) - 1)) + Number(strPlusValue); return String(fSubData.toFixed(Math.abs(nRoundPosition) - 1)); } } else {//내림 if (-1 == nRoundPosition ) {//첫번째 자리수 일때 정수값만 return return arValue[0]; } else {// 포지션의 앞자리까지의 값을 return return arValue[0] + "." + arValue[1].substring(0, Math.abs(nRoundPosition) - 1); } } } } else if(nRoundPosition > 0) {// 정수에 관한 반올림, 내읾 , 올림 일때 if (nRoundPosition > arValue[0].length) {// 존재하지 않는 자릿수에 관한 처리 return strValue; } else { if ("round" == strRoundMode) {// 반올림 if (parseInt(arValue[0].charAt(arValue[0].length - nRoundPosition)) > 4) { strRoundMode = "ceil"; } else { strRoundMode = "floor"; } } if ("ceil" == strRoundMode) {//올림 if (arValue[0].length == nRoundPosition ) {// 포지션의 값이 정수의 맨 앞자리일때 처리 return String(Math.pow(10, nRoundPosition)); } else {//포지션 다음의 정수 자리의 값을 0 처리 var strPlusValue = arValue[0].substring(0, arValue[0].length - nRoundPosition); for (var i=0 ; i < nRoundPosition; i++) { strPlusValue += "0"; } //포지션의 값 + 1 해서 return return String(Number(strPlusValue) + Math.pow(10, nRoundPosition)); } } else {//내림 if (arValue[0].length == nRoundPosition ) {// 포지션의 값이 정수의 맨 앞자리일때 처리 return "0"; } else {// 포지션 다음의 정수 자리의 값을 0처리 var strPlusValue = arValue[0].substring(0, arValue[0].length - nRoundPosition); for (var i=0 ; i < nRoundPosition; i++) { strPlusValue += "0"; } return strPlusValue; } } } } else {// 포지션이 0일 때 처리 return strValue; } //잘못된 포지션 또는 잘못된 값이 넘어올 때 처리 return strValue; }; function recoveryStyle (heTarget, heClone) { heTarget.style.position = heClone.style.position; heTarget.style.left = heClone.style.left; heTarget.style.top = heClone.style.top; heTarget.style.width = heClone.style.width; heTarget.style.height = heClone.style.height; heTarget.style.fontFamily = heClone.style.fontFamily; heTarget.style.fontSize = heClone.style.fontSize; heTarget.style.fontWeight = heClone.style.fontWeight; heTarget.style.fontStyle = heClone.style.fontStyle; heTarget.style.textDecoration = heClone.style.textDecoration; heTarget.style.color = heClone.style.color; heTarget.style.textAlign = heClone.style.textAlign; heTarget.style.verticalAlign = heClone.style.verticalAlign; heTarget.style.wordWrap = heClone.style.wordWrap; heTarget.style.wordSpacing = heClone.style.wordSpacing; heTarget.style.letterSpacing = heClone.style.letterSpacing; heTarget.style.padding = heClone.style.padding; heTarget.style.paddingLeft = heClone.style.paddingLeft; heTarget.style.paddingTop = heClone.style.paddingTop; heTarget.style.paddingRight = heClone.style.paddingRight; heTarget.style.paddingBottom = heClone.style.paddingBottom; heTarget.style.backgroundColor = heClone.style.backgroundColor; heTarget.style.backgroundImage = heClone.style.backgroundImage; heTarget.style.backgroundRepeat = heClone.style.backgroundRepeat; heTarget.style.backgroundPosition = heClone.style.backgroundPosition; heTarget.style.borderColor = heClone.style.borderColor; heTarget.style.borderLeftColor = heClone.style.borderLeftColor; heTarget.style.borderTopColor = heClone.style.borderTopColor; heTarget.style.borderRightColor = heClone.style.borderRightColor; heTarget.style.borderBottomColor = heClone.style.borderBottomColor; heTarget.style.borderWidth = heClone.style.borderWidth; heTarget.style.borderLeftWidth = heClone.style.borderLeftWidth; heTarget.style.borderTopWidth = heClone.style.borderTopWidth; heTarget.style.borderRightWidth = heClone.style.borderRightWidth; heTarget.style.borderBottomWidth = heClone.style.borderBottomWidth; heTarget.style.borderStyle = heClone.style.borderStyle; heTarget.style.borderLeftStyle = heClone.style.borderLeftStyle; heTarget.style.borderTopStyle = heClone.style.borderTopStyle; heTarget.style.borderRightStyle = heClone.style.borderRightStyle; heTarget.style.borderBottomStyle = heClone.style.borderBottomStyle; heTarget.style.margin = heClone.style.margin; heTarget.style.marginLeft = heClone.style.marginLeft; heTarget.style.marginTop = heClone.style.marginTop; heTarget.style.marginRight = heClone.style.marginRight; heTarget.style.marginBottom = heClone.style.marginBottom; }; /** * 사각형 * @param nX * @param nY * @param nWidth * @param nHeight * * @author 김지환 */ function Rectangle (nX, nY, nWidth, nHeight) { this.m_nX = nX; this.m_nY = nY; this.m_nWidth = nWidth; this.m_nHeight = nHeight; this.m_nBottom; this.m_nRight; this.adjustButtomRight(); }; Rectangle.prototype.getX = function () { return this.m_nX; }; Rectangle.prototype.getY = function () { return this.m_nY; }; Rectangle.prototype.setX = function (nX) { this.m_nX = nX; this.adjustButtomRight(); }; Rectangle.prototype.setY = function (nY) { this.m_nY = nY; this.adjustButtomRight(); }; Rectangle.prototype.getWidth = function () { return this.m_nWidth; }; Rectangle.prototype.setWidth = function (nWidth) { this.m_nWidth = nWidth; this.adjustButtomRight(); }; Rectangle.prototype.getHeight = function () { return this.m_nHeight; }; Rectangle.prototype.setHeight = function (nHeight) { this.m_nHeight = nHeight; this.adjustButtomRight(); }; Rectangle.prototype.getBottom = function () { return this.m_nBottom; }; Rectangle.prototype.getRight = function () { return this.m_nRight; }; Rectangle.prototype.adjustButtomRight = function () { this.m_nRight = this.m_nX + this.m_nWidth; this.m_nBottom = this.m_nY + this.m_nHeight; }; Rectangle.prototype.isContainsPoint = function (ptContains) { if (null != ptContains && ptContains instanceof Point) { if (this.m_nX <= ptContains.getX() && this.m_nRight >= ptContains.getX() && this.m_nY <= ptContains.getY() && this.m_nBottom >= ptContains.getY()) { return true; } } return false; }; inputValidateCheck = function(strFormat, strValueData) //keydown 잘못 입력된 값 처리 && input된 초기값에 format 적용 { var strSaveData = ""; var strTempData = ""; var nFormatSwtichPoint = 0; var nInputSwtichPoint = 0; var nFormatLength = strFormat.length; var strInputData = strValueData; var reSpecialChar = /\W|\s/g; strInputData = strInputData.replace(reSpecialChar , ""); for (var i=0 ; i < nFormatLength ; i++) { if( nFormatSwtichPoint != nFormatLength && "" != strInputData.charAt(nInputSwtichPoint)) { if ("9" != strFormat.charAt(nFormatSwtichPoint) && "y" != strFormat.charAt(nFormatSwtichPoint) && "m" != strFormat.charAt(nFormatSwtichPoint) && "d" != strFormat.charAt(nFormatSwtichPoint) && "h" != strFormat.charAt(nFormatSwtichPoint) && "n" != strFormat.charAt(nFormatSwtichPoint) && "s" != strFormat.charAt(nFormatSwtichPoint) && "A" != strFormat.charAt(nFormatSwtichPoint) && "a" != strFormat.charAt(nFormatSwtichPoint) && "C" != strFormat.charAt(nFormatSwtichPoint) && "L" != strFormat.charAt(nFormatSwtichPoint)) { strSaveData = strSaveData + strFormat.charAt(nFormatSwtichPoint); nFormatSwtichPoint++; } else { for (;nInputSwtichPoint < strInputData.length; nInputSwtichPoint++) { strTempData = validateFormat (nFormatSwtichPoint, strInputData.charAt(nInputSwtichPoint), strFormat, strInputData); if ("" != strTempData) { strSaveData = strSaveData + strTempData; nInputSwtichPoint++; if ("9" != strFormat.charAt(nFormatSwtichPoint + 1) && "y" != strFormat.charAt(nFormatSwtichPoint + 1) && "m" != strFormat.charAt(nFormatSwtichPoint + 1) && "d" != strFormat.charAt(nFormatSwtichPoint + 1) && "h" != strFormat.charAt(nFormatSwtichPoint + 1) && "n" != strFormat.charAt(nFormatSwtichPoint + 1) && "s" != strFormat.charAt(nFormatSwtichPoint + 1) && "A" != strFormat.charAt(nFormatSwtichPoint + 1) && "a" != strFormat.charAt(nFormatSwtichPoint + 1) && "C" != strFormat.charAt(nFormatSwtichPoint + 1) && "L" != strFormat.charAt(nFormatSwtichPoint + 1)) { strSaveData = strSaveData + strFormat.charAt(nFormatSwtichPoint + 1); nFormatSwtichPoint++; } break; } } nFormatSwtichPoint++; } } } return strSaveData; }; validateFormat = function (nInputStringLength, strCharValue, strFormat, strInputData) { var nkeyCode = strCharValue.charCodeAt(0); switch (strFormat.charAt(nInputStringLength)) { case "9": { if ( nkeyCode >= 48 && nkeyCode <= 57 ) { return String.fromCharCode(nkeyCode); } return ""; } case "y": { if ( nkeyCode >= 48 && nkeyCode <= 57 ) { return String.fromCharCode(nkeyCode); } return ""; } case "m": { if ("m" == strFormat.charAt(nInputStringLength + 1)) { if ( nkeyCode >= 48 && nkeyCode <= 49 ) { return String.fromCharCode(nkeyCode); } } else { if("m" == strFormat.charAt(nInputStringLength - 1) && "1" == strInputData.charAt(nInputStringLength - 1)) { if ( nkeyCode >= 48 && nkeyCode <= 50 ) { return String.fromCharCode(nkeyCode); } } else { if ( nkeyCode >= 48 && nkeyCode <= 57 ) { return String.fromCharCode(nkeyCode); } } } return ""; } case "d": { if ("d" == strFormat.charAt(nInputStringLength + 1)) { if ("m" == strFormat.charAt(nInputStringLength - 2) && "2" == strInputData.charAt(nInputStringLength - 2) && (("m" == strFormat.charAt(nInputStringLength - 3) && "0" == strInputData.charAt(nInputStringLength - 3)) || "m" != strFormat.charAt(nInputStringLength - 3))) { if ( nkeyCode >= 48 && nkeyCode <= 50 ) { return String.fromCharCode(nkeyCode); } } else { if ( nkeyCode >= 48 && nkeyCode <= 51 ) { return String.fromCharCode(nkeyCode); } } } else { if ("d" == strFormat.charAt(nInputStringLength - 1) && "3" != strInputData.charAt(nInputStringLength - 1)) { if ( nkeyCode >= 48 && nkeyCode <= 57 ) { return String.fromCharCode(nkeyCode); } } else if ("d" == strFormat.charAt(nInputStringLength - 1) && "3" == strInputData.charAt(nInputStringLength - 1)) { if ( nkeyCode >= 48 && nkeyCode <= 49 ) { return String.fromCharCode(nkeyCode); } } else { if ( nkeyCode >= 48 && nkeyCode <= 57 ) { return String.fromCharCode(nkeyCode); } } } return ""; } case "h": { if ("h" == strFormat.charAt(nInputStringLength + 1)) { if ( nkeyCode >= 48 && nkeyCode <= 50 ) { return String.fromCharCode(nkeyCode); } } else { if ("h" == strFormat.charAt(nInputStringLength - 1) && "2" == strInputData.charAt(nInputStringLength - 1)) { if ( nkeyCode >= 48 && nkeyCode <= 52 ) { return String.fromCharCode(nkeyCode); } } else { if ( nkeyCode >= 48 && nkeyCode <= 57 ) { return String.fromCharCode(nkeyCode); } } } return ""; } case "n": { if ("n" == strFormat.charAt(nInputStringLength + 1)) { if ( nkeyCode >= 48 && nkeyCode <= 53 ) { return String.fromCharCode(nkeyCode); } } else { if ( nkeyCode >= 48 && nkeyCode <= 57 ) { return String.fromCharCode(nkeyCode); } } return ""; } case "s": { if ("s" == strFormat.charAt(nInputStringLength + 1)) { if ( nkeyCode >= 48 && nkeyCode <= 53 ) { return String.fromCharCode(nkeyCode); } } else { if ( nkeyCode >= 48 && nkeyCode <= 57 ) { return String.fromCharCode(nkeyCode); } } return ""; } case "A": { if ( (nkeyCode >= 48 && nkeyCode <= 57) || (nkeyCode >= 65 && nkeyCode <= 90) || (nkeyCode >= 97 && nkeyCode <= 129)) { return strCharValue; } return ""; } case "a": { if ((nkeyCode == 32) || (nkeyCode >= 48 && nkeyCode <= 57) || (nkeyCode >= 65 && nkeyCode <= 90) || (nkeyCode >= 97 && nkeyCode <= 129)) { return strCharValue; } return ""; } case "C": { if ((nkeyCode >= 48 && nkeyCode <= 112) || nkeyCode > 185 || (nkeyCode >= 97 && nkeyCode <= 129)) { return strCharValue; } return ""; } case "L": { if ((nkeyCode >= 65 && nkeyCode <= 90) || (nkeyCode >= 97 && nkeyCode <= 129)) { return strCharValue; } return ""; } default: { alert("미구현"); return ""; } } }; /** * String 의 값을 인자로 받는 format형식으로 변환한다. * * @author 김우겸 * */ inputMoneyUnitValidateCheckPattern1 = function (strInputData, nInputDataLength, strFormat, m_strDotZero) { // # 숫자만 존재할 때 var strSaveData = ""; //초기화 var bExistFirstZero = -1 != strFormat.indexOf("9#"); var bExistSaveData = true; var bNumber = parseFloat(strInputData) > 0; nInputDataLength = 0 == m_strDotZero.length ? strInputData.length : m_strDotZero.length; for (var i=0 ; i < nInputDataLength ; i++) { if (strInputData.charCodeAt(i) >= 48 && strInputData.charCodeAt(i) <= 57) { if (strInputData.charCodeAt(i) == 48 && !bExistFirstZero) { bExistFirstZero = false; } else { bExistFirstZero = true; } if (bExistFirstZero) { strSaveData = strSaveData + strInputData.charAt(i); bExistSaveData = false; //this.m_strInputRealityData = this.m_strInputRealityData + strInputData.charAt(i); } if (bNumber && bExistSaveData && strInputData.charCodeAt(i) == 48) { //this.m_strInputRealityData = strInputData.charAt(i); strSaveData = strInputData.charAt(i); } bExistSaveData = true; } } for (var i=0; i= 48 && strInputData.charCodeAt(i) <= 57) { if (strInputData.charCodeAt(i) == 48 && !bExistFirstZero) { bExistFirstZero = false; } else { bExistFirstZero = true; } if (bExistFirstZero) { if (nCommaFirstPoint == nCommaFirstPrintCount) { if (nInputDataLength > 3 && nCommaFirstPoint != 0) { strSaveData = strSaveData + ","; bCommaLoopStarter = true; } else if (nInputDataLength > 3) { bCommaLoopStarter = true; } } if (3 == nCommaLoopPrintCount) { strSaveData = strSaveData + ","; nCommaLoopPrintCount = 0; } strSaveData = strSaveData + strInputData.charAt(i); //this.m_strInputRealityData = this.m_strInputRealityData + strInputData.charAt(i); nCommaFirstPrintCount ++; if (bCommaLoopStarter) { nCommaLoopPrintCount++; } } if (1 == nInputDataLength && 0 == i && strInputData.charCodeAt(i) == 48) { //this.m_strInputRealityData = strInputData.charAt(i); strSaveData = strInputData.charAt(i); } } } return strSaveData; }; inputMoneyUnitValidateCheckPattern3 = function (strInputData, nInputDataLength, strFormat, m_strDotZero) {// (# + .) 소수점 단위일 때 var strSaveData = ""; //초기화 nInputDataLength = strInputData.length; var nCommaFirstPoint = nInputDataLength % 3; var nCommaLoopPoint = (nInputDataLength / 2) - 1 ; var nCommaFirstPrintCount = 0; var nCommaLoopPrintCount = 0; var bCommaLoopStarter = false; var bExistFirstZero = false; var bExistDot = true; for (var i=0 ; i < nInputDataLength ; i++) { if (((strInputData.charCodeAt(i) >= 48 && strInputData.charCodeAt(i) <= 57) || strInputData.charCodeAt(i) == 46) && bExistDot) { if (strInputData.charCodeAt(i) == 46) { // 첫번째 입력값이 .(dot) 일때 if (0 ==i && !strInputData.charCodeAt(i + 1)) { return ""; } else if(0 ==i && strInputData.charCodeAt(i + 1)) { return strInputData.substring(1 , nInputDataLength); } } if (strInputData.charCodeAt(i) == 48 && !bExistFirstZero) { //첫번째 값이 0일때 처리 if (0 == i && !strInputData.charCodeAt(i + 1)) { strSaveData = strSaveData + strInputData.charAt(i); //this.m_strInputRealityData = this.m_strInputRealityData + strInputData.charAt(i); } if(strInputData.charCodeAt(i + 1) != 46) { bExistFirstZero = false; } else { bExistFirstZero = true; } } else { bExistFirstZero = true; } if (bExistFirstZero) { strSaveData = strSaveData + strInputData.charAt(i); this.m_strInputRealityData = this.m_strInputRealityData + strInputData.charAt(i); if (strInputData.charCodeAt(i) == 46) { bExistDot = false; if (-1 != strFormat.indexOf("0")) { for (var i = strFormat.indexOf("0") ; i < this.m_nLength ; i++) { if ("0" == strFormat.charAt(i)) { strSaveData += "0"; //this.m_strInputRealityData += "0"; } } return strSaveData; } } } } else if (strInputData.charCodeAt(i) >= 48 && strInputData.charCodeAt(i) <= 57) { strSaveData = strSaveData + strInputData.charAt(i); //this.m_strInputRealityData = this.m_strInputRealityData + strInputData.charAt(i); } } return strSaveData; }; /** * format의 상태를 숫자로 return함 * * @author 김우겸 * * @return 정수(0:format이 없음 1:기본format 2:숫자format 3:화폐 4:소수점 5:화폐 + 소수점) * */ formatStatus = function (strFormat) { if ("" == strFormat) { return 0; } var nMoneyUnitFormatPattern; if ("-1" == strFormat.indexOf("#") && "-1" == strFormat.indexOf("0")) { return 1; } else { nMoneyUnitFormatPattern = "-1" != strFormat.indexOf(",") ? 3: 2; nMoneyUnitFormatPattern = "-1" != strFormat.indexOf(".") ? (nMoneyUnitFormatPattern + 2): nMoneyUnitFormatPattern; return nMoneyUnitFormatPattern; } }; /** * 캐럿의 위치를 저장할 객체 */ function CaretPosition() { var start = null; var end = null; }; /** * textarea, input tag의 캐럿의 위치를 저장한 객체를 반환한다 * @param {Object} heField * @return {TypeName} */ function getCaretPosition (heField) { var objCaretPos = new CaretPosition(); if (document.selection) { var trBookMark = document.selection.createRange().getBookmark(); var trSel = heField.createTextRange(); trSel.moveToBookmark(trBookMark); var trSelLeft = heField.createTextRange(); trSelLeft.collapse(true); trSelLeft.setEndPoint("EndToStart", trSel); objCaretPos.start = trSelLeft.text.length; objCaretPos.end = trSelLeft.text.length + trSel.text.length; } else if (heField.selectionStart || heField.selectionStart == '0') { objCaretPos.start = heField.selectionStart; objCaretPos.end = heField.selectionEnd; } return objCaretPos; }; /** * textarea, input tag에 지정한 케럿으로 selection 한다 * @param {Object} heField * @param {Object} nCaretStart * @param {Object} nCaretEnd */ function setCaretPosition(heField, nCaretStart, nCaretEnd) { if (document.selection) { heField.blur(); heField.focus(); heField.value = heField.value; var trSel = heField.createTextRange(); trSel.moveStart("character", -heField.value.length); trSel.moveEnd("character", -heField.value.length); trSel.moveStart("character", nCaretStart); trSel.moveEnd("character", nCaretEnd - nCaretStart); trSel.select(); } else if (heField.selectionStart || heField.selectionStart == '0') { heField.selectionStart = null; heField.selectionEnd = null; heField.selectionStart = nCaretStart; heField.selectionEnd = nCaretEnd; heField.focus(); } }; /** * textarea, input tag에 selection 한 내용을 반환한다 * @param {Object} heField * @return {TypeName} */ function getSelectionText(heField) { var objSel =""; if (document.selection) { objSel = document.selection.createRange(); return objSel.text; } else { if (null != heField && null != heField.selectionStart) { return heField.value.substring(heField.selectionStart, heField.selectionEnd); } else { return window.getSelection(); } } }; /** * textarea, input tag에 selection 한 내용을 변환한다 * @param {Object} heField * @param {Object} strText */ function setSelectionText(heField, strText) { if (document.selection) { var trSel = document.selection.createRange(); trSel.text = strText; } else { var nStartPosition = heField.selectionStart; var strHead = 0 != heField.selectionStart ? heField.value.substring(0, heField.selectionStart) : ""; var strLast = heField.value.substring(heField.selectionEnd, heField.value.length); heField.value = strHead + strText + strLast; heField.focus(); heField.selectionStart = nStartPosition; heField.selectionEnd = nStartPosition + strText.length; } }; /** * keyCode의 값으로 검증한다. * @param {Object} nKeyCode */ function getInputKeyCode (nKeyCode) { if ((48 <= nKeyCode && 57 >= nKeyCode) || (65 <= nKeyCode && 90 >= nKeyCode) || (96 <= nKeyCode && 111 >= nKeyCode) || (219 <= nKeyCode && 222 >= nKeyCode) || (186 <= nKeyCode && 192 >= nKeyCode) || 32 == nKeyCode || 229 == nKeyCode) { return true; } return false; }; var viewportwidth; var viewportheight; if (typeof window.innerWidth != 'undefined') { viewportwidth = window.innerWidth; viewportheight = window.innerHeight; } // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { viewportwidth = document.documentElement.clientWidth; viewportheight = document.documentElement.clientHeight; } // older versions of IE else { viewportwidth = document.getElementsByTagName('body')[0].clientWidth; viewportheight = document.getElementsByTagName('body')[0].clientHeight ; }