Add profile data

This commit is contained in:
Ryan Prather 2024-06-23 22:40:50 -04:00
parent 87fb461c26
commit 752b2a291e
3 changed files with 24 additions and 23 deletions

View File

@ -4,11 +4,9 @@ var references = {};
var tabs = []; var tabs = [];
let saved = false; let saved = false;
let textDirty = false; let textDirty = false;
let saveTimeout = 15000;
var to = null; var to = null;
let controller; let controller;
var BOOKS = {}; var BOOKS = {};
let saveFailCounter = 0;
$(function () { $(function () {
setHeight(); setHeight();
@ -105,7 +103,7 @@ function setHeight() {
}); });
} }
if (!to) { if (!to) {
to = setTimeout(saveNote, saveTimeout); to = setTimeout(saveNote, saveInterval);
} }
} }
@ -181,7 +179,7 @@ function saveNote(event) {
if (!textDirty || !validateNote()) { if (!textDirty || !validateNote()) {
clearTimeout(to); clearTimeout(to);
to = setTimeout(saveNote, saveTimeout); to = setTimeout(saveNote, saveInterval);
return; return;
} }
@ -207,11 +205,12 @@ function saveNote(event) {
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify(note), data: JSON.stringify(note),
dataType: 'json', dataType: 'json',
timeout: 5000 timeout: saveTimeout
}) })
.done(function (data) { .done(function (data) {
if (data.msg == 'saved' && !saved) { if (data.msg == 'saved' && !saved) {
saveCheck.classList.remove('saving', 'error', 'fa-times', 'fa-check'); saveFailureCount = SAVE_FAILURE_LIMIT;
saveCheck.classList.remove('saving', 'error', 'fa-times-circle', 'fa-save');
showSave(); showSave();
if (noteText == document.querySelector('#notes').value) { if (noteText == document.querySelector('#notes').value) {
saved = true; saved = true;
@ -225,21 +224,21 @@ function saveNote(event) {
} }
}) })
.fail(function (xhr, status, error) { .fail(function (xhr, status, error) {
saveFailCounter++; saveFailureCount--;
saveCheck.classList.remove('saving', 'fa-check'); saveCheck.classList.remove('saving', 'fa-save');
saveCheck.classList.add('fa-times', 'error'); saveCheck.classList.add('fa-times-circle', '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', 'fa-check'); saveCheck.classList.remove('saving', 'fa-save');
saveCheck.classList.add('error', 'fa-times'); saveCheck.classList.add('error', 'fa-times-circle');
} }
clearTimeout(to); clearTimeout(to);
if (saveFailCounter < 5) { if (saveFailureCount > 0) {
to = setTimeout(saveNote, saveTimeout); to = setTimeout(saveNote, saveInterval);
} else { } else {
saveFailCounter = 0; saveFailureCount = SAVE_FAILURE_LIMIT;
} }
}); });
} }
@ -268,8 +267,8 @@ function isUuidValid(uuid) {
} }
function startSave() { function startSave() {
document.querySelector('#save-check').classList.remove('error', 'fa-times', 'fa-check'); document.querySelector('#save-check').classList.remove('error', 'fa-times-circle', 'fa-save');
document.querySelector('#save-check').classList.add('saving', 'fa-check'); document.querySelector('#save-check').classList.add('saving', 'fa-save');
document.querySelector('#save-check').style.opacity = 1; document.querySelector('#save-check').style.opacity = 1;
} }
@ -283,7 +282,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'); checkmark.classList.add('fa-save');
// 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 () {

File diff suppressed because one or more lines are too long

View File

@ -3227,9 +3227,9 @@ button:disabled,
-webkit-tap-highlight-color: rgba(255, 255, 255, 0); -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
border: 0; border: 0;
display: block; display: block;
height: 7.5em; height: 4.5em;
left: 26em; left: 26em;
line-height: 7.5em; line-height: 4.5em;
outline: 0; outline: 0;
overflow: hidden; overflow: hidden;
position: absolute; position: absolute;
@ -3287,11 +3287,13 @@ button:disabled,
} }
#sidebar .toggle { #sidebar .toggle {
height: 6.25em; height: 4.5em;
left: 24em; left: 24em;
line-height: 6.25em; line-height: 4.5em;
text-indent: 5em; text-indent: 5em;
width: 5em; width: 5em;
background-color: #fff;
margin-left: 1em;
} }
#sidebar .toggle:before { #sidebar .toggle:before {
@ -3336,7 +3338,7 @@ button:disabled,
#sidebar .toggle { #sidebar .toggle {
text-indent: 6em; text-indent: 6em;
width: 6em; width: 4.5em;
} }
#sidebar .toggle:before { #sidebar .toggle:before {