From 27b504790f0de5494e188b54301569a1d3f01803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20W=C3=B3jtowicz?= Date: Sat, 24 Aug 2024 22:48:34 +0200 Subject: [PATCH] Github Pages Init --- JustDoIt/dist/main.js | 1 + JustDoIt/dist/style.css | 1 + index.html | 1 + 3 files changed, 3 insertions(+) create mode 100644 JustDoIt/dist/main.js create mode 100644 JustDoIt/dist/style.css create mode 100644 index.html diff --git a/JustDoIt/dist/main.js b/JustDoIt/dist/main.js new file mode 100644 index 0000000..9c75fda --- /dev/null +++ b/JustDoIt/dist/main.js @@ -0,0 +1 @@ +(()=>{"use strict";var t={260:(t,e,i)=>{i.r(e)},859:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),i(260);const o=n(i(211)),r=i(9);o.default.Instance,(0,r.InitFormModal)()},648:function(t,e,i){var n=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function d(t){try{l(n.next(t))}catch(t){r(t)}}function s(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(d,s)}l((n=n.apply(t,e||[])).next())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=o(i(211)),d=i(9),s=document.getElementById("todo-container"),l=document.getElementById("todo-item-template");let a=null;e.default=function(){return function(t){return class extends t{constructor(...t){var e;super(...t);const i=l.content.cloneNode(!0);this._id=null!==(e=t[3])&&void 0!==e?e:r.default.Instance.GenerateId(),this._imageElement=i.querySelector(".todo-item-icon"),this._titleElement=i.querySelector(".todo-item-details_title"),this._descriptionElement=i.querySelector(".todo-item-details_description"),i.querySelector(".todo-item-details_date").textContent=`${this._date.toLocaleDateString()} ${this._date.toLocaleTimeString()}`,this.SetData(t[0],t[1],t[2]),i.querySelector(".edit-btn").addEventListener("click",(()=>n(this,void 0,void 0,(function*(){const t=yield(0,d.EditForm)(this);if(null==t)return;const e=t.get("todo-form-title"),i=t.get("todo-form-description"),n=+t.get("todo-form-icon");r.default.Instance.Edit(this._id,e,i,n),this.SetData(e,i,n)})))),i.querySelector(".delete-btn").addEventListener("click",(()=>{r.default.Instance.Delete(this._id),s.removeChild(this._)})),s.appendChild(i),this._=s.querySelector(".todo-item:last-child"),this._.setAttribute("data-item-id",this._id.toString()),this._.addEventListener("dragstart",this.dragStartHandler.bind(this)),this._.addEventListener("drop",this.dropHandler.bind(this)),this._.addEventListener("dragend",this.dragEndHandler.bind(this)),this._.addEventListener("dragover",this.dragOverHandler.bind(this)),this._.addEventListener("dragleave",this.dragLeaveHandler.bind(this))}SetData(t,e,i){(i||0===i)&&(this._imageElement.src=`./JustDoIt/img/${i}.png`),t&&(this._titleElement.textContent=t),e&&(this._descriptionElement.textContent=e)}dragStartHandler(t){a=t.target,s.querySelectorAll(".todo-item").forEach((t=>{this._!==t&&t.classList.add("todo-item-dragover_default")}))}dropHandler(t){t.preventDefault(),this._!==a&&(s.insertBefore(a,this._),r.default.Instance.RelocateObjById(a.getAttribute("data-item-id"),this._.getAttribute("data-item-id")))}dragEndHandler(t){a=null,s.querySelectorAll(".todo-item").forEach((t=>{t.classList.remove("todo-item-dragover_default","todo-item-dragover")}))}dragOverHandler(t){t.preventDefault(),this._!==a&&this._.classList.add("todo-item-dragover")}dragLeaveHandler(t){this._.classList.remove("todo-item-dragover")}}}}},524:function(t,e,i){var n=this&&this.__decorate||function(t,e,i,n){var o,r=arguments.length,d=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)d=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(d=(r<3?o(d):r>3?o(e,i,d):o(e,i))||d);return r>3&&d&&Object.defineProperty(e,i,d),d},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=o(i(648)),d=o(i(211));let s=class{constructor(t,e,i,n,o){this._id=null!=n?n:d.default.Instance.GenerateId(),this._date=null!=o?o:new Date,this._title=t,this._description=e,this._toDoType=i}get Id(){return this._id}set Id(t){this._id=t}get Title(){return this._title}set Title(t){if(t.length<3||t.length>64)throw new Error("Title has to be minimum 3 characters long and maximum 64 characters long.");this._title=t}get Description(){return this._description}set Description(t){if(t.length>256)throw new Error("Description has to be maximum 256 characters long.");this._description=t}get ToDoType(){return this._toDoType}set ToDoType(t){this._toDoType=t}};s=n([(0,r.default)()],s),e.default=s},211:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=i(615);class o{constructor(){this.list=[],this.Load()}static get Instance(){return null===o._instance&&(o._instance=new o),o._instance}Save(){localStorage.setItem("todolist",JSON.stringify(this.list.map((t=>(0,n.ToJSON)(t)))))}Load(){var t;this.list=JSON.parse(null!==(t=localStorage.getItem("todolist"))&&void 0!==t?t:"[]").map((t=>(0,n.FromJSON)(t)))}Clear(){this.list=[],this.Save()}Add(t){this.list.push(t),this.Save()}Edit(t,...e){const i=this.list.find((e=>e.Id===t));i&&(i.Title=e[0],i.Description=e[1],i.ToDoType=e[2],this.Save())}Delete(t){const e=this.list.find((e=>e.Id===t));e&&(this.list.splice(this.list.indexOf(e),1),this.Save())}RelocateObjById(t,e){if(t===e)return;const i=this.list.findIndex((e=>e.Id==t)),n=this.list.findIndex((t=>t.Id==e));i<0||n<0||(this.list.splice(i>n?n:n-1,0,this.list.splice(i,1)[0]),this.Save())}GenerateId(){if(0===this.list.length)return 0;let t=0;return this.list.forEach((e=>{e.Id>t&&(t=e.Id)})),t+1}}o._instance=null,e.default=o},9:function(t,e,i){var n=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function d(t){try{l(n.next(t))}catch(t){r(t)}}function s(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(d,s)}l((n=n.apply(t,e||[])).next())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.EditForm=e.InitFormModal=void 0;const r=o(i(211)),d=o(i(524)),s=document.getElementById("modal"),l=document.getElementById("todo-form"),a=s.querySelector("h2"),c=l.querySelector("#todo-form-title"),u=l.querySelector("#todo-form-description"),h=l.querySelector("button");function f(t){t.preventDefault(),r.default.Instance.Add(new d.default(c.value,u.value,+l.querySelector("input[name='todo-form-icon']:checked").value)),s.style.display="none"}e.InitFormModal=function(){document.getElementById("add-btn").addEventListener("click",(()=>{a.textContent="New Task",h.textContent="Add",l.addEventListener("submit",f),l.reset(),s.style.display="block"})),document.getElementById("close-btn").addEventListener("click",(()=>s.style.display="none")),window.addEventListener("dblclick",(t=>{t.target==s&&(s.style.display="none")}))},e.EditForm=function(t){return n(this,void 0,void 0,(function*(){return a.textContent="Edit Task",h.textContent="Edit",l.removeEventListener("submit",f),new Promise(((e,i)=>{l.addEventListener("submit",(t=>{t.preventDefault();try{e(new FormData(l))}catch(t){i(null)}finally{s.style.display="none"}}),{once:!0}),l.reset(),c.value=t.Title,u.value=t.Description,l.querySelector(`#todo-form-icon-${t.ToDoType}`).checked=!0,s.style.display="block"}))}))}},615:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.FromJSON=e.ToJSON=void 0;const o=n(i(524));e.ToJSON=function(t){return{_id:t.Id,_title:t.Title,_description:t.Description,_toDoType:t.ToDoType,_date:Date.parse(t._date.toString())}},e.FromJSON=function(t){return new o.default(t._title,t._description,t._toDoType,t._id,new Date(t._date))}}},e={};function i(n){var o=e[n];if(void 0!==o)return o.exports;var r=e[n]={exports:{}};return t[n].call(r.exports,r,r.exports,i),r.exports}i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i(859)})(); \ No newline at end of file diff --git a/JustDoIt/dist/style.css b/JustDoIt/dist/style.css new file mode 100644 index 0000000..c848199 --- /dev/null +++ b/JustDoIt/dist/style.css @@ -0,0 +1 @@ +*,:after,:before{box-sizing:border-box;margin:0;padding:0}:root{--background-white:#f4f4f4;--white:#fff;--black:#333;--grey:#666;--grey-light:#aaa;--orange:#f0ad4e;--orange-light:#f4c17a;--red:#d9534f;--red-light:#e27e7b;--blue:#5bc0de;--blue-light:#84d0e6;--green:#5cb85c;--box-shadow:rgba(0,0,0,.1);--box-shadow-dark:rgba(0,0,0,.5);--box-shadow-darker:rgba(0,0,0,.5)}body{background-color:var(--background-white);display:flex;flex-direction:column;font-family:Arial,sans-serif;min-height:100vh;padding:0 15px}button{background-color:var(--blue);border:none;border-radius:5px;box-shadow:0 0 10px var(--box-shadow);color:var(--white);cursor:pointer;font-weight:700;padding:10px;transition:all .2s ease-in-out;user-select:none;width:100%}button:hover{background-color:var(--blue-light)}form button{margin-top:5px}#todo-container{margin:20px auto 50px;max-width:600px;width:100%}.todo-item{align-items:flex-start;background:var(--white);border-radius:5px;border-top:2px solid transparent;box-shadow:0 0 10px var(--box-shadow);display:flex;margin-bottom:10px;padding:10px}.todo-item-dragover_default{border-top-color:var(--grey-light)}.todo-item-dragover{border-top-color:var(--green)}.todo-item-icon{height:50px;margin-right:10px;user-select:none;width:50px}.todo-item-details{flex-grow:1;margin-right:10px;word-wrap:break-word;overflow:hidden}.todo-item-details_title{font-size:1.3em}.todo-item-details_description{color:var(--grey);margin-top:.25rem;text-align:justify}.todo-item-details_date{color:var(--grey);font-family:monospace;font-style:italic;margin-top:.5rem;text-decoration:overline;text-decoration-color:var(--black);text-decoration-thickness:2px}.todo-item-actions{display:flex;flex-direction:column;flex-wrap:wrap;gap:5px;max-width:75px}.todo-item-actions button{border-radius:3px;width:75px}.edit-btn{background-color:var(--orange)}.edit-btn:hover{background-color:var(--orange-light)}.delete-btn{background-color:var(--red)}.delete-btn:hover{background-color:var(--red-light)}#add-btn{bottom:0;left:50%;margin:10px auto;max-width:600px;position:fixed;transform:translateX(-50%);width:calc(100% - 30px)}#modal{background-color:var(--box-shadow-darker);display:none;height:100%;left:0;position:fixed;top:0;user-select:none;width:100%}.modal-content{background-color:var(--white);border:2px solid var(--black);border-radius:10px;box-shadow:-10px -10px 3px var(--box-shadow-dark);margin:10% auto;max-width:500px;padding:20px;width:80%}#close-btn{color:var(--grey-light);cursor:pointer;float:right;font-size:40px;transform:translateY(-8px);transition:all .2s linear}#close-btn:focus,#close-btn:hover{color:var(--black)}.form-group{margin-bottom:10px;padding:15px 0 0;position:relative;width:100%}.form-group-field{border:0;border-bottom:3px solid var(--grey-light);color:var(--grey-light);font-size:1.3rem;font-weight:700;outline:0;padding:7px 0 6px;transition:border-color .2s linear;width:100%}.form-group-field::placeholder{color:transparent}.form-group-field:placeholder-shown~.form-group-label{cursor:text;font-size:1.3rem;top:20px}.form-group-field:required:valid{border-color:var(--green)}.form-group-field:required:invalid{border-color:var(--red)}.form-group-label{color:var(--grey-light);display:block;font-weight:700;position:absolute;top:0;transition:.2s}.form-group-field:focus{border-image:linear-gradient(to right,var(--blue),var(--green));border-image-slice:1;border-width:3px;padding-bottom:6px}.form-group-field:focus~.form-group-label{color:var(--blue);position:absolute;top:0;transition:.2s}.form-icon-options input[type=radio]{display:none}.form-icon-options img{border:2px solid transparent;border-radius:5px;cursor:pointer;height:60px;margin:5px 5px 5px 0;padding:10px;transition:all .1s linear;width:60px}.form-icon-options input[type=radio]:checked+label img{border-color:var(--blue);padding:7px} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..68ccb69 --- /dev/null +++ b/index.html @@ -0,0 +1 @@ +JustDoIt
\ No newline at end of file