diff --git a/main.js b/main.js index 1d6a854..98300ff 100644 --- a/main.js +++ b/main.js @@ -1 +1 @@ -(()=>{"use strict";var e={523:(e,t,n)=>{n.d(t,{A:()=>s});var r=n(601),o=n.n(r),i=n(314),a=n.n(i)()(o());a.push([e.id,"* {\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n}\n\nbody {\n height: 100vh;\n}\n\n.main-container {\n height: 100%;\n display: grid;\n grid-template-columns: 4fr 7fr;\n}\n\n.main-sidebar {\n display: grid;\n grid-template-rows: 64px 1fr 1fr;\n}\n\n.form-sidebar {\n display: flex;\n flex-direction: column;\n align-items: center;\n}\n\n.title-sidebar {\n height: 100%;\n border: 2px solid cyan;\n font-size: 2rem;\n display: grid;\n place-content: center;\n}\n\ndialog form {\n width: 300px;\n display: flex;\n flex-direction: column;\n align-items: center;\n & textarea {\n width: 100%;\n height: 150px;\n }\n}\n\ndialog {\n transform: translateX(-50%);\n left: 50%;\n}\ndialog::backdrop {\n backdrop-filter: blur(4px);\n}\n\n.main-grid {\n border: 2px solid blue;\n grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));\n grid-template-rows: repeat(auto-fit, 200px);\n display: grid;\n justify-items: center;\n padding: 16px;\n gap: 24px;\n}\n\n.note-container {\n width: clamp(200px, 100%, 400px);\n height: 200px;\n border-radius: 16px;\n border: 2px solid red;\n display: grid;\n grid-template-rows: 2fr 4fr 1fr;\n}\n\n.title {\n height: fit-content;\n padding: 12px;\n width: 100%;\n font-size: x-large;\n font-weight: 600;\n border: none;\n border-radius: 16px;\n}\n\n.description {\n padding: 12px;\n width: 100%;\n height: 100%;\n border: none;\n}\n\n.note-container input:focus {\n outline: 2px dotted blue;\n}\n\n.note-container input {\n border-radius: 16px;\n}\n\n.note-container textarea {\n resize: none;\n border-radius: 16px;\n &:focus {\n outline: 2px dotted blue;\n }\n}\n",""]);const s=a},314:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,r,o,i){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(r)for(var s=0;s0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=i),n&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=n):l[2]=n),o&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=o):l[4]="".concat(o)),t.push(l))}},t}},601:e=>{e.exports=function(e){return e[1]}},72:e=>{var t=[];function n(e){for(var n=-1,r=0;r{var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},540:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,n)=>{e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.nc=void 0;var r=n(72),o=n.n(r),i=n(825),a=n.n(i),s=n(659),d=n.n(s),c=n(56),l=n.n(c),u=n(540),p=n.n(u),f=n(113),h=n.n(f),m=n(523),v={};v.styleTagTransform=h(),v.setAttributes=l(),v.insert=d().bind(null,"head"),v.domAPI=a(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals;const g={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var y,b=new Uint8Array(16);function x(){if(!y&&!(y="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return y(b)}for(var N=[],w=0;w<256;++w)N.push((w+256).toString(16).slice(1));const C=function(e,t,n){if(g.randomUUID&&!t&&!e)return g.randomUUID();var r=(e=e||{}).random||(e.rng||x)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return function(e,t=0){return(N[e[t+0]]+N[e[t+1]]+N[e[t+2]]+N[e[t+3]]+"-"+N[e[t+4]]+N[e[t+5]]+"-"+N[e[t+6]]+N[e[t+7]]+"-"+N[e[t+8]]+N[e[t+9]]+"-"+N[e[t+10]]+N[e[t+11]]+N[e[t+12]]+N[e[t+13]]+N[e[t+14]]+N[e[t+15]]).toLowerCase()}(r)},E=function(){function e(){this._list=Array();var e=this.loadNotes();0===e.length?this.addNote("Бяка1","wf","low"):this._list=e}return e.prototype.toNote=function(){},e.prototype.addNote=function(e,t,n){var r={uuid:C(),title:e,description:t,priority:n};this._list.push(r),this.saveNotes()},e.prototype.saveNotes=function(){localStorage.setItem("notes",this.getNotesJson())},e.prototype.loadNotes=function(){var e=JSON.parse(localStorage.getItem("notes")),t=Array();return e.forEach((function(e){t.push(e)})),t},e.prototype.deleteNote=function(e){var t=this._list.findIndex((function(t){return t.uuid===e}));this._list.splice(t,1),this.saveNotes()},e.prototype.getNotes=function(){return this.loadNotes()},e.prototype.getNotesJson=function(){return JSON.stringify(this._list)},e.prototype.getNoteUuidByIndex=function(e){var t=this._list[e].uuid;return console.log(t),t},e.prototype.updateNoteByUuid=function(e,t,n){var r=this._list.findIndex((function(t){return t.uuid===e}));console.log(r),-1!==r&&(this._list[r][t]=n,this.saveNotes())},e}(),S=function(){function e(e,t,n){this.document=e,this.dblClickEventCallback=t,this.setChangeEventCallback=n}return e.prototype.renderNotes=function(e){var t=this,n=this.document.querySelector(".main-grid");n.innerHTML="",e.forEach((function(e){console.log("note created"),n.appendChild(t.createNoteDiv(e))}))},e.prototype.createNoteDiv=function(e){var t=this,n=this.document.createElement("div");n.id=e.uuid,n.classList.add("note-container");var r=this.document.createElement("input");r.className="title",r.value=e.title;var o=this.document.createElement("textarea");o.className="description",o.value=e.description;var i=this.document.createElement("div");return i.className="priority",i.textContent="Приоритет: "+e.priority,n.appendChild(r),n.appendChild(o),n.appendChild(i),n.ondblclick=function(e){t.dblClickEventCallback(e)},this.setChangeEventCallback(n),n},e}();new(function(){function e(e){this.model=new E,this.view=new S(e,this.noteDblClickHandler.bind(this),this.setNoteUpdateHandler.bind(this)),this.document=e,this.formSubmitHandler(),this.model.addNote("Бяка1","wf","low"),this.model.addNote("Бяка2","sfd","mid"),this.model.addNote("Бяка3","sfwed","high")}return e.prototype.render=function(){var e=this.model.getNotes();console.log(this.model.getNotesJson()),this.view.renderNotes(e)},e.prototype.noteDblClickHandler=function(e){var t=e.target.parentElement.id;console.log(t),console.log(this),console.log(this.model),this.model.deleteNote(t),this.render()},e.prototype.setNoteUpdateHandler=function(e){var t=this;e.addEventListener("change",(function(e){var n=e.target,r=n.parentElement.id;t.model.updateNoteByUuid(r,n.className,n.value),t.render()}))},e.prototype.formSubmitHandler=function(){var e=this;this.document.querySelector("#newNoteDialog>form").addEventListener("submit",(function(t){var n=e.document.querySelector("#formTitle"),r=e.document.querySelector("#formDescription"),o=e.document.querySelector("#formPriority");e.model.addNote(n.value,r.value,o.value),n.value="",r.value="",o.value="low",e.render()}))},e}())(document).render()})(); \ No newline at end of file +(()=>{"use strict";var e={523:(e,t,n)=>{n.d(t,{A:()=>s});var r=n(601),o=n.n(r),i=n(314),a=n.n(i)()(o());a.push([e.id,"* {\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n}\n\nbody {\n height: 100vh;\n}\n\n.main-container {\n height: 100%;\n display: grid;\n grid-template-columns: 4fr 7fr;\n}\n\n.main-sidebar {\n display: grid;\n grid-template-rows: 64px 1fr 1fr;\n}\n\n.form-sidebar {\n display: flex;\n flex-direction: column;\n align-items: center;\n}\n\n.title-sidebar {\n height: 100%;\n border: 2px solid cyan;\n font-size: 2rem;\n display: grid;\n place-content: center;\n}\n\ndialog form {\n width: 300px;\n display: flex;\n flex-direction: column;\n align-items: center;\n & textarea {\n width: 100%;\n height: 150px;\n }\n}\n\ndialog {\n transform: translateX(-50%);\n left: 50%;\n}\ndialog::backdrop {\n backdrop-filter: blur(4px);\n}\n\n.main-grid {\n border: 2px solid blue;\n grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));\n grid-template-rows: repeat(auto-fit, 200px);\n display: grid;\n justify-items: center;\n padding: 16px;\n gap: 24px;\n}\n\n.note-container {\n width: clamp(200px, 100%, 400px);\n height: 200px;\n border-radius: 16px;\n border: 2px solid red;\n display: grid;\n grid-template-rows: 2fr 4fr 1fr;\n}\n\n.title {\n height: fit-content;\n padding: 12px;\n width: 100%;\n font-size: x-large;\n font-weight: 600;\n border: none;\n border-radius: 16px;\n}\n\n.description {\n padding: 12px;\n width: 100%;\n height: 100%;\n border: none;\n}\n\n.note-container input:focus {\n outline: 2px dotted blue;\n}\n\n.note-container input {\n border-radius: 16px;\n}\n\n.note-container textarea {\n resize: none;\n border-radius: 16px;\n &:focus {\n outline: 2px dotted blue;\n }\n}\n",""]);const s=a},314:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,r,o,i){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(r)for(var s=0;s0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=i),n&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=n):l[2]=n),o&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=o):l[4]="".concat(o)),t.push(l))}},t}},601:e=>{e.exports=function(e){return e[1]}},72:e=>{var t=[];function n(e){for(var n=-1,r=0;r{var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},540:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,n)=>{e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.nc=void 0;var r=n(72),o=n.n(r),i=n(825),a=n.n(i),s=n(659),d=n.n(s),c=n(56),l=n.n(c),u=n(540),p=n.n(u),f=n(113),h=n.n(f),m=n(523),v={};v.styleTagTransform=h(),v.setAttributes=l(),v.insert=d().bind(null,"head"),v.domAPI=a(),v.insertStyleElement=p(),o()(m.A,v),m.A&&m.A.locals&&m.A.locals;const g={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var y,b=new Uint8Array(16);function x(){if(!y&&!(y="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return y(b)}for(var N=[],w=0;w<256;++w)N.push((w+256).toString(16).slice(1));const C=function(e,t,n){if(g.randomUUID&&!t&&!e)return g.randomUUID();var r=(e=e||{}).random||(e.rng||x)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return function(e,t=0){return(N[e[t+0]]+N[e[t+1]]+N[e[t+2]]+N[e[t+3]]+"-"+N[e[t+4]]+N[e[t+5]]+"-"+N[e[t+6]]+N[e[t+7]]+"-"+N[e[t+8]]+N[e[t+9]]+"-"+N[e[t+10]]+N[e[t+11]]+N[e[t+12]]+N[e[t+13]]+N[e[t+14]]+N[e[t+15]]).toLowerCase()}(r)},S=function(){function e(){this._list=Array(),null===JSON.parse(localStorage.getItem("notes"))&&localStorage.setItem("notes",this.getNotesJson());var e=this.loadNotes();console.log(e),this._list=e}return e.prototype.addNote=function(e,t,n){var r={uuid:C(),title:e,description:t,priority:n};this._list.push(r),this.saveNotes()},e.prototype.saveNotes=function(){localStorage.setItem("notes",this.getNotesJson())},e.prototype.loadNotes=function(){var e=JSON.parse(localStorage.getItem("notes")),t=Array();return console.log(e),e.forEach((function(e){t.push(e)})),t},e.prototype.deleteNote=function(e){var t=this._list.findIndex((function(t){return t.uuid===e}));this._list.splice(t,1),this.saveNotes()},e.prototype.getNotes=function(){return this.loadNotes()},e.prototype.getNotesJson=function(){return JSON.stringify(this._list)},e.prototype.getNoteUuidByIndex=function(e){var t=this._list[e].uuid;return console.log(t),t},e.prototype.updateNoteByUuid=function(e,t,n){var r=this._list.findIndex((function(t){return t.uuid===e}));console.log(r),-1!==r&&(this._list[r][t]=n,this.saveNotes())},e}(),E=function(){function e(e,t,n){this.document=e,this.dblClickEventCallback=t,this.setChangeEventCallback=n}return e.prototype.renderNotes=function(e){var t=this,n=this.document.querySelector(".main-grid");n.innerHTML="",e.forEach((function(e){console.log("note created"),n.appendChild(t.createNoteDiv(e))}))},e.prototype.createNoteDiv=function(e){var t=this,n=this.document.createElement("div");n.id=e.uuid,n.classList.add("note-container");var r=this.document.createElement("input");r.className="title",r.value=e.title;var o=this.document.createElement("textarea");o.className="description",o.value=e.description;var i=this.document.createElement("div");return i.className="priority",i.textContent="Приоритет: "+e.priority,n.appendChild(r),n.appendChild(o),n.appendChild(i),n.ondblclick=function(e){t.dblClickEventCallback(e)},this.setChangeEventCallback(n),n},e}();new(function(){function e(e){this.model=new S,this.view=new E(e,this.noteDblClickHandler.bind(this),this.setNoteUpdateHandler.bind(this)),this.document=e,this.formSubmitHandler()}return e.prototype.render=function(){var e=this.model.getNotes();console.log(this.model.getNotesJson()),this.view.renderNotes(e)},e.prototype.noteDblClickHandler=function(e){var t=e.target.parentElement.id;console.log(t),console.log(this),console.log(this.model),this.model.deleteNote(t),this.render()},e.prototype.setNoteUpdateHandler=function(e){var t=this;e.addEventListener("change",(function(e){var n=e.target,r=n.parentElement.id;t.model.updateNoteByUuid(r,n.className,n.value),t.render()}))},e.prototype.formSubmitHandler=function(){var e=this;this.document.querySelector("#newNoteDialog>form").addEventListener("submit",(function(t){var n=e.document.querySelector("#formTitle"),r=e.document.querySelector("#formDescription"),o=e.document.querySelector("#formPriority");e.model.addNote(n.value,r.value,o.value),n.value="",r.value="",o.value="low",e.render()}))},e}())(document).render()})(); \ No newline at end of file