Define.js 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117
  1. /**
  2. * Element Type
  3. */
  4. ET_DYNAMIC = 0x00000001;
  5. ET_STATIC = 0x00000010;
  6. ET_PARENT_AFFECT = 0x00000100;
  7. ET_ACTIVEX = 0x00001000;
  8. /**
  9. * Element Ability
  10. */
  11. EA_HAS_EVENT = 0x00000001;
  12. EA_ACTION = 0x00000002;
  13. EA_HAS_DOM = 0x00000020;
  14. EA_CONTROL_BASE = 0x00000100;
  15. EA_CONTROL = (EA_CONTROL_BASE | EA_HAS_EVENT);
  16. EA_HAS_FORMAT = 0x00000200;
  17. EA_HAS_TEXT = 0x00000400;
  18. EA_GROUP_BASE = 0x00001000;
  19. EA_GROUP = (EA_CONTROL | EA_GROUP_BASE);
  20. EA_PI_BASE = 0x00010000;
  21. /**
  22. * Cell Merge Flag
  23. */
  24. CMS_NORMAL = 0;
  25. CMS_MERGED = 1;
  26. CMS_HIDE = 2;
  27. CMS_LOCK = 3;
  28. /**
  29. * control의 type
  30. *
  31. */
  32. CON_TPYE_EDIT = 1;
  33. CON_TPYE_BUTTON = 2;
  34. CON_TPYE_VIEW = 3;
  35. /**
  36. * 한글의 완성된 형태만 체크할 때 사용
  37. * @memberOf {TypeName}
  38. */
  39. HANGLEREG = /[각-깋,낙-닣,닥-딯,락-맇,막-밓,박-빟,삭-싷,악-잏,작-짛,탁-팋,팍-핗,학-힣,깍-낗,딱-띻,짝-찧,빡-삫]/g;
  40. /**
  41. * EXCELLOAD 그리드를 나타냄
  42. * @memberOf {TypeName}
  43. */
  44. LOAD_EXCEL_GRID = "";
  45. LOAD_EXCEL_BUTTON = "";
  46. /**
  47. * 각 Browser에서 Event Object의 CrossBrowsing을 위하여 추가
  48. *
  49. * @author 김지환
  50. * @since TrustForm Soonsu 0.0.1
  51. */
  52. function TFEvent ()
  53. {
  54. this.name;
  55. this.handler;
  56. this.propagate;
  57. this.defaultAction;
  58. };
  59. /**
  60. * Event Button 의 값
  61. */
  62. TFEvent.BUTTON_LEFT = 1;//(is_ie)? 1 : 0;
  63. TFEvent.BUTTON_MIDDLE = 2;//(is_ie)? 4 : 1;
  64. TFEvent.BUTTON_RIGHT = 3;//2;
  65. /**
  66. * Event Keycode
  67. */
  68. TFEvent.BACKSPACE = 8;
  69. TFEvent.TAB = 9;
  70. TFEvent.ENTER = 13;
  71. TFEvent.SHIFT = 16;
  72. TFEvent.CONTROL = 17;
  73. TFEvent.ALT = 18;
  74. TFEvent.PAUSE_BREAK = 19;
  75. TFEvent.CAPSLOCK = 20;
  76. TFEvent.ESC = 27;
  77. TFEvent.SPACE = 32;
  78. TFEvent.PAGEUP = 33;
  79. TFEvent.PAGEDOWN = 34;
  80. TFEvent.END = 34;
  81. TFEvent.HOME = 34;
  82. TFEvent.LEFT = 37;
  83. TFEvent.UP = 38;
  84. TFEvent.RIGHT = 39;
  85. TFEvent.DOWN = 40;
  86. TFEvent.INSERT = 45;
  87. TFEvent.DELETE = 46;
  88. TFEvent.ZERO = 48;
  89. TFEvent.ONE = 49;
  90. TFEvent.TWO = 50;
  91. TFEvent.THREE = 51;
  92. TFEvent.FOUR = 52;
  93. TFEvent.FIVE = 53;
  94. TFEvent.SIX = 54;
  95. TFEvent.SEVEN = 55;
  96. TFEvent.EIGHT = 56;
  97. TFEvent.NINE = 57;
  98. TFEvent.A = 65;
  99. TFEvent.B = 66;
  100. TFEvent.C = 67;
  101. TFEvent.D = 68;
  102. TFEvent.E = 69;
  103. TFEvent.F = 70;
  104. TFEvent.G = 71;
  105. TFEvent.H = 72;
  106. TFEvent.I = 73;
  107. TFEvent.J = 74;
  108. TFEvent.K = 75;
  109. TFEvent.L = 76;
  110. TFEvent.M = 77;
  111. TFEvent.N = 78;
  112. TFEvent.O = 79;
  113. TFEvent.P = 80;
  114. TFEvent.Q = 81;
  115. TFEvent.R = 82;
  116. TFEvent.S = 83;
  117. TFEvent.T = 84;
  118. TFEvent.U = 85;
  119. TFEvent.V = 86;
  120. TFEvent.W = 87;
  121. TFEvent.X = 88;
  122. TFEvent.Y = 89;
  123. TFEvent.Z = 90;
  124. TFEvent.F1 = 112;
  125. TFEvent.F2 = 113;
  126. TFEvent.F3 = 114;
  127. TFEvent.F4 = 115;
  128. TFEvent.F5 = 116;
  129. TFEvent.F6 = 117;
  130. TFEvent.F7 = 118;
  131. TFEvent.F8 = 119;
  132. TFEvent.F9 = 120;
  133. TFEvent.F10 = 121;
  134. TFEvent.F11 = 122;
  135. TFEvent.F12 = 123;
  136. TFEvent.TRANSLANGUAGE = 229;
  137. /**
  138. * Attribute - Style 관련 : Style 목록을 만들어 둔다.
  139. */
  140. var STYLE_LIST = new Hashtable();
  141. STYLE_LIST["left"] = true;
  142. STYLE_LIST["right"] = true;
  143. STYLE_LIST["top"] = true;
  144. STYLE_LIST["bottom"] = true;
  145. STYLE_LIST["width"] = true;
  146. STYLE_LIST["height"] = true;
  147. STYLE_LIST["font-family"] = true;
  148. STYLE_LIST["font-size"] = true;
  149. STYLE_LIST["font-weight"] = true;
  150. STYLE_LIST["font-style"] = true;
  151. STYLE_LIST["text-decoration"] = true;
  152. STYLE_LIST["color"] = true;
  153. STYLE_LIST["text-align"] = true;
  154. STYLE_LIST["vertical-align"] = true;
  155. STYLE_LIST["word-wrap"] = true;
  156. STYLE_LIST["line-spacing"] = true;
  157. STYLE_LIST["letter-spacing"] = true;
  158. STYLE_LIST["padding"] = true;
  159. STYLE_LIST["padding-left"] = true;
  160. STYLE_LIST["padding-top"] = true;
  161. STYLE_LIST["padding-right"] = true;
  162. STYLE_LIST["padding-bottom"] = true;
  163. STYLE_LIST["background-color"] = true;
  164. STYLE_LIST["background-image"] = true;
  165. STYLE_LIST["background-repeat"] = true;
  166. STYLE_LIST["background-position"] = true;
  167. STYLE_LIST["border-color"] = true;
  168. STYLE_LIST["border-left-color"] = true;
  169. STYLE_LIST["border-top-color"] = true;
  170. STYLE_LIST["border-right-color"] = true;
  171. STYLE_LIST["border-bottom-color"] = true;
  172. STYLE_LIST["border-width"] = true;
  173. STYLE_LIST["border-left-width"] = true;
  174. STYLE_LIST["border-top-width"] = true;
  175. STYLE_LIST["border-right-width"] = true;
  176. STYLE_LIST["border-bottom-width"] = true;
  177. STYLE_LIST["border-style"] = true;
  178. STYLE_LIST["border-left-style"] = true;
  179. STYLE_LIST["border-top-style"] = true;
  180. STYLE_LIST["border-right-style"] = true;
  181. STYLE_LIST["border-bottom-style"] = true;
  182. STYLE_LIST["margin"] = true;
  183. STYLE_LIST["margin-left"] = true;
  184. STYLE_LIST["margin-top"] = true;
  185. STYLE_LIST["margin-right"] = true;
  186. STYLE_LIST["margin-bottom"] = true;
  187. STYLE_LIST["opacity"] = true;
  188. STYLE_LIST["clip"] = true;
  189. STYLE_LIST["gradient"] = true;
  190. STYLE_LIST["cursor"] = true;
  191. STYLE_LIST["focus-rect"] = true;
  192. STYLE_LIST["unloadmark"] = true;
  193. STYLE_LIST["display"] = true;
  194. STYLE_LIST["overflow"] = true;
  195. STYLE_LIST["background-repeat"] = true;
  196. /**
  197. * Tag Name 관련 : 기본컨트롤의 TAG NAME을 목록을 만들어 둔다.
  198. */
  199. var TAG_LIST = new Hashtable();
  200. TAG_LIST["xhtml:body"] = true;
  201. TAG_LIST["xforms:caption"] = true;
  202. TAG_LIST["xforms:output"] = true;
  203. TAG_LIST["xforms:input"] = true;
  204. TAG_LIST["xforms:secret"] = true;
  205. TAG_LIST["xforms:select"] = true;
  206. TAG_LIST["xforms:select1"] = true;
  207. TAG_LIST["xforms:group"] = true;
  208. TAG_LIST["xforms:datagrid"] = true;
  209. TAG_LIST["xforms:textarea"] = true;
  210. TAG_LIST["xforms:treeview"] = true;
  211. TAG_LIST["xforms:calendar"] = true;
  212. TAG_LIST["xforms:table"] = true;
  213. TAG_LIST["xforms:img"] = true;
  214. TAG_LIST["xforms:shape"] = true;
  215. TAG_LIST["xforms:line"] = true;
  216. TAG_LIST["xforms:object"] = true;
  217. TAG_LIST["xforms:browser"] = true;
  218. TAG_LIST["xforms:iviewer"] = true;
  219. TAG_LIST["xforms:switch"] = true;
  220. TAG_LIST["xforms:bool"] = true;
  221. TAG_LIST["xforms:file"] = true;
  222. TAG_LIST["xforms:import"] = true;
  223. var REF_ATTRIBUTE = new Hashtable();
  224. /**
  225. * Hashtable
  226. *
  227. * @author 김지환
  228. * @since TrustForm Soonsu 0.0.1
  229. */
  230. function Hashtable ()
  231. {
  232. };
  233. /**
  234. * Collection 객체
  235. *
  236. * @author 김지환
  237. * @since TrustForm Soonsu 0.0.1
  238. */
  239. function Collection ()
  240. {
  241. this.m_htCollection = new Hashtable();
  242. this.m_arOrder = new Array();
  243. this.length = 0;
  244. };
  245. Collection.prototype.add = function (objKey, objValue)
  246. {
  247. if (null == this.m_htCollection[objKey])
  248. {
  249. this.m_arOrder.push(objKey);
  250. }
  251. this.m_htCollection[objKey] = objValue;
  252. this.length = this.m_arOrder.length;
  253. };
  254. Collection.prototype.count = function ()
  255. {
  256. return this.m_arOrder.length;
  257. };
  258. Collection.prototype.exists = function (objKey)
  259. {
  260. return (null != this.m_htCollection[objKey]);
  261. };
  262. Collection.prototype.item = function (objKey)
  263. {
  264. if (null == this.m_arOrder[objKey])
  265. {
  266. return this.m_htCollection[objKey];
  267. }
  268. else
  269. {
  270. return this.m_htCollection[this.m_arOrder[objKey]];
  271. }
  272. };
  273. Collection.prototype.keys = function ()
  274. {
  275. return this.m_arOrder;
  276. };
  277. Collection.prototype.remove = function (objKey)
  278. {
  279. delete this.m_htCollection[objKey];
  280. var nIndex = this.m_arOrder.find(objKey);
  281. if (0 <= nIndex)
  282. {
  283. this.m_arOrder.splice(nIndex, 1);
  284. }
  285. this.length = this.m_arOrder.length;
  286. };
  287. Collection.prototype.removeAll = function ()
  288. {
  289. for (var objKey in this.m_htCollection)
  290. {
  291. delete this.m_htCollection[objKey];
  292. }
  293. this.m_arOrder.removeAll();
  294. this.length = this.m_arOrder.length;
  295. };
  296. function DOMNodeList ()
  297. {
  298. //property
  299. this.length = 0;
  300. this.m_arNode = new Array();
  301. this.m_nIterator = 0;
  302. };
  303. DOMNodeList.prototype.add = function (objNode)
  304. {
  305. this.m_arNode.push(objNode);
  306. this.length = this.m_arNode.length;
  307. };
  308. DOMNodeList.prototype.item = function (nIndex)
  309. {
  310. if (0 > nIndex && this.length <= nIndex)
  311. {
  312. return null;
  313. }
  314. return this.m_arNode[nIndex];
  315. };
  316. DOMNodeList.prototype.nextNode = function ()
  317. {
  318. if (0 > this.m_nIterator && this.length <= this.m_nIterator)
  319. {
  320. return null;
  321. }
  322. return this.m_arNode[this.m_nIterator++];
  323. };
  324. DOMNodeList.prototype.removeNext = function ()
  325. {
  326. this.m_arNode.splice(this.m_nIterator++, 1);
  327. this.length = this.m_arNode.length;
  328. };
  329. DOMNodeList.prototype.removeAll = function ()
  330. {
  331. this.m_arNode.removeAll();
  332. this.m_nIterator = 0;
  333. this.length = this.m_arNode.length;
  334. };
  335. DOMNodeList.prototype.reset = function ()
  336. {
  337. this.m_nIterator = 0;
  338. };
  339. /**
  340. * Array 객체에 fextractDupArr 함수를 추가한다.
  341. * 배열안의 중복된 값을 제거한다.
  342. */
  343. Array.prototype.fextractDupArr = function ()
  344. {
  345. for(var i=0; i<this.length; i++)
  346. {
  347. var checkDobl = 0;
  348. for(var j=0; j<this.length; j++)
  349. {
  350. if(this[i] != this[j])
  351. {
  352. continue;
  353. }
  354. else
  355. {
  356. checkDobl++;
  357. if(checkDobl>1)
  358. {
  359. spliced = this.splice(j,1);
  360. }
  361. }
  362. }
  363. }
  364. return this;
  365. };
  366. /**
  367. * Array 객체에 find 함수를 추가한다.
  368. * 배열에서 objValue의 index를 리턴한다.
  369. * @param objValue
  370. * @return index
  371. *
  372. * @author 김지환
  373. */
  374. Array.prototype.find = function (objValue)
  375. {
  376. for (var i=0; i<this.length; i++)
  377. {
  378. var objArrayValue = this[i];
  379. if (objArrayValue == objValue)
  380. {
  381. return i;
  382. }
  383. }
  384. return -1;
  385. };
  386. /**
  387. * Array 객체에 removeAt 함수를 추가한다.
  388. * @param nIndex
  389. * @return deleted item
  390. *
  391. * @author 김지환
  392. */
  393. Array.prototype.removeAt = function (nIndex)
  394. {
  395. return this.splice(nIndex, 1);
  396. };
  397. /**
  398. * Array 객체에 removeAll 함수를 추가한다.
  399. * @return null
  400. */
  401. Array.prototype.removeAll = function ()
  402. {
  403. while (0 != this.length)
  404. {
  405. this.pop();
  406. }
  407. };
  408. /**
  409. * 일반 배열에서 사용되는 sort 정의 함수
  410. */
  411. function numberASC(a, b)
  412. {
  413. return a - b;
  414. };
  415. /**
  416. * sort함수에서 숫자로 구성된 col일때 사용되는 함수
  417. */
  418. function numberorder(a, b)
  419. {
  420. return a[0] - b[0];
  421. };
  422. /**
  423. *1~16 까지 숫자를 16진수 형태의 문자로 표현한다.
  424. * @return
  425. */
  426. function giveHex (nDec)
  427. {
  428. switch (nDec)
  429. {
  430. case 10:
  431. {
  432. return "A";
  433. }
  434. case 11:
  435. {
  436. return "B";
  437. }
  438. case 12:
  439. {
  440. return "C";
  441. }
  442. case 13:
  443. {
  444. return "D";
  445. }
  446. case 14:
  447. {
  448. return "E";
  449. }
  450. case 15:
  451. {
  452. return "E";
  453. }
  454. default:
  455. {
  456. return String(nDec);
  457. }
  458. }
  459. };
  460. /**
  461. * String Buffer를 만든다
  462. * @return
  463. */
  464. function StringBuffer()
  465. {
  466. this.buffer = [];
  467. this.bSelect = false;
  468. this.isSelect = function ()
  469. {
  470. return this.bSelect;
  471. };
  472. this.select = function ()
  473. {
  474. this.bSelect = true;
  475. };
  476. this.insertString = function (nPosition, string)
  477. {
  478. this.buffer.splice(nPosition, 0, string);
  479. return this;
  480. };
  481. this.replacePosition = function (nPosition, string)
  482. {
  483. this.buffer[nPosition] = string;
  484. return this;
  485. };
  486. this.append = function(string)
  487. {
  488. this.buffer.push(string);
  489. return this;
  490. };
  491. this.findPosition = function(nPosition)
  492. {
  493. if (null != this.buffer[nPosition])
  494. {
  495. return true;
  496. }
  497. return false;
  498. };
  499. this.findString = function(nPosition ,string)
  500. {
  501. return -1 < this.buffer[nPosition].indexOf(string);
  502. };
  503. this.toString = function()
  504. {
  505. return this.buffer.join("");
  506. };
  507. this.length = function()
  508. {
  509. return this.buffer.length;
  510. };
  511. this.empty = function()
  512. {
  513. this.buffer = [];
  514. this.bSelect = false;
  515. return this;
  516. };
  517. };
  518. /**
  519. * textare,input 개행문자를 변환한다.
  520. */
  521. String.prototype.textCharConvert = function ()
  522. {
  523. var strText = this;
  524. strText = strText.replace(/\\n/g, "\n");
  525. strText = strText.replace(/\\r/g, "\r");
  526. strText = strText.replace(/\\t/g, "\t");
  527. return strText;
  528. };
  529. /**
  530. * 개행문자를 변환한다.
  531. */
  532. String.prototype.newlineCharConvert = function ()
  533. {
  534. var strText = this;
  535. strText = strText.replace(/\&/g, "&amp;");
  536. strText = strText.replace(/\</g,"&lt;");
  537. strText = strText.replace(/\>/g,"&gt;");
  538. strText = strText.split(" ").join("&nbsp;");
  539. strText = strText.split("\n").join("<br>");
  540. strText = strText.split("\r").join("");
  541. strText = strText.split("\t").join("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  542. return strText;
  543. };
  544. /**
  545. * String RGB색상을 반전한다.
  546. * @return
  547. */
  548. String.prototype.invertRGB = function ()
  549. {
  550. var strRGB = this;
  551. if (-1 != this.indexOf("rgb"))
  552. {
  553. var strRGBData = this.substring(this.indexOf("(")+1, this.length);
  554. var alRGBValue = strRGBData.split(/\,/g);
  555. strRGB = "#";
  556. for (var i=0; i<alRGBValue.length; i++)
  557. {
  558. strRGB += giveHex(Math.floor(parseInt(alRGBValue[i])/16));
  559. strRGB += giveHex(parseInt(alRGBValue[i]) % 16);
  560. }
  561. }
  562. var strInvertRGB = "";
  563. for (var i=0; i<strRGB.length; i++)
  564. {
  565. switch (strRGB.charAt(i))
  566. {
  567. case "F":
  568. case "f":
  569. {
  570. strInvertRGB += "0";
  571. break;
  572. }
  573. case "E":
  574. case "e":
  575. {
  576. strInvertRGB += "1";
  577. break;
  578. }
  579. case "D":
  580. case "d":
  581. {
  582. strInvertRGB += "2";
  583. break;
  584. }
  585. case "C":
  586. case "c":
  587. {
  588. strInvertRGB += "3";
  589. break;
  590. }
  591. case "B":
  592. case "b":
  593. {
  594. strInvertRGB += "4";
  595. break;
  596. }
  597. case "A":
  598. case "a":
  599. {
  600. strInvertRGB += "5";
  601. break;
  602. }
  603. case "9":
  604. {
  605. strInvertRGB += "6";
  606. break;
  607. }
  608. case "8":
  609. {
  610. strInvertRGB += "7";
  611. break;
  612. }
  613. case "7":
  614. {
  615. strInvertRGB += "8";
  616. break;
  617. }
  618. case "6":
  619. {
  620. strInvertRGB += "9";
  621. break;
  622. }
  623. case "5":
  624. {
  625. strInvertRGB += "A";
  626. break;
  627. }
  628. case "4":
  629. {
  630. strInvertRGB += "B";
  631. break;
  632. }
  633. case "3":
  634. {
  635. strInvertRGB += "C";
  636. break;
  637. }
  638. case "2":
  639. {
  640. strInvertRGB += "D";
  641. break;
  642. }
  643. case "1":
  644. {
  645. strInvertRGB += "E";
  646. break;
  647. }
  648. case "0":
  649. {
  650. strInvertRGB += "F";
  651. break;
  652. }
  653. default:
  654. {
  655. strInvertRGB += strRGB.charAt(i);
  656. break;
  657. }
  658. }
  659. }
  660. return strInvertRGB;
  661. };
  662. String.prototype.formatting = function (strFormat)
  663. {
  664. var strTextData = this;
  665. var m_strDotZero = "";
  666. var nFormateStatus = formatStatus (strFormat);
  667. //format (-) 형태 판단
  668. var bSubtraction = false;
  669. if (-1 != strFormat.indexOf("(-)") && 0 < nFormateStatus)
  670. {
  671. bSubtraction = 0 == strTextData.indexOf("-");
  672. strFormat = strFormat.replace("(-)","");
  673. }
  674. var nPoint = strFormat.indexOf(".");
  675. if (-1 != nPoint)
  676. {
  677. m_strDotZero = "";
  678. while("0" == strFormat.charAt((nPoint + 1)))
  679. {
  680. m_strDotZero += "0";
  681. nPoint++;
  682. }
  683. }
  684. // format 선행, 후행 문자 저장
  685. var strTransData = strFormat.replace(/(\#|\,|\.|0|9)+/g,"__");
  686. strTransData = "HEAD" + strTransData;
  687. var arData = strTransData.split(/\_\_/g);
  688. if (1 == arData.length)
  689. {
  690. if (-1 == arData[0].indexOf("HEAD"))
  691. {
  692. arData[1] = arData[0];
  693. arData[0] = "";
  694. }
  695. else
  696. {
  697. arData[0] = arData[0].replace(/HEAD/g,"");
  698. arData[1] = "";
  699. }
  700. }
  701. else
  702. {
  703. arData[0] = null != arData[0] ? arData[0].replace(/HEAD/g,"") : "";
  704. arData[1] = null != arData[1] ? arData[1].replace(/\+/g,"") : "";
  705. }
  706. switch (nFormateStatus)
  707. {
  708. case 0:
  709. {
  710. return strTextData;
  711. }
  712. case 1:
  713. {
  714. return inputValidateCheck(strFormat, strTextData);
  715. }
  716. case 2:
  717. {
  718. strTextData = inputMoneyUnitValidateCheckPattern1 (strTextData, strTextData.length, strFormat, m_strDotZero);
  719. break;
  720. }
  721. case 3:
  722. {
  723. strTextData = inputMoneyUnitValidateCheckPattern2 (strTextData, strTextData.length, strFormat, m_strDotZero);
  724. break;
  725. }
  726. case 4:
  727. {
  728. strTextData = inputMoneyUnitValidateCheckPattern3 (strTextData, strTextData.length, strFormat, m_strDotZero);
  729. break;
  730. }
  731. case 5:
  732. { // 화폐 + 소수점 패턴일 경우
  733. if (-1 == strTextData.indexOf("."))
  734. {
  735. strTextData = inputMoneyUnitValidateCheckPattern2 (strTextData, strTextData.length, strFormat, m_strDotZero);
  736. if(0 != strTextData.length)
  737. {
  738. if (0 == m_strDotZero.length)
  739. {
  740. strTextData += ".0";
  741. }
  742. else
  743. {
  744. strTextData += "." + m_strDotZero;
  745. }
  746. }
  747. }
  748. else
  749. {
  750. this.m_bIsEmptyFormatted = true;
  751. var nStrDotTokenPoint = this.indexOf(".");
  752. strTextData = inputMoneyUnitValidateCheckPattern2 (this.substring(0, nStrDotTokenPoint), nStrDotTokenPoint, strFormat, m_strDotZero);
  753. strTextData += ".";
  754. strTextData += inputMoneyUnitValidateCheckPattern1 (this.substring(nStrDotTokenPoint + 1, this.length), this.length - nStrDotTokenPoint - 1, strFormat, m_strDotZero);
  755. }
  756. break;
  757. }
  758. }
  759. strTextData = bSubtraction ? arData[0] + "-" + strTextData + arData[1]: arData[0] + strTextData + arData[1];
  760. return strTextData;
  761. };
  762. /**
  763. * String 정규식의 된 식이 존재하는지 여부를 구한다.
  764. *
  765. * @author 김우겸
  766. *
  767. * @return Boolean
  768. */
  769. String.prototype.isRegular = function (rePattern)
  770. {
  771. var alStringData = this.match(rePattern);
  772. if (null != alStringData)
  773. {
  774. return true;
  775. }
  776. else
  777. {
  778. return false;
  779. }
  780. };
  781. /**
  782. * String tag의 attribute를 추가한다.
  783. *
  784. * @author 김우겸
  785. *
  786. * @return String
  787. */
  788. String.prototype.insertAttribute = function (strAttName, strAttValue)
  789. {
  790. if (!strAttName || !strAttValue)
  791. {
  792. return this;
  793. }
  794. var strTag = this;
  795. var nIndex = strTag.lastIndexOf(">");
  796. if (-1 == nIndex)
  797. {
  798. return this;
  799. }
  800. var strTag = strTag.substring(0, nIndex);
  801. strTag = strTag + " " + strAttName + "=" + "\"" + strAttValue + "\">";
  802. return strTag;
  803. };
  804. /**
  805. * String 객체가 비어 있는지 여부를 구한다.
  806. * @return
  807. *
  808. * @author 김지환
  809. */
  810. String.prototype.isEmpty = function ()
  811. {
  812. if (0 < this.length)
  813. {
  814. return false;
  815. }
  816. return true;
  817. };
  818. /**
  819. * String 객체에 Trim 함수를 추가한다.
  820. *
  821. * @author 김지환
  822. * 수정:2011-11-14 김우겸
  823. */
  824. String.prototype.trim = function ()
  825. {
  826. return this.replace(/^\s+/,"").replace(/\s+$/,"");
  827. };
  828. /**
  829. * String 객체에 ReplaceAll 함수를 추가한다.
  830. *
  831. * @author 김우겸
  832. */
  833. String.prototype.replaceAll = function (strFindString , strChangeString)
  834. {
  835. return this.split(strFindString).join(strChangeString);
  836. };
  837. /**
  838. * String 객체에 getByte 함수를 추가한다.
  839. *
  840. * @author 김우겸
  841. */
  842. String.prototype.getByte = function ()
  843. {
  844. var nBytrCnt = 0;
  845. for (var nCount = 0; nCount < this.length; nCount++)
  846. {
  847. if (this.charCodeAt(nCount) > 127)
  848. {
  849. nBytrCnt += 2;
  850. }
  851. else
  852. {
  853. nBytrCnt++;
  854. }
  855. }
  856. return nBytrCnt;
  857. };
  858. String.prototype.setByteWithStrLength = function (nByte)
  859. {
  860. var nBytrCnt = 0;
  861. var StrReturnValue = "";
  862. for (var nCount = 0; nCount < this.length && nBytrCnt < nByte; nCount++)
  863. {
  864. if (this.charCodeAt(nCount) > 127)
  865. {
  866. nBytrCnt += 2;
  867. StrReturnValue += this.charAt(nCount);
  868. }
  869. else
  870. {
  871. nBytrCnt++;
  872. StrReturnValue += this.charAt(nCount);
  873. }
  874. }
  875. return StrReturnValue;
  876. };
  877. String.prototype.changeExtension = function (strOldExtension, strNewExtension)
  878. {
  879. var nPosition = this.lastIndexOf('.');
  880. if (nPosition > 0 && nPosition < this.length && strOldExtension == this.substr(nPosition + 1))
  881. {
  882. var strNewFileName = this.substring(0, nPosition);
  883. return strNewFileName + "." + strNewExtension;
  884. }
  885. return this;
  886. };
  887. function URIEncoder ()
  888. {
  889. };
  890. URIEncoder.encode = function (strValue, strEncoding)
  891. {
  892. strEncoding = strEncoding.toUpperCase();
  893. if (/*defalut*/"" == strEncoding ||"UTF-8" == strEncoding || "UTF-16" == strEncoding )
  894. {
  895. return encodeURI(strValue);
  896. }
  897. else
  898. {
  899. var objHttpClient = new HttpClient();
  900. var strData = "encode=" + strEncoding + "&" + "value=" + encodeURI(strValue);
  901. var strResult = objHttpClient.post(__getAppName () + "/kr/comsquare/jsp/encoding.jsp", strData);
  902. if (null != strResult)
  903. {
  904. return strResult.trim();
  905. }
  906. }
  907. return strValue;
  908. };
  909. /**
  910. * Base64
  911. */
  912. function Base64 ()
  913. {
  914. };
  915. Base64.keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  916. Base64.encode = function (strValue)
  917. {
  918. strValue = utf16.encode(strValue);
  919. var strResult = "";
  920. var ch1, ch2, ch3, encoded1, encoded2, encoded3, encoded4;
  921. var i = 0;
  922. while(i < strValue.length)
  923. {
  924. ch1 = strValue.charCodeAt(i++);
  925. ch2 = strValue.charCodeAt(i++);
  926. ch3 = strValue.charCodeAt(i++);
  927. encoded1 = ch1 >> 2;
  928. encoded2 = ((ch1 & 3) << 4) | (ch2 >> 4);
  929. encoded3 = ((ch2 & 15) << 2) | (ch3 >> 6);
  930. encoded4 = ch3 & 63;
  931. if (isNaN(ch2))
  932. {
  933. encoded3 = encoded4 = 64;
  934. }
  935. else if (isNaN(ch3))
  936. {
  937. encoded4 = 64;
  938. }
  939. strResult += Base64.keyStr.charAt(encoded1) + Base64.keyStr.charAt(encoded2) +
  940. Base64.keyStr.charAt(encoded3) + Base64.keyStr.charAt(encoded4);
  941. }
  942. return strResult;
  943. };
  944. Base64.decode = function (strValue)
  945. {
  946. strValue = strValue.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  947. var strResult = "";
  948. var ch1, ch2, ch3, encode1, encode2, encode3, encode4;
  949. var i=0;
  950. while (i < strValue.length)
  951. {
  952. encode1 = Base64.keyStr.indexOf(strValue.charAt(i++));
  953. encode2 = Base64.keyStr.indexOf(strValue.charAt(i++));
  954. encode3 = Base64.keyStr.indexOf(strValue.charAt(i++));
  955. encode4 = Base64.keyStr.indexOf(strValue.charAt(i++));
  956. ch1 = (encode1 << 2) | (encode2 >> 4);
  957. ch2 = ((encode2 & 15) << 4) | (encode3 >> 2);
  958. ch3 = ((encode3 & 3) << 6) | encode4;
  959. strResult += String.fromCharCode(ch1);
  960. if (encode3 != 64)
  961. {
  962. strResult += String.fromCharCode(ch2);
  963. }
  964. if (encode4 != 64)
  965. {
  966. strResult += String.fromCharCode(ch3);
  967. }
  968. }
  969. return utf16.decode(strResult);
  970. };
  971. /**
  972. * UTF8 - URI Encoder / Decoder
  973. */
  974. function UTF8 ()
  975. {
  976. };
  977. UTF8.encode = function (strValue)
  978. {
  979. strValue = strValue.replace(/\r\n/g,"\n");
  980. var strUTF = "";
  981. for (var i=0; i<strValue.length; i++)
  982. {
  983. var chIndex = strValue.charCodeAt(i);
  984. if (chIndex < 128)
  985. {
  986. strUTF += String.fromCharCode(chIndex);
  987. }
  988. else if((chIndex > 127) && (chIndex < 2048))
  989. {
  990. strUTF += String.fromCharCode((chIndex >> 6) | 192);
  991. strUTF += String.fromCharCode((chIndex & 63) | 128);
  992. }
  993. else
  994. {
  995. strUTF += String.fromCharCode((chIndex >> 12) | 224);
  996. strUTF += String.fromCharCode(((chIndex >> 6) & 63) | 128);
  997. strUTF += String.fromCharCode((chIndex & 63) | 128);
  998. }
  999. }
  1000. return strUTF;
  1001. };
  1002. UTF8.decode = function (strValue)
  1003. {
  1004. var strDecoded = "";
  1005. var i = 0;
  1006. var chIndex = chIndex1 = chIndex2 = 0;
  1007. while ( i < strValue.length )
  1008. {
  1009. chIndex = strValue.charCodeAt(i);
  1010. if (chIndex < 128)
  1011. {
  1012. strDecoded += String.fromCharCode(chIndex);
  1013. i++;
  1014. }
  1015. else if((chIndex > 191) && (chIndex < 224))
  1016. {
  1017. chIndex1 = strValue.charCodeAt(i+1);
  1018. strDecoded += String.fromCharCode(((chIndex & 31) << 6) | (chIndex1 & 63));
  1019. i += 2;
  1020. }
  1021. else
  1022. {
  1023. chIndex1 = strValue.charCodeAt(i+1);
  1024. chIndex2 = strValue.charCodeAt(i+2);
  1025. strDecoded += String.fromCharCode(((chIndex & 15) << 12) | ((chIndex1 & 63) << 6) | (chIndex2 & 63));
  1026. i += 3;
  1027. }
  1028. }
  1029. return strDecoded;
  1030. };
  1031. function UTF16 ()
  1032. {
  1033. };
  1034. UTF16.decode = function (input)
  1035. {
  1036. var output = [], i=0, len=input.length,value,extra;
  1037. while (i < len)
  1038. {
  1039. value = input.charCodeAt(i++);
  1040. if ((value & 0xF800) === 0xD800)
  1041. {
  1042. extra = input.charCodeAt(i++);
  1043. if (((value & 0xFC00) !== 0xD800) || ((extra & 0xFC00) !== 0xDC00))
  1044. {
  1045. throw new RangeError("UTF-16(decode): Illegal UTF-16 sequence");
  1046. }
  1047. value = ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  1048. }
  1049. output.push(value);
  1050. }
  1051. return output;
  1052. };
  1053. UTF16.encode = function (input)
  1054. {
  1055. var output = [], i=0, len=input.length,value;
  1056. while (i < len)
  1057. {
  1058. value = input[i++];
  1059. if ((value & 0xF800) === 0xD800)
  1060. {
  1061. throw new RangeError("UTF-16(encode): Illegal UTF-16 value");
  1062. }
  1063. if (value > 0xFFFF)
  1064. {
  1065. value -= 0x10000;
  1066. output.push(String.fromCharCode(((value >>>10) & 0x3FF) | 0xD800));
  1067. value = 0xDC00 | (value & 0x3FF);
  1068. }
  1069. output.push(String.fromCharCode(value));
  1070. }
  1071. return output.join("");
  1072. };
  1073. /**
  1074. * 좌표 객체
  1075. * @param nX
  1076. * @param nY
  1077. * @return
  1078. *
  1079. * @author 김지환
  1080. */
  1081. function Point (nX, nY)
  1082. {
  1083. this.m_nX = nX;
  1084. this.m_nY = nY;
  1085. };
  1086. Point.prototype.clone = function ()
  1087. {
  1088. return new Point(this.m_nX, this.m_nY);
  1089. };
  1090. Point.prototype.getX = function ()
  1091. {
  1092. return this.m_nX;
  1093. };
  1094. Point.prototype.setX = function (nX)
  1095. {
  1096. this.m_nX = nX;
  1097. };
  1098. Point.prototype.getY = function ()
  1099. {
  1100. return this.m_nY;
  1101. };
  1102. Point.prototype.setY = function (nY)
  1103. {
  1104. this.m_nY = nY;
  1105. };
  1106. /**
  1107. * roundmode에 관한 수식을 연산하여 return 한다
  1108. */
  1109. function getRoundMode (strValue, strRoundMode, strRoundPosition)
  1110. {
  1111. var arValue = strValue.split(/\./g);
  1112. var nRoundPosition = Number(strRoundPosition);
  1113. if (nRoundPosition < 0 && null != arValue[1])
  1114. { // 소수점에 관한 반올림,올림,내림일때
  1115. if (Math.abs(nRoundPosition) > arValue[1].length)
  1116. { // 입력한 포지션이 존재하지 않는 소수점에 위치할때
  1117. return strValue;
  1118. }
  1119. else
  1120. {
  1121. if ("round" == strRoundMode)
  1122. {//반올림
  1123. if (parseInt(arValue[1].charAt(Math.abs(nRoundPosition) - 1)) > 4)
  1124. {
  1125. strRoundMode = "ceil";
  1126. }
  1127. else
  1128. {
  1129. strRoundMode = "floor";
  1130. }
  1131. }
  1132. if ("ceil" == strRoundMode)
  1133. {//올림
  1134. if (-1 == nRoundPosition )
  1135. {//소수점 첫번째 자리일 때 정수값을 +1 해준다
  1136. return String(Number(arValue[0]) + 1);
  1137. }
  1138. else
  1139. {// 올림할 값을 구함
  1140. var strPlusValue = "0.";
  1141. for (var i=0 ; i < (Math.abs(nRoundPosition) - 1); i++)
  1142. {
  1143. if((i + 1) == (Math.abs(nRoundPosition) - 1))
  1144. {
  1145. strPlusValue += "1";
  1146. break;
  1147. }
  1148. else
  1149. {
  1150. strPlusValue += "0";
  1151. }
  1152. }
  1153. if ("1" == arValue[1].substring(0, Math.abs(nRoundPosition) - 1))
  1154. {//1.1 + 0.1의 값중 뒤에 쓰레기값이 존재 하는 특별한 경우
  1155. return arValue[0] + ".2";
  1156. }
  1157. // 올림한 값을 더하여 return
  1158. var fSubData = Number(arValue[0] + "." + arValue[1].substring(0, Math.abs(nRoundPosition) - 1)) + Number(strPlusValue);
  1159. return String(fSubData.toFixed(Math.abs(nRoundPosition) - 1));
  1160. }
  1161. }
  1162. else
  1163. {//내림
  1164. if (-1 == nRoundPosition )
  1165. {//첫번째 자리수 일때 정수값만 return
  1166. return arValue[0];
  1167. }
  1168. else
  1169. {// 포지션의 앞자리까지의 값을 return
  1170. return arValue[0] + "." + arValue[1].substring(0, Math.abs(nRoundPosition) - 1);
  1171. }
  1172. }
  1173. }
  1174. }
  1175. else if(nRoundPosition > 0)
  1176. {// 정수에 관한 반올림, 내읾 , 올림 일때
  1177. if (nRoundPosition > arValue[0].length)
  1178. {// 존재하지 않는 자릿수에 관한 처리
  1179. return strValue;
  1180. }
  1181. else
  1182. {
  1183. if ("round" == strRoundMode)
  1184. {// 반올림
  1185. if (parseInt(arValue[0].charAt(arValue[0].length - nRoundPosition)) > 4)
  1186. {
  1187. strRoundMode = "ceil";
  1188. }
  1189. else
  1190. {
  1191. strRoundMode = "floor";
  1192. }
  1193. }
  1194. if ("ceil" == strRoundMode)
  1195. {//올림
  1196. if (arValue[0].length == nRoundPosition )
  1197. {// 포지션의 값이 정수의 맨 앞자리일때 처리
  1198. return String(Math.pow(10, nRoundPosition));
  1199. }
  1200. else
  1201. {//포지션 다음의 정수 자리의 값을 0 처리
  1202. var strPlusValue = arValue[0].substring(0, arValue[0].length - nRoundPosition);
  1203. for (var i=0 ; i < nRoundPosition; i++)
  1204. {
  1205. strPlusValue += "0";
  1206. }
  1207. //포지션의 값 + 1 해서 return
  1208. return String(Number(strPlusValue) + Math.pow(10, nRoundPosition));
  1209. }
  1210. }
  1211. else
  1212. {//내림
  1213. if (arValue[0].length == nRoundPosition )
  1214. {// 포지션의 값이 정수의 맨 앞자리일때 처리
  1215. return "0";
  1216. }
  1217. else
  1218. {// 포지션 다음의 정수 자리의 값을 0처리
  1219. var strPlusValue = arValue[0].substring(0, arValue[0].length - nRoundPosition);
  1220. for (var i=0 ; i < nRoundPosition; i++)
  1221. {
  1222. strPlusValue += "0";
  1223. }
  1224. return strPlusValue;
  1225. }
  1226. }
  1227. }
  1228. }
  1229. else
  1230. {// 포지션이 0일 때 처리
  1231. return strValue;
  1232. }
  1233. //잘못된 포지션 또는 잘못된 값이 넘어올 때 처리
  1234. return strValue;
  1235. };
  1236. function recoveryStyle (heTarget, heClone)
  1237. {
  1238. heTarget.style.position = heClone.style.position;
  1239. heTarget.style.left = heClone.style.left;
  1240. heTarget.style.top = heClone.style.top;
  1241. heTarget.style.width = heClone.style.width;
  1242. heTarget.style.height = heClone.style.height;
  1243. heTarget.style.fontFamily = heClone.style.fontFamily;
  1244. heTarget.style.fontSize = heClone.style.fontSize;
  1245. heTarget.style.fontWeight = heClone.style.fontWeight;
  1246. heTarget.style.fontStyle = heClone.style.fontStyle;
  1247. heTarget.style.textDecoration = heClone.style.textDecoration;
  1248. heTarget.style.color = heClone.style.color;
  1249. heTarget.style.textAlign = heClone.style.textAlign;
  1250. heTarget.style.verticalAlign = heClone.style.verticalAlign;
  1251. heTarget.style.wordWrap = heClone.style.wordWrap;
  1252. heTarget.style.wordSpacing = heClone.style.wordSpacing;
  1253. heTarget.style.letterSpacing = heClone.style.letterSpacing;
  1254. heTarget.style.padding = heClone.style.padding;
  1255. heTarget.style.paddingLeft = heClone.style.paddingLeft;
  1256. heTarget.style.paddingTop = heClone.style.paddingTop;
  1257. heTarget.style.paddingRight = heClone.style.paddingRight;
  1258. heTarget.style.paddingBottom = heClone.style.paddingBottom;
  1259. heTarget.style.backgroundColor = heClone.style.backgroundColor;
  1260. heTarget.style.backgroundImage = heClone.style.backgroundImage;
  1261. heTarget.style.backgroundRepeat = heClone.style.backgroundRepeat;
  1262. heTarget.style.backgroundPosition = heClone.style.backgroundPosition;
  1263. heTarget.style.borderColor = heClone.style.borderColor;
  1264. heTarget.style.borderLeftColor = heClone.style.borderLeftColor;
  1265. heTarget.style.borderTopColor = heClone.style.borderTopColor;
  1266. heTarget.style.borderRightColor = heClone.style.borderRightColor;
  1267. heTarget.style.borderBottomColor = heClone.style.borderBottomColor;
  1268. heTarget.style.borderWidth = heClone.style.borderWidth;
  1269. heTarget.style.borderLeftWidth = heClone.style.borderLeftWidth;
  1270. heTarget.style.borderTopWidth = heClone.style.borderTopWidth;
  1271. heTarget.style.borderRightWidth = heClone.style.borderRightWidth;
  1272. heTarget.style.borderBottomWidth = heClone.style.borderBottomWidth;
  1273. heTarget.style.borderStyle = heClone.style.borderStyle;
  1274. heTarget.style.borderLeftStyle = heClone.style.borderLeftStyle;
  1275. heTarget.style.borderTopStyle = heClone.style.borderTopStyle;
  1276. heTarget.style.borderRightStyle = heClone.style.borderRightStyle;
  1277. heTarget.style.borderBottomStyle = heClone.style.borderBottomStyle;
  1278. heTarget.style.margin = heClone.style.margin;
  1279. heTarget.style.marginLeft = heClone.style.marginLeft;
  1280. heTarget.style.marginTop = heClone.style.marginTop;
  1281. heTarget.style.marginRight = heClone.style.marginRight;
  1282. heTarget.style.marginBottom = heClone.style.marginBottom;
  1283. };
  1284. /**
  1285. * 사각형
  1286. * @param nX
  1287. * @param nY
  1288. * @param nWidth
  1289. * @param nHeight
  1290. *
  1291. * @author 김지환
  1292. */
  1293. function Rectangle (nX, nY, nWidth, nHeight)
  1294. {
  1295. this.m_nX = nX;
  1296. this.m_nY = nY;
  1297. this.m_nWidth = nWidth;
  1298. this.m_nHeight = nHeight;
  1299. this.m_nBottom;
  1300. this.m_nRight;
  1301. this.adjustButtomRight();
  1302. };
  1303. Rectangle.prototype.getX = function ()
  1304. {
  1305. return this.m_nX;
  1306. };
  1307. Rectangle.prototype.getY = function ()
  1308. {
  1309. return this.m_nY;
  1310. };
  1311. Rectangle.prototype.setX = function (nX)
  1312. {
  1313. this.m_nX = nX;
  1314. this.adjustButtomRight();
  1315. };
  1316. Rectangle.prototype.setY = function (nY)
  1317. {
  1318. this.m_nY = nY;
  1319. this.adjustButtomRight();
  1320. };
  1321. Rectangle.prototype.getWidth = function ()
  1322. {
  1323. return this.m_nWidth;
  1324. };
  1325. Rectangle.prototype.setWidth = function (nWidth)
  1326. {
  1327. this.m_nWidth = nWidth;
  1328. this.adjustButtomRight();
  1329. };
  1330. Rectangle.prototype.getHeight = function ()
  1331. {
  1332. return this.m_nHeight;
  1333. };
  1334. Rectangle.prototype.setHeight = function (nHeight)
  1335. {
  1336. this.m_nHeight = nHeight;
  1337. this.adjustButtomRight();
  1338. };
  1339. Rectangle.prototype.getBottom = function ()
  1340. {
  1341. return this.m_nBottom;
  1342. };
  1343. Rectangle.prototype.getRight = function ()
  1344. {
  1345. return this.m_nRight;
  1346. };
  1347. Rectangle.prototype.adjustButtomRight = function ()
  1348. {
  1349. this.m_nRight = this.m_nX + this.m_nWidth;
  1350. this.m_nBottom = this.m_nY + this.m_nHeight;
  1351. };
  1352. Rectangle.prototype.isContainsPoint = function (ptContains)
  1353. {
  1354. if (null != ptContains && ptContains instanceof Point)
  1355. {
  1356. if (this.m_nX <= ptContains.getX()
  1357. && this.m_nRight >= ptContains.getX()
  1358. && this.m_nY <= ptContains.getY()
  1359. && this.m_nBottom >= ptContains.getY())
  1360. {
  1361. return true;
  1362. }
  1363. }
  1364. return false;
  1365. };
  1366. inputValidateCheck = function(strFormat, strValueData) //keydown 잘못 입력된 값 처리 && input된 초기값에 format 적용
  1367. {
  1368. var strSaveData = "";
  1369. var strTempData = "";
  1370. var nFormatSwtichPoint = 0;
  1371. var nInputSwtichPoint = 0;
  1372. var nFormatLength = strFormat.length;
  1373. var strInputData = strValueData;
  1374. var reSpecialChar = /\W|\s/g;
  1375. strInputData = strInputData.replace(reSpecialChar , "");
  1376. for (var i=0 ; i < nFormatLength ; i++)
  1377. {
  1378. if( nFormatSwtichPoint != nFormatLength && "" != strInputData.charAt(nInputSwtichPoint))
  1379. {
  1380. if ("9" != strFormat.charAt(nFormatSwtichPoint) && "y" != strFormat.charAt(nFormatSwtichPoint) &&
  1381. "m" != strFormat.charAt(nFormatSwtichPoint) && "d" != strFormat.charAt(nFormatSwtichPoint) &&
  1382. "h" != strFormat.charAt(nFormatSwtichPoint) && "n" != strFormat.charAt(nFormatSwtichPoint) &&
  1383. "s" != strFormat.charAt(nFormatSwtichPoint) && "A" != strFormat.charAt(nFormatSwtichPoint) &&
  1384. "a" != strFormat.charAt(nFormatSwtichPoint) && "C" != strFormat.charAt(nFormatSwtichPoint) &&
  1385. "L" != strFormat.charAt(nFormatSwtichPoint))
  1386. {
  1387. strSaveData = strSaveData + strFormat.charAt(nFormatSwtichPoint);
  1388. nFormatSwtichPoint++;
  1389. }
  1390. else
  1391. {
  1392. for (;nInputSwtichPoint < strInputData.length; nInputSwtichPoint++)
  1393. {
  1394. strTempData = validateFormat (nFormatSwtichPoint, strInputData.charAt(nInputSwtichPoint), strFormat, strInputData);
  1395. if ("" != strTempData)
  1396. {
  1397. strSaveData = strSaveData + strTempData;
  1398. nInputSwtichPoint++;
  1399. if ("9" != strFormat.charAt(nFormatSwtichPoint + 1) && "y" != strFormat.charAt(nFormatSwtichPoint + 1) &&
  1400. "m" != strFormat.charAt(nFormatSwtichPoint + 1) && "d" != strFormat.charAt(nFormatSwtichPoint + 1) &&
  1401. "h" != strFormat.charAt(nFormatSwtichPoint + 1) && "n" != strFormat.charAt(nFormatSwtichPoint + 1) &&
  1402. "s" != strFormat.charAt(nFormatSwtichPoint + 1) && "A" != strFormat.charAt(nFormatSwtichPoint + 1) &&
  1403. "a" != strFormat.charAt(nFormatSwtichPoint + 1) && "C" != strFormat.charAt(nFormatSwtichPoint + 1) &&
  1404. "L" != strFormat.charAt(nFormatSwtichPoint + 1))
  1405. {
  1406. strSaveData = strSaveData + strFormat.charAt(nFormatSwtichPoint + 1);
  1407. nFormatSwtichPoint++;
  1408. }
  1409. break;
  1410. }
  1411. }
  1412. nFormatSwtichPoint++;
  1413. }
  1414. }
  1415. }
  1416. return strSaveData;
  1417. };
  1418. validateFormat = function (nInputStringLength, strCharValue, strFormat, strInputData)
  1419. {
  1420. var nkeyCode = strCharValue.charCodeAt(0);
  1421. switch (strFormat.charAt(nInputStringLength))
  1422. {
  1423. case "9":
  1424. {
  1425. if ( nkeyCode >= 48 && nkeyCode <= 57 )
  1426. {
  1427. return String.fromCharCode(nkeyCode);
  1428. }
  1429. return "";
  1430. }
  1431. case "y":
  1432. {
  1433. if ( nkeyCode >= 48 && nkeyCode <= 57 )
  1434. {
  1435. return String.fromCharCode(nkeyCode);
  1436. }
  1437. return "";
  1438. }
  1439. case "m":
  1440. {
  1441. if ("m" == strFormat.charAt(nInputStringLength + 1))
  1442. {
  1443. if ( nkeyCode >= 48 && nkeyCode <= 49 )
  1444. {
  1445. return String.fromCharCode(nkeyCode);
  1446. }
  1447. }
  1448. else
  1449. {
  1450. if("m" == strFormat.charAt(nInputStringLength - 1) && "1" == strInputData.charAt(nInputStringLength - 1))
  1451. {
  1452. if ( nkeyCode >= 48 && nkeyCode <= 50 )
  1453. {
  1454. return String.fromCharCode(nkeyCode);
  1455. }
  1456. }
  1457. else
  1458. {
  1459. if ( nkeyCode >= 48 && nkeyCode <= 57 )
  1460. {
  1461. return String.fromCharCode(nkeyCode);
  1462. }
  1463. }
  1464. }
  1465. return "";
  1466. }
  1467. case "d":
  1468. {
  1469. if ("d" == strFormat.charAt(nInputStringLength + 1))
  1470. {
  1471. if ("m" == strFormat.charAt(nInputStringLength - 2) && "2" == strInputData.charAt(nInputStringLength - 2) &&
  1472. (("m" == strFormat.charAt(nInputStringLength - 3) && "0" == strInputData.charAt(nInputStringLength - 3)) ||
  1473. "m" != strFormat.charAt(nInputStringLength - 3)))
  1474. {
  1475. if ( nkeyCode >= 48 && nkeyCode <= 50 )
  1476. {
  1477. return String.fromCharCode(nkeyCode);
  1478. }
  1479. }
  1480. else
  1481. {
  1482. if ( nkeyCode >= 48 && nkeyCode <= 51 )
  1483. {
  1484. return String.fromCharCode(nkeyCode);
  1485. }
  1486. }
  1487. }
  1488. else
  1489. {
  1490. if ("d" == strFormat.charAt(nInputStringLength - 1) && "3" != strInputData.charAt(nInputStringLength - 1))
  1491. {
  1492. if ( nkeyCode >= 48 && nkeyCode <= 57 )
  1493. {
  1494. return String.fromCharCode(nkeyCode);
  1495. }
  1496. }
  1497. else if ("d" == strFormat.charAt(nInputStringLength - 1) && "3" == strInputData.charAt(nInputStringLength - 1))
  1498. {
  1499. if ( nkeyCode >= 48 && nkeyCode <= 49 )
  1500. {
  1501. return String.fromCharCode(nkeyCode);
  1502. }
  1503. }
  1504. else
  1505. {
  1506. if ( nkeyCode >= 48 && nkeyCode <= 57 )
  1507. {
  1508. return String.fromCharCode(nkeyCode);
  1509. }
  1510. }
  1511. }
  1512. return "";
  1513. }
  1514. case "h":
  1515. {
  1516. if ("h" == strFormat.charAt(nInputStringLength + 1))
  1517. {
  1518. if ( nkeyCode >= 48 && nkeyCode <= 50 )
  1519. {
  1520. return String.fromCharCode(nkeyCode);
  1521. }
  1522. }
  1523. else
  1524. {
  1525. if ("h" == strFormat.charAt(nInputStringLength - 1) && "2" == strInputData.charAt(nInputStringLength - 1))
  1526. {
  1527. if ( nkeyCode >= 48 && nkeyCode <= 52 )
  1528. {
  1529. return String.fromCharCode(nkeyCode);
  1530. }
  1531. }
  1532. else
  1533. {
  1534. if ( nkeyCode >= 48 && nkeyCode <= 57 )
  1535. {
  1536. return String.fromCharCode(nkeyCode);
  1537. }
  1538. }
  1539. }
  1540. return "";
  1541. }
  1542. case "n":
  1543. {
  1544. if ("n" == strFormat.charAt(nInputStringLength + 1))
  1545. {
  1546. if ( nkeyCode >= 48 && nkeyCode <= 53 )
  1547. {
  1548. return String.fromCharCode(nkeyCode);
  1549. }
  1550. }
  1551. else
  1552. {
  1553. if ( nkeyCode >= 48 && nkeyCode <= 57 )
  1554. {
  1555. return String.fromCharCode(nkeyCode);
  1556. }
  1557. }
  1558. return "";
  1559. }
  1560. case "s":
  1561. {
  1562. if ("s" == strFormat.charAt(nInputStringLength + 1))
  1563. {
  1564. if ( nkeyCode >= 48 && nkeyCode <= 53 )
  1565. {
  1566. return String.fromCharCode(nkeyCode);
  1567. }
  1568. }
  1569. else
  1570. {
  1571. if ( nkeyCode >= 48 && nkeyCode <= 57 )
  1572. {
  1573. return String.fromCharCode(nkeyCode);
  1574. }
  1575. }
  1576. return "";
  1577. }
  1578. case "A":
  1579. {
  1580. if ( (nkeyCode >= 48 && nkeyCode <= 57) || (nkeyCode >= 65 && nkeyCode <= 90) || (nkeyCode >= 97 && nkeyCode <= 129))
  1581. {
  1582. return strCharValue;
  1583. }
  1584. return "";
  1585. }
  1586. case "a":
  1587. {
  1588. if ((nkeyCode == 32) || (nkeyCode >= 48 && nkeyCode <= 57) || (nkeyCode >= 65 && nkeyCode <= 90) || (nkeyCode >= 97 && nkeyCode <= 129))
  1589. {
  1590. return strCharValue;
  1591. }
  1592. return "";
  1593. }
  1594. case "C":
  1595. {
  1596. if ((nkeyCode >= 48 && nkeyCode <= 112) || nkeyCode > 185 || (nkeyCode >= 97 && nkeyCode <= 129))
  1597. {
  1598. return strCharValue;
  1599. }
  1600. return "";
  1601. }
  1602. case "L":
  1603. {
  1604. if ((nkeyCode >= 65 && nkeyCode <= 90) || (nkeyCode >= 97 && nkeyCode <= 129))
  1605. {
  1606. return strCharValue;
  1607. }
  1608. return "";
  1609. }
  1610. default:
  1611. {
  1612. alert("미구현");
  1613. return "";
  1614. }
  1615. }
  1616. };
  1617. /**
  1618. * String 의 값을 인자로 받는 format형식으로 변환한다.
  1619. *
  1620. * @author 김우겸
  1621. *
  1622. */
  1623. inputMoneyUnitValidateCheckPattern1 = function (strInputData, nInputDataLength, strFormat, m_strDotZero)
  1624. { // # 숫자만 존재할 때
  1625. var strSaveData = ""; //초기화
  1626. var bExistFirstZero = -1 != strFormat.indexOf("9#");
  1627. var bExistSaveData = true;
  1628. var bNumber = parseFloat(strInputData) > 0;
  1629. nInputDataLength = 0 == m_strDotZero.length ? strInputData.length : m_strDotZero.length;
  1630. for (var i=0 ; i < nInputDataLength ; i++)
  1631. {
  1632. if (strInputData.charCodeAt(i) >= 48 && strInputData.charCodeAt(i) <= 57)
  1633. {
  1634. if (strInputData.charCodeAt(i) == 48 && !bExistFirstZero)
  1635. {
  1636. bExistFirstZero = false;
  1637. }
  1638. else
  1639. {
  1640. bExistFirstZero = true;
  1641. }
  1642. if (bExistFirstZero)
  1643. {
  1644. strSaveData = strSaveData + strInputData.charAt(i);
  1645. bExistSaveData = false;
  1646. //this.m_strInputRealityData = this.m_strInputRealityData + strInputData.charAt(i);
  1647. }
  1648. if (bNumber && bExistSaveData && strInputData.charCodeAt(i) == 48)
  1649. {
  1650. //this.m_strInputRealityData = strInputData.charAt(i);
  1651. strSaveData = strInputData.charAt(i);
  1652. }
  1653. bExistSaveData = true;
  1654. }
  1655. }
  1656. for (var i=0; i<m_strDotZero.length; i++)
  1657. {
  1658. if (strSaveData.length == m_strDotZero.length)
  1659. {
  1660. break;
  1661. }
  1662. if ("" == strSaveData.charAt(i))
  1663. {
  1664. // this.m_strInputRealityData = this.m_strInputRealityData + "0";
  1665. strSaveData = strSaveData + "0";
  1666. }
  1667. }
  1668. return strSaveData;
  1669. };
  1670. inputMoneyUnitValidateCheckPattern2 = function (strInputData, nInputDataLength, strFormat, m_strDotZero)
  1671. { // (# + ,) 화폐단위 format일때
  1672. var strSaveData = ""; //초기화
  1673. if (-1 != strInputData.indexOf("."))
  1674. {
  1675. strInputData = strInputData.split(/\./g)[0]; //소숫점이 존재한다면 뒷부분 내림
  1676. }
  1677. nInputDataLength = strInputData.length;
  1678. strInputData = strInputData.replace(/\W|\s|\D/g,""); //문자열에서 , 제외
  1679. nInputDataLength = strInputData.length;
  1680. var nCommaFirstPoint = nInputDataLength % 3;
  1681. var nCommaLoopPoint = (nInputDataLength / 2) - 1 ;
  1682. var nCommaFirstPrintCount = 0;
  1683. var nCommaLoopPrintCount = 0;
  1684. var bCommaLoopStarter = false;
  1685. var bExistFirstZero = false;
  1686. for (var i=0 ; i < nInputDataLength ; i++)
  1687. {
  1688. if (strInputData.charCodeAt(i) >= 48 && strInputData.charCodeAt(i) <= 57)
  1689. {
  1690. if (strInputData.charCodeAt(i) == 48 && !bExistFirstZero)
  1691. {
  1692. bExistFirstZero = false;
  1693. }
  1694. else
  1695. {
  1696. bExistFirstZero = true;
  1697. }
  1698. if (bExistFirstZero)
  1699. {
  1700. if (nCommaFirstPoint == nCommaFirstPrintCount)
  1701. {
  1702. if (nInputDataLength > 3 && nCommaFirstPoint != 0)
  1703. {
  1704. strSaveData = strSaveData + ",";
  1705. bCommaLoopStarter = true;
  1706. }
  1707. else if (nInputDataLength > 3)
  1708. {
  1709. bCommaLoopStarter = true;
  1710. }
  1711. }
  1712. if (3 == nCommaLoopPrintCount)
  1713. {
  1714. strSaveData = strSaveData + ",";
  1715. nCommaLoopPrintCount = 0;
  1716. }
  1717. strSaveData = strSaveData + strInputData.charAt(i);
  1718. //this.m_strInputRealityData = this.m_strInputRealityData + strInputData.charAt(i);
  1719. nCommaFirstPrintCount ++;
  1720. if (bCommaLoopStarter)
  1721. {
  1722. nCommaLoopPrintCount++;
  1723. }
  1724. }
  1725. if (1 == nInputDataLength && 0 == i && strInputData.charCodeAt(i) == 48)
  1726. {
  1727. //this.m_strInputRealityData = strInputData.charAt(i);
  1728. strSaveData = strInputData.charAt(i);
  1729. }
  1730. }
  1731. }
  1732. return strSaveData;
  1733. };
  1734. inputMoneyUnitValidateCheckPattern3 = function (strInputData, nInputDataLength, strFormat, m_strDotZero)
  1735. {// (# + .) 소수점 단위일 때
  1736. var strSaveData = ""; //초기화
  1737. nInputDataLength = strInputData.length;
  1738. var nCommaFirstPoint = nInputDataLength % 3;
  1739. var nCommaLoopPoint = (nInputDataLength / 2) - 1 ;
  1740. var nCommaFirstPrintCount = 0;
  1741. var nCommaLoopPrintCount = 0;
  1742. var bCommaLoopStarter = false;
  1743. var bExistFirstZero = false;
  1744. var bExistDot = true;
  1745. for (var i=0 ; i < nInputDataLength ; i++)
  1746. {
  1747. if (((strInputData.charCodeAt(i) >= 48 && strInputData.charCodeAt(i) <= 57) || strInputData.charCodeAt(i) == 46) && bExistDot)
  1748. {
  1749. if (strInputData.charCodeAt(i) == 46)
  1750. { // 첫번째 입력값이 .(dot) 일때
  1751. if (0 ==i && !strInputData.charCodeAt(i + 1))
  1752. {
  1753. return "";
  1754. }
  1755. else if(0 ==i && strInputData.charCodeAt(i + 1))
  1756. {
  1757. return strInputData.substring(1 , nInputDataLength);
  1758. }
  1759. }
  1760. if (strInputData.charCodeAt(i) == 48 && !bExistFirstZero)
  1761. { //첫번째 값이 0일때 처리
  1762. if (0 == i && !strInputData.charCodeAt(i + 1))
  1763. {
  1764. strSaveData = strSaveData + strInputData.charAt(i);
  1765. //this.m_strInputRealityData = this.m_strInputRealityData + strInputData.charAt(i);
  1766. }
  1767. if(strInputData.charCodeAt(i + 1) != 46)
  1768. {
  1769. bExistFirstZero = false;
  1770. }
  1771. else
  1772. {
  1773. bExistFirstZero = true;
  1774. }
  1775. }
  1776. else
  1777. {
  1778. bExistFirstZero = true;
  1779. }
  1780. if (bExistFirstZero)
  1781. {
  1782. strSaveData = strSaveData + strInputData.charAt(i);
  1783. this.m_strInputRealityData = this.m_strInputRealityData + strInputData.charAt(i);
  1784. if (strInputData.charCodeAt(i) == 46)
  1785. {
  1786. bExistDot = false;
  1787. if (-1 != strFormat.indexOf("0"))
  1788. {
  1789. for (var i = strFormat.indexOf("0") ; i < this.m_nLength ; i++)
  1790. {
  1791. if ("0" == strFormat.charAt(i))
  1792. {
  1793. strSaveData += "0";
  1794. //this.m_strInputRealityData += "0";
  1795. }
  1796. }
  1797. return strSaveData;
  1798. }
  1799. }
  1800. }
  1801. }
  1802. else if (strInputData.charCodeAt(i) >= 48 && strInputData.charCodeAt(i) <= 57)
  1803. {
  1804. strSaveData = strSaveData + strInputData.charAt(i);
  1805. //this.m_strInputRealityData = this.m_strInputRealityData + strInputData.charAt(i);
  1806. }
  1807. }
  1808. return strSaveData;
  1809. };
  1810. /**
  1811. * format의 상태를 숫자로 return함
  1812. *
  1813. * @author 김우겸
  1814. *
  1815. * @return 정수(0:format이 없음 1:기본format 2:숫자format 3:화폐 4:소수점 5:화폐 + 소수점)
  1816. *
  1817. */
  1818. formatStatus = function (strFormat)
  1819. {
  1820. if ("" == strFormat)
  1821. {
  1822. return 0;
  1823. }
  1824. var nMoneyUnitFormatPattern;
  1825. if ("-1" == strFormat.indexOf("#") && "-1" == strFormat.indexOf("0"))
  1826. {
  1827. return 1;
  1828. }
  1829. else
  1830. {
  1831. nMoneyUnitFormatPattern = "-1" != strFormat.indexOf(",") ? 3: 2;
  1832. nMoneyUnitFormatPattern = "-1" != strFormat.indexOf(".") ? (nMoneyUnitFormatPattern + 2): nMoneyUnitFormatPattern;
  1833. return nMoneyUnitFormatPattern;
  1834. }
  1835. };
  1836. /**
  1837. * 캐럿의 위치를 저장할 객체
  1838. */
  1839. function CaretPosition()
  1840. {
  1841. var start = null;
  1842. var end = null;
  1843. };
  1844. /**
  1845. * textarea, input tag의 캐럿의 위치를 저장한 객체를 반환한다
  1846. * @param {Object} heField
  1847. * @return {TypeName}
  1848. */
  1849. function getCaretPosition (heField)
  1850. {
  1851. var objCaretPos = new CaretPosition();
  1852. if (document.selection)
  1853. {
  1854. var trBookMark = document.selection.createRange().getBookmark();
  1855. var trSel = heField.createTextRange();
  1856. trSel.moveToBookmark(trBookMark);
  1857. var trSelLeft = heField.createTextRange();
  1858. trSelLeft.collapse(true);
  1859. trSelLeft.setEndPoint("EndToStart", trSel);
  1860. objCaretPos.start = trSelLeft.text.length;
  1861. objCaretPos.end = trSelLeft.text.length + trSel.text.length;
  1862. }
  1863. else if (heField.selectionStart || heField.selectionStart == '0')
  1864. {
  1865. objCaretPos.start = heField.selectionStart;
  1866. objCaretPos.end = heField.selectionEnd;
  1867. }
  1868. return objCaretPos;
  1869. };
  1870. /**
  1871. * textarea, input tag에 지정한 케럿으로 selection 한다
  1872. * @param {Object} heField
  1873. * @param {Object} nCaretStart
  1874. * @param {Object} nCaretEnd
  1875. */
  1876. function setCaretPosition(heField, nCaretStart, nCaretEnd)
  1877. {
  1878. if (document.selection)
  1879. {
  1880. heField.blur();
  1881. heField.focus();
  1882. heField.value = heField.value;
  1883. var trSel = heField.createTextRange();
  1884. trSel.moveStart("character", -heField.value.length);
  1885. trSel.moveEnd("character", -heField.value.length);
  1886. trSel.moveStart("character", nCaretStart);
  1887. trSel.moveEnd("character", nCaretEnd - nCaretStart);
  1888. trSel.select();
  1889. }
  1890. else if (heField.selectionStart || heField.selectionStart == '0')
  1891. {
  1892. heField.selectionStart = null;
  1893. heField.selectionEnd = null;
  1894. heField.selectionStart = nCaretStart;
  1895. heField.selectionEnd = nCaretEnd;
  1896. heField.focus();
  1897. }
  1898. };
  1899. /**
  1900. * textarea, input tag에 selection 한 내용을 반환한다
  1901. * @param {Object} heField
  1902. * @return {TypeName}
  1903. */
  1904. function getSelectionText(heField)
  1905. {
  1906. var objSel ="";
  1907. if (document.selection)
  1908. {
  1909. objSel = document.selection.createRange();
  1910. return objSel.text;
  1911. }
  1912. else
  1913. {
  1914. if (null != heField && null != heField.selectionStart)
  1915. {
  1916. return heField.value.substring(heField.selectionStart, heField.selectionEnd);
  1917. }
  1918. else
  1919. {
  1920. return window.getSelection();
  1921. }
  1922. }
  1923. };
  1924. /**
  1925. * textarea, input tag에 selection 한 내용을 변환한다
  1926. * @param {Object} heField
  1927. * @param {Object} strText
  1928. */
  1929. function setSelectionText(heField, strText)
  1930. {
  1931. if (document.selection)
  1932. {
  1933. var trSel = document.selection.createRange();
  1934. trSel.text = strText;
  1935. }
  1936. else
  1937. {
  1938. var nStartPosition = heField.selectionStart;
  1939. var strHead = 0 != heField.selectionStart ? heField.value.substring(0, heField.selectionStart) : "";
  1940. var strLast = heField.value.substring(heField.selectionEnd, heField.value.length);
  1941. heField.value = strHead + strText + strLast;
  1942. heField.focus();
  1943. heField.selectionStart = nStartPosition;
  1944. heField.selectionEnd = nStartPosition + strText.length;
  1945. }
  1946. };
  1947. /**
  1948. * keyCode의 값으로 검증한다.
  1949. * @param {Object} nKeyCode
  1950. */
  1951. function getInputKeyCode (nKeyCode)
  1952. {
  1953. if ((48 <= nKeyCode && 57 >= nKeyCode) || (65 <= nKeyCode && 90 >= nKeyCode) ||
  1954. (96 <= nKeyCode && 111 >= nKeyCode) || (219 <= nKeyCode && 222 >= nKeyCode) ||
  1955. (186 <= nKeyCode && 192 >= nKeyCode) || 32 == nKeyCode || 229 == nKeyCode)
  1956. {
  1957. return true;
  1958. }
  1959. return false;
  1960. };
  1961. var viewportwidth;
  1962. var viewportheight;
  1963. if (typeof window.innerWidth != 'undefined')
  1964. { viewportwidth = window.innerWidth;
  1965. viewportheight = window.innerHeight; }
  1966. // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
  1967. else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
  1968. { viewportwidth = document.documentElement.clientWidth;
  1969. viewportheight = document.documentElement.clientHeight; }
  1970. // older versions of IE
  1971. else {
  1972. viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
  1973. viewportheight = document.getElementsByTagName('body')[0].clientHeight ;
  1974. }