From 55b0a366cffb8761de4a28248dfdbd803a07142f Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Sep 12 2017 19:46:31 +0000 Subject: Fixes #23 This commit is dedicated to Schoumi, who is supporting me on Tipeee. Many thanks :-) --- diff --git a/CHANGELOG b/CHANGELOG index 2e49c35..f8a3763 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ Revision history for Lufi - Portuguese translation - Catalan translation - IE 11 support + - Deleting files from "My files" is now done with Ajax (#23) - Bugfixes 0.01 2017-01-09 diff --git a/themes/default/public/js/lufi-files.js b/themes/default/public/js/lufi-files.js index 74e7719..7315dc2 100644 --- a/themes/default/public/js/lufi-files.js +++ b/themes/default/public/js/lufi-files.js @@ -106,6 +106,30 @@ function importStorage(f) { reader.readAsArrayBuffer(f[0]); } +function delFile() { + var dlink = $(this).attr('data-dlink'); + var short = $(this).attr('data-short'); + $.ajax({ + url: dlink, + method: 'GET', + data: { + format: 'json' + }, + success: function(data) { + if (data.success) { + $('#row-'+short).remove(); + delItem(short); + } else { + alert(data.msg); + } + }, + error: function() { + }, + complete: function() { + } + }); +} + function populateFilesTable() { $('#myfiles').empty(); @@ -125,7 +149,7 @@ function populateFilesTable() { var limit = (element.delay === 0) ? i18n.noExpiration : moment.unix(element.delay * 86400 + element.created_at).locale(window.navigator.language).format('LLLL'); var created_at = moment.unix(element.created_at).locale(window.navigator.language).format('LLLL'); - var tr = $(''); + var tr = $(''); tr.html([ '', escapeHtml(element.name), '', @@ -144,12 +168,13 @@ function populateFilesTable() { limit, '', '', - '', + '', '', '', '', ''].join('')); $('#myfiles').append(tr); + $('#del-'+element.short).on('click', delFile); $.ajax({ url: counterURL,