7 Commits
Author SHA1 Message Date
ryan c2c08db342 Add saveFailCounter
Fix bug with not clearing noteId
Refactor a class removal and additions
Add script.min.js
2024-06-09 20:26:54 -04:00
ryan 4d55711190 Adding new reference type retrieval 2024-06-09 20:24:44 -04:00
ryan 164ed62a48 add method for retrieving 39 articles 2024-06-09 20:18:54 -04:00
ryan bdc67942ea Add validation for email registration 2024-06-09 20:18:27 -04:00
ryan 4a6191e287 Add link to markdown cheat sheet 2024-06-09 20:17:40 -04:00
ryan d809e7eb38 Add new reference types 2024-06-09 20:17:20 -04:00
ryan 83709509f2 Move markdown cheat sheet 2024-06-09 20:16:42 -04:00
9 changed files with 67 additions and 9 deletions

No files matched your search

File renamed without changes.
+20
View File
@@ -1358,5 +1358,25 @@
"lbc": [ "lbc": [
1, 1,
32 32
],
"39a": [
1,
39
],
"1hc": [
1,
10
],
"2hc": [
1,
30
],
"sd": [
1,
32
],
"agc": [
1,
28
] ]
} }
+15 -7
View File
@@ -8,6 +8,7 @@ let saveTimeout = 15000;
var to = null; var to = null;
let controller; let controller;
var BOOKS = {}; var BOOKS = {};
let saveFailCounter = 0;
$(function () { $(function () {
setHeight(); setHeight();
@@ -160,6 +161,7 @@ function newNote() {
document.querySelector('#template').value = 0; document.querySelector('#template').value = 0;
document.querySelector('#passage').value = ''; document.querySelector('#passage').value = '';
document.querySelector('#recording').value = ''; document.querySelector('#recording').value = '';
document.querySelector('#noteId').value = '';
document.querySelector('#ref-list').innerHTML = ''; document.querySelector('#ref-list').innerHTML = '';
document.querySelector('#ref').innerHTML = ''; document.querySelector('#ref').innerHTML = '';
@@ -209,8 +211,7 @@ function saveNote(event) {
}) })
.done(function (data) { .done(function (data) {
if (data.msg == 'saved' && !saved) { if (data.msg == 'saved' && !saved) {
saveCheck.classList.remove('saving'); saveCheck.classList.remove('saving', 'error', 'fa-times', 'fa-check');
saveCheck.classList.remove('error');
showSave(); showSave();
if (noteText == document.querySelector('#notes').value) { if (noteText == document.querySelector('#notes').value) {
saved = true; saved = true;
@@ -224,17 +225,22 @@ function saveNote(event) {
} }
}) })
.fail(function (xhr, status, error) { .fail(function (xhr, status, error) {
saveCheck.classList.remove('saving'); saveFailCounter++;
saveCheck.classList.add('error'); saveCheck.classList.remove('saving', 'fa-check');
saveCheck.classList.add('fa-times', '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'); saveCheck.classList.remove('saving', 'fa-check');
saveCheck.classList.add('error'); saveCheck.classList.add('error', 'fa-times');
} }
clearTimeout(to); clearTimeout(to);
if (saveFailCounter < 5) {
to = setTimeout(saveNote, saveTimeout); to = setTimeout(saveNote, saveTimeout);
} else {
saveFailCounter = 0;
}
}); });
} }
@@ -262,7 +268,8 @@ function isUuidValid(uuid) {
} }
function startSave() { function startSave() {
document.querySelector('#save-check').classList.add('saving'); document.querySelector('#save-check').classList.remove('error', 'fa-times', 'fa-check');
document.querySelector('#save-check').classList.add('saving', 'fa-check');
document.querySelector('#save-check').style.opacity = 1; document.querySelector('#save-check').style.opacity = 1;
} }
@@ -276,6 +283,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');
// 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 () {
+1
View File
@@ -0,0 +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,saveTimeout))}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,saveTimeout));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:5e3}).done(function(data){"saved"!=data.msg||saved||(saveCheck.classList.remove("saving","error","fa-times","fa-check"),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){saveFailCounter++,saveCheck.classList.remove("saving","fa-check"),saveCheck.classList.add("fa-times","error"),console.error(error)}).always(function(xhr,status){"timeout"==status&&(saveCheck.classList.remove("saving","fa-check"),saveCheck.classList.add("error","fa-times")),clearTimeout(to),saveFailCounter<5?to=setTimeout(saveNote,saveTimeout):saveFailCounter=0})}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 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;returLine truncated
+12 -1
View File
@@ -178,6 +178,11 @@ class AjaxController extends AbstractController
'wlc' => ReferenceController::retrieveWLC($ref), 'wlc' => ReferenceController::retrieveWLC($ref),
'lbc' => ReferenceController::retrieveLBC($ref), 'lbc' => ReferenceController::retrieveLBC($ref),
'creed' => ReferenceController::retrieveCreed($data->book), 'creed' => ReferenceController::retrieveCreed($data->book),
'39a' => ReferenceController::retrieve39a($ref),
'1hc' => ReferenceController::retrieve1HC($ref),
'2hc' => ReferenceController::retrieve2HC($ref),
'sd' => ReferenceController::retrieveSD($ref),
'agc' => ReferenceController::retrieveAGC($ref),
'note' => ReferenceController::retrieveNote($user) 'note' => ReferenceController::retrieveNote($user)
}; };
@@ -220,7 +225,13 @@ class AjaxController extends AbstractController
'cd' => 'Dort', 'cd' => 'Dort',
'wcf' => 'Westminster/Confessions', 'wcf' => 'Westminster/Confessions',
'wsc' => 'Westminster/Shorter Catechism', 'wsc' => 'Westminster/Shorter Catechism',
'wlc' => 'Westminster/Larger Catechism' 'wlc' => 'Westminster/Larger Catechism',
'lbc' => 'London',
'39a' => '39 Articles',
'1hc' => '1 Helvetic Catechism',
'2hc' => '2 Helvetic Catechism',
'sd' => 'Savor Declaration',
'agc' => 'Augsburg Confession'
}; };
$ret = file_put_contents(dirname(dirname(__DIR__))."/references/{$path}/{$data->file}", $data->text); $ret = file_put_contents(dirname(dirname(__DIR__))."/references/{$path}/{$data->file}", $data->text);
+9
View File
@@ -202,6 +202,15 @@ class ReferenceController extends AbstractController
return $r[0]; return $r[0];
} }
public static function retrieve39a($ref): Reference
{
$r = self::$emi->getRepository(Reference::class)->findBy(['type' => '39a', 'ndx' => $ref->getNdx()]);
if (!$r) {
return new Reference();
}
return $r[0];
}
public static function retrieve1HC($ref): Reference public static function retrieve1HC($ref): Reference
{ {
$r = self::$emi->getRepository(Reference::class)->findBy(['type' => '1hc', 'ndx' => $ref->getNdx()]); $r = self::$emi->getRepository(Reference::class)->findBy(['type' => '1hc', 'ndx' => $ref->getNdx()]);
+4
View File
@@ -11,6 +11,7 @@ use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: UserRepository::class)] #[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])] #[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
@@ -23,6 +24,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, JsonSer
private ?Uuid $id = null; private ?Uuid $id = null;
#[ORM\Column(length: 180)] #[ORM\Column(length: 180)]
#[Assert\Email(
message: 'The email {{ value }} is not a valid email.',
)]
private ?string $email = null; private ?string $email = null;
/** /**
+5 -1
View File
@@ -127,7 +127,11 @@
<option value='wsc'>Westminster Shorter Catechism</option> <option value='wsc'>Westminster Shorter Catechism</option>
<option value='wlc'>Westminster Larger Catechism</option> <option value='wlc'>Westminster Larger Catechism</option>
<option value='lbc'>London Baptist Confession</option> <option value='lbc'>London Baptist Confession</option>
<option value='note'>Note</option> <option value='39a'>Thirty-Nine Articles</option>
<option value='1hc'>First Helvetic Confession</option>
<option value='2hc'>Second Helvetic Confession</option>
<option value='sd'>Savoy Declaration</option>
<option value='agc'>Augsburg Confession</option>
</select> </select>
<select id='referenceBook' onchange='filterBooks()'> <select id='referenceBook' onchange='filterBooks()'>
</select> </select>
+1
View File
@@ -29,6 +29,7 @@
{% endif %} {% endif %}
<li><a href='#' onclick="openRef()">Open Reference</a></li> <li><a href='#' onclick="openRef()">Open Reference</a></li>
<li><a href='/index.php/template-editor'>Template Editor</a></li> <li><a href='/index.php/template-editor'>Template Editor</a></li>
<li><a href='/docs/markdown-cheat-sheet.md' target='_blank'>Markdown Cheat Sheet</a></li>
{% else %} {% else %}
<li><a href="/index.php/">Home</a></li> <li><a href="/index.php/">Home</a></li>
<li><a href='/index.php/register'>Register</a></li> <li><a href='/index.php/register'>Register</a></li>