mirror of
https://github.com/Luzifer/past3.git
synced 2024-12-22 20:31:16 +00:00
Some small UX improvements
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
74290c0647
commit
c31b86d22a
1 changed files with 24 additions and 6 deletions
30
app.js
30
app.js
|
@ -28,6 +28,8 @@ function deleteFile(filename) {
|
||||||
Bucket: window.past3_config.bucket,
|
Bucket: window.past3_config.bucket,
|
||||||
Key: getFilePrefix() + filename,
|
Key: getFilePrefix() + filename,
|
||||||
}, fileActionCallback)
|
}, fileActionCallback)
|
||||||
|
|
||||||
|
window.localStorage.removeItem(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
// error displays the error in the frontend
|
// error displays the error in the frontend
|
||||||
|
@ -71,6 +73,20 @@ function getAWSCredentials(googleIDToken) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getCurrentFileListEntry returns the element of the currently loaded file list entry
|
||||||
|
function getCurrentFileListEntry() {
|
||||||
|
let filename = $('#filename').val()
|
||||||
|
let resp = null
|
||||||
|
|
||||||
|
$(".file-list-item").each((idx, e) => {
|
||||||
|
if ($(e).data('file') === filename) {
|
||||||
|
resp = $(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
// getFile retrieves an object from the bucket and loads it into the editor
|
// getFile retrieves an object from the bucket and loads it into the editor
|
||||||
function getFile(filename) {
|
function getFile(filename) {
|
||||||
let s3 = new AWS.S3()
|
let s3 = new AWS.S3()
|
||||||
|
@ -144,6 +160,9 @@ function init() {
|
||||||
text: btoa(cm.getValue()),
|
text: btoa(cm.getValue()),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cf = getCurrentFileListEntry()
|
||||||
|
if (cf) cf.find('i').removeClass('fa-file').addClass('fa-file-upload')
|
||||||
})
|
})
|
||||||
|
|
||||||
// Set up bindings
|
// Set up bindings
|
||||||
|
@ -173,11 +192,8 @@ function init() {
|
||||||
getFile(filename)
|
getFile(filename)
|
||||||
|
|
||||||
$('.file-list-item').removeClass('active')
|
$('.file-list-item').removeClass('active')
|
||||||
$(".file-list-item").each(() => {
|
let cf = getCurrentFileListEntry()
|
||||||
if ($(this).data('file') == filename) {
|
if (cf) cf.addClass('active')
|
||||||
$(this).addClass('active')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -253,7 +269,9 @@ function loadFileList(err, data) {
|
||||||
|
|
||||||
let fileIcon = 'file-alt'
|
let fileIcon = 'file-alt'
|
||||||
if (window.localStorage.getItem(key) !== null) {
|
if (window.localStorage.getItem(key) !== null) {
|
||||||
fileIcon = 'file-signature'
|
fileIcon = 'file-upload'
|
||||||
|
} else if (obj.Size === 0) {
|
||||||
|
fileIcon = 'file'
|
||||||
}
|
}
|
||||||
|
|
||||||
let li = $(`<a href='#${key}' class='list-group-item file-list-item'><span class='badge'></span> <i class="fas fa-fw fa-${fileIcon}"></i> ${key}</a>`)
|
let li = $(`<a href='#${key}' class='list-group-item file-list-item'><span class='badge'></span> <i class="fas fa-fw fa-${fileIcon}"></i> ${key}</a>`)
|
||||||
|
|
Loading…
Reference in a new issue