JS updates and expand HC

This commit is contained in:
ryan committed 2024-11-18 00:24:05 -05:00
1 parent cb849308cc
commit 979443da36
3 files changed
+256 -7

No files matched your search

+231 -2
View File
@@ -1333,8 +1333,237 @@
37 37
], ],
"hc": [ "hc": [
1, [
52 1,
2
],
[
3,
4,
5
],
[
6,
7,
8
],
[
9,
10,
11
],
[
12,
13,
14,
15
],
[
16,
17,
18,
19
],
[
20,
21,
22,
23
],
[
24,
25,
26
],
[
27,
28
],
[
29,
30
],
[
31,
32
],
[
33,
34
],
[
35,
36
],
[
37,
38,
39
],
[
40,
41,
42,
43,
44
],
[
45
],
[
46,
47,
48,
49
],
[
50,
51,
52
],
[
53
],
[
54,
55,
56
],
[
57,
58
],
[
59,
60,
61
],
[
62,
63,
64
],
[
65,
66,
67,
68
],
[
69,
70,
71
],
[
72,
73,
74
],
[
75,
76,
77
],
[
78,
79
],
[
80,
81,
82
],
[
83,
84,
85
],
[
86,
87
],
[
88,
89,
90,
91
],
[
92,
93,
94,
95
],
[
96,
97,
98
],
[
99,
100
],
[
101,
102
],
[
103
],
[
104
],
[
105,
106,
107
],
[
108,
109
],
[
110,
111
],
[
112
],
[
113,
114,
115
],
[
116,
117,
118,
119
],
[
120,
121
],
[
122
],
[
123
],
[
124
],
[
125
],
[
126
],
[
127,
128,
129
]
], ],
"cd": [ "cd": [
"1", "1",
+24 -4
View File
@@ -98,13 +98,13 @@ function setHeight() {
tabs.style.height = (window.innerHeight - 13) + 'px'; tabs.style.height = (window.innerHeight - 13) + 'px';
ref = document.querySelector('.ref'); ref = document.querySelector('.ref');
ref.style.height = (window.innerHeight - 50) + 'px'; ref.style.height = (window.innerHeight - 60) + 'px';
noteList = document.querySelector('#note-list'); noteList = document.querySelector('#note-list');
noteList.style.height = (window.innerHeight - 50) + 'px'; noteList.style.height = (window.innerHeight - 60) + 'px';
notes = document.querySelector('.notes'); notes = document.querySelector('.notes');
notes.style.height = (window.innerHeight - 50) + 'px'; notes.style.height = (window.innerHeight - 60) + 'px';
notePreview = document.querySelector('#notePreview'); notePreview = document.querySelector('#notePreview');
notePreview.style.height = (window.innerHeight - 50) + 'px'; notePreview.style.height = (window.innerHeight - 50) + 'px';
@@ -437,7 +437,6 @@ function saveSpeaker(event) {
/** /**
* A description of the entire function. * A description of the entire function.
*
*/ */
function newSeries() { function newSeries() {
if (document.querySelector('#series').value == 'new') { if (document.querySelector('#series').value == 'new') {
@@ -739,6 +738,27 @@ function retrieveBooks() {
newBook.text = BOOKS.cd[x]; newBook.text = BOOKS.cd[x];
bookList.appendChild(newBook); bookList.appendChild(newBook);
} }
} else if (selectedType == 'hc') {
var none = document.createElement("option");
none.value = '';
none.text = '-- Select --';
bookList.appendChild(none);
for (var x in BOOKS[selectedType]) {
var newBook = document.createElement("optgroup");
newBook.label = "Lord's Day " + (parseInt(x) + 1)
var ld = document.createElement("option");
ld.value = parseInt(x) + 1;
ld.text = "LD " + (parseInt(x) + 1) + " All";
newBook.appendChild(ld);
for (var y in BOOKS[selectedType][x]) {
var question = document.createElement("option");
question.value = y;
question.text = "HC" + BOOKS[selectedType][x][y];
newBook.appendChild(question);
}
bookList.appendChild(newBook);
}
} else if (selectedType == 'note') { } else if (selectedType == 'note') {
var none = document.createElement("option"); var none = document.createElement("option");
none.value = ''; none.value = '';
+1 -1
View File
@@ -1 +1 @@
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){"F3"==event.key&&openRef(!1)}),document.querySelector("#notes").addEventListener("keyup",function(event){let key=event.keyCode;(key>=48&&key<=90||key>=96&&key<=111||key>=186&&key<=222)&&(textDirty=!0,document.querySelector("#note-header-left h2").classList.add("dirty"))})}function setHeight(){md=new markdownit({html:!0,linkify:!0,breaks:!0}),body=document.querySelector("body"),body.style.height=window.innerHeight+"px",cont=document.querySelector("#main"),cont.style.height=window.innerHeight+"px",tabs=document.querySelector(".ref-tab"),tabs.style.height=window.innerHeight-13+"px",ref=document.querySelector(".ref"),ref.style.height=window.innerHeight-50+"px",noteList=document.querySelector("#note-list"),noteList.style.height=window.innerHeight-50+"px",notes=document.querySelector(".notes"),notes.style.height=window.innerHeight-50+"px",notePreview=document.querySelector("#notePreview"),notePreview.style.height=window.innerHeight-50+"px",$("#noteDate")&&$("#noteDate").datepicker(),$("#query")&&document.querySelector("#query").addEventListener("keyup",function(event){"Enter"==event.key&&search()}),to||(to=setTimeout(saveNote,saveInterval))}function search(){query=document.querySelector("#query").value,fetch("/index.php/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:query})}).then(response=>response.json()).then(results=>{var oldNotes=document.querySelector("#old-notes");for(var n in oldNotes.innerHTML="",results){var link=document.createElement("a");link.href="#",link.setAttribute("onclick","retrieveNote('"+results[n].id+"');openNote();"),link.innerHTML=results[n].title;var p=document.createElement("p");p.innerHTML=results[n].passage;var article=document.createElement("article");article.appendChild(link),article.appendChild(p),oldNotes.append(article)}})}function newNote(){notes=document.querySelector("#notes"),notes.text="",notes.value="",references={},saved=!0,textDirty=!1,document.querySelector("#note-header-left h2").classList.remove("dirty"),dt=new Date,document.querySelector("#noteDate").value=dt.getFullYear()+"-"+(dt.getMonth()<9?"0"+(dt.getMonth()+1):dt.getMonth()+1)+"-"+(dt.getDate()<10?"0"+dt.getDate():dt.getDate()),document.querySelector("#noteTitle").value="",document.querySelector("#speaker").value=0,document.querySelector("#series").value=0,document.querySelector("#template").value=0,document.querySelector("#passage").value="",document.querySelector("#recording").value="",document.querySelector("#noteId").value="",document.querySelector("#ref-list").innerHTML="",document.querySelector("#ref").innerHTML="",document.querySelector(".toggle").click()}function saveNote(event){if(event&&event.preventDefault(),!textDirty||!validateNote())return clearTimeout(to),void(to=setTimeout(saveNote,saveInterval));let saveCheck=document.querySelector("#save-check");var noteText=document.querySelector("#notes").value;startSave();var note={id:document.querySelector("#noteId").value,date:document.querySelector("#noteDate").value,title:document.querySelector("#noteTitle").value,speaker:document.querySelector("#speaker").value,series:document.querySelector("#series").value,passage:document.querySelector("#passage").value,note:document.querySelector("#notes").value,recording:document.querySelector("#recording").value,refs:references};$.ajax({url:"/index.php/save-note",method:"POST",contentType:"application/json",data:JSON.stringify(note),dataType:"json",timeout:saveTimeout}).done(function(data){"saved"!=data.msg||saved||(saveFailureCount=SAVE_FAILURE_LIMIT,saveCheck.classList.remove("saving","error","fa-times-circle","fa-save"),showSave(),noteText==document.querySelector("#notes").value&&(saved=!0,textDirty=!1,document.querySelector("#note-header-left h2").classList.remove("dirty")),data.new&&(document.querySelector("#noteId").value=data.id))}).fail(function(xhr,status,error){saveFailureCount--,saveCheck.classList.remove("saving","fa-save"),saveCheck.classList.add("fa-times-circle","error"),console.error(error)}).always(function(xhr,status){"timeout"==status&&(saveCheck.classList.remove("saving","fa-save"),saveCheck.classList.add("error","fa-times-circle")),clearTimeout(to),saveFailureCount>0?to=setTimeout(saveNote,saveInterval):saveFailureCount=SAVE_FAILURE_LIMIT})}function validateNote(){const note=document.querySelector("#notes"),date=document.querySelector("#noteDate"),speaker=document.querySelector("#speaker"),series=document.querySelector("#series"),title=document.querySelector("#noteTitle"),psg=document.querySelector("#passage");return!!title.value.length&&(!!date.value&&(!!parseInt(speaker.value)&&(!!parseInt(series.value)&&(!!psg.value&&!!note.value.length))))}function isUuidValid(uuid){const rLine truncated 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){"F3"==event.key&&openRef(!1)}),document.querySelector("#notes").addEventListener("keyup",function(event){let key=event.keyCode;(key>=48&&key<=90||key>=96&&key<=111||key>=186&&key<=222)&&(textDirty=!0,document.querySelector("#note-header-left h2").classList.add("dirty"))})}function setHeight(){md=new markdownit({html:!0,linkify:!0,breaks:!0}),body=document.querySelector("body"),body.style.height=window.innerHeight+"px",cont=document.querySelector("#main"),cont.style.height=window.innerHeight+"px",tabs=document.querySelector(".ref-tab"),tabs.style.height=window.innerHeight-13+"px",ref=document.querySelector(".ref"),ref.style.height=window.innerHeight-60+"px",noteList=document.querySelector("#note-list"),noteList.style.height=window.innerHeight-60+"px",notes=document.querySelector(".notes"),notes.style.height=window.innerHeight-60+"px",notePreview=document.querySelector("#notePreview"),notePreview.style.height=window.innerHeight-50+"px",$("#noteDate")&&$("#noteDate").datepicker(),$("#query")&&document.querySelector("#query").addEventListener("keyup",function(event){"Enter"==event.key&&search()}),to||(to=setTimeout(saveNote,saveInterval))}function search(){query=document.querySelector("#query").value,fetch("/index.php/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:query})}).then(response=>response.json()).then(results=>{var oldNotes=document.querySelector("#old-notes");for(var n in oldNotes.innerHTML="",results){var link=document.createElement("a");link.href="#",link.setAttribute("onclick","retrieveNote('"+results[n].id+"');openNote();"),link.innerHTML=results[n].title;var p=document.createElement("p");p.innerHTML=results[n].passage;var article=document.createElement("article");article.appendChild(link),article.appendChild(p),oldNotes.append(article)}})}function newNote(){notes=document.querySelector("#notes"),notes.text="",notes.value="",references={},saved=!0,textDirty=!1,document.querySelector("#note-header-left h2").classList.remove("dirty"),dt=new Date,document.querySelector("#noteDate").value=dt.getFullYear()+"-"+(dt.getMonth()<9?"0"+(dt.getMonth()+1):dt.getMonth()+1)+"-"+(dt.getDate()<10?"0"+dt.getDate():dt.getDate()),document.querySelector("#noteTitle").value="",document.querySelector("#speaker").value=0,document.querySelector("#series").value=0,document.querySelector("#template").value=0,document.querySelector("#passage").value="",document.querySelector("#recording").value="",document.querySelector("#noteId").value="",document.querySelector("#ref-list").innerHTML="",document.querySelector("#ref").innerHTML="",document.querySelector(".toggle").click()}function saveNote(event){if(event&&event.preventDefault(),!textDirty||!validateNote())return clearTimeout(to),void(to=setTimeout(saveNote,saveInterval));let saveCheck=document.querySelector("#save-check");var noteText=document.querySelector("#notes").value;startSave();var note={id:document.querySelector("#noteId").value,date:document.querySelector("#noteDate").value,title:document.querySelector("#noteTitle").value,speaker:document.querySelector("#speaker").value,series:document.querySelector("#series").value,passage:document.querySelector("#passage").value,note:document.querySelector("#notes").value,recording:document.querySelector("#recording").value,refs:references};$.ajax({url:"/index.php/save-note",method:"POST",contentType:"application/json",data:JSON.stringify(note),dataType:"json",timeout:saveTimeout}).done(function(data){"saved"!=data.msg||saved||(saveFailureCount=SAVE_FAILURE_LIMIT,saveCheck.classList.remove("saving","error","fa-times-circle","fa-save"),showSave(),noteText==document.querySelector("#notes").value&&(saved=!0,textDirty=!1,document.querySelector("#note-header-left h2").classList.remove("dirty")),data.new&&(document.querySelector("#noteId").value=data.id))}).fail(function(xhr,status,error){saveFailureCount--,saveCheck.classList.remove("saving","fa-save"),saveCheck.classList.add("fa-times-circle","error"),console.error(error)}).always(function(xhr,status){"timeout"==status&&(saveCheck.classList.remove("saving","fa-save"),saveCheck.classList.add("error","fa-times-circle")),clearTimeout(to),saveFailureCount>0?to=setTimeout(saveNote,saveInterval):saveFailureCount=SAVE_FAILURE_LIMIT})}function validateNote(){const note=document.querySelector("#notes"),date=document.querySelector("#noteDate"),speaker=document.querySelector("#speaker"),series=document.querySelector("#series"),title=document.querySelector("#noteTitle"),psg=document.querySelector("#passage");return!!title.value.length&&(!!date.value&&(!!parseInt(speaker.value)&&(!!parseInt(series.value)&&(!!psg.value&&!!note.value.length))))}function isUuidValid(uuid){const rLine truncated