Add saveFailCounter
Fix bug with not clearing noteId Refactor a class removal and additions Add script.min.js
This commit is contained in:
parent
4d55711190
commit
c2c08db342
@ -8,6 +8,7 @@ let saveTimeout = 15000;
|
|||||||
var to = null;
|
var to = null;
|
||||||
let controller;
|
let controller;
|
||||||
var BOOKS = {};
|
var BOOKS = {};
|
||||||
|
let saveFailCounter = 0;
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
setHeight();
|
setHeight();
|
||||||
@ -160,6 +161,7 @@ function newNote() {
|
|||||||
document.querySelector('#template').value = 0;
|
document.querySelector('#template').value = 0;
|
||||||
document.querySelector('#passage').value = '';
|
document.querySelector('#passage').value = '';
|
||||||
document.querySelector('#recording').value = '';
|
document.querySelector('#recording').value = '';
|
||||||
|
document.querySelector('#noteId').value = '';
|
||||||
|
|
||||||
document.querySelector('#ref-list').innerHTML = '';
|
document.querySelector('#ref-list').innerHTML = '';
|
||||||
document.querySelector('#ref').innerHTML = '';
|
document.querySelector('#ref').innerHTML = '';
|
||||||
@ -209,8 +211,7 @@ function saveNote(event) {
|
|||||||
})
|
})
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
if (data.msg == 'saved' && !saved) {
|
if (data.msg == 'saved' && !saved) {
|
||||||
saveCheck.classList.remove('saving');
|
saveCheck.classList.remove('saving', 'error', 'fa-times', 'fa-check');
|
||||||
saveCheck.classList.remove('error');
|
|
||||||
showSave();
|
showSave();
|
||||||
if (noteText == document.querySelector('#notes').value) {
|
if (noteText == document.querySelector('#notes').value) {
|
||||||
saved = true;
|
saved = true;
|
||||||
@ -224,17 +225,22 @@ function saveNote(event) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function (xhr, status, error) {
|
.fail(function (xhr, status, error) {
|
||||||
saveCheck.classList.remove('saving');
|
saveFailCounter++;
|
||||||
saveCheck.classList.add('error');
|
saveCheck.classList.remove('saving', 'fa-check');
|
||||||
|
saveCheck.classList.add('fa-times', 'error');
|
||||||
console.error(error);
|
console.error(error);
|
||||||
})
|
})
|
||||||
.always(function (xhr, status) {
|
.always(function (xhr, status) {
|
||||||
if (status == 'timeout') {
|
if (status == 'timeout') {
|
||||||
saveCheck.classList.remove('saving');
|
saveCheck.classList.remove('saving', 'fa-check');
|
||||||
saveCheck.classList.add('error');
|
saveCheck.classList.add('error', 'fa-times');
|
||||||
}
|
}
|
||||||
clearTimeout(to);
|
clearTimeout(to);
|
||||||
to = setTimeout(saveNote, saveTimeout);
|
if (saveFailCounter < 5) {
|
||||||
|
to = setTimeout(saveNote, saveTimeout);
|
||||||
|
} else {
|
||||||
|
saveFailCounter = 0;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +268,8 @@ function isUuidValid(uuid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startSave() {
|
function startSave() {
|
||||||
document.querySelector('#save-check').classList.add('saving');
|
document.querySelector('#save-check').classList.remove('error', 'fa-times', 'fa-check');
|
||||||
|
document.querySelector('#save-check').classList.add('saving', 'fa-check');
|
||||||
document.querySelector('#save-check').style.opacity = 1;
|
document.querySelector('#save-check').style.opacity = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,6 +283,7 @@ function showSave() {
|
|||||||
if (saved) { return; }
|
if (saved) { return; }
|
||||||
|
|
||||||
var checkmark = document.getElementById("save-check");
|
var checkmark = document.getElementById("save-check");
|
||||||
|
checkmark.classList.add('fa-check');
|
||||||
|
|
||||||
// Schedule the animation to run every 1 second (which is equivalent to a 1-second delay between each iteration)
|
// Schedule the animation to run every 1 second (which is equivalent to a 1-second delay between each iteration)
|
||||||
var si = setInterval(function () {
|
var si = setInterval(function () {
|
||||||
|
1
public/js/script.min.js
vendored
Normal file
1
public/js/script.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user