Merge pull request #20 from andre-d/master

Use in-memory deletion keys
This commit is contained in:
ultramancool 2015-07-10 15:31:12 -04:00
commit de9532ac43
2 changed files with 18 additions and 2 deletions

View file

@ -1,5 +1,6 @@
upload.modules.addmodule({
name: 'download',
delkeys: {},
// Dear santa, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings
template: '\
<div class="modulecontent" id="dlarea">\
@ -89,7 +90,15 @@ upload.modules.addmodule({
this._.filename.text(data.header.name)
this._.title.text(data.header.name + ' - Up1')
var stored = localStorage.getItem('delete-' + data.ident)
var stored = this.delkeys[data.ident]
if (!stored) {
try {
stored = localStorage.getItem('delete-' + data.ident)
} catch (e) {
console.log(e)
}
}
if (stored && !isiframed()) {
this._.deletebtn.show().prop('href', (upload.config.server ? upload.config.server : '') + 'del?delkey=' + stored + '&ident=' + data.ident)

View file

@ -136,7 +136,14 @@ upload.modules.addmodule({
upload.textpaste.render(this._.view, 'Pasted text.txt', data, 'text/plain', this.closepaste.bind(this))
},
uploaded: function (data, response) {
localStorage.setItem('delete-' + data.ident, response.delkey)
upload.download.delkeys[data.ident] = response.delkey
try {
localStorage.setItem('delete-' + data.ident, response.delkey)
} catch (e) {
console.log(e)
}
if (window.location.hash == '#noref') {
history.replaceState(undefined, undefined, '#' + data.seed)
upload.route.setroute(upload.download, undefined, data.seed)