|
1 | | -// Header Menu Icons/Buttons |
| 1 | +// Header IDS |
2 | 2 | const stateButton = document.getElementById('state_button') |
3 | 3 | const themeButton = document.getElementById('theme_button') |
4 | 4 | const settingsButton = document.getElementById('settings_button') |
5 | 5 |
|
6 | | -// Editor Actions |
| 6 | +// Editor IDS |
7 | 7 | const editorType = document.getElementById('editor_type') |
8 | 8 | const editorCSS = document.getElementById('editor_css') |
9 | 9 | const editorJS = document.getElementById('editor_js') |
| 10 | +const editorTaburl = document.getElementById('editor_taburl') |
| 11 | +const editorRender = document.getElementById('editor_render') |
| 12 | +const editorLock = document.getElementById('editor_lock') |
10 | 13 |
|
11 | | -// Snipx Pages |
12 | | -const editorPage = document.getElementById('editor_page_container') |
13 | | -const settingsPage = document.getElementById('settings_page_container') |
| 14 | +// Page IDS |
| 15 | +const editorPage = document.getElementById('editor_page') |
| 16 | +const settingsPage = document.getElementById('settings_page') |
14 | 17 |
|
15 | 18 | // Create localStorage key/value if not there already |
16 | 19 | let defaultStorage = { |
@@ -43,6 +46,7 @@ chrome.tabs.query({ |
43 | 46 | let currentTabURL = newArray.join('') |
44 | 47 | // Insert URL directly into localStorage |
45 | 48 | localStorage.setItem('SnipxTabURL', currentTabURL) |
| 49 | + editorTaburl.innerText = currentTabURL |
46 | 50 | }) |
47 | 51 |
|
48 | 52 | // Set localStorage defaultStorage values |
@@ -107,6 +111,14 @@ window.addEventListener('load', (e) => { |
107 | 111 | }) |
108 | 112 | break |
109 | 113 | } |
| 114 | + switch(localStorage.getItem('SnipxEditorRender')) { |
| 115 | + case 'true': editorRender.innerText = 'visibility'; break |
| 116 | + case 'false': editorRender.innerText = 'visibility_off'; break |
| 117 | + } |
| 118 | + switch(localStorage.getItem('SnipxEditorLock')) { |
| 119 | + case 'true': editorLock.innerText = 'lock'; break |
| 120 | + case 'false': editorLock.innerText = 'no_encryption'; break |
| 121 | + } |
110 | 122 | // HEADER UPDATE |
111 | 123 | // ................................. |
112 | 124 | // Load Event Listeners towards the end of the file |
@@ -168,7 +180,44 @@ window.addEventListener('load', (e) => { |
168 | 180 | // TYPE |
169 | 181 | editorType.addEventListener('change', (e) => { |
170 | 182 | localStorage.setItem('SnipxEditor', editorType.value) |
171 | | - // Change editor type |
| 183 | + switch(editorType.value) { |
| 184 | + case 'css': |
| 185 | + editorJS.style.display = 'none' |
| 186 | + editorCSS.style.display = 'block' |
| 187 | + break |
| 188 | + case 'js': |
| 189 | + editorCSS.style.display = 'none' |
| 190 | + editorJS.style.display = 'block' |
| 191 | + break |
| 192 | + } |
| 193 | + }, false) |
| 194 | + editorRender.addEventListener('click', (e) => { |
| 195 | + switch(localStorage.getItem('SnipxEditorRender')) { |
| 196 | + case 'true': |
| 197 | + localStorage.setItem('SnipxEditorRender', 'false') |
| 198 | + // insert current editor code into TabURL |
| 199 | + window.location.reload() |
| 200 | + break |
| 201 | + case 'false': |
| 202 | + localStorage.setItem('SnipxEditorRender', 'true') |
| 203 | + // remove current editor code from TabURL |
| 204 | + window.location.reload() |
| 205 | + break |
| 206 | + } |
| 207 | + }, false) |
| 208 | + editorLock.addEventListener('click', (e) => { |
| 209 | + switch(localStorage.getItem('SnipxEditorLock')) { |
| 210 | + case 'true': |
| 211 | + localStorage.setItem('SnipxEditorLock', 'false') |
| 212 | + // unlock the current editor |
| 213 | + window.location.reload() |
| 214 | + break |
| 215 | + case 'false': |
| 216 | + localStorage.setItem('SnipxEditorLock', 'true') |
| 217 | + // lock the current editor |
| 218 | + window.location.reload() |
| 219 | + break |
| 220 | + } |
172 | 221 | }, false) |
173 | 222 | }, false) |
174 | 223 |
|
0 commit comments