tfHelper.js.soonsu 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443
  1. function addComboItem( comboID, label, value, position ) {
  2. var comboObj = document.allElement.item(comboID);
  3. var comboItemNodeSet = comboObj.choices.itemset.attribute["nodeset"];
  4. var comboLabelRef = comboObj.choices.itemset.label.attribute["ref"];
  5. var comboValueRef = comboObj.choices.itemset.value.attribute["ref"];
  6. var nodeNn = instance1.selectSingleNode(comboItemNodeSet);
  7. if (nodeNn == null) {
  8. model.makeNode(comboItemNodeSet);
  9. model.makeNode(comboItemNodeSet+"/"+comboLabelRef);
  10. model.makeNode(comboItemNodeSet+"/"+comboValueRef);
  11. position = "init";
  12. }
  13. var itemNode = instance1.createNode("element", instance1.selectSingleNode(comboItemNodeSet).nodeName, "");
  14. var labelNode = instance1.createNode("element", comboLabelRef, "");
  15. var valueNode = instance1.createNode("element", comboValueRef, "");
  16. if( label == null || label == "" ) label = "- �� ü -";
  17. labelNode.setValue(label);
  18. itemNode.appendChild(labelNode);
  19. if( value == null || value == "" ) value = "";
  20. valueNode.setValue(value);
  21. itemNode.appendChild(valueNode);
  22. if( position == null || position == "" )
  23. position = "above";
  24. var destNode = instance1.selectSingleNode(comboItemNodeSet);
  25. var pDestNode = destNode.parentNode;
  26. if( position == "above" ) {
  27. pDestNode.insertBefore(itemNode, destNode);
  28. } else if ( position == "init" ) {
  29. pDestNode.insertBefore(itemNode, destNode);
  30. pDestNode.removeChild(destNode);
  31. }
  32. else {
  33. pDestNode.appendChild(itemNode);
  34. }
  35. comboObj.refresh();
  36. }
  37. function addComboItemAll( comboIDs, label ) {
  38. var comboIDArray = comboIDs.split("|");
  39. if(label == null || label == "" )
  40. label = "- �� ü -";
  41. for( var i = 0; i < comboIDArray.length; i++ )
  42. addComboItem( comboIDArray[i], label, "");
  43. }
  44. function fileDownload( filePath, encode ) {
  45. if( encode == null )
  46. encode = true;
  47. if( encode )
  48. filePath = encodeURI(filePath);
  49. if(!body.isChild("_tmp_browserObj_forDown")) {
  50. document.body.createChild("xforms:browser", "id:_tmp_browserObj_forDown; visibility:hidden");
  51. }
  52. _tmp_browserObj_forDown.navigate(filePath);
  53. }
  54. function checkFileSize( uploadObj ) {
  55. var fileCnt = uploadObj.getFileCount();
  56. var lastIndex = fileCnt - 1;
  57. var fileSize = uploadObj.getFileSize(lastIndex);
  58. var maxSize = uploadObj.attribute["filesize"];
  59. if ( fileSize <= maxSize )
  60. return true;
  61. else
  62. return false;
  63. }
  64. function checkFormUpdate() {
  65. return gvFormUpdateYN;
  66. }
  67. function checkKeyColumn( gridID ) {
  68. var rowsArray = getUpdateRows( gridID, "insert" );
  69. var colsArray = getKeyCols( gridID, "_key" );
  70. var gridObj = document.controls.item(gridID);
  71. var i, j;
  72. for( i = 0; i < rowsArray.length; i++ ) {
  73. for( j = 0; j < colsArray.length; j++ ) {
  74. if( gridObj.valueMatrix(rowsArray[i], colsArray[j]) == "" ) {
  75. messageBox(gridObj.valueMatrix(gridObj.fixedRows - 1, colsArray[j]) + "��(��)", "I003");
  76. gridObj.setRow(rowsArray[i]);
  77. gridObj.setCol(colsArray[j]);
  78. gridObj.editCell();
  79. return false;
  80. }
  81. }
  82. }
  83. return true;
  84. }
  85. function checkRequiredColumn( gridID ) {
  86. var rowsArray = getUpdateRows( gridID, "insert" );
  87. rowsArray = getUpdateRows( gridID, "update", rowsArray );
  88. var colsArray = getKeyCols( gridID, "_required" );
  89. var gridObj = document.controls.item(gridID);
  90. var i, j;
  91. for( i = 0; i < rowsArray.length; i++ ) {
  92. for( j = 0; j < colsArray.length; j++ ) {
  93. if( gridObj.valueMatrix(rowsArray[i], colsArray[j]) == "" ) {
  94. messageBox(gridObj.valueMatrix(gridObj.fixedRows - 1, colsArray[j]) + "��(��)", "I003");
  95. gridObj.setRow(rowsArray[i]);
  96. gridObj.setCol(colsArray[j]);
  97. gridObj.editCell();
  98. return false;
  99. }
  100. }
  101. }
  102. return true;
  103. }
  104. function getUpdateRows( gridID, status, rowsArray ) {
  105. var gridObj = document.controls.item(gridID);
  106. var sCol = gridObj.attribute["colsep"];
  107. var sRow = gridObj.attribute["rowsep"];
  108. var gridStatus = gridObj.getUpdateData(status);
  109. var rowStatusArray = gridStatus.split(sRow);
  110. var rowStatusCnt = rowStatusArray.length;
  111. var rowsArrayLen = 0;
  112. if( rowsArray == null ) {
  113. rowsArray = new Array();
  114. }
  115. else {
  116. rowsArrayLen = rowsArray.length;
  117. }
  118. for( var i = 0; i < rowStatusCnt - 2; i++ ) {
  119. rowsArray[i + rowsArrayLen] = rowStatusArray[i + 1].split(sCol)[1];
  120. }
  121. return rowsArray;
  122. }
  123. function getKeyCols( gridID, atttibutezName ) {
  124. var gridObj = document.controls.item(gridID);
  125. var gridCols = gridObj.cols;
  126. var rColsArray = new Array();
  127. var i, j = 0;
  128. for( i = 0; i < gridCols; i++) {
  129. if( gridObj.colAttribute(i, atttibutezName) == "true" ) {
  130. rColsArray[j++] = i;
  131. }
  132. }
  133. return rColsArray;
  134. }
  135. function copyNodeListType(strDest, strSrc, mode, destModel, srcModel) {
  136. if( typeof(destModel) == "object" || typeof(destModel) == "undefined" ) {
  137. if( destModel == null ) {
  138. destModel = model;
  139. }
  140. }
  141. else {
  142. if( destModel == "" ) {
  143. destModel = model;
  144. }
  145. }
  146. var destNode = destModel.instance1.selectSingleNode(strDest);
  147. if( destNode == null )
  148. return;
  149. var destChildNodeList = destNode.childNodes;
  150. if( typeof(srcModel) == "object" || typeof(srcModel) == "undefined" ) {
  151. if( srcModel == null ) {
  152. srcModel = model;
  153. }
  154. }
  155. else {
  156. if( srcModel == "" ) {
  157. srcModel = model;
  158. }
  159. }
  160. var srcNodeList = srcModel.instance1.selectNodes(strSrc);
  161. var srcNode;
  162. if( srcNodeList.length == 0 )
  163. return;
  164. if( mode != "before" ) {
  165. if( mode == "replace" || mode == null ) {
  166. removeChildren(strDest, destModel)
  167. }
  168. while( srcNode = srcNodeList.nextNode() ) {
  169. model.duplicate(destNode, srcNode);
  170. }
  171. }
  172. else {
  173. for( var i = srcNodeList.length - 1; i >= 0; i-- ) {
  174. destNode = destModel.instance1.selectSingleNode(strDest);
  175. srcNode = srcNodeList.item(i);
  176. model.duplicate(destNode, srcNode, "*[1]");
  177. }
  178. }
  179. }
  180. function copyNodesetType(strDest, strSrc, mode, destModel, srcModel) {
  181. if( typeof(destModel) == "object" || typeof(destModel) == "undefined" ) {
  182. if( destModel == null ) {
  183. destModel = model;
  184. }
  185. }
  186. else {
  187. if( destModel == "" ) {
  188. destModel = model;
  189. }
  190. }
  191. if( typeof(srcModel) == "object" || typeof(srcModel) == "undefined" ) {
  192. if( srcModel == null ) {
  193. srcModel = model;
  194. }
  195. }
  196. else {
  197. if( srcModel == "" ) {
  198. srcModel = model;
  199. }
  200. }
  201. var destNodeList = destModel.instance1.selectNodes(strDest);
  202. if( destNodeList == null || destNodeList.length == 0 ) {
  203. return;
  204. }
  205. var pDestNode = destNodeList(0).parentNode;
  206. var destLastNodesetName = destNodeList(0).nodeName;
  207. var srcNodeList = srcModel.instance1.selectNodes(strSrc);
  208. if( srcNodeList == null || srcNodeList.length == 0 )
  209. return;
  210. if( mode != "before" ) {
  211. if( mode == "replace" || mode == null ) {
  212. destModel.removeNodeset(strDest);
  213. }
  214. var srcNode;
  215. var tmpSrcNode;
  216. while( srcNode = srcNodeList.nextNode() ) {
  217. tmpSrcNode = srcNode.cloneNode(true);
  218. tmpSrcNode.nodeName = destLastNodesetName;
  219. model.duplicate(pDestNode, tmpSrcNode);
  220. }
  221. }
  222. else {
  223. var tmpSrcNode;
  224. for( var i = srcNodeList.length - 1; i >= 0; i-- ) {
  225. pDestNode = destModel.instance1.selectSingleNode(strDest).parentNode;
  226. tmpSrcNode = srcNodeList.item(i).cloneNode(true);
  227. tmpSrcNode.nodeName = destLastNodesetName;
  228. model.duplicate(pDestNode, tmpSrcNode, "*[1]");
  229. }
  230. }
  231. }
  232. function copyNodeType(strDest, strSrc, mode, destModel, srcModel) {
  233. if( typeof(destModel) == "object" || typeof(destModel) == "undefined" ) {
  234. if( destModel == null ) {
  235. destModel = model;
  236. }
  237. }
  238. else {
  239. if( destModel == "" ) {
  240. destModel = model;
  241. }
  242. }
  243. var destNode = destModel.instance1.selectSingleNode(strDest);
  244. if( destNode == null )
  245. return;
  246. var destChildNodeList = destNode.childNodes;
  247. if( typeof(srcModel) == "object" || typeof(srcModel) == "undefined" ) {
  248. if( srcModel == null ) {
  249. srcModel = model;
  250. }
  251. }
  252. else {
  253. if( srcModel == "" ) {
  254. srcModel = model;
  255. }
  256. }
  257. var srcNode = srcModel.instance1.selectSingleNode(strSrc);
  258. if( srcNode == null )
  259. return;
  260. var cSrcNode = srcNode.cloneNode(true);
  261. var cSrcChildNodeList = cSrcNode.childNodes;
  262. var cSrcChildNode;
  263. if( cSrcChildNodeList.length == 0 )
  264. return;
  265. if( mode != "before" ) {
  266. if( mode == "replace" || mode == null ) {
  267. removeChildren(strDest, destModel)
  268. }
  269. while( cSrcChildNode = cSrcChildNodeList.nextNode() ) {
  270. model.duplicate(destNode, cSrcChildNode);
  271. }
  272. }
  273. else {
  274. for( var i = cSrcChildNodeList.length - 1; i >= 0; i-- ) {
  275. destNode = destModel.instance1.selectSingleNode(strDest);
  276. cSrcChildNode = cSrcChildNodeList.item(i);
  277. model.duplicate(destNode, cSrcChildNode, "*[1]");
  278. }
  279. }
  280. }
  281. function copyNodeWithPostfix(strDest, strSrc, postfix, destModel, srcModel) {
  282. removeChildren(strDest, destModel);
  283. var modelObj;
  284. if( srcModel == null ) {
  285. modelObj = model;
  286. }
  287. else
  288. modelObj = srcModel;
  289. var srcNode = modelObj.instance1.selectSingleNode(strSrc);
  290. var cSrcNode = srcNode.cloneNode(true);
  291. var cSrcChildNodeList = cSrcNode.childNodes;
  292. var cSrcChildNode;
  293. var destNode;
  294. if( destModel == null )
  295. destNode = instance1.selectSingleNode(strDest);
  296. else
  297. destNode = destModel.instance1.selectSingleNode(strDest);
  298. while( cSrcChildNode = cSrcChildNodeList.nextNode() ) {
  299. cSrcChildNode.nodeName = cSrcChildNode.nodeName + postfix;
  300. model.duplicate(destNode, cSrcChildNode);
  301. }
  302. }
  303. function setCSVToNode(destRef, CSV, nodeSetName) {
  304. var sColSep = "��";
  305. var sRowSep = "��";
  306. var nodeNameArray = CSV.split(sRowSep)[0].split(sColSep);
  307. var nodeNameArrayCnt = nodeNameArray.length;
  308. if( nodeSetName == null || nodeSetName == "")
  309. nodeSetName = "list";
  310. var tmpDestNode = instance1.createElement(nodeSetName);
  311. var tmpDestChildNode;
  312. var i, j;
  313. for( i = 0; i < nodeNameArrayCnt; i++ ) {
  314. tmpDestChildNode = instance1.createElement(nodeNameArray[i]);
  315. model.duplicate(tmpDestNode, tmpDestChildNode);
  316. }
  317. var CSVArray = CSV.split(sRowSep);
  318. var CSVArrayCnt = CSVArray.length - 1;
  319. var srcNode = instance1.selectSingleNode(destRef);
  320. var nodeValueArray;
  321. for( i = 1; i < CSVArrayCnt; i++ ) {
  322. nodeValueArray = CSVArray[i];
  323. for ( j = 0; j < nodeNameArrayCnt; j++ ) {
  324. tmpDestNode.childNodes.item(j).text = nodeValueArray.split(sColSep)[j];
  325. }
  326. model.duplicate(srcNode, tmpDestNode);
  327. }
  328. }
  329. function deleteSelectedRows(grd,markonly) {
  330. var rowIdx;
  331. if (grd.selectedRows > 0) {
  332. var selectedRows = Array(grd.selectedRows);
  333. for(i=0;i<grd.selectedRows;i++) {
  334. selectedRows[i] = grd.selectedRow(i);
  335. }
  336. if (markonly != null && markonly == true) {
  337. for(i=selectedRows.length-1;i>=0;i--) {
  338. rowIdx = selectedRows[i];
  339. if(grd.rowstatus(rowIdx) == 1 ) {
  340. grd.deleterow(rowIdx,false);
  341. } else {
  342. grd.addStatus(rowIdx,"delete");
  343. }
  344. }
  345. } else {
  346. for(i=selectedRows.length-1;i>=0;i--) {
  347. rowIdx = selectedRows[i];
  348. grd.deleterow(rowIdx,false);
  349. }
  350. }
  351. }
  352. }
  353. function getGridUpdateData(gridObj, statusType) {
  354. var updataData = gridObj.getUpdateData(statusType);
  355. var rowsep = gridObj.attribute["rowsep"];
  356. var split = updataData.split(rowsep);
  357. if(split.length > 2){
  358. return updataData;
  359. }
  360. else
  361. return "";
  362. }
  363. function getImageSize(fileName) {
  364. var newCtrObj = null;
  365. if(document.controls.item("_image_forSize") == null) {
  366. newCtrObj = body.createChild("xforms:img", "id:_image_forSize; src:" + fileName + "; left:0px; top:0px; width:1px; height:1px;");
  367. newCtrObj.setVisible(false);
  368. }
  369. else{
  370. newCtrObj = document.controls.item("_image_forSize");
  371. newCtrObj.setSrc(fileName);
  372. }
  373. newCtrObj.setAttribute("width", null);
  374. newCtrObj.setAttribute("height", null);
  375. newCtrObj.setVisible(false);
  376. var imgW = newCtrObj.attribute["width"].replace("px", "");
  377. var imgH = newCtrObj.attribute["height"].replace("px", "");
  378. body.removeChild("_image_forSize");
  379. return imgW + "^" + imgH;
  380. }
  381. function getNodeListCSV(nodeList) {
  382. if( nodeList.length == 0 )
  383. return;
  384. var sColSep = "��";
  385. var sRowSep = "��";
  386. var rCSV = "";
  387. var childNodeList = nodeList.item(0).childNodes;
  388. var childNodeCnt = childNodeList.length;
  389. if( childNodeCnt == 0 )
  390. return;
  391. var i, j;
  392. for( i = 0; i < childNodeCnt - 1; i++) {
  393. rCSV += childNodeList.item(i).nodeName + sColSep;
  394. }
  395. rCSV += childNodeList.item(i).nodeName + sRowSep;
  396. var node;
  397. while( node = nodeList.nextNode() ) {
  398. childNodeList = node.childNodes;
  399. for( i = 0; i < childNodeCnt - 1; i++) {
  400. rCSV += childNodeList.item(i).text + sColSep;
  401. }
  402. rCSV += childNodeList.item(i).text + sRowSep;
  403. }
  404. return rCSV;
  405. }
  406. function getNodesetCount( nodeSet ) {
  407. var xPathFunction = "count(" + nodeSet + ")";
  408. return model.getXPathValue(xPathFunction);
  409. }
  410. function isDataCell() {
  411. var gridObj = m_event.ptarget.parent;
  412. if( gridObj.isCell(m_event.target) && gridObj.row >= gridObj.fixedRows && gridObj.col >= gridObj.fixedCols) {
  413. return true;
  414. }
  415. else
  416. return false;
  417. }
  418. function isRequiredControls() {
  419. var controlCnt = isRequiredControls.arguments.length;
  420. var controlID, captionID;
  421. var controlObj, captionObj;
  422. for(var i=0; i<controlCnt ;i++) {
  423. controlID = isRequiredControls.arguments[i];
  424. controlObj = document.controls.item(controlID);
  425. if(controlObj != null) {
  426. if(controlObj.value == "") {
  427. captionID = controlID.replace(controlID.substr(0, 3), "cap");
  428. captionObj = document.controls.item(captionID);
  429. if(captionObj != null) {
  430. var captionLabel = captionObj.label;
  431. if(captionLabel.indexOf(":") == captionLabel.length - 1) {
  432. captionLabel = captionLabel.substr(0, captionLabel.length - 1);
  433. }
  434. messageBox(captionLabel, "I003");
  435. }
  436. else
  437. messageBox("", "I003");
  438. model.setFocus(controlID);
  439. return false;
  440. }
  441. }
  442. }
  443. return true;
  444. }
  445. function isRequiredGroup(groupID){
  446. var groupObj = document.controls.item(groupID);
  447. var childID, captionID;
  448. var childObj, captionObj;
  449. for(var i=0; i<groupObj.children.length; i++) {
  450. childObj = groupObj.children.item(i)
  451. if(childObj.elementName == "xforms:input" || childObj.elementName == "xforms:secret" || childObj.elementName == "xforms:textarea" || childObj.elementName == "xforms:select" || childObj.elementName == "xforms:select1") {
  452. if(childObj.attribute["_required"] == "true") {
  453. if(childObj.value == "") {
  454. childID = childObj.attribute["id"];
  455. captionID = childID.replace(childID.substr(0, 3), "cap");
  456. captionObj = document.controls.item(captionID);
  457. if(captionObj != null) {
  458. var captionLabel = captionObj.label;
  459. if(captionLabel.indexOf(":") == captionLabel.length - 1) {
  460. captionLabel = captionLabel.substr(0, captionLabel.length - 1);
  461. }
  462. messageBox(captionLabel, "I003");
  463. }
  464. else
  465. messageBox("", "I003");
  466. model.setFocus(childID);
  467. return false;
  468. }
  469. }
  470. }
  471. }
  472. return true;
  473. }
  474. function isXPathTextNull(xPath) {
  475. var node = instance1.selectSingleNode(xPath);
  476. if( node != null ) {
  477. if( node.text == "" ) {
  478. return true;
  479. }
  480. else
  481. return false;
  482. }
  483. else
  484. return false;
  485. }
  486. function inputEnterKey( controlID, dispatchEvent, mask ) {
  487. if(m_event.keyCode == "13") {
  488. setInputNodeCurText(mask);
  489. var controlObj = document.controls.item(controlID);
  490. controlObj.dispatch(dispatchEvent);
  491. }
  492. }
  493. function openImageFileDialog(maxBytes) {
  494. var file = window.fileDialog("open","","false","","","All Files (*.*)|*.*|JPEG Files(*.jpg)|*.jpg|GIF Files(*.gif)|*.gif|BMP Files(*.bmp)|*.bmp");
  495. if (file != "" && maxBytes != null) {
  496. var fso = new ActiveXObject("Scripting.FileSystemObject");
  497. var f = fso.GetFile(file);
  498. if (f.size > maxBytes) {
  499. messageBox("���� ũ�Ⱑ �ִ�ġ("+(maxBytes/1024)+"K)��","E003");
  500. return "";
  501. }
  502. }
  503. return file;
  504. }
  505. function removeChildren( destNodePath, destModel ) {
  506. var modelObj;
  507. if( destModel == null ) {
  508. modelObj = model;
  509. }
  510. else
  511. modelObj = destModel;
  512. var node = modelObj.instance1.selectSingleNode(destNodePath);
  513. var childNodeList = node.childNodes;
  514. var childNode;
  515. while( childNode = childNodeList.nextNode() ) {
  516. node.removeChild( childNode );
  517. }
  518. }
  519. String.prototype.removeMask = removeMask;
  520. function removeMask( mask ) {
  521. var tmp_this = this;
  522. while( tmp_this.indexOf(mask) > -1 ) {
  523. tmp_this = tmp_this.replace(mask, "");
  524. }
  525. return tmp_this;
  526. }
  527. function setFormUpdate() {
  528. gvFormUpdateYN = true;
  529. }
  530. function setImageRefInstance(xpath) {
  531. var node = instance1.selectSingleNode(xpath);
  532. if( node == null )
  533. return;
  534. node.setattribute("type","xsd:base64Binary");
  535. }
  536. function setInputNodeCurText( mask ) {
  537. var inputID = m_event.target;
  538. var inputObj = document.controls.item(inputID);
  539. var inputRef = inputObj.attribute["ref"];
  540. if( mask == null )
  541. model.setValue(inputRef, inputObj.m_heControl.value);
  542. else
  543. model.setValue(inputRef, inputObj.m_heControl.value.removeMask(mask));
  544. inputObj.refresh();
  545. setFormUpdate();
  546. }
  547. function setCellStyle( gridID , styleFlag , data , colRef , control ) {
  548. var style = new Array("#fcd2c1" , "#ffe79d" , "#f3e1bf" , "#7BE6B7" , "#b9e5fb" , "#f7a08b" , "#fec34d" , "#dec6a4" , "#c8e67b" , "#43c8f5", "#99cf16", "#e5f3c2" );
  549. var styleFlags = styleFlag.split("^");
  550. var datas = data.split("^");
  551. if( control == null || control == "" )
  552. control = "equal";
  553. var controls = control.split("^");
  554. gridObj = document.allElement.item(gridID);
  555. gridObj.backcoloralternate = "transparent";
  556. for( var j = 0 ; j < datas.length ; j++ ) {
  557. var dataValue = datas[j];
  558. var styleValue = style[styleFlags[j]];
  559. for( var i = gridObj.fixedRows ; i < gridObj.Rows ; i++ ) {
  560. if(controls[j] == null)
  561. controls[j] = "equal";
  562. switch( controls[j] ) {
  563. case "small":
  564. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) < dataValue ) {
  565. gridObj.setCellStyle("background-color", i, gridObj.colRef(colRef), styleValue);
  566. }
  567. break;
  568. case "smallThen":
  569. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) <= dataValue ) {
  570. gridObj.setCellStyle("background-color", i, gridObj.colRef(colRef), styleValue);
  571. }
  572. break;
  573. case "bigger":
  574. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) > dataValue ) {
  575. gridObj.setCellStyle("background-color", i, gridObj.colRef(colRef), styleValue);
  576. }
  577. break;
  578. case "biggerThen":
  579. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) >= dataValue ) {
  580. gridObj.setCellStyle("background-color", i, gridObj.colRef(colRef), styleValue);
  581. }
  582. break;
  583. case "notEqual":
  584. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) != dataValue ) {
  585. gridObj.setCellStyle("background-color", i, gridObj.colRef(colRef), styleValue);
  586. }
  587. break;
  588. case "equal":
  589. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) == dataValue ) {
  590. gridObj.setCellStyle("background-color", i, gridObj.colRef(colRef), styleValue);
  591. }
  592. break;
  593. }
  594. }
  595. }
  596. }
  597. function setRowStyle( gridID , styleFlag , data , colRef , control ) {
  598. var style = new Array("#fcd2c1" , "#ffe79d" , "#f3e1bf" , "#7BE6B7" , "#b9e5fb" , "#f7a08b" , "#fec34d" , "#dec6a4" , "#c8e67b" , "#43c8f5", "#99cf16", "#e5f3c2" ,"#fd97b7", "#99ccff", "#ffff99", "#ccffcc");
  599. var styleFlags = styleFlag.split("^");
  600. var datas = data.split("^");
  601. if( control == null || control == "" )
  602. control = "equal";
  603. var controls = control.split("^");
  604. gridObj = document.allElement.item(gridID);
  605. gridObj.backcoloralternate = "transparent";
  606. for( var j = 0 ; j < datas.length ; j++ ) {
  607. var dataValue = datas[j];
  608. var styleValue = style[styleFlags[j]];
  609. for( var i = gridObj.fixedRows ; i < gridObj.Rows ; i++ ) {
  610. if(controls[j] == null)
  611. controls[j] = "equal";
  612. switch( controls[j] ) {
  613. case "small":
  614. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) < dataValue ) {
  615. gridObj.rowstyle( i , "data" , "background-color" ) = styleValue;
  616. }
  617. break;
  618. case "smallThen":
  619. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) <= dataValue ) {
  620. gridObj.rowstyle( i , "data" , "background-color" ) = styleValue;
  621. }
  622. break;
  623. case "bigger":
  624. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) > dataValue ) {
  625. gridObj.rowstyle( i , "data" , "background-color" ) = styleValue;
  626. }
  627. break;
  628. case "biggerThen":
  629. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) >= dataValue ) {
  630. gridObj.rowstyle( i , "data" , "background-color" ) = styleValue;
  631. }
  632. break;
  633. case "notEqual":
  634. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) != dataValue ) {
  635. gridObj.rowstyle( i , "data" , "background-color" ) = styleValue;
  636. }
  637. break;
  638. case "equal":
  639. if( gridObj.valueMatrix(i , gridObj.colRef(colRef)) == dataValue ) {
  640. gridObj.rowstyle( i , "data" , "background-color" ) = styleValue;
  641. }
  642. break;
  643. }
  644. }
  645. }
  646. }
  647. function initGridStyle(gridID){
  648. gridObj = document.allElement.item(gridID);
  649. gridObj.rebuildStyle();
  650. gridObj.backcoloralternate = "#f4f4f4";
  651. }
  652. function setTree( gridObj, levelcol, targetcol, collapsed, outlinebar ) {
  653. for(var i = gridObj.fixedRows; i < gridObj.rows; i++)
  654. {
  655. try {
  656. gridObj.outlinelevel(i)=gridObj.valuematrix(i, levelcol);
  657. } catch(e) {
  658. }
  659. }
  660. gridObj.outlinecol=targetcol;
  661. if (outlinebar == "" || outlinebar == null) {
  662. gridObj.outlinebar = 2;
  663. } else {
  664. gridObj.outlinebar=outlinebar;
  665. }
  666. gridObj.treecolor="#948777"
  667. if(collapsed != null) {
  668. setCollapsed(gridObj, collapsed);
  669. }
  670. }
  671. function setCollapsed( gridObj, collapsed ) {
  672. for(var i = gridObj.fixedrows; i <gridObj.rows; i++)
  673. {
  674. gridObj.iscollapsed(i)=collapsed;
  675. }
  676. }
  677. function sortNodeList( nodeset, trgRef, mode ) {
  678. var nodesetCnt = model.getXPathValue("count(" + nodeset + ")");
  679. if( nodesetCnt == 0 )
  680. return;
  681. var tmpValue_01, tmpValue_02;
  682. var tmpIndex;
  683. var i, j;
  684. for( i = 1; i <= nodesetCnt; i++ ) {
  685. tmpIndex = i;
  686. for( j = i + 1; j <= nodesetCnt; j++ ) {
  687. tmpValue_01 = model.getValue(nodeset + "[" + i + "]/" + trgRef);
  688. tmpValue_02 = model.getValue(nodeset + "[" + j + "]/" + trgRef);
  689. switch(mode) {
  690. case "desc":
  691. if( tmpValue_01 < tmpValue_02 ) {
  692. tmpIndex = j;
  693. }
  694. break;
  695. default :
  696. if( tmpValue_01 > tmpValue_02 ) {
  697. tmpIndex = j;
  698. }
  699. break;
  700. }
  701. if( i != tmpIndex ) {
  702. model.duplicate(instance1.selectSingleNode(nodeset).parentNode, nodeset + "[" + tmpIndex + "]", "*[" + i + "]");
  703. model.removenode(nodeset + "[" + ( tmpIndex + 1 ) + "]");
  704. tmpIndex = i;
  705. }
  706. }
  707. }
  708. }
  709. var gvFormUpdateYN = false;
  710. function onaftersort() {
  711. var gridObj = document.controls.item(m_event.target);
  712. var gridSelMode = gridObj.selectionMode;
  713. var smallistNum, tempNum;
  714. var i;
  715. if( gridSelMode != "free" && gridSelMode != "bycol" ) {
  716. gridObj.topRow = gridObj.selectedRow(0);
  717. }
  718. else {
  719. if(gridObj.selectedCells.length > 0) {
  720. gridObj.topRow = gridObj.selectedCells.item(0).row;
  721. }
  722. }
  723. }
  724. function onkeypress(){
  725. var ctrlObj = m_event.ptarget;
  726. var pGridObj = ctrlObj.parent;
  727. if(pGridObj.elementName == "xforms:multilinegrid" || pGridObj.elementName == "xforms:row")
  728. return;
  729. if(ctrlObj.elementName == "xforms:input") {
  730. input_onkeypress(ctrlObj);
  731. }
  732. else if(ctrlObj.elementName == "xforms:col") {
  733. if(pGridObj.colAttribute(pGridObj.col, "type") == "input" || pGridObj.colAttribute(pGridObj.col, "type") == "inputbutton")
  734. grid_onkeypress(m_event.ptarget);
  735. }
  736. else if(ctrlObj.elementName == "xforms:gridinput") {
  737. grid_onkeypress(m_event.ptarget);
  738. }
  739. }
  740. function grid_onkeypress(ctrlObj) {
  741. var pObj = ctrlObj.parent;
  742. var charType = pObj.colAttribute (pObj.col, "_chartype");
  743. if( charType == "upper") {
  744. if(m_event.keyCode >= 97 && m_event.keyCode <= 122) {
  745. m_event.keyCode = m_event.keyCode - 32;
  746. }
  747. }
  748. else if( charType == "lower" ) {
  749. if(m_event.keyCode >= 65 && m_event.keyCode <= 90) {
  750. m_event.keyCode = m_event.keyCode + 32;
  751. }
  752. }
  753. var inputMode = pObj.colAttribute (pObj.col, "_inputmode");
  754. if( inputMode == "koreanOnly" ) {
  755. var pattern = new RegExp('[a-zA-Z]', 'i');
  756. if (pattern.exec(String.fromCharCode(m_event.keyCode)) != null){
  757. m_event.preventDefault();
  758. }
  759. }
  760. }
  761. function input_onkeypress(ctrlObj) {
  762. if( ctrlObj.attribute["_chartype"] == "upper") {
  763. if(m_event.keyCode >= 97 && m_event.keyCode <= 122) {
  764. m_event.keyCode = m_event.keyCode - 32;
  765. }
  766. }
  767. else if( ctrlObj.attribute["_chartype"] == "lower" ) {
  768. if(m_event.keyCode >= 65 && m_event.keyCode <= 90) {
  769. m_event.keyCode = m_event.keyCode + 32;
  770. }
  771. }
  772. if( ctrlObj.attribute["_inputmode"] == "koreanOnly" ) {
  773. var pattern = new RegExp('[a-zA-Z]', 'i');
  774. if (pattern.exec(String.fromCharCode(m_event.keyCode)) != null){
  775. m_event.preventDefault();
  776. }
  777. }
  778. }
  779. function grid_oncopy(type) {
  780. if (type == null || type == "") type = "value";
  781. var trgObj = document.allElement.item(m_event.target);
  782. if( trgObj.elementName == "xforms:datagrid" )
  783. gridObj = trgObj;
  784. else
  785. return;
  786. var cellValue;
  787. var rClipBoardValue = "";
  788. var gridSelMode = gridObj.selectionMode;
  789. if( gridSelMode == "free" ) {
  790. if( gridObj.selectedCells.length == 0 )
  791. return;
  792. var firstCell = getFirstCell(gridObj.selectedCells);
  793. var lastCell = getLastCell(gridObj.selectedCells);
  794. var i, j;
  795. if (type == "value") {
  796. for( i = firstCell.row; i <= lastCell.row; i++ ) {
  797. for ( j = firstCell.col; j <= lastCell.col; j++ ) {
  798. cellValue = gridObj.valueMatrix(i, j);
  799. if( cellValue.indexOf("\n") != -1 )
  800. cellValue = '"' + cellValue + '"';
  801. rClipBoardValue += cellValue;
  802. if( j != lastCell.col )
  803. rClipBoardValue += "\t";
  804. }
  805. rClipBoardValue += "\r\n";
  806. }
  807. } else if (type == "label") {
  808. for( i = firstCell.row; i <= lastCell.row; i++ ) {
  809. for ( j = firstCell.col; j <= lastCell.col; j++ ) {
  810. cellValue = gridObj.labelMatrix(i, j);
  811. if( cellValue.indexOf("\n") != -1 )
  812. cellValue = '"' + cellValue + '"';
  813. rClipBoardValue += cellValue;
  814. if( j != lastCell.col )
  815. rClipBoardValue += "\t";
  816. }
  817. rClipBoardValue += "\r\n";
  818. }
  819. }
  820. var setClipBoardFlag = true;
  821. var cntRClip = 0;
  822. var cntRRow = rClipBoardValue.split("\r\n").length;
  823. var cntRCol = rClipBoardValue.split("\r\n")[0].split("\t").length;
  824. if( gridObj.selectedCells.length != ( cntRRow - 1 ) * cntRCol ) {
  825. setClipBoardFlag = false;
  826. }
  827. for( i = 0; i < gridObj.selectedCells.length; i++ ) {
  828. if( firstCell.row > gridObj.selectedCells.item(i).row || lastCell.row < gridObj.selectedCells.item(i).row ) {
  829. setClipBoardFlag = false;
  830. break;
  831. }
  832. if( firstCell.col > gridObj.selectedCells.item(i).col || lastCell.col < gridObj.selectedCells.item(i).col ) {
  833. setClipBoardFlag = false;
  834. break;
  835. }
  836. }
  837. if( !setClipBoardFlag ) {
  838. messageBox("���� ���� ����������", "E001");
  839. return;
  840. }
  841. }
  842. else if( gridSelMode == "bycol" ) {
  843. if( gridObj.selectedCells.length == 0 )
  844. return;
  845. var firstCell = getFirstCell(gridObj.selectedCells);
  846. var lastCell = getLastCell(gridObj.selectedCells);
  847. var i, j;
  848. if (type == "value") {
  849. for( i = gridObj.fixedRows; i < gridObj.rows; i++ ) {
  850. for ( j = firstCell.col; j <= lastCell.col; j++ ) {
  851. cellValue = gridObj.valueMatrix(i, j);
  852. if( cellValue.indexOf("\n") != -1 )
  853. cellValue = '"' + cellValue + '"';
  854. rClipBoardValue += cellValue;
  855. if( j != lastCell.col )
  856. rClipBoardValue += "\t";
  857. }
  858. rClipBoardValue += "\r\n";
  859. }
  860. } else if (type == "label") {
  861. for( i = gridObj.fixedRows; i < gridObj.rows; i++ ) {
  862. for ( j = firstCell.col; j <= lastCell.col; j++ ) {
  863. cellValue = gridObj.labelMatrix(i, j);
  864. if( cellValue.indexOf("\n") != -1 )
  865. cellValue = '"' + cellValue + '"';
  866. rClipBoardValue += cellValue;
  867. if( j != lastCell.col )
  868. rClipBoardValue += "\t";
  869. }
  870. rClipBoardValue += "\r\n";
  871. }
  872. }
  873. }
  874. else {
  875. var gridCols = gridObj.Cols;
  876. var selRow;
  877. var i, j;
  878. if (type == "value") {
  879. for( i = 0; i < gridObj.selectedRows; i++ ) {
  880. selRow = gridObj.selectedRow(i);
  881. for ( j = gridObj.fixedCols; j < gridCols; j++ ) {
  882. cellValue = gridObj.valueMatrix(selRow, j);
  883. if( cellValue.indexOf("\n") != -1 )
  884. cellValue = '"' + cellValue + '"';
  885. rClipBoardValue += cellValue;
  886. if( j != gridCols - 1 )
  887. rClipBoardValue += "\t";
  888. }
  889. rClipBoardValue += "\r\n";
  890. }
  891. } else if (type == "label") {
  892. for( i = 0; i < gridObj.selectedRows; i++ ) {
  893. selRow = gridObj.selectedRow(i);
  894. for ( j = gridObj.fixedCols; j < gridCols; j++ ) {
  895. cellValue = gridObj.labelMatrix(selRow, j);
  896. if( cellValue.indexOf("\n") != -1 )
  897. cellValue = '"' + cellValue + '"';
  898. rClipBoardValue += cellValue;
  899. if( j != gridCols - 1 )
  900. rClipBoardValue += "\t";
  901. }
  902. rClipBoardValue += "\r\n";
  903. }
  904. }
  905. }
  906. if( rClipBoardValue != "" )
  907. window.setClipBoardData(rClipBoardValue);
  908. }
  909. function getFirstCell( cellCollection ) {
  910. var cntCell = cellCollection.length;
  911. if( cntCell == 0 )
  912. return null;
  913. var curCell = null;
  914. var tmpCell = cellCollection.item(0);
  915. for( var i = 0; i < cntCell; i++ ) {
  916. curCell = cellCollection.item(i);
  917. if( curCell.row <= tmpCell.row ) {
  918. if( curCell.col <= tmpCell.col ) {
  919. tmpCell = curCell;
  920. }
  921. }
  922. }
  923. return tmpCell;
  924. }
  925. function getLastCell( cellCollection ) {
  926. var cntCell = cellCollection.length;
  927. if( cntCell == 0 )
  928. return null;
  929. var curCell = null;
  930. var tmpCell = cellCollection.item(0);
  931. for( var i = 0; i < cntCell; i++ ) {
  932. curCell = cellCollection.item(i);
  933. if( curCell.row >= tmpCell.row ) {
  934. if( curCell.col >= tmpCell.col ) {
  935. tmpCell = curCell;
  936. }
  937. }
  938. }
  939. return tmpCell;
  940. }
  941. function initPopupMenu() {
  942. window.setPopupMenu(false);
  943. }
  944. function setPopupMenu(ctrlID, onmenuEvent, itemNodeset, label, value) {
  945. if(m_event.button == 3) {
  946. if( itemNodeset == null )
  947. itemNodeset = "/root/hidden/popupmenu/item";
  948. if( label == null )
  949. itemNodeset = "name";
  950. if( value == null )
  951. value = "func";
  952. var ctrlObj = document.controls.item(ctrlID);
  953. if( ctrlObj.elementName == "xforms:datagrid" ) {
  954. if( ctrlObj.isCell(m_event.target) && ctrlObj.mouseRow >= ctrlObj.fixedrows ){
  955. window.showPopupMenu(true);
  956. window.setPopupMenu(true, itemNodeset, label, value, onmenuEvent);
  957. }else{
  958. initPopupMenu();
  959. }
  960. }else if( ctrlObj.elementName == "xforms:treeview" ) {
  961. if( ctrlObj.isCell(m_event.target) ){
  962. window.showPopupMenu(true);
  963. window.setPopupMenu(true, itemNodeset, label, value, onmenuEvent);
  964. }else{
  965. initPopupMenu();
  966. }
  967. }else {
  968. window.showPopupMenu(true);
  969. window.setPopupMenu(true, itemNodeset, label, value, onmenuEvent);
  970. }
  971. }
  972. }
  973. function onstartedit(){
  974. var ctrlObj = m_event.ptarget;
  975. if(ctrlObj.elementName == "xforms:datagrid") {
  976. grid_onstartedit(ctrlObj);
  977. }
  978. }
  979. function grid_onstartedit(ctrlObj)
  980. {
  981. var colIndex = ctrlObj.col;
  982. var _keyValue = ctrlObj.colAttribute(colIndex, "_key");
  983. if(_keyValue == "true")
  984. {
  985. if( ctrlObj.rowStatus( ctrlObj.row ) != 3 && ctrlObj.rowStatus( ctrlObj.row ) != 1)
  986. {
  987. m_event.preventDefault();
  988. return;
  989. }
  990. }
  991. }
  992. function xforms_submit_done() {
  993. if( document.allElement.item(m_event.currentTarget).elementName == "xforms:model" ) {
  994. m_event.stopPropagation();
  995. return;
  996. }
  997. gvFormUpdateYN = false;
  998. }
  999. function xforms_value_changed() {
  1000. if( m_event.currentTarget == "document") {
  1001. m_event.stopPropagation();
  1002. return;
  1003. }
  1004. setFormUpdate();
  1005. }