Migrate openNotes table to use DataTables
Added couple helper methods Fixed not clearing recording link on "New Note" add retrieveReferenceType method for reference editor
This commit is contained in:
parent
74b24afc75
commit
2552335513
@ -9,34 +9,60 @@ var to = null;
|
||||
let controller;
|
||||
var BOOKS = {};
|
||||
|
||||
fetch('/js/data.json')
|
||||
.then((res) => {
|
||||
if (!res.ok) {
|
||||
throw new Error('HTTP Error: Status: ${res.status}');
|
||||
$(function () {
|
||||
setHeight();
|
||||
setBooks();
|
||||
setEventListeners();
|
||||
$('#note-table').DataTable({
|
||||
paging: false,
|
||||
ajax: {
|
||||
url: '/index.php/get-notes',
|
||||
type: 'POST'
|
||||
},
|
||||
columns: [
|
||||
{ data: 'link' },
|
||||
{ data: 'speaker.name' },
|
||||
{ data: 'passage' },
|
||||
{
|
||||
data: 'date.date',
|
||||
render: DataTable.render.date("L")
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
function setBooks() {
|
||||
fetch('/js/data.json')
|
||||
.then((res) => {
|
||||
if (!res.ok) {
|
||||
throw new Error('HTTP Error: Status: ${res.status}');
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then((data) => {
|
||||
BOOKS = data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
function setEventListeners() {
|
||||
document.addEventListener('keyup', function (event) {
|
||||
if (event.key == "F3") {
|
||||
openRef(false);
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then((data) => {
|
||||
BOOKS = data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
})
|
||||
});
|
||||
|
||||
document.addEventListener('keyup', function (event) {
|
||||
if (event.key == "F3") {
|
||||
openRef(false);
|
||||
}
|
||||
});
|
||||
document.querySelector('#notes').addEventListener('keyup', function (event) {
|
||||
let key = event.keyCode;
|
||||
|
||||
document.querySelector('#notes').addEventListener('keyup', function (event) {
|
||||
let key = event.keyCode;
|
||||
|
||||
if (key >= 48 && key <= 90 || key >= 96 && key <= 111 || key >= 186 && key <= 222) {
|
||||
textDirty = true;
|
||||
document.querySelector('#note-header-left h2').classList.add('dirty');
|
||||
}
|
||||
});
|
||||
if (key >= 48 && key <= 90 || key >= 96 && key <= 111 || key >= 186 && key <= 222) {
|
||||
textDirty = true;
|
||||
document.querySelector('#note-header-left h2').classList.add('dirty');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setHeight() {
|
||||
md = new markdownit({
|
||||
@ -133,7 +159,7 @@ function newNote() {
|
||||
document.querySelector('#series').value = 0;
|
||||
document.querySelector('#template').value = 0;
|
||||
document.querySelector('#passage').value = '';
|
||||
document.querySelector('#noteId').value = uuidv4();
|
||||
document.querySelector('#recording').value = '';
|
||||
|
||||
document.querySelector('#ref-list').innerHTML = '';
|
||||
document.querySelector('#ref').innerHTML = '';
|
||||
@ -658,6 +684,30 @@ function filterVerse() {
|
||||
verseRange.innerText = 'Verse: ' + verse;
|
||||
}
|
||||
|
||||
function retrieveReferenceType(el) {
|
||||
fetch('/index.php/reference/' + el.value, {
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(results => {
|
||||
document.querySelector('#referenceSeries').innerHTML = '';
|
||||
var none = document.createElement('option');
|
||||
none.value = '';
|
||||
none.text = '-- Select --';
|
||||
document.querySelector('#referenceSeries').appendChild(none);
|
||||
|
||||
for (var x in results) {
|
||||
var newSeries = document.createElement('option');
|
||||
newSeries.value = results[x].id;
|
||||
newSeries.text = results[x].label;
|
||||
document.querySelector('#referenceSeries').appendChild(newSeries);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function retrieveReference(el) {
|
||||
if (el.value == 'new') {
|
||||
document.querySelector('#refName').style.display = 'inline-block';
|
||||
@ -669,8 +719,7 @@ function retrieveReference(el) {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
file: el.value,
|
||||
type: el.options[el.selectedIndex].getAttribute('type')
|
||||
id: el.value
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
|
Loading…
Reference in New Issue
Block a user