CSZ001.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116
  1. var condesNode = "/root/codes";
  2. var indent = 20;
  3. var tabWidth = 780;
  4. // node set 생성
  5. function makeNodeSet(parentNode, codes) {
  6. for(var i = 0; i < codes.length; i++) {
  7. var itemNode = parentNode + "/item[" + (i + 1) + "]";
  8. model.makeValue(itemNode + "/label", codes[i].value + ") " + codes[i].label);
  9. model.makeValue(itemNode + "/value", codes[i].value);
  10. }
  11. } // end function
  12. // item set 생성
  13. function makeItemset(control, nodeSetXPath) {
  14. var choices = control.createChild("xforms:choices", "");
  15. var itemset = choices.createChild("xforms:itemset", "nodeset:" + nodeSetXPath + "/item");
  16. itemset.createChild("xforms:label", "ref:label");
  17. itemset.createChild("xforms:value", "ref:value ");
  18. }
  19. // node set data 추출
  20. function retriveNodeSet(ctrlInfos) {
  21. var nodeSet = new Array();
  22. for (var i = 0; i < ctrlInfos.length; i++) {
  23. nodeSet[i] = {"label":ctrlInfos[i].qestitemanswcnts , "value":ctrlInfos[i].answseqno};
  24. }
  25. return nodeSet;
  26. }
  27. // 라디오 버튼 생성
  28. function makeRadio(prnt, id, ref, parentNode, nodeSet, cols, left, top, width, height) {
  29. var attributes = "";
  30. // alert("id = " + id +"\n ref = " + ref +"\n rows = " + cols +"\n left = " + left + "\n top = " + top +"\n width = " + width +"\n height = " + height);
  31. if(id != undefined && id != "" ) {
  32. attributes = attributes + "id:" + id + "; ";
  33. } else {
  34. alert("id는 필수 입니다.");
  35. return;
  36. }
  37. if(ref != undefined && ref != "" ) {
  38. attributes = attributes + "ref:" + ref + "; ";
  39. } else {
  40. alert(" ref 는 필수 입니다.");
  41. return;
  42. }
  43. // ndoeSet 생성
  44. var nodeSetXPath = parentNode +("/radioNodeSet" + id);
  45. var length = 0;
  46. if(nodeSet != undefined && nodeSet != "" && nodeSet.length > 1 ) {
  47. makeNodeSet(nodeSetXPath, nodeSet);
  48. length = nodeSet.length;
  49. }
  50. if(left != undefined && left != "" ) {
  51. attributes = attributes + "left:" + left + "; ";
  52. } else {
  53. attributes = attributes + "left:0; ";
  54. }
  55. if(top != undefined && top != "" ) {
  56. attributes = attributes + "top:" + top + "; ";
  57. } else {
  58. attributes = attributes + "top:0; ";
  59. }
  60. // 컬럼수
  61. var tmpCols = 1;
  62. if(cols != undefined && cols != "" && cols != 0) {
  63. tmpCols = cols;
  64. }
  65. // 넓이
  66. var tmWidth = 300;
  67. if(width != undefined && width != "" ) {
  68. tmWidth = width;
  69. }
  70. attributes = attributes + "cols:" + tmpCols + "; ";
  71. attributes = attributes + "width:" + (tmWidth * tmpCols) + "; ";
  72. // 행수 기본 1
  73. var tmpRows = 1;
  74. if(length > 0) {
  75. tmpRows = Math.floor((length / tmpCols)) + ( (length % tmpCols) == 0 ? 0 : 1);
  76. }
  77. // 높이
  78. var tmpHeight = 20;
  79. if(height != undefined && height != "" ) {
  80. tmpHeight = height;
  81. }
  82. attributes = attributes + "rows:" + tmpRows + "; ";
  83. attributes = attributes + "height:" + ((tmpHeight * tmpRows) - ( 2 * (tmpRows - 1))) + "; ";
  84. // 기본 스타일
  85. // attributes = attributes + " border-style:solid; ";
  86. attributes = attributes + "appearance:full; overflow:visible; border-style:none; ";
  87. var radio = prnt.createChild("xforms:select1", attributes);
  88. makeItemset(radio, nodeSetXPath);
  89. // radio.refresh();
  90. return radio;
  91. }
  92. // 라디오 버튼 생성
  93. function makeRadioSingleItem(prnt, id, ref, parentNode, item, cols, left, top, width, height) {
  94. var attributes = "";
  95. // alert("id = " + id +"\n ref = " + ref +"\n rows = " + cols +"\n left = " + left + "\n top = " + top +"\n width = " + width +"\n height = " + height);
  96. if(id != undefined && id != "" ) {
  97. attributes = attributes + "id:" + id + "; ";
  98. } else {
  99. alert("id는 필수 입니다.");
  100. return;
  101. }
  102. if(ref != undefined && ref != "" ) {
  103. attributes = attributes + "ref:" + ref + "; ";
  104. } else {
  105. alert(" ref 는 필수 입니다.");
  106. return;
  107. }
  108. if(left != undefined && left != "" ) {
  109. attributes = attributes + "left:" + left + "; ";
  110. } else {
  111. attributes = attributes + "left:0; ";
  112. }
  113. if(top != undefined && top != "" ) {
  114. attributes = attributes + "top:" + top + "; ";
  115. } else {
  116. attributes = attributes + "top:0; ";
  117. }
  118. // 컬럼수
  119. var tmpCols = 1;
  120. if(cols != undefined && cols != "" && cols != 0) {
  121. tmpCols = cols;
  122. }
  123. // 넓이
  124. var tmWidth = 300;
  125. if(width != undefined && width != "" ) {
  126. tmWidth = width;
  127. }
  128. attributes = attributes + "cols:" + tmpCols + "; ";
  129. attributes = attributes + "width:" + (tmWidth * tmpCols) + "; ";
  130. // 행수 기본 1
  131. var tmpRows = 1;
  132. // 높이
  133. var tmpHeight = 32;
  134. if(height != undefined && height != "" ) {
  135. tmpHeight = height;
  136. }
  137. attributes = attributes + "rows:" + tmpRows + "; ";
  138. attributes = attributes + "height:" + ((tmpHeight * tmpRows) - ( 2 * (tmpRows - 1))) + "; ";
  139. // 기본 스타일
  140. // attributes = attributes + " border-style:solid; ";
  141. attributes = attributes + "appearance:full; overflow:visible; border-style:none; ";
  142. var radio = prnt.createChild("xforms:select1", attributes);
  143. var choices = radio.createChild("xforms:choices", "");
  144. var Itemset = choices.createChild("xforms:item", "");
  145. Itemset.createChild("xforms:label", "text:" + item.label);
  146. Itemset.createChild("xforms:value", "text:" + item.value);
  147. radio.refresh();
  148. return radio;
  149. }
  150. //10점척도 Radio
  151. function makeRadioSingleItem10(prnt, id, ref, parentNode, item, cols, left, top, width, height) {
  152. var attributes = "";
  153. // alert("id = " + id +"\n ref = " + ref +"\n rows = " + cols +"\n left = " + left + "\n top = " + top +"\n width = " + width +"\n height = " + height);
  154. if(id != undefined && id != "" ) {
  155. attributes = attributes + "id:" + id + "; ";
  156. } else {
  157. alert("id는 필수 입니다.");
  158. return;
  159. }
  160. if(ref != undefined && ref != "" ) {
  161. attributes = attributes + "ref:" + ref + "; ";
  162. } else {
  163. alert(" ref 는 필수 입니다.");
  164. return;
  165. }
  166. if(left != undefined && left != "" ) {
  167. attributes = attributes + "left:" + left + "; ";
  168. } else {
  169. attributes = attributes + "left:0; ";
  170. }
  171. if(top != undefined && top != "" ) {
  172. attributes = attributes + "top:" + top + "; ";
  173. } else {
  174. attributes = attributes + "top:0; ";
  175. }
  176. // 컬럼수
  177. var tmpCols = 1;
  178. if(cols != undefined && cols != "" && cols != 0) {
  179. tmpCols = cols;
  180. }
  181. // 넓이
  182. var tmWidth = 30;
  183. if(width != undefined && width != "" ) {
  184. tmWidth = width;
  185. }
  186. attributes = attributes + "cols:" + tmpCols + "; ";
  187. attributes = attributes + "width:" + (tmWidth * tmpCols) + "; ";
  188. // 행수 기본 1
  189. var tmpRows = 1;
  190. // 높이
  191. var tmpHeight = 32;
  192. if(height != undefined && height != "" ) {
  193. tmpHeight = height;
  194. }
  195. attributes = attributes + "rows:" + tmpRows + "; ";
  196. attributes = attributes + "height:" + ((tmpHeight * tmpRows) - ( 2 * (tmpRows - 1))) + "; ";
  197. // 기본 스타일
  198. // attributes = attributes + " border-style:solid; ";
  199. attributes = attributes + "appearance:full; overflow:visible; border-style:none; ";
  200. var radio = prnt.createChild("xforms:select1", attributes);
  201. var choices = radio.createChild("xforms:choices", "");
  202. var Itemset = choices.createChild("xforms:item", "");
  203. Itemset.createChild("xforms:label", "text:" + item.label);
  204. Itemset.createChild("xforms:value", "text:" + item.value);
  205. radio.refresh();
  206. return radio;
  207. }
  208. // 체크 박스 생성
  209. function makeCheckbox(prnt, id, ref, parentNode, nodeSet, cols, left, top, width, height) {
  210. var attributes = "";
  211. // alert("id = " + id +"\n ref = " + ref +"\n rows = " + rows + "\n cols = " + cols +"\n left = " + left + "\n top = " + top +"\n width = " + width +"\n height = " + height);
  212. if(id != undefined && id != "" ) {
  213. attributes = attributes + "id:" + id + "; ";
  214. } else {
  215. alert("id는 필수 입니다.");
  216. return;
  217. }
  218. if(ref != undefined && ref != "" ) {
  219. attributes = attributes + "ref:" + ref + "; ";
  220. } else {
  221. alert(" ref 는 필수 입니다.");
  222. return;
  223. }
  224. // ndoeSet 생성
  225. var nodeSetXPath = parentNode +("/checkBoxNodeSet" + id);
  226. var length = 0;
  227. if(nodeSet != undefined && nodeSet != "" && nodeSet.length > 0 ) {
  228. makeNodeSet(nodeSetXPath, nodeSet);
  229. length = nodeSet.length;
  230. } // end if
  231. if(left != undefined && left != "" ) {
  232. attributes = attributes + "left:" + left + "; ";
  233. } else {
  234. attributes = attributes + "left:0; ";
  235. }
  236. if(top != undefined && top != "" ) {
  237. attributes = attributes + "top:" + top + "; ";
  238. } else {
  239. attributes = attributes + "top:0; ";
  240. }
  241. // 컬럼수
  242. var tmpCols = 1;
  243. if(cols != undefined && cols != "" && cols != 0) {
  244. tmpCols = cols;
  245. }
  246. // 넓이
  247. var tmWidth = 300;
  248. if(width != undefined && width != "" ) {
  249. tmWidth = width;
  250. }
  251. attributes = attributes + "cols:" + tmpCols + "; ";
  252. attributes = attributes + "width:" + (tmWidth * tmpCols) + "; ";
  253. // 행수 기본 1
  254. var tmpRows = 1;
  255. if(length > 0) {
  256. tmpRows = Math.floor((length / tmpCols)) + ( (length % tmpCols) == 0 ? 0 : 1);
  257. }
  258. // 높이
  259. var tmpHeight = 20;
  260. if(height != undefined && height != "" ) {
  261. tmpHeight = height;
  262. } // end if
  263. attributes = attributes + "rows:" + tmpRows + "; ";
  264. attributes = attributes + "height:" + ((tmpHeight * tmpRows) - (2 * (tmpRows - 1))) + "; ";
  265. // 기본 스타일
  266. // attributes = attributes + " border-style:solid; ";
  267. attributes = attributes + "appearance:full; sep:,; overflow:visible; border-style:none; ";
  268. var checkbox = prnt.createChild("xforms:select", attributes);
  269. makeItemset(checkbox, nodeSetXPath);
  270. //checkbox.refresh();
  271. return checkbox;
  272. }
  273. // 콤보박스 생성
  274. function makeCombo(prnt, id, ref, parentNode, nodeSet, cols, left, top, width, height) {
  275. var attributes = "";
  276. // alert("id = " + id +"\n ref = " + ref +"\n rows = " + rows + "\n cols = " + cols +"\n left = " + left + "\n top = " + top +"\n width = " + width +"\n height = " + height);
  277. if(id != undefined && id != "" ) {
  278. attributes = attributes + "id:" + id + "; ";
  279. } else {
  280. alert("id는 필수 입니다.");
  281. return;
  282. }
  283. if(ref != undefined && ref != "" ) {
  284. attributes = attributes + "ref:" + ref + "; ";
  285. } else {
  286. alert(" ref 는 필수 입니다.");
  287. return;
  288. }
  289. if(left != undefined && left != "" ) {
  290. attributes = attributes + "left:" + left + "; ";
  291. } else {
  292. attributes = attributes + "left:0; ";
  293. }
  294. if(top != undefined && top != "" ) {
  295. attributes = attributes + "top:" + top + "; ";
  296. } else {
  297. attributes = attributes + "top:0; ";
  298. }
  299. // 컬럼수
  300. var tmpCols = 1;
  301. if(cols != undefined && cols != "" && cols != 0) {
  302. tmpCols = cols;
  303. }
  304. // 넓이
  305. var tmWidth = 100;
  306. if(width != undefined && width != "" ) {
  307. tmWidth = width;
  308. }
  309. attributes = attributes + "cols:" + tmpCols + "; ";
  310. attributes = attributes + "width:" + (tmWidth * tmpCols) + "; ";
  311. // 높이
  312. var tmpHeight = 20;
  313. if(height != undefined && height != "" ) {
  314. tmpHeight = height;
  315. }
  316. attributes = attributes + "height:" + tmpHeight + "; ";
  317. // 기본 스타일
  318. attributes = attributes + "appearance:minimal; ";
  319. // ndoeSet 생성
  320. var nodeSetXPath = parentNode +("/comboNodeSet" + id);
  321. if(nodeSet != undefined && nodeSet != "" && nodeSet.length > 0 ) {
  322. makeNodeSet(nodeSetXPath, nodeSet);
  323. }
  324. var combo = prnt.createChild("xforms:select1", attributes);
  325. makeItemset(combo, nodeSetXPath);
  326. //combo.refresh();
  327. return combo;
  328. }
  329. // Input 생성
  330. function makeInput(prnt, id, ref, left, top, width, height) {
  331. var attributes = "";
  332. // alert("id = " + id +"\n ref = " + ref +"\n left = " + left + "\n top = " + top +"\n width = " + width +"\n height = " + height);
  333. if(id != undefined && id != "" ) {
  334. attributes = attributes + "id:" + id + "; ";
  335. } else {
  336. alert("id는 필수 입니다.");
  337. return;
  338. }
  339. if(ref != undefined && ref != "" ) {
  340. attributes = attributes + "ref:" + ref + "; ";
  341. } else {
  342. alert(" ref 는 필수 입니다.");
  343. return;
  344. }
  345. if(left != undefined && left != "" ) {
  346. attributes = attributes + "left:" + left + "; ";
  347. } else {
  348. attributes = attributes + "left:0; ";
  349. }
  350. if(top != undefined && top != "" ) {
  351. attributes = attributes + "top:" + top + "; ";
  352. } else {
  353. attributes = attributes + "top:0; ";
  354. }
  355. // 넓이
  356. var tmWidth = 400;
  357. if(width != undefined && width != "" ) {
  358. tmWidth = width;
  359. }
  360. attributes = attributes + "width:" + tmWidth + "; ";
  361. // 높이
  362. var tmpHeight = 20;
  363. if(height != undefined && height != "" ) {
  364. tmpHeight = height;
  365. } // end if
  366. attributes = attributes + "height:" + tmpHeight + "; ";
  367. var input = prnt.createChild("xforms:input", attributes);
  368. //input.refresh();
  369. return input;
  370. }
  371. // Textarea 생성
  372. function makeTextarea(prnt, id, ref, left, top, width, height) {
  373. var attributes = "";
  374. // alert("id = " + id +"\n ref = " + ref +"\n left = " + left + "\n top = " + top +"\n width = " + width +"\n height = " + height);
  375. if(id != undefined && id != "" ) {
  376. attributes = attributes + "id:" + id + "; ";
  377. } else {
  378. alert("id는 필수 입니다.");
  379. return;
  380. }
  381. if(ref != undefined && ref != "" ) {
  382. attributes = attributes + "ref:" + ref + "; ";
  383. } else {
  384. alert(" ref 는 필수 입니다.");
  385. return;
  386. }
  387. if(left != undefined && left != "" ) {
  388. attributes = attributes + "left:" + left + "; ";
  389. } else {
  390. attributes = attributes + "left:0; ";
  391. }
  392. if(top != undefined && top != "" ) {
  393. attributes = attributes + "top:" + top + "; ";
  394. } else {
  395. attributes = attributes + "top:0; ";
  396. }
  397. // 넓이
  398. var tmWidth = 600;
  399. if(width != undefined && width != "" ) {
  400. tmWidth = width;
  401. }
  402. attributes = attributes + "width:" + tmWidth + "; ";
  403. // 높이
  404. var tmpHeight = 60;
  405. if(height != undefined && height != "" ) {
  406. tmpHeight = height;
  407. } // end if
  408. attributes = attributes + "height:" + tmpHeight + "; ";
  409. attributes = attributes + "scroll:auto; ";
  410. var textarea = prnt.createChild("xforms:textarea", attributes);
  411. //textarea.refresh();
  412. return textarea;
  413. }
  414. // 출력 필요한 넓이 구하기
  415. var korCharWidth = 13; // 한글 자평
  416. var engCharWidth = 7; // 영어 자평
  417. var spaceCharWidth = 4; // 공백 자평
  418. function getNeedWidth(value) {
  419. var needWidth = 0;
  420. for (var i = 0; i < value.length; i++) {
  421. if(value.charCodeAt(i) > 255) {
  422. needWidth += korCharWidth;
  423. } else if(value.charCodeAt(i) == 32) {
  424. needWidth += spaceCharWidth;
  425. } else {
  426. needWidth += engCharWidth;
  427. } // end if
  428. } // end for
  429. return needWidth;
  430. }
  431. // Output 생성
  432. function makeOutput(prnt, value, left, top, width, height) {
  433. var attributes = "";
  434. // alert("id = " + id +"\n ref = " + ref +"\n left = " + left + "\n top = " + top +"\n width = " + width +"\n height = " + height);
  435. if(left != undefined && left != "" ) {
  436. attributes = attributes + "left:" + left + "; ";
  437. } else {
  438. attributes = attributes + "left:0; ";
  439. }
  440. if(top != undefined && top != "" ) {
  441. attributes = attributes + "top:" + top + "; ";
  442. } else {
  443. attributes = attributes + "top:0; ";
  444. }
  445. // 넓이
  446. var tmWidth = tabWidth;
  447. if(width != undefined && width != "" ) {
  448. tmWidth = width;
  449. }
  450. attributes = attributes + "width:" + tmWidth + "; ";
  451. attributes = attributes + "word-wrap:word; ";
  452. var needWidth = getNeedWidth(value);
  453. var rows = Math.floor(needWidth / tmWidth);
  454. //var rows = Math.ceil(needWidth / tmWidth);
  455. //alert(value + "\n" + rows + "\n" + needWidth);
  456. // 높이
  457. var tmpHeight = 20;
  458. if(height != undefined && height != "" ) {
  459. tmpHeight = height;
  460. } // end if
  461. //attributes = attributes + "height:" + (20 + (14 * rows)) + "; ";
  462. attributes = attributes + "height:" + (tmpHeight + (14 * rows)) + "; ";
  463. attributes = attributes + "class:output_free; "; //높이 조정이 안되어서
  464. var output = prnt.createChild("xforms:output", attributes);
  465. output.value = value;
  466. //output.refresh();
  467. return output;
  468. }
  469. // Button 생성
  470. function makeButton(prnt, value, left, top, width, height) {
  471. var attributes = "";
  472. // alert("id = " + id +"\n ref = " + ref +"\n left = " + left + "\n top = " + top +"\n width = " + width +"\n height = " + height);
  473. if(left != undefined && left != "" ) {
  474. attributes = attributes + "left:" + left + "; ";
  475. } else {
  476. attributes = attributes + "left:0; ";
  477. }
  478. if(top != undefined && top != "" ) {
  479. attributes = attributes + "top:" + top + "; ";
  480. } else {
  481. attributes = attributes + "top:0; ";
  482. }
  483. var needWidth = getNeedWidth(value) + 16; // 좌우 공백과 초기 이미지
  484. // 넓이
  485. var tmWidth = 100;
  486. if(width != undefined && width != "" ) {
  487. tmWidth = width;
  488. }
  489. // attributes = attributes + "width:" + tmWidth + "; ";
  490. // attributes = attributes + "word-wrap:word; ";
  491. attributes = attributes + "width:" + needWidth + "; ";
  492. // alert(value + "\n" + rows + "\n" + needWidth);
  493. // 높이
  494. var tmpHeight = 20;
  495. if(height != undefined && height != "" ) {
  496. tmpHeight = height;
  497. } // end if
  498. //var rows = Math.floor(needWidth / tmWidth);
  499. //attributes = attributes + "height:" + (20 + (14 * rows)) + "; ";
  500. attributes = attributes + "height:" + tmpHeight + "; ";
  501. attributes = attributes + "class:btn_sw; ";
  502. var button = prnt.createChild("xforms:button", attributes);
  503. button.value = value;
  504. //button.refresh();
  505. return button;
  506. }
  507. var nodeColumnNames = new Array("qpaprseqno", "qestitemgrupseqno", "qestseqno", "qpaprsortseq", "itemkindcd",
  508. "qestanswno", "qestmltlanswno", "divpnt", "descinptcnts", "descinptaddcnts",
  509. "qestrspsyn", "norpaddyn");
  510. // 데이타를 저장할 노드 생성
  511. function makeDataNode(ref, ctrlInfos) {
  512. var ctrlInfo = ctrlInfos[ctrlInfos.length - 1];
  513. var rowRef = ref + "/row" + ctrlInfo.qpaprsortseq;
  514. //ctrlInfo.qestseqno;
  515. model.makeNode(rowRef);
  516. for(var i = 0; i < nodeColumnNames.length; i ++) {
  517. var colName = nodeColumnNames[i];
  518. var colRef = rowRef + "/" + colName;
  519. if (colName == "qestanswno"){
  520. model.makeValue(colRef, "");
  521. } else if (colName == "qestmltlanswno"){
  522. model.makeValue(colRef, "");
  523. } else if (colName == "divpnt"){
  524. model.makeValue(colRef, "");
  525. } else {
  526. model.makeValue(colRef, ctrlInfo[colName]);
  527. }
  528. }
  529. return rowRef;
  530. }
  531. // group 생성
  532. function makeGroup(prnt, left, top, width, height) {
  533. var attributes = "";
  534. if(left != undefined && left != "" ) {
  535. attributes = attributes + "left:" + left + "; ";
  536. } else {
  537. attributes = attributes + "left:0; ";
  538. }
  539. if(top != undefined && top != "" ) {
  540. attributes = attributes + "top:" + top + "; ";
  541. } else {
  542. attributes = attributes + "top:0; ";
  543. }
  544. if(width != undefined && width != "" ) {
  545. attributes = attributes + "width:" + width + "; ";
  546. }
  547. if(height != undefined && height != "" ) {
  548. attributes = attributes + "height:" + height + "; ";
  549. }
  550. var group = prnt.createChild("xforms:group", attributes);
  551. return group
  552. }
  553. // Case 생성
  554. function makeCase(prnt, id, left, top, width, height) {
  555. var attributes = "";
  556. if(id != undefined && id != "" ) {
  557. attributes = attributes + "id:" + id + "; ";
  558. } else {
  559. alert("id는 필수 입니다.");
  560. return;
  561. }
  562. if(left != undefined && left != "" ) {
  563. attributes = attributes + "left:" + left + "; ";
  564. } else {
  565. attributes = attributes + "left:0; ";
  566. }
  567. if(top != undefined && top != "" ) {
  568. attributes = attributes + "top:" + top + "; ";
  569. } else {
  570. attributes = attributes + "top:0; ";
  571. }
  572. if(width != undefined && width != "" ) {
  573. attributes = attributes + "width:" + width + "; ";
  574. }
  575. if(height != undefined && height != "" ) {
  576. attributes = attributes + "height:" + height + "; ";
  577. }
  578. var switchCase = prnt.createChild("xforms:case", attributes);
  579. return switchCase
  580. }
  581. // 단일 선택
  582. function makeSingleSelect(prnt, ctrlInfos, ref, left, top) {
  583. var group = makeGroup(prnt, left, top);
  584. var qestcnts = ctrlInfos[0].qpaprsortseq + ". " + ctrlInfos[0].qestcnts;
  585. var output = makeOutput(group, qestcnts, 0, 0, tabWidth);
  586. var inTop = parseInt(output.attribute("height") ,10) ;
  587. var nodeSet = retriveNodeSet(ctrlInfos);
  588. var qestseqno = ctrlInfos[0].qestseqno; //
  589. var qestitemanswchoicolcnt = ctrlInfos[0].qestitemanswchoicolcnt; // clos 수
  590. var descinptyn = ctrlInfos[ctrlInfos.length - 1].descinptyn; // 서술 입력 필드 여부
  591. var rowRef = makeDataNode(ref, ctrlInfos);
  592. var radio = makeRadio(group, "rd" + qestseqno, rowRef + "/qestanswno", condesNode, nodeSet, qestitemanswchoicolcnt, indent, inTop);
  593. inTop = inTop + parseInt(radio.attribute("height") ,10) ;
  594. if(descinptyn == "Y") {
  595. colRef = rowRef + "/";
  596. model.makeNode(colRef);
  597. var input = makeInput(group, "ip" + qestseqno, rowRef + "/descinptcnts", indent, inTop);
  598. inTop = inTop + parseInt(input.attribute("height") ,10) ;
  599. }
  600. group.attribute("height") = inTop;
  601. group.attribute("width") = tabWidth;
  602. return group;
  603. }
  604. // 다중 선택
  605. function makeMultiSelect(prnt, ctrlInfos, ref, left, top) {
  606. var group = makeGroup(prnt, left, top);
  607. var qestcnts = ctrlInfos[0].qpaprsortseq + ". " + ctrlInfos[0].qestcnts;
  608. var output = makeOutput(group, qestcnts, 0, 0, tabWidth);
  609. var inTop = parseInt(output.attribute("height") ,10) ;
  610. var nodeSet = retriveNodeSet(ctrlInfos);
  611. var qestseqno = ctrlInfos[0].qestseqno;
  612. var qestitemanswchoicolcnt = ctrlInfos[0].qestitemanswchoicolcnt;
  613. var rowRef = makeDataNode(ref, ctrlInfos);
  614. var checkbox = makeCheckbox(group, "ch" + qestseqno, rowRef + "/qestmltlanswno", condesNode, nodeSet, qestitemanswchoicolcnt, indent, inTop);
  615. inTop = inTop + parseInt(checkbox.attribute("height") ,10) ;
  616. var descinptyn = ctrlInfos[ctrlInfos.length - 1].descinptyn;
  617. if(descinptyn == "Y") {
  618. var input = makeInput(group, "ip" + qestseqno, rowRef + "/descinptcnts", indent, inTop);
  619. inTop = inTop + parseInt(input.attribute("height") ,10) ;
  620. }
  621. group.attribute("height") = inTop;
  622. group.attribute("width") = tabWidth;
  623. return group;
  624. }
  625. // 단답형
  626. function makeShortAnswer(prnt, ctrlInfos, ref, left, top) {
  627. var group = makeGroup(prnt, left, top);
  628. var qestcnts = ctrlInfos[0].qpaprsortseq + ". " + ctrlInfos[0].qestcnts;
  629. var output = makeOutput(group, qestcnts, 0, 0, tabWidth);
  630. var inTop = parseInt(output.attribute("height") ,10) ;
  631. var nodeSet = retriveNodeSet(ctrlInfos);
  632. var qestseqno = ctrlInfos[0].qestseqno;
  633. var qestitemanswcnts = ctrlInfos[0].answseqno + ") " + ctrlInfos[0].qestitemanswcnts;
  634. var addinptyn = ctrlInfos[0].addinptyn;
  635. var answaddcnts = ctrlInfos[0].answaddcnts;
  636. var width;
  637. var left = indent;
  638. if(qestitemanswcnts.length > 0) {
  639. width = qestitemanswcnts.length * 18;
  640. var output = makeOutput(group, qestitemanswcnts, left, inTop, width);
  641. left = left + width;
  642. width = 100;
  643. } // end if
  644. var rowRef = makeDataNode(ref, ctrlInfos);
  645. var input = makeInput(group, "ip" + qestseqno, rowRef + "/descinptcnts", left, inTop, width);
  646. if(addinptyn == "Y") {
  647. left += 110;
  648. if(answaddcnts.length > 0) {
  649. width = answaddcnts.length * 18;
  650. var output = makeOutput(group, answaddcnts, left, inTop, width);
  651. left = left + width;
  652. } // end if
  653. width = 100;
  654. var appInput = makeInput(group, "ipapp" + qestseqno, rowRef + "/descinptaddcnts", left, inTop, width);
  655. } // if
  656. //inTop = inTop + parseInt(input.attribute("height"), 10);
  657. inTop = inTop + 32;
  658. group.attribute("height") = inTop;
  659. group.attribute("width") = tabWidth;
  660. return group;
  661. }
  662. // 서술 입력
  663. function makeDescriptiveAnswer(prnt, ctrlInfos, ref, left, top) {
  664. var group = makeGroup(prnt, left, top);
  665. var qestcnts = ctrlInfos[0].qpaprsortseq + ". " + ctrlInfos[0].qestcnts;
  666. var output = makeOutput(group, qestcnts, 0, 0, tabWidth);
  667. var inTop = parseInt(output.attribute("height") ,10) ;
  668. var nodeSet = retriveNodeSet(ctrlInfos);
  669. var qestseqno = ctrlInfos[0].qestseqno;
  670. var rowRef = makeDataNode(ref, ctrlInfos);
  671. var textarea = makeTextarea(group, "ta" + qestseqno, rowRef + "/descinptcnts", indent, inTop);
  672. inTop = inTop + parseInt(textarea.attribute("height") ,10) ;
  673. group.attribute("height") = inTop;
  674. group.attribute("width") = tabWidth;
  675. return group;
  676. }
  677. // 순위 입력
  678. function makePriority(prnt, ctrlInfos, ref, left, top) {
  679. var group = makeGroup(prnt, left, top);
  680. var qestcnts = ctrlInfos[0].qpaprsortseq + ". " + ctrlInfos[0].qestcnts;
  681. var output = makeOutput(group, qestcnts, 0, 0, tabWidth);
  682. var inTop = parseInt(output.attribute("height") ,10) ;
  683. var qestseqno = ctrlInfos[0].qestseqno; //
  684. var qestitemanswchoicolcnt = ctrlInfos[0].qestitemanswchoicolcnt; // cols 수
  685. var descinptyn = ctrlInfos[ctrlInfos.length - 1].descinptyn; // 서술 입력 필드 여부
  686. var rowRef = makeDataNode(ref, ctrlInfos);
  687. // 문항 갯수 설정
  688. model.makeValue(rowRef + "/qestmltlanswno_count", ctrlInfos.length);
  689. var colRef = "";
  690. for (var i = 0; i < ctrlInfos.length; i++) {
  691. var answseqno = ctrlInfos[i].answseqno;
  692. var nodeSet = new Array();
  693. for (var j = 0; j < ctrlInfos.length; j++) {
  694. nodeSet[j] = {"label":ctrlInfos[j].answseqno, "value":answseqno + ":" + ctrlInfos[j].answseqno};
  695. } // end for
  696. // 문항별 값 저장 node 생성
  697. //var colRef = rowRef + "/qestmltlanswno" + i;
  698. colRef = rowRef +"/qestmltlanswno" + i;
  699. model.makeNode(colRef);
  700. var combo = makeCombo(group, "cb" + qestseqno + answseqno, colRef, condesNode, nodeSet, qestitemanswchoicolcnt, indent, inTop, 50);
  701. //var output = makeOutput(group, ctrlInfos[i].answseqno + ") " + ctrlInfos[i].qestitemanswcnts, indent + parseInt(combo.attribute("width") ,10) + 10, inTop, 300);
  702. var output = makeOutput(group, ctrlInfos[i].qestitemanswcnts, indent + parseInt(combo.attribute("width") ,10) + 10, inTop, 300);
  703. //inTop = inTop + parseInt(combo.attribute("height") ,10) ;
  704. inTop = inTop + 32 ;
  705. } // end for
  706. //model.makeNode(colRef);
  707. group.attribute("height") = inTop;
  708. group.attribute("width") = tabWidth;
  709. return group;
  710. }
  711. var cellWidth = 80; // 척도 컬럼 width
  712. // 척도 선택
  713. function makeMeasure(prnt, ctrlInfos, ref, left, top, isPrintTitle) {
  714. var group = makeGroup(prnt, left, top);
  715. var nodeSet = retriveNodeSet(ctrlInfos);
  716. var rowIndex = ctrlInfos.length - 1;
  717. var qestcnts = ctrlInfos[rowIndex].qpaprsortseq + ". " + ctrlInfos[rowIndex].qestcnts;
  718. var qestseqno = ctrlInfos[rowIndex].qestseqno;
  719. var itemkindcd = ctrlInfos[rowIndex].itemkindcd;
  720. var qestitemanswchoicolcnt = ctrlInfos[rowIndex].qestitemanswchoicolcnt; // cols 수
  721. var norpaddyn = ctrlInfos[rowIndex].norpaddyn; // 무응답여부
  722. var width = tabWidth - (cellWidth * ctrlInfos.length);
  723. var inTop = 0;
  724. var inLeft = width;
  725. // 타이틀 출력
  726. if(isPrintTitle) {
  727. var headCells = new Array();
  728. var titleOutput = makeOutput(group, "질문", 0, inTop, width);
  729. headCells[0] = titleOutput;
  730. var maxHeadHeight = parseInt(titleOutput.attribute("height"), 10);
  731. for (var i = 0; i < ctrlInfos.length; i++) {
  732. titleOutput = makeOutput(group, nodeSet[i].label, inLeft, inTop, cellWidth);
  733. headCells[i + 1] = titleOutput;
  734. var headHeight = parseInt(titleOutput.attribute("height"), 10);
  735. maxHeadHeight = maxHeadHeight > headHeight ? maxHeadHeight: headHeight;
  736. inLeft += cellWidth;
  737. } // end for
  738. for (var i = 0; i < headCells.length; i++) {
  739. headCells[i].attribute("height") = maxHeadHeight;
  740. headCells[i].attribute("border-style") = "solid";
  741. headCells[i].attribute("background-color") = "#cce8ff"; //"#00ccff";
  742. headCells[i].attribute("text-align") = "center";
  743. headCells[i].attribute("vertical-align") = "middle";
  744. } // end for
  745. inTop = inTop + maxHeadHeight;
  746. } // end if
  747. // 텍스트 출력
  748. var output = makeOutput(group, qestcnts, 0, inTop, width);
  749. output.attribute("border-style") = "solid";
  750. var inHeight = parseInt(output.attribute("height"), 10);
  751. var rowRef = makeDataNode(ref, ctrlInfos);
  752. var colRef = rowRef + "/qestanswno";
  753. inLeft = width;
  754. var cellGroup;
  755. var radio;
  756. for (var i = 0; i < ctrlInfos.length; i++) {
  757. var answseqno = ctrlInfos[i].answseqno;
  758. cellGroup = makeGroup(group, inLeft, inTop, cellWidth, inHeight);
  759. cellGroup.attribute("border-style") = "solid";
  760. radio = makeRadioSingleItem(cellGroup, "rd" + qestseqno + answseqno, colRef, condesNode, {label: "", value:nodeSet[i].value}, qestitemanswchoicolcnt, cellWidth / 2 - 10, inHeight / 2 - 10, cellWidth);
  761. inLeft += cellWidth;
  762. } // end for
  763. inTop = inTop + parseInt(cellGroup.attribute("height"), 10);
  764. group.attribute("height") = inTop;
  765. group.attribute("width") = tabWidth;
  766. return group;
  767. }
  768. var cell10Width = 30; // 척도 컬럼 width
  769. // 10점 척도 선택
  770. function make10Measure(prnt, ctrlInfos, ref, left, top, isPrintTitle) {
  771. var group = makeGroup(prnt, left, top);
  772. var nodeSet = retriveNodeSet(ctrlInfos);
  773. var rowIndex = ctrlInfos.length - 1;
  774. var qestcnts = ctrlInfos[rowIndex].qpaprsortseq + ". " + ctrlInfos[rowIndex].qestcnts;
  775. var qestseqno = ctrlInfos[rowIndex].qestseqno;
  776. var itemkindcd = ctrlInfos[rowIndex].itemkindcd;
  777. var qestitemanswchoicolcnt = ctrlInfos[rowIndex].qestitemanswchoicolcnt; // cols 수
  778. var norpaddyn = ctrlInfos[rowIndex].norpaddyn; // 무응답여부
  779. var width = tabWidth - (cell10Width * ctrlInfos.length);
  780. var inTop = 0;
  781. var inLeft = width;
  782. // 타이틀 출력
  783. if(isPrintTitle) {
  784. var headCells = new Array();
  785. var titleOutput = makeOutput(group, "질문", 0, inTop, width);
  786. headCells[0] = titleOutput;
  787. var maxHeadHeight = parseInt(titleOutput.attribute("height"), 10);
  788. for (var i = 0; i < ctrlInfos.length; i++) {
  789. titleOutput = makeOutput(group, nodeSet[i].label, inLeft, inTop, cell10Width);
  790. headCells[i + 1] = titleOutput;
  791. var headHeight = parseInt(titleOutput.attribute("height"), 10);
  792. maxHeadHeight = maxHeadHeight > headHeight ? maxHeadHeight: headHeight;
  793. inLeft += cell10Width;
  794. } // end for
  795. for (var i = 0; i < headCells.length; i++) {
  796. headCells[i].attribute("height") = maxHeadHeight;
  797. headCells[i].attribute("border-style") = "solid";
  798. headCells[i].attribute("background-color") = "#cce8ff"; //"#00ccff";
  799. headCells[i].attribute("text-align") = "center";
  800. headCells[i].attribute("vertical-align") = "middle";
  801. } // end for
  802. inTop = inTop + maxHeadHeight;
  803. } // end if
  804. // 텍스트 출력
  805. var output = makeOutput(group, qestcnts, 0, inTop, width);
  806. output.attribute("border-style") = "solid";
  807. var inHeight = parseInt(output.attribute("height"), 10);
  808. var rowRef = makeDataNode(ref, ctrlInfos);
  809. var colRef = rowRef + "/qestanswno";
  810. inLeft = width;
  811. var cellGroup;
  812. var radio;
  813. for (var i = 0; i < ctrlInfos.length; i++) {
  814. var answseqno = ctrlInfos[i].answseqno;
  815. cellGroup = makeGroup(group, inLeft, inTop, cell10Width, inHeight);
  816. cellGroup.attribute("border-style") = "solid";
  817. radio = makeRadioSingleItem10(cellGroup, "rd" + qestseqno + answseqno, colRef, condesNode, {label: "", value:nodeSet[i].value}, qestitemanswchoicolcnt, 5, inHeight / 2 - 10, cell10Width);
  818. inLeft += cell10Width;
  819. } // end for
  820. inTop = inTop + parseInt(cellGroup.attribute("height"), 10);
  821. group.attribute("height") = inTop;
  822. group.attribute("width") = tabWidth;
  823. return group;
  824. }
  825. // 설문 생성
  826. function createPoll(prnt, ctrlInfos, ref, left, top, isContinuous) {
  827. if(ctrlInfos.length < 1) {
  828. alert("설문이 없습니다");
  829. return;
  830. } // end if
  831. var poll;
  832. var itemkindcd = ctrlInfos[0].itemkindcd;
  833. switch(itemkindcd) {
  834. case "1":
  835. poll = makeSingleSelect(prnt, ctrlInfos, ref, left, top);
  836. break;
  837. case "2":
  838. poll = makeMultiSelect(prnt, ctrlInfos, ref, left, top);
  839. break;
  840. case "3":
  841. poll = makePriority(prnt, ctrlInfos, ref, left, top);
  842. break;
  843. case "4":
  844. poll = makeShortAnswer(prnt, ctrlInfos, ref, left, top);
  845. break;
  846. case "5":
  847. poll = makeDescriptiveAnswer(prnt, ctrlInfos, ref, left, top);
  848. break;
  849. case "6":
  850. case "7":
  851. case "8":
  852. poll = makeMeasure(prnt, ctrlInfos, ref, left, top, isContinuous);
  853. break;
  854. case "10":
  855. poll = make10Measure(prnt, ctrlInfos, ref, left, top, isContinuous);
  856. break;
  857. } // end switch
  858. return poll;
  859. };
  860. function isIdentical(arPreDatas, arDatas) {
  861. var identical = false;
  862. if (arPreDatas != undefined && arPreDatas != null) {
  863. if(arPreDatas.length == arDatas.length) {
  864. for(var i = 0; i < arPreDatas.length; i ++) {
  865. if(arPreDatas[i].qestitemanswcnts == arDatas[i].qestitemanswcnts) {
  866. identical = true;
  867. } else {
  868. identical = false;
  869. break;
  870. }
  871. } // end for
  872. } else {
  873. identical = false;
  874. }
  875. } else {
  876. identical = false;
  877. } // end if
  878. return identical;
  879. }