Skip to content

Commit f82dcd7

Browse files
authored
Fix Popup Timeout (#30)
* Fix Popup Timeout * Fix Media Width * Revert Media Outer * Add mediaOuter d-none to Auth * Add Error Alert * Add view=gallery for the future
1 parent f7eadcd commit f82dcd7

File tree

6 files changed

+36
-15
lines changed

6 files changed

+36
-15
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ and upload any Image, Video or Audio files with right click.
2323
* [Install](#install)
2424
* [Features](#features)
2525
* [Configure](#configure)
26-
* [Known Building](#building)
26+
* [Setup](#setup)
27+
* [Building](#building)
2728
* [Development](#development)
2829

2930
# Install
@@ -45,15 +46,20 @@ All Chromium Based Browsers can install the extension from the
4546
## Features
4647

4748
* View Recent Uploads on Popup
48-
* Right Click to Upload any Image, Video, or Audio
49-
* Right Click to Shorten any URL
49+
* Preview Popup Images on Hover.
50+
* Right Click any Image, Video, or Audio to Upload.
51+
* Right Click any URL to Shorten.
52+
* Automatically Auth with Django Files.
53+
* Automatic Dark/Light Mode based on Browser Settings.
5054

5155
## Configure
5256

5357
You can pin the Addon by clicking the `Puzzle Piece`, find the `Django Files icon`, then;
5458
**Firefox**, click the `Settings Wheel` and `Pin to Toolbar`.
5559
**Chrome**, click the `Pin` icon.
5660

61+
## Setup
62+
5763
To automatically configure the web extension to work with your Django Files instance do the following:
5864

5965
- Log in to your Django Files Instance
@@ -62,8 +68,8 @@ To automatically configure the web extension to work with your Django Files inst
6268

6369
The addon should now be configured to work with your Django Files instance.
6470

65-
You can now click the Django Files icon to view your recent uploads.
66-
Right-click on any Image, Video, Audio, or URL upload to Django Files or Shorten URL.
71+
You can now click the Django Files icon to view your recent uploads or open Options.
72+
Right-click on any Image, Video, Audio, or URL upload to Django Files or Shorten URL.
6773

6874
# Development
6975

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"manifest_version": 3,
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"name": "Django Files",
55
"description": "Django Files Web Extension designed to work with github.com/django-files/django-files.",
66
"homepage_url": "https://github.com/django-files/web-extension",

src/css/popup.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ body {
1111

1212
#media-image {
1313
max-height: 44vh;
14-
max-width: 100%;
1514
background-color: #303030;
1615
}

src/html/popup.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@
1212
</head>
1313
<body>
1414

15-
<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">
15+
<div id="media-outer" class="d-none position-fixed top-0 p-1 w-100">
16+
<img id="media-image" src="../media/loading.gif" alt="" class="d-block img-thumbnail rounded border-white mx-auto mw-100">
17+
<div id="media-error" class="d-flex align-items-center justify-content-center d-none">
18+
<div class="alert alert-danger text-center d-inline-block" role="alert">
19+
<i class="fa-solid fa-triangle-exclamation me-2"></i> Error Loading Image!<br>
20+
Inspect Popup for More Details...
21+
</div>
1822
</div>
23+
</div>
24+
25+
<div class="container-fluid p-2">
1926

2027
<div class=" mb-1">
2128
<div class="form-check form-switch float-start form-select-lg me-2" style="padding-top: 1px; padding-bottom: 0;"

src/js/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// JS for options.html
22

3-
document.addEventListener('DOMContentLoaded', initOptions)
43
chrome.storage.onChanged.addListener(onChanged)
4+
document.addEventListener('DOMContentLoaded', initOptions)
55
document
66
.querySelectorAll('input')
77
.forEach((el) => el.addEventListener('change', saveOptions))

src/js/popup.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// JS for popup.html
22

3-
document.addEventListener('DOMContentLoaded', initPopup)
43
chrome.runtime.onMessage.addListener(onMessage)
4+
document.addEventListener('DOMContentLoaded', initPopup)
55
document
66
.querySelectorAll('a[href]')
77
.forEach((el) => el.addEventListener('click', popupLinks))
@@ -21,6 +21,7 @@ const authButton = document.getElementById('auth-button')
2121
const mediaImage = document.getElementById('media-image')
2222
const mediaOuter = document.getElementById('media-outer')
2323
const alwaysAuth = document.getElementById('always-auth')
24+
const mediaError = document.getElementById('media-error')
2425

2526
const loadingImage = '../media/loading.gif'
2627
let authError = false
@@ -117,9 +118,9 @@ async function initPopup() {
117118
.forEach((el) => el.addEventListener('click', popupLinks))
118119

119120
// Enable Popup Mouseover Preview if popupPreview
121+
timeout = options.popupTimeout * 1000
120122
if (options.popupPreview) {
121123
console.log('Enabling Mouseover Preview')
122-
timeout = options.popupTimeout * 1000
123124
initPopupMouseover()
124125
}
125126
}
@@ -219,6 +220,7 @@ async function authCredentials(event) {
219220
authButton.classList.add('d-none')
220221
errorAlert.classList.add('d-none')
221222
alwaysAuth.classList.add('d-none')
223+
mediaOuter.classList.add('d-none')
222224
await initPopup()
223225
} else {
224226
displayAlert({ message: 'Error Getting or Setting Credentials.' })
@@ -311,7 +313,10 @@ function updateTable(data) {
311313
'link-underline-opacity-75-hover'
312314
)
313315
link.target = '_blank'
314-
link.dataset.raw = url.origin + url.pathname.replace(/^\/u\//, '/raw/')
316+
link.dataset.raw =
317+
url.origin +
318+
url.pathname.replace(/^\/u\//, '/raw/') +
319+
'?view=gallery'
315320
const cell1 = row.cells[1]
316321
cell1.classList.add('text-break')
317322
cell1.innerHTML = ''
@@ -380,7 +385,9 @@ function initPopupMouseover() {
380385
})
381386
mediaImage.addEventListener('error', (event) => {
382387
console.log('mediaError:', event)
383-
mediaImage.src = '../media/error.png'
388+
mediaImage.classList.add('d-none')
389+
mediaError.classList.remove('d-none')
390+
mediaImage.src = '../media/loading.gif'
384391
})
385392
document.querySelectorAll('.link-underline').forEach((el) => {
386393
el.addEventListener('mouseover', onMouseOver)
@@ -390,6 +397,8 @@ function initPopupMouseover() {
390397

391398
function onMouseOver(event) {
392399
// console.log('onMouseOver:', event)
400+
mediaError.classList.add('d-none')
401+
mediaImage.classList.remove('d-none')
393402
if (event.pageY < window.innerHeight / 2) {
394403
mediaOuter.classList.remove('top-0')
395404
mediaOuter.classList.add('bottom-0')

0 commit comments

Comments
 (0)