2018-10-08 19:30:22 +00:00
|
|
|
/* global page */
|
|
|
|
|
|
|
|
page.prepareShareX = function () {
|
|
|
|
if (!page.token) { return }
|
|
|
|
var origin = (location.hostname + location.pathname).replace(/\/(dashboard)?$/, '')
|
|
|
|
var originClean = origin.replace(/\//g, '_')
|
|
|
|
var sharexElement = document.getElementById('ShareX')
|
|
|
|
var sharexFile =
|
|
|
|
'{\r\n' +
|
|
|
|
' "Name": "' + originClean + '",\r\n' +
|
|
|
|
' "DestinationType": "ImageUploader, FileUploader",\r\n' +
|
|
|
|
' "RequestType": "POST",\r\n' +
|
2018-10-08 19:33:06 +00:00
|
|
|
' "RequestURL": "' + location.protocol + '//' + origin + '/api/upload",\r\n' +
|
2018-10-08 19:30:22 +00:00
|
|
|
' "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', originClean + '.sxcu')
|
|
|
|
}
|