
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
<!DOCTYPE html> <html> <head> <style> .console { flex: 1; display: block; min-height: 0; font-family: Consolas; background-color: #222; color: #f1f1f1; white-space: pre-wrap; word-break: break-word; overflow-wrap: normal; outline: none; overflow-y: auto; overflow-x: hidden; margin: 0; padding: 5px 5px 0 15px; line-height: 1.2; font-size: 37%; font-weight: 100; } </style> </head> <body> <section class="split"> <div class="panel left"> <div class="header active"> <span class="badge-num">1</span> <span>Windows1</span> <span class="more-dots"> <input type="color" class="bg-picker" data-target="leftConsole"> <input type="color" class="txt-picker" data-target="leftConsole"> <select class="font-picker" data-target="leftConsole"> <option value="Consolas">Consolas</option> <option value="Courier New">Courier New</option> <option value="Menlo">Menlo</option> <option value="Monaco">Monaco</option> <option value="Noto Sans Mono KR">Noto Sans Mono KR</option> </select> <select class="size-picker" data-target="leftConsole"> <option value="12px">12px</option> <option value="14px">14px</option> <option value="16px">16px</option> <option value="18px">18px</option> <option value="18px">20px</option> </select> <button type="button" class="reset-btn" data-target="leftConsole">초기화</button> </span> </div> <textarea class="console" id="leftConsole" tabindex="0" data-index="0" spellcheck="false" rows="6" cols="50">></textarea> </div> <div class="splitbar1" aria-hidden="true"></div> <div class="panel right" style="flex:1"> <div class="header"> <span class="badge-num">2</span> <span>Windows2</span> <input type="color" class="bg-picker" data-target="rightConsole"> <input type="color" class="txt-picker" data-target="rightConsole"> <select class="font-picker" data-target="rightConsole"> <option value="Consolas">Consolas</option> <option value="Courier New">Courier New</option> <option value="Menlo">Menlo</option> <option value="Monaco">Monaco</option> <option value="Noto Sans Mono KR">Noto Sans Mono KR</option> </select> <select class="size-picker" data-target="rightConsole"> <option value="12px">12px</option> <option value="14px">14px</option> <option value="16px">16px</option> <option value="18px">18px</option> <option value="18px">20px</option> </select> <button type="button" class="reset-btn" data-target="rightConsole">초기화</button> </div> <textarea class="console" id="rightConsole" tabindex="0" data-index="1" spellcheck="false" rows="6" cols="50">></textarea> </div> </section> <br><br> <script> const DEFAULT_STYLE = { bg: "#222222", txt: "#f1f1f1", font: "Consolas", size: "14px" }; const KEY_PREFIX = "CONSOLE_STYLE_"; // 초기화 & 복원 document.querySelectorAll("textarea.console").forEach(initConsole); function initConsole(ta) { const id = ta.id; const saved = JSON.parse(localStorage.getItem(KEY_PREFIX + id) || "{}"); const style = { ...DEFAULT_STYLE, ...saved }; ta.style.backgroundColor = style.bg; ta.style.color = style.txt; ta.style.fontFamily = style.font; ta.style.fontSize = style.size; syncPicker(id, "bg-picker", style.bg); syncPicker(id, "txt-picker", style.txt); syncPicker(id, "font-picker", style.font); syncPicker(id, "size-picker", style.size); } // 공통 이벤트 처리 document.addEventListener("input", handleChange); document.addEventListener("change", handleChange); function handleChange(e) { const t = e.target; const id = t.dataset.target; if (!id) return; const ta = document.getElementById(id); if (t.classList.contains("bg-picker")) { ta.style.backgroundColor = t.value; save(id, { bg: t.value }); } if (t.classList.contains("txt-picker")) { ta.style.color = t.value; save(id, { txt: t.value }); } if (t.classList.contains("font-picker")) { ta.style.fontFamily = t.value; save(id, { font: t.value }); } if (t.classList.contains("size-picker")) { ta.style.fontSize = t.value; save(id, { size: t.value }); } } // 초기화 document.addEventListener("click", function (e) { if (!e.target.classList.contains("reset-btn")) return; const id = e.target.dataset.target; const ta = document.getElementById(id); localStorage.removeItem(KEY_PREFIX + id); initConsole(ta); }); // 저장 function save(id, patch) { const key = KEY_PREFIX + id; const cur = JSON.parse(localStorage.getItem(key) || "{}"); localStorage.setItem(key, JSON.stringify({ ...cur, ...patch })); } // picker 동기화 function syncPicker(id, cls, value) { document .querySelectorAll(`.${cls}[data-target="${id}"]`) .forEach(p => p.value = value); } </script> </body> </html> |
댓글