Skip to content

Commit f7eadcd

Browse files
authored
Updates (#29)
* Updates * Cleanup Popup * Fix media container on resize * Update Default Options
1 parent 1f2badb commit f7eadcd

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

src/html/options.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!doctype html>
2-
<html lang="en" data-bs-theme="dark" class="h-100">
2+
<html lang="en" class="h-100" data-bs-theme="dark">
33
<head>
4+
<meta charset="utf-8">
45
<title>Django Files Options</title>
56
<link rel="icon" href="../media/logo16.png" sizes="any">
67
<link rel="stylesheet" type="text/css" href="../dist/bootstrap/bootstrap.min.css">

src/html/popup.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4+
<meta charset="utf-8">
45
<title>Django Files</title>
56
<link rel="icon" href="../media/logo16.png" sizes="any">
67
<link rel="stylesheet" type="text/css" href="../dist/bootstrap/bootstrap.min.css">
@@ -11,19 +12,20 @@
1112
</head>
1213
<body>
1314

14-
<div id="media-outer" class="d-none position-fixed top-0 p-1 w-100">
15-
<img id="media-image" src="../media/loading.gif" alt="" class="d-block img-thumbnail rounded border-white mx-auto mw-100">
16-
</div>
17-
1815
<div class="container-fluid p-2">
16+
<div id="media-outer" class="d-none position-fixed top-0 p-1 w-100">
17+
<img id="media-image" src="../media/loading.gif" alt="" class="d-block img-thumbnail rounded border-white mx-auto mw-100">
18+
</div>
19+
1920
<div class=" mb-1">
20-
<a id="always-auth" class="d-none btn btn-sm btn-outline-secondary disabled float-start me-3 add-auth" role="button">
21-
<i class="fa-solid fa-key"></i></a>
22-
<div class="form-check form-switch float-start form-select-lg" style="padding-top: 1px; padding-bottom: 0;"
21+
<div class="form-check form-switch float-start form-select-lg me-2" style="padding-top: 1px; padding-bottom: 0;"
2322
data-bs-title="Disable/Enable Mouseover Preview." data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-trigger="hover">
2423
<input class="form-check-input" id="popupPreview" type="checkbox" role="switch">
2524
<label class="form-check-label visually-hidden" for="popupPreview" aria-describedby="popupPreviewHelp"></label>
2625
</div>
26+
<a id="always-auth" class="d-none btn btn-sm btn-outline-warning float-start add-auth" role="button"
27+
data-bs-title="Update Authentication with Current Site." data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-trigger="hover">
28+
<i class="fa-solid fa-key"></i></a>
2729
<a class="btn btn-sm btn-outline-primary float-end" role="button" href="../html/options.html" title="Options">
2830
<i class="fa-solid fa-gears"></i></a>
2931
<div class="d-flex align-items-center justify-content-center">

src/js/popup.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,20 @@ let timeout
3434
*/
3535
async function initPopup() {
3636
console.log('initPopup')
37+
38+
// Get options
3739
const { options } = await chrome.storage.sync.get(['options'])
3840
console.log('options:', options)
3941

40-
// Set Options (since this is the only one)
42+
// Set Options (this is currently the only one in the popup)
4143
document.getElementById('popupPreview').checked = options.popupPreview
4244

45+
// Ensure authError is set to false
4346
authError = false
47+
4448
// Check auth if checkAuth is enabled in options
4549
if (options.checkAuth) {
46-
alwaysAuth.classList.remove('d-none')
50+
await checkSiteAuth()
4751
}
4852

4953
// If missing auth data or options.checkAuth check current site for auth
@@ -103,14 +107,7 @@ async function initPopup() {
103107
return displayAlert({ message: 'No Files Returned.' })
104108
}
105109

106-
// Check auth if checkAuth is enabled in options
107-
if (options.checkAuth) {
108-
alwaysAuth.classList.remove('d-none')
109-
await checkSiteAuth()
110-
}
111-
112-
// Hide loading display table, update table
113-
// loadingTable.classList.add('d-none')
110+
// Update table should only be called here, changes should use initPopup()
114111
updateTable(data)
115112

116113
// Re-init clipboardJS and popupLinks after updateTable
@@ -168,8 +165,7 @@ async function onMessage(message) {
168165
await chrome.storage.local.set({ auth })
169166
console.log('New Authentication Found.')
170167
if (options.checkAuth) {
171-
alwaysAuth.classList.remove('disabled', 'btn-outline-secondary')
172-
alwaysAuth.classList.add('btn-warning')
168+
alwaysAuth.classList.remove('d-none')
173169
}
174170
if (authError) {
175171
authButton.classList.remove('d-none')
@@ -222,7 +218,7 @@ async function authCredentials(event) {
222218
console.log('Auth Credentials Updated...')
223219
authButton.classList.add('d-none')
224220
errorAlert.classList.add('d-none')
225-
alwaysAuth.classList.add('disabled', 'btn-outline-secondary')
221+
alwaysAuth.classList.add('d-none')
226222
await initPopup()
227223
} else {
228224
displayAlert({ message: 'Error Getting or Setting Credentials.' })

src/js/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ async function onInstalled(details) {
2121
popupTimeout: 3,
2222
contextMenu: true,
2323
popupPreview: true,
24+
checkAuth: true,
2425
showUpdate: false,
25-
checkAuth: false,
2626
})
2727
)
2828
console.log('options:', options)

0 commit comments

Comments
 (0)