a5f6d19609acc87476e814cc247005893041e741.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. // ================================================================
  2. // CHEditor 5
  3. // ----------------------------------------------------------------
  4. // Homepage: http://www.chcode.com
  5. // Copyright (c) 1997-2014 CHSOFT
  6. // ================================================================
  7. var oEditor = null;
  8. var colour = ["ffffcc","ffcc66","ff9900","ffcc99","ff6633","ffcccc","cc9999","ff6699","ff99cc","ff66cc","ffccff","cc99cc","cc66ff","cc99ff","9966cc","ccccff","9999cc","3333ff","6699ff","0066ff","99ccff","66ccff","99cccc","ccffff","99ffcc","66cc99","66ff99","99ff99","ccffcc","33ff33","66ff00","ccff99","99ff00","ccff66","cccc66","ffffff",
  9. "ffff99","ffcc00","ff9933","ff9966","cc3300","ff9999","cc6666","ff3366","ff3399","ff00cc","ff99ff","cc66cc","cc33ff","9933cc","9966ff","9999ff","6666ff","3300ff","3366ff","0066cc","3399ff","33ccff","66cccc","99ffff","66ffcc","33cc99","33ff99","66ff66","99cc99","00ff33","66ff33","99ff66","99ff33","ccff00","cccc33","cccccc",
  10. "ffff66","ffcc33","cc9966","ff6600","ff3300","ff6666","cc3333","ff0066","ff0099","ff33cc","ff66ff","cc00cc","cc00ff","9933ff","6600cc","6633ff","6666cc","3300cc","0000ff","3366cc","0099ff","00ccff","339999","66ffff","33ffcc","00cc99","00ff99","33ff66","66cc66","00ff00","33ff00","66cc00","99cc66","ccff33","999966","999999",
  11. "ffff33","cc9900","cc6600","cc6633","ff0000","ff3333","993333","cc3366","cc0066","cc6699","ff33ff","cc33cc","9900cc","9900ff","6633cc","6600ff","666699","3333cc","0000cc","0033ff","6699cc","3399cc","669999","33ffff","00ffcc","339966","33cc66","00ff66","669966","00cc00","33cc00","66cc33","99cc00","cccc99","999933","666666",
  12. "ffff00","cc9933","996633","993300","cc0000","ff0033","990033","996666","993366","cc0099","ff00ff","990099","996699","660099","663399","330099","333399","000099","0033cc","003399","336699","0099cc","006666","00ffff","33cccc","009966","00cc66","339933","336633","33cc33","339900","669933","99cc33","666633","999900","333333",
  13. "cccc00","996600","663300","660000","990000","cc0033","330000","663333","660033","990066","cc3399","993399","660066","663366","330033","330066","333366","000066","000033","003366","006699","003333","336666","00cccc","009999","006633","009933","006600","003300","00cc33","009900","336600","669900","333300","666600","000000"];
  14. var none = '없음';
  15. var whichColor = null;
  16. function popupClose() {
  17. oEditor.popupWinCancel();
  18. }
  19. function getColor()
  20. {
  21. var color = this.bgColor;
  22. var input = document.getElementById("id"+whichColor);
  23. input.style.backgroundColor = input.value = color;
  24. }
  25. function drawColor() {
  26. var table, tr, td, insideTable, k = 0, i, j, tr2, td2;
  27. table = document.createElement('table');
  28. table.cellPadding = 0;
  29. table.cellSpacing = 0;
  30. table.border = 0;
  31. table.align = 'center';
  32. tr = table.insertRow(0);
  33. td = tr.insertCell(0);
  34. td.style.backgroundColor = '#fff';
  35. insideTable = document.createElement('table');
  36. insideTable.border = 0;
  37. insideTable.cellSpacing = 1;
  38. insideTable.cellPadding = 0;
  39. insideTable.align = 'center';
  40. var onMouseOver = function() { this.className = 'colorCellMouseOver'; };
  41. var onMouseOut = function() { this.className = 'colorCellMouseOut'; };
  42. for (i = 0; i < 6; i++) {
  43. tr2 = insideTable.insertRow(i);
  44. for (j = 0; j < 36; j++) {
  45. td2 = tr2.insertCell(j);
  46. td2.setAttribute('bgColor', '#' + colour[k]);
  47. td2.className = 'colorCellMouseOut';
  48. td2.onclick = getColor;
  49. td2.appendChild(document.createTextNode('\u00a0'));
  50. td2.onmouseover = onMouseOver;
  51. td2.onmouseout = onMouseOut;
  52. k++;
  53. }
  54. }
  55. td.appendChild(insideTable);
  56. document.getElementById('colorWrapper').appendChild(table);
  57. }
  58. function setColor(which) {
  59. whichColor = which;
  60. }
  61. function doSubmit()
  62. {
  63. var rows, cols, border, width, widthType, height, cellpd, cellsp, bgcolor, align, bordercolor, cssclass, cssid, cellWidth;
  64. rows = document.getElementById("numrows").value;
  65. rows = parseInt(oEditor.trimSpace(rows), 10);
  66. if (isNaN(rows)) {
  67. rows = 0;
  68. }
  69. cols = document.getElementById("numcols").value;
  70. cols = parseInt(oEditor.trimSpace(cols), 10);
  71. if (isNaN(cols)) {
  72. cols = 0;
  73. }
  74. border = document.getElementById("bordersize").value;
  75. border = parseInt(oEditor.trimSpace(border), 10);
  76. if (isNaN(border)) {
  77. border = 0;
  78. }
  79. width = document.getElementById("width").value;
  80. width = parseInt(oEditor.trimSpace(width), 10);
  81. widthType = document.getElementById("widthtype").value;
  82. if (isNaN(width)) {
  83. cellWidth = width = null;
  84. }
  85. else {
  86. cellWidth = parseInt(width / cols, 10) + widthType;
  87. width += widthType;
  88. }
  89. height = document.getElementById("height").value;
  90. height = parseInt(oEditor.trimSpace(height), 10);
  91. if (isNaN(height)) {
  92. height = null;
  93. }
  94. else {
  95. height += document.getElementById("heighttype").value;
  96. }
  97. cellpd = document.getElementById("cellpd").value;
  98. cellpd = parseInt(oEditor.trimSpace(cellpd), 10);
  99. if (isNaN(cellpd)) {
  100. cellpd = 0;
  101. }
  102. cellsp = document.getElementById("cellsp").value;
  103. cellsp = parseInt(oEditor.trimSpace(cellsp), 10);
  104. if (isNaN(cellsp)) {
  105. cellsp = 0;
  106. }
  107. bgcolor = document.getElementById("idbgcolor").value;
  108. bgcolor = oEditor.trimSpace(bgcolor);
  109. if (bgcolor === none || bgcolor === '') {
  110. bgcolor = null;
  111. }
  112. align = document.getElementById("talign").value;
  113. if (align === 'none') {
  114. align = null;
  115. }
  116. bordercolor = document.getElementById("idbordercolor").value;
  117. bordercolor = oEditor.trimSpace(bordercolor);
  118. if (bordercolor === '') {
  119. bordercolor = null;
  120. }
  121. cssclass = document.getElementById("cssClass").value;
  122. cssclass = oEditor.trimSpace(cssclass);
  123. if (cssclass === '') {
  124. cssclass = null;
  125. }
  126. cssid = document.getElementById("cssId").value;
  127. cssid = oEditor.trimSpace(cssid);
  128. if (cssid === '') {
  129. cssid = null;
  130. }
  131. if (rows < 1 || cols < 1) {
  132. alert('표의 줄 또는 칸 개수가 1개 이상 필요합니다.');
  133. return;
  134. }
  135. var caption = document.getElementById('tableCaption');
  136. var captionValue = oEditor.trimSpace(caption.value);
  137. var summary = document.getElementById('tableSummary');
  138. var summaryValue = oEditor.trimSpace(summary.value);
  139. var header = document.getElementById('tableHeader').value;
  140. var table = document.createElement("table");
  141. var createHeadCell = function(scope) {
  142. var cell = document.createElement('th');
  143. cell.setAttribute('scope', scope);
  144. return cell;
  145. };
  146. var oHead = document.createElement('thead');
  147. var oBody = document.createElement('tbody');
  148. if (border) {
  149. if (bordercolor) {
  150. table.style.borderColor = oEditor.colorConvert(bordercolor, 'rgb');
  151. }
  152. table.style.borderStyle = 'solid';
  153. table.style.borderWidth = border + 'px';
  154. }
  155. table.style.borderCollapse = "collapse";
  156. var i, row, tr, j, cell;
  157. for (i=0; i < rows; i++) {
  158. tr = document.createElement('tr');
  159. if ((header === 'col' || header === 'all') && i===0) {
  160. row = oHead.appendChild(tr);
  161. }
  162. else {
  163. row = oBody.appendChild(tr);
  164. }
  165. for (j=0; j < cols; j++) {
  166. if (header === 'col' && i===0) {
  167. cell = createHeadCell('col');
  168. }
  169. else if (header === 'all') {
  170. if (j === 0) {
  171. cell = createHeadCell('row');
  172. }
  173. else if (i === 0 && j > 0) {
  174. cell = createHeadCell('col');
  175. }
  176. else {
  177. cell = document.createElement('td');
  178. }
  179. }
  180. else if (header === 'row' && j === 0) {
  181. cell = createHeadCell('row');
  182. }
  183. else {
  184. cell = document.createElement('td');
  185. }
  186. if (border) {
  187. cell.style.borderStyle = 'solid';
  188. cell.style.borderWidth = table.style.borderWidth;
  189. cell.style.borderColor = table.style.borderColor;
  190. }
  191. // cell.setAttribute("width", cellWidth);
  192. cell.appendChild(document.createTextNode('\u00a0'));
  193. row.appendChild(cell);
  194. }
  195. }
  196. if (oHead.hasChildNodes()) {
  197. table.appendChild(oHead);
  198. }
  199. table.appendChild(oBody);
  200. if (summaryValue !== '') {
  201. table.setAttribute('summary', summaryValue);
  202. }
  203. if (width) {
  204. table.style.width = width;
  205. }
  206. if (height) {
  207. table.style.height = height;
  208. }
  209. if (align) {
  210. table.setAttribute("align", align);
  211. }
  212. if (bgcolor) {
  213. table.setAttribute("bgcolor", bgcolor);
  214. }
  215. table.style.tableLayout = 'fixed';
  216. table.setAttribute("cellpadding", cellpd);
  217. table.setAttribute("cellspacing", cellsp);
  218. if (captionValue !== '') {
  219. var hideCaption, tableCaption;
  220. tableCaption = table.createCaption();
  221. tableCaption.appendChild(document.createTextNode(captionValue));
  222. hideCaption = document.getElementById('hideCaption');
  223. if (hideCaption.checked === true) {
  224. tableCaption.style.visibility = 'hidden';
  225. tableCaption.style.overFlow = 'hidden';
  226. tableCaption.style.lineHeight = '0px';
  227. tableCaption.style.position = 'absolute';
  228. tableCaption.style.display = 'none';
  229. }
  230. }
  231. table.id = oEditor.makeRandomString();
  232. oEditor.insertHtmlPopup(table.cloneNode(true));
  233. var newTable = oEditor.$(table.id);
  234. newTable.removeAttribute('id');
  235. if (cssclass) {
  236. newTable.className = cssclass;
  237. }
  238. if (cssid) {
  239. newTable.id = cssid;
  240. }
  241. var focusCell = newTable.getElementsByTagName('th')[0];
  242. if (oEditor.undefined(focusCell)) {
  243. focusCell = newTable.getElementsByTagName('td')[0];
  244. }
  245. if (oEditor.getBrowser().msie) {
  246. var cursor = oEditor.doc.body.createTextRange();
  247. cursor.moveToElementText(focusCell);
  248. cursor.collapse(false);
  249. cursor.select();
  250. oEditor.backupRange(oEditor.getRange());
  251. }
  252. else {
  253. var selection = oEditor.getSelection();
  254. var range = oEditor.getRange();
  255. range.selectNodeContents(focusCell);
  256. range.collapse(false);
  257. selection.removeAllRanges();
  258. selection.addRange(range);
  259. }
  260. oEditor.popupWinClose();
  261. }
  262. function init(dialog) {
  263. oEditor = this;
  264. oEditor.dialog = dialog;
  265. var button = [ { alt : "", img : 'submit.gif', cmd : doSubmit },
  266. { alt : "", img : 'cancel.gif', cmd : popupClose } ];
  267. var dlg = new Dialog(oEditor);
  268. dlg.showButton(button);
  269. dlg.setDialogHeight();
  270. }