var myModalEl, kanbanboard, scroll, addNewBoard, addMember, profileField, reader, tasks_list = [ document.getElementById("kanbanboard"), document.getElementById("incomplete-task"), document.getElementById("to-do-task"), document.getElementById("doing-task"), document.getElementById("in-review-task"), document.getElementById("completed-task"), // document.getElementById("new-task"), ]; function noTaskImage() { Array.from(document.querySelectorAll("#kanbanboard .tasks-list")).forEach( function (e) { 0 < e.querySelectorAll(".tasks-box").length ? e.querySelector(".tasks").classList.remove("noTask") : e.querySelector(".tasks").classList.add("noTask"); }, ); } function taskCounter() { (task_lists = document.querySelectorAll("#kanbanboard .tasks-list")) && Array.from(task_lists).forEach(function (e) { (tasks = e.getElementsByClassName("tasks")), Array.from(tasks).forEach(function (e) { (task_box = e.getElementsByClassName("tasks-box")), (task_counted = task_box.length); }), (badge = e.querySelector(".totaltask-badge").innerText = ""), (badge = e.querySelector(".totaltask-badge").innerText = task_counted); }); } function newKanbanbaord() { var e = document.getElementById("boardName").value, a = Math.floor(100 * Math.random()), t = "review_task_" + a; (kanbanlisthtml = '
' + e + '0
'), document .getElementById("kanbanboard") .insertAdjacentHTML("beforeend", kanbanlisthtml), document.getElementById("addBoardBtn-close").click(), noTaskImage(), taskCounter(), drake.destroy(), tasks_list.push(document.getElementById(t)), (drake = dragula(tasks_list).on("out", function (e, a) { noTaskImage(), taskCounter(); })), (document.getElementById("boardName").value = ""); } function newMemberAdd() { var e = document.getElementById("firstnameInput").value, a = localStorage.getItem("kanbanboard-member"); (newMembar = '' + a + ""), document .getElementById("newMembar") .insertAdjacentHTML("afterbegin", newMembar), document.getElementById("btn-close-member").click(); } tasks_list && ((myModalEl = document.getElementById("deleteRecordModal")) && myModalEl.addEventListener("show.bs.modal", function (e) { document .getElementById("delete-record") .addEventListener("click", function () { e.relatedTarget.closest(".tasks-box").remove(), document.getElementById("delete-btn-close").click(), taskCounter(); }); }), (drake = dragula(tasks_list) .on("drag", function (e) { e.className = e.className.replace("ex-moved", ""); }) .on("drop", function (e, a) { e.className += " ex-moved"; id = e.getAttribute('data-id'); changeStatus = e.closest('.tasks-list').getAttribute('data-status-key'); $.ajax({ type: "GET", url: '/task/changeStatus', data: { id: id, changeStatus: changeStatus }, success: function (data) { console.log(data); }, }); }) .on("over", function (e, a) { a.className += " ex-over"; }) .on("out", function (e, a) { (a.className = a.className.replace("ex-over", "")), noTaskImage(), taskCounter(); })), (kanbanboard = document.querySelectorAll("#kanbanboard")) && (scroll = autoScroll([document.querySelector("#kanbanboard")], { margin: 20, maxSpeed: 100, scrollWhenOutside: !0, autoScroll: function () { return this.down && drake.dragging; }, })), (addNewBoard = document.getElementById("addNewBoard")) && document .getElementById("addNewBoard") .addEventListener("click", newKanbanbaord), (addMember = document.getElementById("addMember"))) && (document.getElementById("addMember").addEventListener("click", newMemberAdd), (profileField = document.getElementById("profileimgInput")), (reader = new FileReader()), profileField.addEventListener("change", function (e) { reader.readAsDataURL(profileField.files[0]), (reader.onload = function () { var e = reader.result; localStorage.setItem( "kanbanboard-member", 'profile', ); }); }));