Updated dashboard

* Added "ShareX user profile" menu item to administration sidebar. This do the same thing as the ShareX icon in the homepage, which is to download a ShareX config.

* Updated version string in _globals.njk. A few of the previous commits also modified some JS files, but I forgot to update the version string back then.
This commit is contained in:
Bobby Wibowo 2018-09-07 22:22:17 +07:00
parent 2bfe24758c
commit 8e74c7f5bd
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
4 changed files with 31 additions and 1 deletions

View File

@ -110,6 +110,8 @@ page.prepareDashboard = function () {
logoutBtn.innerHTML = 'Logout ( ' + page.username + ' )'
page.getAlbumsSidebar()
page.prepareShareX()
}
page.logout = function () {
@ -1395,6 +1397,30 @@ page.setActiveMenu = function (activeItem) {
activeItem.classList.add('is-active')
}
page.prepareShareX = function () {
if (page.token) {
// TODO: "location.origin" is unsuitable if the safe is hosted in a subdir (e.i. http://example.com/safe)
var sharexElement = document.getElementById('ShareX')
var sharexFile =
'{\r\n' +
' "Name": "' + location.hostname + '",\r\n' +
' "DestinationType": "ImageUploader, FileUploader",\r\n' +
' "RequestType": "POST",\r\n' +
' "RequestURL": "' + location.origin + '/api/upload",\r\n' +
' "FileFormName": "files[]",\r\n' +
' "Headers": {\r\n' +
' "token": "' + page.token + '"\r\n' +
' },\r\n' +
' "ResponseType": "Text",\r\n' +
' "URL": "$json:files[0].url$",\r\n' +
' "ThumbnailURL": "$json:files[0].url$"\r\n' +
'}'
var sharexBlob = new Blob([sharexFile], { type: 'application/octet-binary' })
sharexElement.setAttribute('href', URL.createObjectURL(sharexBlob))
sharexElement.setAttribute('download', location.hostname + '.sxcu')
}
}
window.onload = function () {
// Add 'no-touch' class to non-touch devices
if (!('ontouchstart' in document.documentElement)) {

View File

@ -393,6 +393,7 @@ page.updateTemplate = function (file, response) {
page.prepareShareX = function () {
if (page.token) {
// TODO: "location.origin" is unsuitable if the safe is hosted in a subdir (e.i. http://example.com/safe)
var sharexElement = document.getElementById('ShareX')
var sharexFile =
'{\r\n' +

View File

@ -15,7 +15,7 @@
v2: Images and config files (manifest.json, browserconfig.xml, etc).
v3: CSS and JS files (libs such as bulma, lazyload, etc).
#}
{% set v1 = "IooRwmMNti" %}
{% set v1 = "SLAsa9Rk5w" %}
{% set v2 = "Ii3JYKIhb0" %}
{% set v3 = "HrvcYD3KTh" %}

View File

@ -70,6 +70,9 @@
</ul>
<p class="menu-label">Administration</p>
<ul class="menu-list">
<li>
<a id="ShareX">ShareX user profile</a>
</li>
<li>
<a id="itemFileLength">File name length</a>
</li>