From fbf5ac564ad9aa42e8b48fddf42145751406b57d Mon Sep 17 00:00:00 2001 From: Ryan Prather Date: Mon, 24 Jun 2024 15:43:03 -0400 Subject: [PATCH] To support note deletion --- public/css/style.css | 5 +++++ public/css/style.css.map | 2 +- public/css/style.min.css | 2 +- public/css/style.min.css.map | 2 +- public/css/style.scss | 5 +++++ public/js/script.js | 25 ++++++++++++++----------- public/js/script.min.js | 2 +- src/Controller/AjaxController.php | 2 +- src/Entity/Note.php | 5 ++++- 9 files changed, 33 insertions(+), 17 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index 9d5ca4d..1344b62 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -245,4 +245,9 @@ div#refQuery #referenceSearch { font-size: 8pt; color: blue; text-decoration: none; +} + +.fas-trash-alt { + color: red; + cursor: pointer; }/*# sourceMappingURL=style.css.map */ \ No newline at end of file diff --git a/public/css/style.css.map b/public/css/style.css.map index 7c5f9b0..b838589 100644 --- a/public/css/style.css.map +++ b/public/css/style.css.map @@ -1 +1 @@ -{"version":3,"sources":["style.scss","style.css"],"names":[],"mappings":"AAAA,kCAAA;AACA;EACI,SAAA;ACCJ;;ADEA,6BAAA;AAEA;EACI,aAAA;EACA,mBAAA;EACA,eAAA;EACA,6BAAA;EACA,oBAAA;EACA,yBAAA;EACA,iBAAA;EACA,iCAAA;EACA,cAAA;ACAJ;;ADGA;EACI,WAAA;EACA,4BAAA;ACAJ;;ADGA;EACI,SAAA;EACA,UAAA;ACAJ;;ADGA;EACI,gBAAA;EACA,qBAAA;ACAJ;;ADGA;EACI,kBAAA;ACAJ;;ADGA,GAAA;AACA;EACI,aAAA;EACA,uBAAA;EACA,mBAAA;EACA,YAAA;EACA,WAAA;EACA,kBAAA;EACA,eAAA;EACA,kBAAA;ACAJ;;ADIA;EACI,UAAA;ACDJ;;ADIA;EACI,mBAAA;EACA,2BAAA;EACA,yBAAA;EACA,kBAAA;EACA,WAAA;EACA,YAAA;EACA,uBAAA;EACA,kBAAA;EACA,wCAAA;ACDJ;;ADIA;EACI,wBAAA;ACDJ;;ADIA;EACI,YAAA;ACDJ;;ADIA;EACI,aAAA;EACA,YAAA;ACDJ;;ADIA;EACI,aAAA;EACA,YAAA;ACDJ;;ADIA;EACI,aAAA;ACDJ;;ADIA;EACI,cAAA;ACDJ;;ADIA;EACI,UAAA;ACDJ;;ADIA;EACI,WAAA;EACA,YAAA;EACA,eAAA;ACDJ;;ADIA;EACI,aAAA;EACA,kBAAA;EACA,kBAAA;ACDJ;;ADIA;;EAEI,2BAAA;ACDJ;;ADIA;;;;EAII,oCAAA;EACA,uBAAA;ACDJ;;ADIA;EACI,oBAAA;EACA,mBAAA;EACA,UAAA;ACDJ;;ADIA;EACI,oBAAA;EACA,2BAAA;EACA,UAAA;ACDJ;;ADIA;EACI,iBAAA;ACDJ;;ADIA;EACI,aAAA;EACA,YAAA;EACA,kBAAA;ACDJ;;ADIA;EACI,SAAA;EACA,UAAA;EACA,qBAAA;EACA,gBAAA;ACDJ;;ADIA;EACI,aAAA;EACA,kBAAA;EACA,YAAA;EACA,oCAAA;EACA,YAAA;EACA,aAAA;ACDJ;;ADIA;EACI,YAAA;EACA,kBAAA;EACA,kBAAA;EACA,eAAA;EACA,gBAAA;EACA,WAAA;EACA,yBAAA;EACA,YAAA;EACA,YAAA;EACA,eAAA;EACA,aAAA;ACDJ;;ADIA;EACI,aAAA;EACA,kBAAA;EACA,YAAA;EACA,sBAAA;EACA,YAAA;EACA,aAAA;EACA,sBAAA;EACA,kBAAA;EACA,wCAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ACDJ;;ADIA;EACI,UAAA;EACA,iBAAA;EACA,eAAA;EACA,iBAAA;EACA,YAAA;ACDJ;;ADIA;EACI,aAAA;ACDJ;;ADIA;EACI,UAAA;ACDJ;;ADIA;;EAEI,YAAA;EACA,qBAAA;ACDJ;;ADIA;EACI,2BAAA;EACA,eAAA;ACDJ;;ADIA;EACI,eAAA;ACDJ;;ADIA;EACI,eAAA;ACDJ;;ADIA;EACI,eAAA;ACDJ;;ADIA;EACI,qBAAA;ACDJ;;ADIA;EACI,eAAA;ACDJ;;ADIA;;EAEI,2BAAA;ACDJ;;ADIA;EACI,aAAA;ACDJ;;ADIA;EACI,cAAA;EACA,WAAA;EACA,qBAAA;ACDJ","file":"style.css"} \ No newline at end of file +{"version":3,"sources":["style.scss","style.css"],"names":[],"mappings":"AAAA,kCAAA;AACA;EACI,SAAA;ACCJ;;ADEA,6BAAA;AAEA;EACI,aAAA;EACA,mBAAA;EACA,eAAA;EACA,6BAAA;EACA,oBAAA;EACA,yBAAA;EACA,iBAAA;EACA,iCAAA;EACA,cAAA;ACAJ;;ADGA;EACI,WAAA;EACA,4BAAA;ACAJ;;ADGA;EACI,SAAA;EACA,UAAA;ACAJ;;ADGA;EACI,gBAAA;EACA,qBAAA;ACAJ;;ADGA;EACI,kBAAA;ACAJ;;ADGA,GAAA;AACA;EACI,aAAA;EACA,uBAAA;EACA,mBAAA;EACA,YAAA;EACA,WAAA;EACA,kBAAA;EACA,eAAA;EACA,kBAAA;ACAJ;;ADIA;EACI,UAAA;ACDJ;;ADIA;EACI,mBAAA;EACA,2BAAA;EACA,yBAAA;EACA,kBAAA;EACA,WAAA;EACA,YAAA;EACA,uBAAA;EACA,kBAAA;EACA,wCAAA;ACDJ;;ADIA;EACI,wBAAA;ACDJ;;ADIA;EACI,YAAA;ACDJ;;ADIA;EACI,aAAA;EACA,YAAA;ACDJ;;ADIA;EACI,aAAA;EACA,YAAA;ACDJ;;ADIA;EACI,aAAA;ACDJ;;ADIA;EACI,cAAA;ACDJ;;ADIA;EACI,UAAA;ACDJ;;ADIA;EACI,WAAA;EACA,YAAA;EACA,eAAA;ACDJ;;ADIA;EACI,aAAA;EACA,kBAAA;EACA,kBAAA;ACDJ;;ADIA;;EAEI,2BAAA;ACDJ;;ADIA;;;;EAII,oCAAA;EACA,uBAAA;ACDJ;;ADIA;EACI,oBAAA;EACA,mBAAA;EACA,UAAA;ACDJ;;ADIA;EACI,oBAAA;EACA,2BAAA;EACA,UAAA;ACDJ;;ADIA;EACI,iBAAA;ACDJ;;ADIA;EACI,aAAA;EACA,YAAA;EACA,kBAAA;ACDJ;;ADIA;EACI,SAAA;EACA,UAAA;EACA,qBAAA;EACA,gBAAA;ACDJ;;ADIA;EACI,aAAA;EACA,kBAAA;EACA,YAAA;EACA,oCAAA;EACA,YAAA;EACA,aAAA;ACDJ;;ADIA;EACI,YAAA;EACA,kBAAA;EACA,kBAAA;EACA,eAAA;EACA,gBAAA;EACA,WAAA;EACA,yBAAA;EACA,YAAA;EACA,YAAA;EACA,eAAA;EACA,aAAA;ACDJ;;ADIA;EACI,aAAA;EACA,kBAAA;EACA,YAAA;EACA,sBAAA;EACA,YAAA;EACA,aAAA;EACA,sBAAA;EACA,kBAAA;EACA,wCAAA;EACA,YAAA;EACA,aAAA;EACA,kBAAA;ACDJ;;ADIA;EACI,UAAA;EACA,iBAAA;EACA,eAAA;EACA,iBAAA;EACA,YAAA;ACDJ;;ADIA;EACI,aAAA;ACDJ;;ADIA;EACI,UAAA;ACDJ;;ADIA;;EAEI,YAAA;EACA,qBAAA;ACDJ;;ADIA;EACI,2BAAA;EACA,eAAA;ACDJ;;ADIA;EACI,eAAA;ACDJ;;ADIA;EACI,eAAA;ACDJ;;ADIA;EACI,eAAA;ACDJ;;ADIA;EACI,qBAAA;ACDJ;;ADIA;EACI,eAAA;ACDJ;;ADIA;;EAEI,2BAAA;ACDJ;;ADIA;EACI,aAAA;ACDJ;;ADIA;EACI,cAAA;EACA,WAAA;EACA,qBAAA;ACDJ;;ADIA;EACI,UAAA;EACA,eAAA;ACDJ","file":"style.css"} \ No newline at end of file diff --git a/public/css/style.min.css b/public/css/style.min.css index 39fd2aa..166b2ea 100644 --- a/public/css/style.min.css +++ b/public/css/style.min.css @@ -1 +1 @@ -body{margin:0}.inner{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:space-evenly;align-items:stretch;align-content:flex-start;max-width:1060px;margin:0 auto}.ref-tab{width:60px;padding-top:55px !important}.ref-tab ul{margin:0;padding:0}.ref-tab ul li{list-style:none;list-style-type:none}.tab{margin-bottom:3px}.tab button{display:flex;justify-content:center;align-items:center;height:80px;width:100%;text-align:center;font-size:14px;margin-bottom:3px}.ref{width:36%}.ref>div#ref{vertical-align:top;justify-content:flex-start;align-content:flex-start;overflow-y:scroll;width:100%;height:100%;border:#000 solid 1px;border-radius:3px;box-shadow:0 2px 5px rgba(0,0,0,.3)}#ref{padding:3px 3px 3px 3px}#passage{width:100px}#newSpeaker{display:none;width:110px}#newSeries{display:none;width:110px}#fields-container{display:none}#fields-container.show{display:block}.notes{width:57%}textarea#notes{width:100%;height:100%;font-size:14pt}#notePreview{display:none;overflow-x:scroll;padding-left:10px}#notePreview ul,#notePreview ol{list-style-position:inside}#previewBtn.active,#show-hide-btn.active,.tab button.active,#openRefBtn.active{background-color:#f56a6a !important;color:#fff !important}#note-header-left{display:inline-flex;flex-direction:row;width:25%}#note-header-right{display:inline-flex;flex-direction:row-reverse;width:74%}#note-header-left h2.dirty{color:#ff8c00}#note-list{display:none;height:100%;overflow-y:scroll}#note-list ul{margin:0;padding:0;list-style-type:none;list-style:none}div#refQuery{display:none;position:absolute;z-index:100;background-color:rgba(0,0,0,.8);width:400px;height:200px}div#refQuery #referenceSearch{border:none;border-radius:5px;padding:10px 20px;font-size:16px;line-height:1.5;color:#333;background-color:#f4f4f4;width:150px;height:25px;cursor:pointer;display:none}#passage-popup{display:none;position:absolute;z-index:100;background-color:#fff;color:#000;padding:10px;border:1px solid #ccc;border-radius:5px;box-shadow:0 2px 5px rgba(0,0,0,.3);width:300px;height:300px;overflow-x:scroll}#save-check{opacity:0;text-align:right;font-size:20pt;margin-left:15px;color:green}#save-check.saving{color:orange}#save-check.error{color:red}#fields-container input,#fields-container select{width:32.5%;display:inline-block}#old-notes article p:first-child{margin-bottom:0 !important;font-size:10pt}#old-notes article a{font-size:12pt}#old-notes article p:last-child{font-size:12pt}.inner{padding-left:0}.ref h2{display:inline-block}#ref{font-size:12pt}#ref ol,#ref ul{list-style-position:inside}#referenceBook{display:none}.recording-link{font-size:8pt;color:blue;text-decoration:none}/*# sourceMappingURL=style.min.css.map */ \ No newline at end of file +body{margin:0}.inner{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:space-evenly;align-items:stretch;align-content:flex-start;max-width:1060px;margin:0 auto}.ref-tab{width:60px;padding-top:55px !important}.ref-tab ul{margin:0;padding:0}.ref-tab ul li{list-style:none;list-style-type:none}.tab{margin-bottom:3px}.tab button{display:flex;justify-content:center;align-items:center;height:80px;width:100%;text-align:center;font-size:14px;margin-bottom:3px}.ref{width:36%}.ref>div#ref{vertical-align:top;justify-content:flex-start;align-content:flex-start;overflow-y:scroll;width:100%;height:100%;border:#000 solid 1px;border-radius:3px;box-shadow:0 2px 5px rgba(0,0,0,.3)}#ref{padding:3px 3px 3px 3px}#passage{width:100px}#newSpeaker{display:none;width:110px}#newSeries{display:none;width:110px}#fields-container{display:none}#fields-container.show{display:block}.notes{width:57%}textarea#notes{width:100%;height:100%;font-size:14pt}#notePreview{display:none;overflow-x:scroll;padding-left:10px}#notePreview ul,#notePreview ol{list-style-position:inside}#previewBtn.active,#show-hide-btn.active,.tab button.active,#openRefBtn.active{background-color:#f56a6a !important;color:#fff !important}#note-header-left{display:inline-flex;flex-direction:row;width:25%}#note-header-right{display:inline-flex;flex-direction:row-reverse;width:74%}#note-header-left h2.dirty{color:#ff8c00}#note-list{display:none;height:100%;overflow-y:scroll}#note-list ul{margin:0;padding:0;list-style-type:none;list-style:none}div#refQuery{display:none;position:absolute;z-index:100;background-color:rgba(0,0,0,.8);width:400px;height:200px}div#refQuery #referenceSearch{border:none;border-radius:5px;padding:10px 20px;font-size:16px;line-height:1.5;color:#333;background-color:#f4f4f4;width:150px;height:25px;cursor:pointer;display:none}#passage-popup{display:none;position:absolute;z-index:100;background-color:#fff;color:#000;padding:10px;border:1px solid #ccc;border-radius:5px;box-shadow:0 2px 5px rgba(0,0,0,.3);width:300px;height:300px;overflow-x:scroll}#save-check{opacity:0;text-align:right;font-size:20pt;margin-left:15px;color:green}#save-check.saving{color:orange}#save-check.error{color:red}#fields-container input,#fields-container select{width:32.5%;display:inline-block}#old-notes article p:first-child{margin-bottom:0 !important;font-size:10pt}#old-notes article a{font-size:12pt}#old-notes article p:last-child{font-size:12pt}.inner{padding-left:0}.ref h2{display:inline-block}#ref{font-size:12pt}#ref ol,#ref ul{list-style-position:inside}#referenceBook{display:none}.recording-link{font-size:8pt;color:blue;text-decoration:none}.fas-trash-alt{color:red;cursor:pointer}/*# sourceMappingURL=style.min.css.map */ \ No newline at end of file diff --git a/public/css/style.min.css.map b/public/css/style.min.css.map index 8a292b5..1834dab 100644 --- a/public/css/style.min.css.map +++ b/public/css/style.min.css.map @@ -1 +1 @@ -{"version":3,"sources":["style.scss"],"names":[],"mappings":"AACA,KACI,QAAA,CAKJ,OACI,YAAA,CACA,kBAAA,CACA,cAAA,CACA,4BAAA,CACA,mBAAA,CACA,wBAAA,CACA,gBAAA,CAEA,aAAA,CAGJ,SACI,UAAA,CACA,2BAAA,CAGJ,YACI,QAAA,CACA,SAAA,CAGJ,eACI,eAAA,CACA,oBAAA,CAGJ,KACI,iBAAA,CAIJ,YACI,YAAA,CACA,sBAAA,CACA,kBAAA,CACA,WAAA,CACA,UAAA,CACA,iBAAA,CACA,cAAA,CACA,iBAAA,CAIJ,KACI,SAAA,CAGJ,aACI,kBAAA,CACA,0BAAA,CACA,wBAAA,CACA,iBAAA,CACA,UAAA,CACA,WAAA,CACA,qBAAA,CACA,iBAAA,CACA,mCAAA,CAGJ,KACI,uBAAA,CAGJ,SACI,WAAA,CAGJ,YACI,YAAA,CACA,WAAA,CAGJ,WACI,YAAA,CACA,WAAA,CAGJ,kBACI,YAAA,CAGJ,uBACI,aAAA,CAGJ,OACI,SAAA,CAGJ,eACI,UAAA,CACA,WAAA,CACA,cAAA,CAGJ,aACI,YAAA,CACA,iBAAA,CACA,iBAAA,CAGJ,gCAEI,0BAAA,CAGJ,+EAII,mCAAA,CACA,qBAAA,CAGJ,kBACI,mBAAA,CACA,kBAAA,CACA,SAAA,CAGJ,mBACI,mBAAA,CACA,0BAAA,CACA,SAAA,CAGJ,2BACI,aAAA,CAGJ,WACI,YAAA,CACA,WAAA,CACA,iBAAA,CAGJ,cACI,QAAA,CACA,SAAA,CACA,oBAAA,CACA,eAAA,CAGJ,aACI,YAAA,CACA,iBAAA,CACA,WAAA,CACA,+BAAA,CACA,WAAA,CACA,YAAA,CAGJ,8BACI,WAAA,CACA,iBAAA,CACA,iBAAA,CACA,cAAA,CACA,eAAA,CACA,UAAA,CACA,wBAAA,CACA,WAAA,CACA,WAAA,CACA,cAAA,CACA,YAAA,CAGJ,eACI,YAAA,CACA,iBAAA,CACA,WAAA,CACA,qBAAA,CACA,UAAA,CACA,YAAA,CACA,qBAAA,CACA,iBAAA,CACA,mCAAA,CACA,WAAA,CACA,YAAA,CACA,iBAAA,CAGJ,YACI,SAAA,CACA,gBAAA,CACA,cAAA,CACA,gBAAA,CACA,WAAA,CAGJ,mBACI,YAAA,CAGJ,kBACI,SAAA,CAGJ,iDAEI,WAAA,CACA,oBAAA,CAGJ,iCACI,0BAAA,CACA,cAAA,CAGJ,qBACI,cAAA,CAGJ,gCACI,cAAA,CAGJ,OACI,cAAA,CAGJ,QACI,oBAAA,CAGJ,KACI,cAAA,CAGJ,gBAEI,0BAAA,CAGJ,eACI,YAAA,CAGJ,gBACI,aAAA,CACA,UAAA,CACA,oBAAA","file":"style.min.css"} \ No newline at end of file +{"version":3,"sources":["style.scss"],"names":[],"mappings":"AACA,KACI,QAAA,CAKJ,OACI,YAAA,CACA,kBAAA,CACA,cAAA,CACA,4BAAA,CACA,mBAAA,CACA,wBAAA,CACA,gBAAA,CAEA,aAAA,CAGJ,SACI,UAAA,CACA,2BAAA,CAGJ,YACI,QAAA,CACA,SAAA,CAGJ,eACI,eAAA,CACA,oBAAA,CAGJ,KACI,iBAAA,CAIJ,YACI,YAAA,CACA,sBAAA,CACA,kBAAA,CACA,WAAA,CACA,UAAA,CACA,iBAAA,CACA,cAAA,CACA,iBAAA,CAIJ,KACI,SAAA,CAGJ,aACI,kBAAA,CACA,0BAAA,CACA,wBAAA,CACA,iBAAA,CACA,UAAA,CACA,WAAA,CACA,qBAAA,CACA,iBAAA,CACA,mCAAA,CAGJ,KACI,uBAAA,CAGJ,SACI,WAAA,CAGJ,YACI,YAAA,CACA,WAAA,CAGJ,WACI,YAAA,CACA,WAAA,CAGJ,kBACI,YAAA,CAGJ,uBACI,aAAA,CAGJ,OACI,SAAA,CAGJ,eACI,UAAA,CACA,WAAA,CACA,cAAA,CAGJ,aACI,YAAA,CACA,iBAAA,CACA,iBAAA,CAGJ,gCAEI,0BAAA,CAGJ,+EAII,mCAAA,CACA,qBAAA,CAGJ,kBACI,mBAAA,CACA,kBAAA,CACA,SAAA,CAGJ,mBACI,mBAAA,CACA,0BAAA,CACA,SAAA,CAGJ,2BACI,aAAA,CAGJ,WACI,YAAA,CACA,WAAA,CACA,iBAAA,CAGJ,cACI,QAAA,CACA,SAAA,CACA,oBAAA,CACA,eAAA,CAGJ,aACI,YAAA,CACA,iBAAA,CACA,WAAA,CACA,+BAAA,CACA,WAAA,CACA,YAAA,CAGJ,8BACI,WAAA,CACA,iBAAA,CACA,iBAAA,CACA,cAAA,CACA,eAAA,CACA,UAAA,CACA,wBAAA,CACA,WAAA,CACA,WAAA,CACA,cAAA,CACA,YAAA,CAGJ,eACI,YAAA,CACA,iBAAA,CACA,WAAA,CACA,qBAAA,CACA,UAAA,CACA,YAAA,CACA,qBAAA,CACA,iBAAA,CACA,mCAAA,CACA,WAAA,CACA,YAAA,CACA,iBAAA,CAGJ,YACI,SAAA,CACA,gBAAA,CACA,cAAA,CACA,gBAAA,CACA,WAAA,CAGJ,mBACI,YAAA,CAGJ,kBACI,SAAA,CAGJ,iDAEI,WAAA,CACA,oBAAA,CAGJ,iCACI,0BAAA,CACA,cAAA,CAGJ,qBACI,cAAA,CAGJ,gCACI,cAAA,CAGJ,OACI,cAAA,CAGJ,QACI,oBAAA,CAGJ,KACI,cAAA,CAGJ,gBAEI,0BAAA,CAGJ,eACI,YAAA,CAGJ,gBACI,aAAA,CACA,UAAA,CACA,oBAAA,CAGJ,eACI,SAAA,CACA,cAAA","file":"style.min.css"} \ No newline at end of file diff --git a/public/css/style.scss b/public/css/style.scss index 2ad484f..fb9cdae 100644 --- a/public/css/style.scss +++ b/public/css/style.scss @@ -247,4 +247,9 @@ div#refQuery #referenceSearch { font-size: 8pt; color: blue; text-decoration: none; +} + +.fas-trash-alt { + color: red; + cursor: pointer; } \ No newline at end of file diff --git a/public/js/script.js b/public/js/script.js index aa3ac89..d4b6928 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -302,7 +302,7 @@ function showSave() { /** * Function to discard the note by clearing all input fields and closing the menu. */ -function discardNote() { +function deleteNote(noteId, link) { document.querySelector('#noteTitle').value = ''; document.querySelector('#speaker').value = 0; document.querySelector('#series').value = 0; @@ -313,23 +313,26 @@ function discardNote() { document.querySelector('#noteDate').value = ''; document.querySelector('#noteId').value = ''; - fetch('/index.php/discard-note', { + var row = link.parentElement.parentElement; + + fetch('/index.php/delete-note', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ - 'id': document.querySelector('#noteId').value + 'id': noteId }) - .then(response => response.json()) - .then(data => { - if (data.msg == 'deleted') { - alert('Note deleted.'); - } - }) - }); + }) + .then(response => response.json()) + .then(data => { + if (data.msg != 'deleted') { + return; + } - openRef(); + alert('Note deleted.'); + row.remove(); + }); } function newSpeaker() { diff --git a/public/js/script.min.js b/public/js/script.min.js index 8b1dc82..7222773 100644 --- a/public/js/script.min.js +++ b/public/js/script.min.js @@ -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 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)}function startSave(){document.querySelector("#save-check").classList.remove("error","fa-times-circle","fa-save"),document.querySelector("#save-check").classList.add("saving","fa-save"),document.querySelector("#save-check").style.opacity=1}function showSave(){if(!saved){var checkmark=document.getElementById("save-check");checkmark.classList.add("fa-save");var si=setInterval(function(){op=parseFloat(checkmark.style.opacity),checkmark.style.opacity=op-.1,.1==checkmark.style.opacity&&(checkmark.style.opacity=0,clearInterval(si),saved=!1)},100)}}function discardNote(){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("#notes").value="",document.querySelector("#recording").value="",document.querySelector("#noteDate").value="",document.querySelector("#noteId").value="",fetch("/index.php/discard-note",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:document.querySelector("#noteId").value}).then(response=>response.json()).then(data=>{"deleted"==data.msg&&alert("Note deleted.")})}),openRef()}function newSpeaker(){"new"==document.querySelector("#speaker").value&&(document.querySelector("#newSpeaker").style.display="inline-block",document.querySelector("#speaker").style.display="none"),saved=!1,textDirty=!0}function saveSpeaker(event){13==event.keyCode&&fetch("/index.php/save-speaker",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({speakerName:document.querySelector("#newSpeaker").value})}).then(response=>response.json()).then(results=>{var newSpeaker=document.createElement("option");newSpeaker.text=document.querySelector("#newSpeaker").value,newSpeaker.value=results.id,document.querySelector("#speaker").add(newSpeaker),alert(results.msg),document.querySelector("#newSpeaker").style.display="none",document.querySelector("#speaker").style.display="inline-block",document.querySelector("#newSpeaker").value="",document.querySelector("#speaker").value=results.id})}function newSeries(){"new"==document.querySelector("#series").value&&(document.querySelector("#newSeries").style.display="inline-block",document.querySelector("#series").style.display="none"),saved=!1,textDirty=!0}function saveSeries(event){13==event.keyCode&&fetch("/index.php/save-series",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({seriesName:document.querySelector("#newSeries").value})}).then(response=>response.json()).then(results=>{var newSeries=document.createElement("option");newSeries.text=document.querySelector("#newSeries").value,newSeries.value=results.id,document.querySelector("#series").add(newSeries),alert(results.msg),document.querySelector("#newSeries").style.display="none",document.querySelector("#series").style.display="inline-block",document.querySelector("#newSeries").value="",document.querySelector("#series").value=results.id})}function openRef(closeSidebar=!0){document.querySelector("#openRefBtn").classList.add("active"),refQuery=document.querySelector("#refQuery"),refQuery.style.display="block",ref=document.querySelector("#ref"),refQuery.style.left=ref.offsetLeft+"px",refQuery.style.top=ref.offsetTop+"px",closeSidebar&&document.querySelector(".toggle").click()}function closeRef(){document.querySelector("#referenceSearch").value="",document.querySelector("#referenceSearch").style.display="",document.querySelector("#referenceType").value="",document.querySelector("#referenceBook").value="",document.querySelector("#referenceBook").style.display="none",document.querySelector("#chapter-range").innerText="",document.querySelector("#verse-range").innerText="",document.querySelector("#refQuery").style.display="none",document.querySelector("#openRefBtn").classList.remove("active")}function queryRef(type=null,book=null,input=null){if(!input)var input=document.querySelector("#refQuery #referenceSearch").value;if(!type)var type=document.querySelector("#referenceType").value;if(!book)var book=document.querySelector("#referenceBook").value;fetch("/index.php/retrieve-reference",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:type,book:book,reference:input})}).then(response=>response.json()).then(results=>{const list=document.querySelector("#ref-list");var newList=document.createElement("li");newList.className="tab",button=makeButton(results.title),newList.appendChild(button),list.appendChild(newList);const ref=document.querySelector("#ref");ref.innerHTML=md.render(results.text),references[results.title]=results.text,closeRef(),saved=!1,textDirty=!0,saveNote(),findRefLinks()})}function makeButton(title){var btn=document.createElement("button");return btn.innerText=title,btn.class="button",btn.addEventListener("click",function(){removeActiveRef(),document.querySelector("#ref").innerHTML=md.render(references[title]),this.classList.add("active"),findRefLinks()}),btn.addEventListener("dblclick",function(){document.querySelector("#ref").innerHTML="",delete references[title];var list=this.parentElement;list.remove(),saved=!1,textDirty=!0,saveNote()}),removeActiveRef(),btn.classList.add("active"),btn}function removeActiveRef(){for(var t in tabs=document.querySelectorAll(".active"),tabs)isFinite(parseInt(t))&&tabs[t].classList.remove("active")}function retrieveTemplate(orig,dest){const temp=document.querySelector("#"+orig);"0"!=temp.value?fetch("/index.php/retrieve-template",{method:"POST",headers:{"Content-Type":"plain/text"},body:JSON.stringify({template:temp.value})}).then(response=>response.text()).then(results=>{const div=document.querySelector("#"+dest);div.value=results}):document.querySelector("#"+dest).value=""}function saveTemplate(){fetch("/index.php/save-template",{method:"POST",headers:{"Content-Type":"plain/text"},body:JSON.stringify({template_id:document.querySelector("#template_id").value,template_name:document.querySelector("#template_name").value,template_value:document.querySelector("#template_value").value})}).then(response=>response.text()).then(results=>{alert(results)})}function toggleFields(){const fieldsContainer=document.getElementById("fields-container"),showHideBtn=document.getElementById("show-hide-btn");fieldsContainer.classList.contains("show")?(fieldsContainer.classList.remove("show"),fieldsContainer.style.display="none",showHideBtn.classList.remove("active")):(fieldsContainer.classList.add("show"),fieldsContainer.style.display="block",showHideBtn.classList.add("active")),setHeight()}function retrieveBooks(){document.querySelector("#chapter-range").innerText="",document.querySelector("#verse-range").innerText="",document.querySelector("#referenceSearch").value="",document.querySelector("#referenceSearch").style.display="none";const selectedType=document.querySelector("#referenceType").value;if(selectedType){var bookList=document.querySelector("#referenceBook");if(bookList.style.display="block",bookList.innerHTML="","bible"==selectedType){document.querySelector("#referenceSearch").style.display="block";var none=document.createElement("option");for(var x in none.value="",none.text="-- Select --",bookList.appendChild(none),BOOKS.bible){var newBook=document.createElement("option");newBook.text=x,bookList.appendChild(newBook)}}else if("creed"==selectedType){var none=document.createElement("option");for(var x in none.value="",none.text="-- Select --",bookList.appendChild(none),BOOKS.creed){var newBook=document.createElement("option");newBook.value=x,newBook.text=BOOKS.creed[x],bookList.appendChild(newBook)}}else if("cd"==selectedType){var none=document.createElement("option");for(var x in none.value="",none.text="-- Select --",bookList.appendChild(none),BOOKS.cd){var newBook=document.createElement("option");newBook.text=BOOKS.cd[x],bookList.appendChild(newBook)}}else if("note"==selectedType){var none=document.createElement("option");none.value="",none.text="-- Select --",bookList.appendChild(none),fetch("/index.php/retrieve-reference",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"note"})}).then(response=>response.json()).then(results=>{for(var x in results){var newBook=document.createElement("option");newBook.value=results[x].id,newBook.text=results[x].title,bookList.appendChild(newBook)}})}else{var min=BOOKS[selectedType][0],max=BOOKS[selectedType][1],none=document.createElement("option");none.value="",none.text="-- Select --",bookList.appendChild(none);for(var x=min;x<=max;x++){var newBook=document.createElement("option");newBook.value=x,newBook.text=x,bookList.appendChild(newBook)}}}}function filterBooks(){if(document.querySelector("#chapter-range").innerText="",document.querySelector("#verse-range").innerText="","bible"==document.querySelector("#referenceType").value){var bookList=document.querySelector("#referenceBook"),book=BOOKS.bible[bookList.value],max=Object.keys(book).length,chapterRange=document.querySelector("#chapter-range");chapterRange.innerText="Chapters: "+max}}function filterVerse(){if("bible"==document.querySelector("#referenceType").value){var bookList=document.querySelector("#referenceBook").value,search=document.querySelector("#referenceSearch").value,chapter=search.split(":")[0],verseRange=document.querySelector("#verse-range");if(BOOKS.bible[bookList]&&BOOKS.bible[bookList][chapter]){var verse=BOOKS.bible[bookList][chapter];verseRange.innerText="Verse: "+verse}else verseRange.innerText="Unknown Chapter"}}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");for(var x in none.value="",none.text="-- Select --",document.querySelector("#referenceSeries").appendChild(none),results){var newSeries=document.createElement("option");newSeries.value=results[x].id,newSeries.text=results[x].label,document.querySelector("#referenceSeries").appendChild(newSeries)}})}function retrieveReference(el){"new"!=el.value?fetch("/index.php/get-reference",{method:"POST",header:{"Content-Type":"application/json"},body:JSON.stringify({id:el.value})}).then(response=>response.json()).then(results=>{document.querySelector("#reference").value=results.text}):document.querySelector("#refName").style.display="inline-block"}function saveReference(){var select=document.querySelector("#references");fetch("/index.php/save-reference",{method:"POST",header:{"Content-Type":"application/json"},body:JSON.stringify({type:select.options[select.selectedIndex].getAttribute("type"),file:select.value,text:document.querySelector("#reference").value})}).then(response=>response.json()).then(results=>{alert(results.msg),document.querySelector("#reference").value="",document.querySelector("#references").value=""})}function previewNote(){var noteText=document.querySelector("#notes"),notePreview=document.querySelector("#notePreview"),previewButton=document.querySelector("#previewBtn");const title=document.querySelector("#noteTitle"),speaker=document.querySelector("#speaker"),passage=document.querySelector("#passage"),markdownPreview="# "+title.value+" - "+speaker.options[speaker.selectedIndex].text+" - "+passage.value+"\n\n"+noteText.value;notePreview.innerHTML=md.render(markdownPreview),previewButton.classList.contains("active")?(noteText.style.display="block",notePreview.style.display="none",previewButton.classList.remove("active")):(noteText.style.display="none",notePreview.style.display="block",previewButton.classList.add("active")),findLinks()}function findLinks(){for(var links=document.querySelector("#notePreview").querySelectorAll("a"),i=0;iresponse.text()).then(result=>{passage=passage.replace(/\+/g," "),psg=passage.split(" "),psg.length>2?(book=psg[0]+" "+psg[1],cv=psg[2]):(book=psg[0],cv=psg[1]),showPassage(e,"  
"+result)})}})}function findRefLinks(){for(var links=document.querySelector("#ref").querySelectorAll("a"),i=0;iresponse.text()).then(result=>{passage=passage.replace(/\+/g," "),psg=passage.split(" "),psg.length>2?(book=psg[0]+" "+psg[1],cv=psg[2]):(book=psg[0],cv=psg[1]),showPassage(e,"  
"+result)})}})}function showPassage(event,text){const popup=document.querySelector("#passage-popup");popup.innerHTML=md.render(text);let x=event.clientX+window.scrollX,y=event.clientY+window.scrollY;popup.style.top=`${y}px`,popup.style.left=`${x}px`,popup.style.display="block"}function closePopup(){const popup=document.querySelector("#passage-popup");popup.innerHTML="",popup.style.display="none"}function openNote(openSidebar=!0){const noteList=document.querySelector("#note-list"),refs=document.querySelector("#ref");"block"==noteList.style.display?(noteList.style.display="none",refs.style.display="block"):(noteList.style.display="block",refs.style.display="none"),openSidebar&&document.querySelector(".toggle").click()}function retrieveNote(id,runOpen=!0){fetch("/index.php/get-note",{method:"POST",header:{"Content-Type":"application/json"},body:JSON.stringify({id:id})}).then(response=>response.json()).then(result=>{var dt=new Date(result.date.date);document.querySelector("#notes").value=result.text,document.querySelector("#passage").value=result.passage,document.querySelector("#series").value=result.series.id,document.querySelector("#speaker").value=result.speaker.id,document.querySelector("#noteTitle").value=result.title,document.querySelector("#noteDate").value="",document.querySelector("#noteDate").value=(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,result.refs&&(references=result.refs);const list=document.querySelector("#ref-list");list.innerHTML="";var newList=null;for(var x in references){var newList=document.createElement("li");newList.className="tab";var button=makeButton(x);newList.appendChild(button),list.appendChild(newList)}runOpen&&openNote(!1)})}function increaseFont(){var currentSize=document.querySelector("#ref").style.fontSize;document.querySelector("#ref").style.fontSize=parseInt(currentSize)+1+"pt"}function decreaseFont(){var currentSize=document.querySelector("#ref").style.fontSize;document.querySelector("#ref").style.fontSize=parseInt(currentSize)-1+"pt"}function uuidv4(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){const r=16*Math.random()|0,v="x"==c?r:3&r|8;return v.toString(16)})}var md=null,references={},tabs=[];let saved=!1,textDirty=!1;var to=null;let controller;var BOOKS={};$(function(){setHeight(),setBooks(),setEventListeners(),$("#note-table").DataTable({paging:!1,ajax:{url:"/index.php/get-notes",type:"POST"},columns:[{data:"link"},{data:"speaker.name"},{data:"passage"},{data:"date.date",render:DataTable.render.date("L")}]})}); \ No newline at end of file +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 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)}function startSave(){document.querySelector("#save-check").classList.remove("error","fa-times-circle","fa-save"),document.querySelector("#save-check").classList.add("saving","fa-save"),document.querySelector("#save-check").style.opacity=1}function showSave(){if(!saved){var checkmark=document.getElementById("save-check");checkmark.classList.add("fa-save");var si=setInterval(function(){op=parseFloat(checkmark.style.opacity),checkmark.style.opacity=op-.1,.1==checkmark.style.opacity&&(checkmark.style.opacity=0,clearInterval(si),saved=!1)},100)}}function deleteNote(noteId,link){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("#notes").value="",document.querySelector("#recording").value="",document.querySelector("#noteDate").value="",document.querySelector("#noteId").value="";var row=link.parentElement.parentElement;fetch("/index.php/delete-note",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:noteId})}).then(response=>response.json()).then(data=>{"deleted"==data.msg&&(alert("Note deleted."),row.remove())})}function newSpeaker(){"new"==document.querySelector("#speaker").value&&(document.querySelector("#newSpeaker").style.display="inline-block",document.querySelector("#speaker").style.display="none"),saved=!1,textDirty=!0}function saveSpeaker(event){13==event.keyCode&&fetch("/index.php/save-speaker",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({speakerName:document.querySelector("#newSpeaker").value})}).then(response=>response.json()).then(results=>{var newSpeaker=document.createElement("option");newSpeaker.text=document.querySelector("#newSpeaker").value,newSpeaker.value=results.id,document.querySelector("#speaker").add(newSpeaker),alert(results.msg),document.querySelector("#newSpeaker").style.display="none",document.querySelector("#speaker").style.display="inline-block",document.querySelector("#newSpeaker").value="",document.querySelector("#speaker").value=results.id})}function newSeries(){"new"==document.querySelector("#series").value&&(document.querySelector("#newSeries").style.display="inline-block",document.querySelector("#series").style.display="none"),saved=!1,textDirty=!0}function saveSeries(event){13==event.keyCode&&fetch("/index.php/save-series",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({seriesName:document.querySelector("#newSeries").value})}).then(response=>response.json()).then(results=>{var newSeries=document.createElement("option");newSeries.text=document.querySelector("#newSeries").value,newSeries.value=results.id,document.querySelector("#series").add(newSeries),alert(results.msg),document.querySelector("#newSeries").style.display="none",document.querySelector("#series").style.display="inline-block",document.querySelector("#newSeries").value="",document.querySelector("#series").value=results.id})}function openRef(closeSidebar=!0){document.querySelector("#openRefBtn").classList.add("active"),refQuery=document.querySelector("#refQuery"),refQuery.style.display="block",ref=document.querySelector("#ref"),refQuery.style.left=ref.offsetLeft+"px",refQuery.style.top=ref.offsetTop+"px",closeSidebar&&document.querySelector(".toggle").click()}function closeRef(){document.querySelector("#referenceSearch").value="",document.querySelector("#referenceSearch").style.display="",document.querySelector("#referenceType").value="",document.querySelector("#referenceBook").value="",document.querySelector("#referenceBook").style.display="none",document.querySelector("#chapter-range").innerText="",document.querySelector("#verse-range").innerText="",document.querySelector("#refQuery").style.display="none",document.querySelector("#openRefBtn").classList.remove("active")}function queryRef(type=null,book=null,input=null){if(!input)var input=document.querySelector("#refQuery #referenceSearch").value;if(!type)var type=document.querySelector("#referenceType").value;if(!book)var book=document.querySelector("#referenceBook").value;fetch("/index.php/retrieve-reference",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:type,book:book,reference:input})}).then(response=>response.json()).then(results=>{const list=document.querySelector("#ref-list");var newList=document.createElement("li");newList.className="tab",button=makeButton(results.title),newList.appendChild(button),list.appendChild(newList);const ref=document.querySelector("#ref");ref.innerHTML=md.render(results.text),references[results.title]=results.text,closeRef(),saved=!1,textDirty=!0,saveNote(),findRefLinks()})}function makeButton(title){var btn=document.createElement("button");return btn.innerText=title,btn.class="button",btn.addEventListener("click",function(){removeActiveRef(),document.querySelector("#ref").innerHTML=md.render(references[title]),this.classList.add("active"),findRefLinks()}),btn.addEventListener("dblclick",function(){document.querySelector("#ref").innerHTML="",delete references[title];var list=this.parentElement;list.remove(),saved=!1,textDirty=!0,saveNote()}),removeActiveRef(),btn.classList.add("active"),btn}function removeActiveRef(){for(var t in tabs=document.querySelectorAll(".active"),tabs)isFinite(parseInt(t))&&tabs[t].classList.remove("active")}function retrieveTemplate(orig,dest){const temp=document.querySelector("#"+orig);"0"!=temp.value?fetch("/index.php/retrieve-template",{method:"POST",headers:{"Content-Type":"plain/text"},body:JSON.stringify({template:temp.value})}).then(response=>response.text()).then(results=>{const div=document.querySelector("#"+dest);div.value=results}):document.querySelector("#"+dest).value=""}function saveTemplate(){fetch("/index.php/save-template",{method:"POST",headers:{"Content-Type":"plain/text"},body:JSON.stringify({template_id:document.querySelector("#template_id").value,template_name:document.querySelector("#template_name").value,template_value:document.querySelector("#template_value").value})}).then(response=>response.text()).then(results=>{alert(results)})}function toggleFields(){const fieldsContainer=document.getElementById("fields-container"),showHideBtn=document.getElementById("show-hide-btn");fieldsContainer.classList.contains("show")?(fieldsContainer.classList.remove("show"),fieldsContainer.style.display="none",showHideBtn.classList.remove("active")):(fieldsContainer.classList.add("show"),fieldsContainer.style.display="block",showHideBtn.classList.add("active")),setHeight()}function retrieveBooks(){document.querySelector("#chapter-range").innerText="",document.querySelector("#verse-range").innerText="",document.querySelector("#referenceSearch").value="",document.querySelector("#referenceSearch").style.display="none";const selectedType=document.querySelector("#referenceType").value;if(selectedType){var bookList=document.querySelector("#referenceBook");if(bookList.style.display="block",bookList.innerHTML="","bible"==selectedType){document.querySelector("#referenceSearch").style.display="block";var none=document.createElement("option");for(var x in none.value="",none.text="-- Select --",bookList.appendChild(none),BOOKS.bible){var newBook=document.createElement("option");newBook.text=x,bookList.appendChild(newBook)}}else if("creed"==selectedType){var none=document.createElement("option");for(var x in none.value="",none.text="-- Select --",bookList.appendChild(none),BOOKS.creed){var newBook=document.createElement("option");newBook.value=x,newBook.text=BOOKS.creed[x],bookList.appendChild(newBook)}}else if("cd"==selectedType){var none=document.createElement("option");for(var x in none.value="",none.text="-- Select --",bookList.appendChild(none),BOOKS.cd){var newBook=document.createElement("option");newBook.text=BOOKS.cd[x],bookList.appendChild(newBook)}}else if("note"==selectedType){var none=document.createElement("option");none.value="",none.text="-- Select --",bookList.appendChild(none),fetch("/index.php/retrieve-reference",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"note"})}).then(response=>response.json()).then(results=>{for(var x in results){var newBook=document.createElement("option");newBook.value=results[x].id,newBook.text=results[x].title,bookList.appendChild(newBook)}})}else{var min=BOOKS[selectedType][0],max=BOOKS[selectedType][1],none=document.createElement("option");none.value="",none.text="-- Select --",bookList.appendChild(none);for(var x=min;x<=max;x++){var newBook=document.createElement("option");newBook.value=x,newBook.text=x,bookList.appendChild(newBook)}}}}function filterBooks(){if(document.querySelector("#chapter-range").innerText="",document.querySelector("#verse-range").innerText="","bible"==document.querySelector("#referenceType").value){var bookList=document.querySelector("#referenceBook"),book=BOOKS.bible[bookList.value],max=Object.keys(book).length,chapterRange=document.querySelector("#chapter-range");chapterRange.innerText="Chapters: "+max}}function filterVerse(){if("bible"==document.querySelector("#referenceType").value){var bookList=document.querySelector("#referenceBook").value,search=document.querySelector("#referenceSearch").value,chapter=search.split(":")[0],verseRange=document.querySelector("#verse-range");if(BOOKS.bible[bookList]&&BOOKS.bible[bookList][chapter]){var verse=BOOKS.bible[bookList][chapter];verseRange.innerText="Verse: "+verse}else verseRange.innerText="Unknown Chapter"}}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");for(var x in none.value="",none.text="-- Select --",document.querySelector("#referenceSeries").appendChild(none),results){var newSeries=document.createElement("option");newSeries.value=results[x].id,newSeries.text=results[x].label,document.querySelector("#referenceSeries").appendChild(newSeries)}})}function retrieveReference(el){"new"!=el.value?fetch("/index.php/get-reference",{method:"POST",header:{"Content-Type":"application/json"},body:JSON.stringify({id:el.value})}).then(response=>response.json()).then(results=>{document.querySelector("#reference").value=results.text}):document.querySelector("#refName").style.display="inline-block"}function saveReference(){var select=document.querySelector("#references");fetch("/index.php/save-reference",{method:"POST",header:{"Content-Type":"application/json"},body:JSON.stringify({type:select.options[select.selectedIndex].getAttribute("type"),file:select.value,text:document.querySelector("#reference").value})}).then(response=>response.json()).then(results=>{alert(results.msg),document.querySelector("#reference").value="",document.querySelector("#references").value=""})}function previewNote(){var noteText=document.querySelector("#notes"),notePreview=document.querySelector("#notePreview"),previewButton=document.querySelector("#previewBtn");const title=document.querySelector("#noteTitle"),speaker=document.querySelector("#speaker"),passage=document.querySelector("#passage"),markdownPreview="# "+title.value+" - "+speaker.options[speaker.selectedIndex].text+" - "+passage.value+"\n\n"+noteText.value;notePreview.innerHTML=md.render(markdownPreview),previewButton.classList.contains("active")?(noteText.style.display="block",notePreview.style.display="none",previewButton.classList.remove("active")):(noteText.style.display="none",notePreview.style.display="block",previewButton.classList.add("active")),findLinks()}function findLinks(){for(var links=document.querySelector("#notePreview").querySelectorAll("a"),i=0;iresponse.text()).then(result=>{passage=passage.replace(/\+/g," "),psg=passage.split(" "),psg.length>2?(book=psg[0]+" "+psg[1],cv=psg[2]):(book=psg[0],cv=psg[1]),showPassage(e,"  
"+result)})}})}function findRefLinks(){for(var links=document.querySelector("#ref").querySelectorAll("a"),i=0;iresponse.text()).then(result=>{passage=passage.replace(/\+/g," "),psg=passage.split(" "),psg.length>2?(book=psg[0]+" "+psg[1],cv=psg[2]):(book=psg[0],cv=psg[1]),showPassage(e,"  
"+result)})}})}function showPassage(event,text){const popup=document.querySelector("#passage-popup");popup.innerHTML=md.render(text);let x=event.clientX+window.scrollX,y=event.clientY+window.scrollY;popup.style.top=`${y}px`,popup.style.left=`${x}px`,popup.style.display="block"}function closePopup(){const popup=document.querySelector("#passage-popup");popup.innerHTML="",popup.style.display="none"}function openNote(openSidebar=!0){const noteList=document.querySelector("#note-list"),refs=document.querySelector("#ref");"block"==noteList.style.display?(noteList.style.display="none",refs.style.display="block"):(noteList.style.display="block",refs.style.display="none"),openSidebar&&document.querySelector(".toggle").click()}function retrieveNote(id,runOpen=!0){fetch("/index.php/get-note",{method:"POST",header:{"Content-Type":"application/json"},body:JSON.stringify({id:id})}).then(response=>response.json()).then(result=>{var dt=new Date(result.date.date);document.querySelector("#notes").value=result.text,document.querySelector("#passage").value=result.passage,document.querySelector("#series").value=result.series.id,document.querySelector("#speaker").value=result.speaker.id,document.querySelector("#noteTitle").value=result.title,document.querySelector("#noteDate").value="",document.querySelector("#noteDate").value=(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,result.refs&&(references=result.refs);const list=document.querySelector("#ref-list");list.innerHTML="";var newList=null;for(var x in references){var newList=document.createElement("li");newList.className="tab";var button=makeButton(x);newList.appendChild(button),list.appendChild(newList)}runOpen&&openNote(!1)})}function increaseFont(){var currentSize=document.querySelector("#ref").style.fontSize;document.querySelector("#ref").style.fontSize=parseInt(currentSize)+1+"pt"}function decreaseFont(){var currentSize=document.querySelector("#ref").style.fontSize;document.querySelector("#ref").style.fontSize=parseInt(currentSize)-1+"pt"}function uuidv4(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){const r=16*Math.random()|0,v="x"==c?r:3&r|8;return v.toString(16)})}var md=null,references={},tabs=[];let saved=!1,textDirty=!1;var to=null;let controller;var BOOKS={};$(function(){setHeight(),setBooks(),setEventListeners(),$("#note-table").DataTable({paging:!1,ajax:{url:"/index.php/get-notes",type:"POST"},columns:[{data:"link"},{data:"speaker.name"},{data:"passage"},{data:"date.date",render:DataTable.render.date("L")}]})}); \ No newline at end of file diff --git a/src/Controller/AjaxController.php b/src/Controller/AjaxController.php index a573f5c..5d31caa 100644 --- a/src/Controller/AjaxController.php +++ b/src/Controller/AjaxController.php @@ -332,7 +332,7 @@ class AjaxController extends AbstractController return $res; } - #[Route('/discard-note', name: 'app_discard_note', methods: ['POST'])] + #[Route('/delete-note', name: 'app_discard_note', methods: ['POST'])] public function discardNote(Request $req, EntityManagerInterface $emi): Response { $data = json_decode($req->getContent()); diff --git a/src/Entity/Note.php b/src/Entity/Note.php index 421bfa0..0148d58 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -169,6 +169,9 @@ class Note implements JsonSerializable { return "id}')\">". $this->title. + " ". + "id}', this)\">". + "". "". ( $this->recording ? "
". @@ -180,7 +183,7 @@ class Note implements JsonSerializable public function toTableRow(): string { - return "". + return "". "{$this->toLink()}". "{$this->speaker->getName()}". "{$this->passage}".