Files
thetempusproject/app/plugins/notes/js/notes.js
2024-08-04 21:15:59 -04:00

32 lines
1019 B
JavaScript

function setIcon(iconName, iconText) {
document.getElementById('iconValue').value = iconName;
document.getElementById('selected-icon').innerHTML = '<span class="glyphicon glyphicon-' + iconName + '"></span> ' + iconText;
}
$( document ).ready( function () {
function autosave() {
var title = $( "#title" ).val();
var color = $( "#color" ).val();
var notebookID = $( "#notebookID" ).val();
var noteID = $( "#noteID" ).val();
var note = $( "#note" ).val();
$.post( "/notes/autoUpdate/" + noteID, {
title: title,
color: color,
notebookID: notebookID,
note: note,
});
console.log( 'note saved' );
}
var lastSegment = window.location.pathname.split('/').pop();
if (!isNaN(lastSegment)) {
if (window.location.pathname.endsWith('/notes/byNote/'+lastSegment)) {
console.log( 'autosave enabled' );
setInterval(autosave, 60 * 1000);
}
}
});