Skip to content

Commit cb8fd18

Browse files
committed
Update a bunch of files and create new ones
1 parent fa27a0f commit cb8fd18

File tree

11 files changed

+119
-7
lines changed

11 files changed

+119
-7
lines changed

src/css/styles.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ display: none;
9898
/* font-weight: bold; */
9999
font-family: var(--snipx-header-title-family);
100100
}
101+
.snipx-editor-menu-action {
102+
cursor: pointer;
103+
padding: 5px 10px !important;
104+
border-right: 1px solid green;
105+
}
101106
.snipx-editor-textarea {
102107
padding: 8px;
103108
font-size: 14px;

src/index.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
<option id="snipx-editor-menu-js" value="js">JS</option>
4343
</select>
4444
<div id="snipx-editor-menu-actions">
45-
<span class="material-icons snipx-editor-menu-action" style="padding: 5px 10px;border-right: 1px solid green;">visibility</span>
46-
<span class="material-icons snipx-editor-menu-action" style="padding: 5px 10px;margin-left: -3px;border-right: 1px solid green;">lock</span>
45+
<span id="snipx-editor-action-shown" class="material-icons snipx-editor-menu-action">visibility</span>
46+
<span id="snipx-editor-action-hidden" class="material-icons snipx-editor-menu-action snipx-hide">visibility_off</span>
47+
<span id="snipx-editor-action-locked" class="material-icons snipx-editor-menu-action" style="margin-left: -3px;">lock</span>
48+
<span id="snipx-editor-action-unlocked" class="material-icons snipx-editor-menu-action" style="margin-left: -3px;">no_encryption</span>
4749
</div>
4850
<div id="snipx-editor-menu-tablink"></div>
4951
</div>
@@ -52,9 +54,18 @@
5254
<button id="snipx-editor-menu-saveBtn">Save</button>
5355
</div>
5456
</div>
55-
<!-- Load the textarea using JavaScript to load from LocalStorage -->
56-
<textarea id="snipx-editor-textarea-css" class="snipx-editor-textarea snipx-hide" spellcheck="false">/* Add CSS Snippet Here! */</textarea>
57-
<textarea id="snipx-editor-textarea-js" class="snipx-editor-textarea snipx-hide" spellcheck="false">/* Add JS Snippet Here! */</textarea>
57+
<!-- Snipx CSS Editor -->
58+
<!-- ................................................ -->
59+
<textarea
60+
id="snipx-editor-textarea-css"
61+
class="snipx-editor-textarea snipx-hide"
62+
spellcheck="false">/* Add CSS Snippet Here! */</textarea>
63+
<!-- Snipx JS Editor -->
64+
<!-- ................................................ -->
65+
<textarea
66+
id="snipx-editor-textarea-js"
67+
class="snipx-editor-textarea snipx-hide"
68+
spellcheck="false">/* Add JS Snippet Here! */</textarea>
5869
</main>
5970
<!-- Snipx Settings -->
6071
<!-- ................................................ -->

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import './js/InsertURL.js'
2-
import './js/ThemeToggle.js'
32
import './js/FileToggle.js'
3+
import './js/FileLockToggle.js'
4+
import './js/FileVisibilityToggle.js'
5+
import './js/InsertPage.js'
6+
import './js/ThemeToggle.js'
47
import './js/SettingsOpen.js'
58
import './js/SettingsClose.js'
69
import './js/ApplicationToggle.js'

src/js/FileClear.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const snipxEditorClearBtn = document.getElementById('snipx-editor-menu-clearBtn')
2-
const snipxEditorTextarea = document.getElementById('snipx-editor-textarea')
2+
const snipxEditorTextarea = document.getElementById(`snipx-editor-textarea-${localStorage.getItem('SnipXFile')}`)
33

44
snipxEditorClearBtn.addEventListener('click', (e) => {
5+
// console.log(snipxEditorTextarea.value)
56
snipxEditorTextarea.value = ''
7+
// window.location.reload()
68
})

src/js/FileLockToggle.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const snipxEditorFileLock = document.getElementById('snipx-editor-action-locked')
2+
const snipxEditorFileUnlock = document.getElementById('snipx-editor-action-unlocked')
3+
4+
if(localStorage.getItem('SnipXFileIsLocked')) {
5+
snipxEditorFileUnlock.style.display = 'none'
6+
}
7+
else snipxEditorFileLock.style.display = 'none'
8+
9+
function fileLock() {
10+
snipxEditorFileUnlock.style.display = 'none'
11+
snipxEditorFileLock.style.display = 'inline-block'
12+
}
13+
function fileUnlock() {
14+
snipxEditorFileLock.style.display = 'none'
15+
snipxEditorFileUnlock.style.display = 'inline-block'
16+
}
17+
if(!localStorage.getItem('SnipXFileIsLocked')) {
18+
localStorage.setItem('SnipXFileIsLocked', false)
19+
snipxEditorFileUnlock.style.display = 'none'
20+
snipxEditorFileLock.style.display = 'inline-block'
21+
}
22+
else {
23+
if(localStorage.getItem('SnipXFileIsLocked') === true) {
24+
snipxEditorFileLock.style.display = 'none'
25+
snipxEditorFileUnlock.style.display = 'inline-block'
26+
}
27+
if(localStorage.getItem('SnipXFileIsLocked') === false) {
28+
snipxEditorFileUnlock.style.display = 'none'
29+
snipxEditorFileLock.style.display = 'inline-block'
30+
}
31+
}
32+
33+
// Lock File
34+
snipxEditorFileLock.addEventListener('click', (e) => {
35+
localStorage.setItem('SnipXFileIsLocked', true)
36+
fileUnlock()
37+
})
38+
// Unlock File
39+
snipxEditorFileUnlock.addEventListener('click', (e) => {
40+
localStorage.setItem('SnipXFileIsLocked', false)
41+
fileLock()
42+
})

src/js/FileToggle.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ snipxFileType.addEventListener('change', (e) => {
2727
snipxMenuCSS.setAttribute('selected', true)
2828
snipxEditorJS.style.display = 'none'
2929
snipxEditorCSS.style.display = 'block'
30+
window.location.reload()
3031
break
3132
case 'js':
3233
snipxMenuJS.setAttribute('selected', true)
3334
snipxEditorCSS.style.display = 'none'
3435
snipxEditorJS.style.display = 'block'
36+
window.location.reload()
3537
break
3638
default:
3739
return undefined

src/js/FileVisibilityToggle.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const snipxEditorFileRender = document.getElementById('snipx-editor-action-shown')
2+
const snipxEditorFileRemoveRender = document.getElementById('snipx-editor-action-hidden')
3+
4+
if(localStorage.getItem('SnipXFileIsRendered') === true) {
5+
snipxEditorFileRender.style.display = 'none'
6+
snipxEditorFileRemoveRender.style.display = 'inline-block'
7+
}
8+
else {
9+
snipxEditorFileRemoveRender.style.display = 'none'
10+
snipxEditorFileRender.style.display = 'inline-block'
11+
}
12+
13+
snipxEditorFileRender.addEventListener('click', (e) => {
14+
localStorage.setItem('SnipXFileIsRendered', false)
15+
snipxEditorFileRender.style.display = 'none'
16+
snipxEditorFileRemoveRender.style.display = 'inline-block'
17+
})
18+
19+
snipxEditorFileRemoveRender.addEventListener('click', (e) => {
20+
localStorage.setItem('SnipXFileIsRendered', true)
21+
snipxEditorFileRemoveRender.style.display = 'none'
22+
snipxEditorFileRender.style.display = 'inline-block'
23+
})

src/js/InsertPage.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(!localStorage.getItem('SnipXPage')) {
2+
localStorage.setItem('SnipXPage', 'editor')
3+
const settings = document.getElementById('snipx-settings')
4+
const editor = document.getElementById(`snipx-editor-textarea-${localStorage.getItem('SnipXFile')}`)
5+
settings.style.display = 'none'
6+
editor.style.display = 'block'
7+
}
8+
else {
9+
if(localStorage.getItem('SnipXPage') === 'editor') {
10+
const settings = document.getElementById('snipx-settings')
11+
const editor = document.getElementById(`snipx-editor-textarea-${localStorage.getItem('SnipXFile')}`)
12+
settings.style.display = 'none'
13+
editor.style.display = 'block'
14+
}
15+
if(localStorage.getItem('SnipXPage') === 'settings') {
16+
const editor = document.getElementById('snipx-editor')
17+
const settings = document.getElementById('snipx-settings')
18+
editor.style.display = 'none'
19+
settings.style.display = 'block'
20+
}
21+
}

src/js/InsertURL.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ chrome.tabs.query({
44
active: true,
55
currentWindow: true
66
}, ([currentTab]) => {
7+
// Take only the domain name and remove everything else
78
let array = currentTab.url.split('')
89
let newArray = []
910
let slashCount = 0

src/js/SettingsClose.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ const snipxSettingsCloserIcon = document.getElementById('snipx-settings-closer')
55
snipxSettingsCloserIcon.addEventListener('click', (e) => {
66
snipxSettingsTemplate.style.display = 'none'
77
snipxEditorTemplate.style.display = 'block'
8+
localStorage.setItem('SnipXPage', 'editor')
89
})

0 commit comments

Comments
 (0)