mirror of https://github.com/espruino/BangleApps
[sleeplog] Correct deleteBefore function 4
parent
1b467cfa99
commit
983878647a
|
@ -101,18 +101,18 @@ function deleteFile(filename, callback) {
|
|||
|
||||
function deleteBefore(dateString) {
|
||||
date = new Date(dateString);
|
||||
if (window.confirm("Do you really want to remove all data before" + date.toLocaleDateString(undefined))) {
|
||||
if (window.confirm("Do you really want to remove all data before " + date.toLocaleDateString(undefined))) {
|
||||
Util.showModal("Deleting all data before" + date.toLocaleDateString(undefined) + " ...");
|
||||
Puck.eval(`require("Storage").list(/^sleeplog_\\d+.log$/)`, files => {
|
||||
files = files.filter(file => (parseInt(file.match(/\\d+/)[0]) + 0.25) * 12096E5 < date);
|
||||
total = "" + files.length
|
||||
files.forEach((file, i) => {
|
||||
Util.showModal("Deleting file " + ("" + (i + 1)).padStart(total.length) + "/" + total + ": " + file);
|
||||
Util.eraseStorage(filename);
|
||||
})
|
||||
});
|
||||
Util.hideModal();
|
||||
callback();
|
||||
Puck.eval(`require("Storage").list(/^sleeplog_\\d+.log$/).forEach(file => {
|
||||
date = (parseInt(file.match(/\\d+/)[0]) + 0.25) * 12096E5
|
||||
print(date < ` + date + `)
|
||||
if (date < ` + date + `) {
|
||||
require("Storage").erase(file)
|
||||
}
|
||||
})`, () => {
|
||||
Util.hideModal();
|
||||
callback();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ function viewFiles() {
|
|||
<input class="form-input" id="delBeforeDate" type="date" value="2022-01-01">
|
||||
</div>
|
||||
<div class="col-mx-auto">
|
||||
<button class="btn tooltip btn-error" data-tooltip="delete old files" task="delBefore" filename="" date="">
|
||||
<button class="btn tooltip btn-error" data-tooltip="delete old files" task="delBefore" filename="_" date="_">
|
||||
<i class="icon icon-delete"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue