fix: various updates
Add jquery-ui fix uuid validation for other versions expand queryRef method to include parameters converted mouseover to click events for embedded links added additional parameters to openNote and retrieveNote
This commit is contained in:
parent
7506b1156c
commit
090fd864b4
@ -49,11 +49,9 @@ function setHeight() {
|
|||||||
notePreview = document.querySelector('#notePreview');
|
notePreview = document.querySelector('#notePreview');
|
||||||
notePreview.style.height = (window.innerHeight - 50) + 'px';
|
notePreview.style.height = (window.innerHeight - 50) + 'px';
|
||||||
|
|
||||||
date = document.querySelector('#noteDate');
|
if ($('#noteDate')) {
|
||||||
dt = new Date();
|
$('#noteDate').datepicker();
|
||||||
date.value = dt.getFullYear() + '-' +
|
}
|
||||||
((dt.getMonth() < 9) ? '0' + (dt.getMonth() + 1) : (dt.getMonth() + 1)) + '-' +
|
|
||||||
(dt.getDate() < 10 ? '0' + dt.getDate() : dt.getDate());
|
|
||||||
setTimeout(saveNote, saveTimeout);
|
setTimeout(saveNote, saveTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +136,7 @@ function validateNote() {
|
|||||||
const id = document.querySelector('#noteId');
|
const id = document.querySelector('#noteId');
|
||||||
const psg = document.querySelector('#passage');
|
const psg = document.querySelector('#passage');
|
||||||
|
|
||||||
if (!isUuidV4Valid(id.value)) { return false; }
|
if (!isUuidValid(id.value)) { return false; }
|
||||||
if (!title.value.length) { return false; }
|
if (!title.value.length) { return false; }
|
||||||
if (!date.value) { return false; }
|
if (!date.value) { return false; }
|
||||||
if (!parseInt(speaker.value)) { return false; }
|
if (!parseInt(speaker.value)) { return false; }
|
||||||
@ -149,8 +147,8 @@ function validateNote() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUuidV4Valid(uuid) {
|
function isUuidValid(uuid) {
|
||||||
const regex = /^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[8|9|a|b][a-f0-9]{3}-[a-f0-9]{12}$/i;
|
const regex = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[8|9|a|b][a-f0-9]{3}-[a-f0-9]{12}$/i;
|
||||||
return regex.test(uuid);
|
return regex.test(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,19 +301,25 @@ function closeRef() {
|
|||||||
refQuery.style.display = 'none';
|
refQuery.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryRef() {
|
function queryRef(type = null, book = null, input = null) {
|
||||||
var input = document.querySelector('#refQuery #search');
|
if (!input) {
|
||||||
var type = document.querySelector('#referenceType');
|
var input = document.querySelector('#refQuery #search').value;
|
||||||
var book = document.querySelector('#referenceBook');
|
}
|
||||||
|
if (!type) {
|
||||||
|
var type = document.querySelector('#referenceType').value;
|
||||||
|
}
|
||||||
|
if (!book) {
|
||||||
|
var book = document.querySelector('#referenceBook').value;
|
||||||
|
}
|
||||||
fetch('/index.php/retrieve-reference', {
|
fetch('/index.php/retrieve-reference', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
'type': type.value,
|
'type': type,
|
||||||
'book': book.value,
|
'book': book,
|
||||||
'reference': input.value,
|
'reference': input,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
@ -566,9 +570,9 @@ function findLinks() {
|
|||||||
var links = document.querySelector('#notePreview').querySelectorAll('a');
|
var links = document.querySelector('#notePreview').querySelectorAll('a');
|
||||||
|
|
||||||
for (var i = 0; i < links.length; i++) {
|
for (var i = 0; i < links.length; i++) {
|
||||||
links[i].addEventListener('mouseover', function (e) {
|
links[i].addEventListener('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!this.href.contains('notes\.rkprather\.com')) {
|
if (!this.href.includes('get-passage')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var passage = this.href.split('/');
|
var passage = this.href.split('/');
|
||||||
@ -597,7 +601,7 @@ function findLinks() {
|
|||||||
showPassage(
|
showPassage(
|
||||||
e,
|
e,
|
||||||
"<button onclick='closePopup()'>Close</button> " +
|
"<button onclick='closePopup()'>Close</button> " +
|
||||||
"<button onclick=\"getRef('" + book + "', '" + cv + "')\">Open Ref</button><br/>" +
|
"<button onclick=\"queryRef('bible', '" + book + "', '" + cv + "')\">Open Ref</button><br/>" +
|
||||||
result);
|
result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -608,9 +612,9 @@ function findRefLinks() {
|
|||||||
var links = document.querySelector('#ref').querySelectorAll('a');
|
var links = document.querySelector('#ref').querySelectorAll('a');
|
||||||
|
|
||||||
for (var i = 0; i < links.length; i++) {
|
for (var i = 0; i < links.length; i++) {
|
||||||
links[i].addEventListener('mouseover', function (e) {
|
links[i].addEventListener('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!this.href.contains('get-passage')) {
|
if (!this.href.includes('get-passage')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var passage = this.href.split('/');
|
var passage = this.href.split('/');
|
||||||
@ -639,7 +643,7 @@ function findRefLinks() {
|
|||||||
showPassage(
|
showPassage(
|
||||||
e,
|
e,
|
||||||
"<button onclick='closePopup()'>Close</button> " +
|
"<button onclick='closePopup()'>Close</button> " +
|
||||||
"<button onclick=\"getRef('" + book + "', '" + cv + "')\">Open Ref</button><br/>" +
|
"<button onclick=\"queryRef('bible', '" + book + "', '" + cv + "')\">Open Ref</button><br/>" +
|
||||||
result);
|
result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -667,7 +671,7 @@ function closePopup() {
|
|||||||
popup.style.display = 'none';
|
popup.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
function openNote() {
|
function openNote(openSidebar = true) {
|
||||||
const noteList = document.querySelector('#note-list');
|
const noteList = document.querySelector('#note-list');
|
||||||
const refs = document.querySelector('#ref');
|
const refs = document.querySelector('#ref');
|
||||||
|
|
||||||
@ -679,10 +683,12 @@ function openNote() {
|
|||||||
refs.style.display = 'none';
|
refs.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (openSidebar) {
|
||||||
document.querySelector('.toggle').click();
|
document.querySelector('.toggle').click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function retrieveNote(id) {
|
function retrieveNote(id, runOpen = true) {
|
||||||
fetch('/index.php/get-note', {
|
fetch('/index.php/get-note', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
header: {
|
header: {
|
||||||
@ -694,23 +700,26 @@ function retrieveNote(id) {
|
|||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(result => {
|
.then(result => {
|
||||||
var dt = new Date(result.date);
|
var dt = new Date(result.date.date);
|
||||||
|
|
||||||
document.querySelector('#notes').value = result.text;
|
document.querySelector('#notes').value = result.text;
|
||||||
document.querySelector('#passage').value = result.passage;
|
document.querySelector('#passage').value = result.passage;
|
||||||
document.querySelector('#series').value = result.series.id;
|
document.querySelector('#series').value = result.series.id;
|
||||||
document.querySelector('#speaker').value = result.speaker.id;
|
document.querySelector('#speaker').value = result.speaker.id;
|
||||||
document.querySelector('#noteTitle').value = result.title;
|
document.querySelector('#noteTitle').value = result.title;
|
||||||
document.querySelector('#noteDate').value = dt.getFullYear() + '-' +
|
document.querySelector('#noteDate').value = '';
|
||||||
(dt.getMonth() < 9 ? '0' + (dt.getMonth() + 1) : (dt.getMonth() + 1)) + '-' +
|
document.querySelector('#noteDate').value =
|
||||||
(dt.getDate() < 10 ? '0' + dt.getDate() : dt.getDate());
|
(dt.getMonth() < 9 ? '0' + (dt.getMonth() + 1) : (dt.getMonth() + 1)) + '/' +
|
||||||
|
(dt.getDate() < 10 ? '0' + dt.getDate() : dt.getDate()) + '/' +
|
||||||
|
dt.getFullYear();
|
||||||
document.querySelector('#noteId').value = result.id;
|
document.querySelector('#noteId').value = result.id;
|
||||||
|
|
||||||
if (result.references) {
|
if (result.refs) {
|
||||||
references = result.references;
|
references = result.refs;
|
||||||
}
|
}
|
||||||
|
|
||||||
const list = document.querySelector('#ref-list');
|
const list = document.querySelector('#ref-list');
|
||||||
|
list.innerHTML = '';
|
||||||
var newList = null;
|
var newList = null;
|
||||||
for (var x in references) {
|
for (var x in references) {
|
||||||
var newList = document.createElement('li');
|
var newList = document.createElement('li');
|
||||||
@ -720,7 +729,9 @@ function retrieveNote(id) {
|
|||||||
list.appendChild(newList);
|
list.appendChild(newList);
|
||||||
}
|
}
|
||||||
|
|
||||||
openNote();
|
if (runOpen) {
|
||||||
|
openNote(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user