From bae0af76cde338f78d2b77e3768a00235fa676d9 Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Wed, 26 Feb 2020 21:21:06 +0530 Subject: [PATCH] Updating to new UI V 8.2.5 --- RIBC.html | 22470 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 13447 insertions(+), 9023 deletions(-) diff --git a/RIBC.html b/RIBC.html index e267660..15b6450 100644 --- a/RIBC.html +++ b/RIBC.html @@ -1,5052 +1,8059 @@ - - - - RIBC - - - - - - -
- RIBC - (use console) -
- - + + +
+ Message + +
+ + + + +
+
+
+ + + + +

Projects you are watching

+ + +
+
+ + +
+
+

My task

+
+

+

+
+ + + +
+
+
+
+ + + +

Leaderboard

+ All +
+
+ +
+
+
+
+ + + + + +

Projects

+ All +
+
+
+
+ +
+
+

Settings

+
+

Account

+

+ +
+
+

Dark mode

+
+ + Automatic
+ Dark mode active : 6pm - 6am +
+ +
+
+ Manual
+ Dark mode +
+ +
+
+
+

About

+
Version 8.2.5
+ +
Powered by
+ + + + + + + + + + + + + +
+
+
+
+
+ + Go back to previous page + + +

+
+
+
+
+
+ + Go back to previous page + + +

Projects

+
+
+

My projects

+
+

Other projects

+
+
+ +
+
+
+
+
+

Projects

+ + show project adding panel + + +
+
- })(); -} +
+
+
+
+

Interns

+ + show new intern adding panel + + +
+
+ +
+
+
+
+
+ + admin panel illustration + + + +

Click on a project to manage it.

+
+
+
+
+

Project Name

+
+

+

+
+
+

Tasks

+
+
+ +
    +
  • + + Open intern assignment popup + + + + + + + Assign an intern +
  • +
  • + + show new branch creation popup + + + + + + + Create new Branch +
  • +
  • + + remove this task + + + + Delete +
  • +
+
+
+
+ Copied +
+ - //Adding SHA1 to fix basic PKBDF2 - /* - * Crypto-JS v2.5.4 - * http://code.google.com/p/crypto-js/ - * (c) 2009-2012 by Jeff Mott. All rights reserved. - * http://code.google.com/p/crypto-js/wiki/License - */ - (function () { + - // Public API - var SHA1 = C.SHA1 = function (message, options) { - var digestbytes = util.wordsToBytes(SHA1._sha1(message)); - return options && options.asBytes ? digestbytes : - options && options.asString ? Binary.bytesToString(digestbytes) : - util.bytesToHex(digestbytes); - }; + - // The core - SHA1._sha1 = function (message) { - - // Convert to byte array - if (message.constructor == String) message = UTF8.stringToBytes(message); - /* else, assume byte array already */ - - var m = util.bytesToWords(message), - l = message.length * 8, - w = [], - H0 = 1732584193, - H1 = -271733879, - H2 = -1732584194, - H3 = 271733878, - H4 = -1009589776; - - // Padding - m[l >> 5] |= 0x80 << (24 - l % 32); - m[((l + 64 >>> 9) << 4) + 15] = l; - - for (var i = 0; i < m.length; i += 16) { - - var a = H0, - b = H1, - c = H2, - d = H3, - e = H4; - - for (var j = 0; j < 80; j++) { - - if (j < 16) w[j] = m[i + j]; - else { - var n = w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16]; - w[j] = (n << 1) | (n >>> 31); - } - - var t = ((H0 << 5) | (H0 >>> 27)) + H4 + (w[j] >>> 0) + ( - j < 20 ? (H1 & H2 | ~H1 & H3) + 1518500249 : - j < 40 ? (H1 ^ H2 ^ H3) + 1859775393 : - j < 60 ? (H1 & H2 | H1 & H3 | H2 & H3) - 1894007588 : - (H1 ^ H2 ^ H3) - 899497514); - - H4 = H3; - H3 = H2; - H2 = (H1 << 30) | (H1 >>> 2); - H1 = H0; - H0 = t; - - } - - H0 += a; - H1 += b; - H2 += c; - H3 += d; - H4 += e; - - } - - return [H0, H1, H2, H3, H4]; - - }; - - // Package private blocksize - SHA1._blocksize = 16; - - SHA1._digestsize = 20; - - })(); - - //Added to make PKBDF2 work - /* - * Crypto-JS v2.5.4 - * http://code.google.com/p/crypto-js/ - * (c) 2009-2012 by Jeff Mott. All rights reserved. - * http://code.google.com/p/crypto-js/wiki/License - */ - (function () { - - // Shortcuts - var C = Crypto, - util = C.util, - charenc = C.charenc, - UTF8 = charenc.UTF8, - Binary = charenc.Binary; - - C.HMAC = function (hasher, message, key, options) { - - // Convert to byte arrays - if (message.constructor == String) message = UTF8.stringToBytes(message); - if (key.constructor == String) key = UTF8.stringToBytes(key); - /* else, assume byte arrays already */ - - // Allow arbitrary length keys - if (key.length > hasher._blocksize * 4) - key = hasher(key, { - asBytes: true - }); - - // XOR keys with pad constants - var okey = key.slice(0), - ikey = key.slice(0); - for (var i = 0; i < hasher._blocksize * 4; i++) { - okey[i] ^= 0x5C; - ikey[i] ^= 0x36; - } - - var hmacbytes = hasher(okey.concat(hasher(ikey.concat(message), { - asBytes: true - })), { - asBytes: true + + + + + + - - - + + - - - - + + + + + + + - - + function logout(){ + askConfirmation("Do you want to sign out?").then((result) => { + if(result){ + floDapps.clearCredentials() + showMessage('','You have signed out successfully.') + onLoadStartUp() + if(window.innerWidth > 768) + showPage('dashboard_btn', 'dashboard'); + else + showPage('bottom_dashboard_btn', 'dashboard'); + } + }) + } + let allInterns = []; + + document.getElementById('interns_list_container').addEventListener('click', (event) => { + if(event.target.closest('.intern-card')){ + let floid = event.target.closest('.intern-card').dataset.internId; + if(RIBC.manage.assignInternToTask(floid, currentProject, currentBranch, currentTask.id)){ + showMessage('',`${event.target.closest('.intern-card').children[1].textContent} assigned to ${RIBC.getProjectDetails(currentProject).projectName}`) + currentTask.querySelector('.assigned-interns').appendChild(render.assignedInternCard(getInternDetails(floid)[0], 'yes')) + setTimeout(() => { + allInterns.forEach((intern) => { + intern.style.display = ""; + }) + },1000) + } + else + showMessage('error', 'intern already assigned') + hidePopup('interns_list') + } + }) + + function unassignIntern(){ + RIBC.manage.unassignInternFromTask(currentProject, currentBranch, currentTask) + } + + function populateIntens(){ + iList = RIBC.getInternList(); + let internsPopup = document.getElementById('interns_list_container'); + for(intern in iList){ + frag.appendChild(render.internCard(iList[intern],intern, RIBC.getInternRating(intern))) + } + internsPopup.innerHTML = '' + internsPopup.appendChild(frag) + } + + function changeScore(scoreUpdate, parent){ + let score = parseInt(parent.children[1].textContent) + if(score === 1 && scoreUpdate === -1){ + parent.children[3].disabled = true; + return; + } + score += scoreUpdate; + parent.children[1].textContent = score + if(score > 0){ + parent.children[3].disabled = false; + RIBC.manage.updateInternRating(currentIntern, scoreUpdate) + } + } + + function addNewBranch(){ + showPopup('create_branch') + let popup = document.getElementById('create_branch'), + startPoint = document.getElementById('branch_start_point'), + mergePoint = document.getElementById('branch_merge_point'), + branchName = ''; + startPoint.value = parseInt(currentTask.id); + document.getElementById('create_branch_btn').onclick = () =>{ + branchName = RIBC.manage.addBranch(currentProject, currentBranch, startPoint, parseInt(mergePoint.value)); + showMessage('',`Branch added ${branchName}`) + document.getElementById('branch_container').appendChild(render.branchBtn(currentProject, branchName)) + hidePopup('create_branch') + } + } + + function showUpdatePanel(){ + let container = document.getElementById('updates'), + updateContainer = document.getElementById('update_container'); + updateFeed(updateContainer, 8) + this.classList.add('update-mi') + this.addEventListener('animationend', () => { + this.classList.remove('update-mi') + }) + this.addEventListener('webkitAnimationEnd', () => { + this.classList.remove('update-mi') + }) + container.classList.toggle('hide') + let y = document.addEventListener("mousedown", function(event) { + if (event.target.closest('#intern_updates')) return; + container.classList.add('hide') + document.removeEventListener('click', y); + }); + } + + function updateFeed(container, limit){ + let updateContainer = container; + if(typeof container === "string") + updateContainer = document.getElementById(container); + updateContainer.innerHTML = ``; + let updates = RIBC.getInternUpdates(limit); + updates.forEach((entry) => { + frag.appendChild(render.updateCard(getInternDetails(entry.floID)[0].split(':')[1], entry.update.topic, entry.update.description)) + }) + updateContainer.appendChild(frag) + } + + function watchThisProject(thisBtn){ + watchList = JSON.parse(localStorage.getItem('watchList')) + if(!watchList.includes(currentProject)){ + watchList.push(currentProject) + thisBtn.textContent = 'watching' + localStorage.setItem('watchList', JSON.stringify(watchList)) + showMessage('', `${RIBC.getProjectDetails(currentProject).projectName} added to your watch list.`) + } + else{ + watchList.splice(watchList.indexOf(currentProject), 1) + thisBtn.textContent = 'Watch' + if(watchList.length === 0){ + document.getElementById('status_map').innerHTML = '

No project added to watch list.

' + } + localStorage.setItem('watchList', JSON.stringify(watchList)) + showMessage('', `${RIBC.getProjectDetails(currentProject).projectName} removed from your watch list.`) + } + changeProject(0) + } + + function showProjectMap(projectCode, container){ + if(projectCode === undefined) return; + let tempCard = render.projectMapCard(projectCode), + containerCard = document.getElementById(container); + containerCard.innerHTML =``; + currentProject = projectCode; + containerCard.appendChild(tempCard[0]) + document.getElementById(tempCard[2]).addEventListener('click', (event) => { + if(event.target.closest('.branch-btn')){ + showTasksOfBranch(event.target.closest('.branch-btn'), tempCard[1], tempCard[3], '') + } + }) + document.getElementById(tempCard[2]).firstElementChild.click() + } + let index = 0; + function changeProject(change){ + let list = JSON.parse(localStorage.getItem('watchList')), + listButtons = document.querySelectorAll('.watch-list-button'); + index += change; + index = Math.min(Math.max(index,0), list.length-1); + if(list.length === 0){ + disableBtn('prev_proj') + disableBtn('next_proj') + listButtons.forEach((btn) => { + btn.classList.add('hide') + }) + } + else{ + listButtons.forEach((btn) => { + btn.classList.remove('hide') + }) + if(index === 0){ + disableBtn('prev_proj') + } + else{ + enableBtn('prev_proj') + } + if(index+1 === list.length){ + disableBtn('next_proj') + } + else + enableBtn('next_proj') + } + dashboardProject = list[index] + showProjectMap(dashboardProject, 'status_map') + } + + function sendUpdatePopup(){ + showPopup('post_update') + document.getElementById('post_update_btn').classList.remove('no-transformations') + if(Object.keys(iList).includes(myFloID) && !floGlobals.subAdmins.includes(myFloID)) + document.getElementById('update_topic').value = `${currentTaskObj.projectName} / ${RIBC.getTaskDetails(currentTaskObj.project, currentTaskObj.pBranch, currentTaskObj.task).taskTitle}`; + } + + let allRequests = []; + function requestForTask(btn){ + askConfirmation('Do you want to apply for this task?').then((result) => { + if(result){ + if(localStorage.getItem('requests') === null) + localStorage.setItem('requests', JSON.stringify(allRequests)) + btn.textContent = 'Applied' + disableBtn(btn) + RIBC.applyForTask(btn.dataset.projectCode, btn.dataset.branch, btn.dataset.taskNo) + .then((result) => { + showMessage('', 'Applied sucessfully.') + allRequests = JSON.parse(localStorage.getItem('requests')) + allRequests.push({projectCode: btn.dataset.projectCode, branch: btn.dataset.branch, taskNo: btn.dataset.taskNo}) + localStorage.setItem('requests', JSON.stringify(allRequests)) + }) + } + }) + .catch((error) => { + showMessage('error' ,error) + }) + } + + function showThisFeed(container, type, btn){ + document.querySelectorAll('.feed-item').forEach((item) => { + item.classList.add('hide-completely') + }) + document.querySelectorAll('.feed-btn').forEach((item) => { + item.classList.remove('active') + }) + document.getElementById(container).classList.remove('hide-completely') + btn.classList.add('active') + } + + window.addEventListener('load', () => { + document.querySelectorAll('textarea').forEach((textArea) => { + textArea.setAttribute('style', 'height:' + (textArea.scrollHeight) + 'px;overflow-y:hidden;'); + textArea.addEventListener("input", OnInput, false); + }) + }) + function OnInput(e) { + this.style.height = 'auto'; + this.style.height = (this.scrollHeight) + 'px'; + if(this.value.trim() !== '' && this.parentNode.classList.contains('chatInput')) + this.parentNode.children[1].classList.add('no-transformations') + else + this.parentNode.children[1].classList.remove('no-transformations') + } + + function loader(mode){ + let loader = document.getElementById('loader'); + if(mode === 'show'){ + loader.classList.remove('hide') + loader.firstElementChild.children[0].classList.add('loading-animation') + } + else{ + loader.classList.add('hide') + loader.firstElementChild.children[0].classList.remove('loading-animation') + } + } + let myInput = function(){ + return new Promise((resolve, reject) => { + loader('hide') + showPopup('sign_in' ,'no'); + let container = document.getElementById('priv_key_sign_in'), + signIn = document.getElementById('sign_in'), + privField = document.getElementById('priv_key_field'), + btn = document.getElementById('back_to_main_page'); + document.getElementById('guest_btn').onclick = function(){ + hidePopup('sign_in') + reject(null); + } + document.getElementById('priv_key_btn').onclick = function(){ + container.classList.remove('hide-completely') + signIn.children[2].classList.add('hide-completely') + btn.classList.remove('hide-completely') + privField.focus() + } + btn.onclick = function(){ + container.classList.add('hide-completely') + signIn.children[2].classList.remove('hide-completely') + btn.classList.add('hide-completely') + } + privField.addEventListener('keyup', (event) => { + if(privField.value.trim() !== '') + enableBtn('sign_in_btn') + else + disableBtn('sign_in_btn') + if(event.keyCode === 13 || event.key === 13){ + if(privField.value.trim().length > 40){ + resolve(privField.value.trim()) + hidePopup('sign_in') + loader('show') + } + else{ + showMessage('error', 'Please enter correct private key.') + } + } + }) + document.getElementById('sign_in_btn').onclick = function(){ + if(privField.value.trim().length > 40){ + resolve(privField.value.trim()) + hidePopup('sign_in') + loader('show') + } + else{ + showMessage('error', 'Please enter correct private key.') + } + } + }) + } + // Event listeners + + document.getElementById('best_interns').addEventListener('click', (event) => { + if(event.target.closest('.intern-card')) + showInternInfo(event.target.closest('.intern-card')) + }) + document.getElementById('status_map').addEventListener('click', (e) => { + if(e.target.closest('.apply-btn')){ + requestForTask(e.target.closest('.apply-btn')) + } + }) + let projectList = document.getElementById('project_list'); + projectList.addEventListener('click', (event) => { + if(event.target.closest('.project-card')){ + appState.btn = ''; + appState.page = 'project_explorer'; + appState.offsprings = 'explorer'; + appState.type = 'innerPage'; + showPage('', 'project_explorer', 'explorer', 'innerPage') + if(lastState !== appState.page) + history.pushState(appState, null, null) + lastState = appState.page; + showProjectInfo(event.target.closest('.project-card'), 'right', 'no', [...projectList.children].indexOf(event.target.closest('.project-card'))) + } + }) + document.getElementById('show_all').addEventListener('click', (event) => { + if(event.target.closest('.intern-card')) + showInternInfo(event.target.closest('.intern-card')) + }) + document.getElementById('interns').addEventListener('click', (event) => { + if(event.target.closest('.intern-card')) + showInternInfo(event.target.closest('.intern-card')) + }) + document.getElementById('projects').addEventListener('click', (event) => { + if(event.target.closest('.project-card')) + editProjectInfo(event.target.closest('.project-card')) + }) + + function renderAllElements(){ + + let frag = document.createDocumentFragment(), + pList = RIBC.getProjectList(); + //creates cards for highest performing interns + //sort interns earned points + + + iList = RIBC.getInternList(); + newIList = []; + for(let intern in iList){ + newIList.push([intern, iList[intern], RIBC.getInternRating(intern)]) + } + newIList.sort(function(a, b) { + return a[2] - b[2]; + }); + + // Intern's view + + let newPList = [],x; + if(Object.keys(iList).includes(myFloID) && !floGlobals.subAdmins.includes(myFloID)){ + typeOfUser = 'intern'; + document.querySelectorAll('.intern-option').forEach((option) => { + option.classList.remove('hide-completely') + }) + document.getElementById('status_map_container').classList.add('hide-completely') + for(let i =0;i < pList.length; i++){ + nextProject: + for(branch in RIBC.getProjectMap(pList[i])){ + x = RIBC.getProjectMap(pList[i])[branch].slice(4); + for(let j = 0;j < x.length; j++) + if(Array.isArray(RIBC.getAssignedInterns(pList[i],branch,x[j])) && RIBC.getAssignedInterns(pList[i],branch,x[j]).includes(myFloID)){ + newPList.push(pList[i]) + break nextProject; + } + } + } + + for(let i =0;i < newPList.length; i++){ + for(branch in RIBC.getProjectMap(newPList[i])){ + x = RIBC.getProjectMap(newPList[i])[branch].slice(4); + for(let j = 0;j < x.length; j++) + if(RIBC.getTaskStatus(newPList[i], branch, x[j]) === 'incomplete' && Array.isArray(RIBC.getAssignedInterns(newPList[i],branch,x[j])) && RIBC.getAssignedInterns(newPList[i],branch,x[j]).includes(myFloID)){ + currentTaskObj.project = pList[i]; + currentTaskObj.projectName = RIBC.getProjectDetails(pList[i]).projectName; + currentTaskObj.pBranch = branch; + currentTaskObj.task = x[j] + break; + } + } + } + document.getElementById('project_list_container').firstElementChild.children[1].textContent = 'My projects' + let parent = document.getElementById('assigned_task'); + if(!Object.keys(currentTaskObj).length){ + parent.children[0].textContent = 'No task assigned yet.'; + parent.children[1].textContent = ''; + } + else{ + let taskDetails = RIBC.getTaskDetails(currentTaskObj.project, currentTaskObj.pBranch, currentTaskObj.task) + parent.children[0].textContent = taskDetails.taskTitle; + parent.children[1].textContent = taskDetails.taskDescription; + } + + } + else{ + document.querySelectorAll('.intern-option').forEach((option) => { + option.classList.add('hide-completely') + }) + document.getElementById('status_map_container').classList.remove('hide-completely') + document.getElementById('project_list_container').firstElementChild.children[1].textContent = 'Projects' + } + + // admin view + if(floGlobals.subAdmins.includes(myFloID)){ + typeOfUser = 'admin' + let requestsContainer = document.getElementById('requests_container'); + RIBC.getTaskApplications().forEach((app) => { + try{ + if(!Array.isArray(RIBC.getAssignedInterns(app.projectCode, app.branch, app.task)) && typeof RIBC.getTaskDetails(app.projectCode, app.branch, app.task) !== 'undefined') + frag.appendChild(render.requestCard(app.floID, app.projectCode, app.branch, app.task)) + } + catch(error){ + console.error(error) + } + }) + requestsContainer.appendChild(frag) + if(requestsContainer.children.length === 0) + requestsContainer.innerHTML = '

Nothing to see here.

' + requestsContainer.addEventListener('click' ,(e) => { + if(e.target.closest('.accept-app')){ + let btn = e.target.closest('.accept-app'), + parent = e.target.closest('.request-card'); + if(RIBC.manage.assignInternToTask(btn.dataset.floId, btn.dataset.projectCode, btn.dataset.branch, btn.dataset.taskNo)){ + showMessage('', 'Intern assinged.') + parent.classList.add('slide-left') + setTimeout(() => { + parent.remove() + }, 600) + if(requestsContainer.children.length === 0) + requestsContainer.innerHTML = '

Nothing to see here.

' + } + else{ + showMessage('error', 'Intern already assinged.') + } + } + if(e.target.closest('.reject-app')){ + let parent = e.target.closest('.request-card'); + parent.classList.add('slide-left') + setTimeout(() => { + parent.remove() + }, 400) + if(requestsContainer.children.length === 0) + requestsContainer.innerHTML = '

Nothing to see here.

' + } + }) + + document.querySelectorAll('.admin-options').forEach((option) => { + option.classList.remove('hide-completely') + }) + + //show interns + document.getElementById('interns').innerHTML = ``; + for(intern in iList){ + frag.appendChild(render.internCard(iList[intern],intern, RIBC.getInternRating(intern),'interns')) + } + document.getElementById('interns').appendChild(frag) + + //show project + document.getElementById('projects').innerHTML = ``; + for(i = 0; i < pList.length; i++){ + frag.appendChild(render.projectCard(RIBC.getProjectDetails(pList[i]).projectName, pList[i])) + } + document.getElementById('projects').appendChild(frag) + } + else{ + document.querySelectorAll('.admin-options').forEach((option) => { + option.classList.add('hide-completely') + }) + } + + document.getElementById('best_interns').innerHTML = ``; + let limit = 4; + newIList.reverse() + for(let p=0; p < newIList.length; p++){ + frag.appendChild(render.internCard(newIList[p][1],newIList[p][0], newIList[p][2],'best_interns')) + limit--; + if(!limit) + break; + } + document.getElementById('best_interns').appendChild(frag) + + // displays recent projects + + document.getElementById('project_list').innerHTML=''; + if(Object.keys(iList).includes(myFloID) && !floGlobals.subAdmins.includes(myFloID)){ + newPList.forEach((project) => { + frag.appendChild(render.projectCard(RIBC.getProjectDetails(project).projectName, project)) + }) + if(newPList.length === 0){ + let elem = document.createElement('h4'); + elem.textContent = 'No project assigned yet.' + elem.classList.add('padding') + frag.appendChild(elem) + } + } + else{ + pList.forEach((project) => { + frag.appendChild(render.projectCard(RIBC.getProjectDetails(project).projectName, project)) + }) + } + document.getElementById('project_list').appendChild(frag) + + if(localStorage.getItem('watchList') === null) + localStorage.setItem('watchList', JSON.stringify(watchList)) + + populateIntens() + + allInterns = document.getElementById('interns_list_container').querySelectorAll('.intern-card'); + + document.getElementById('branch_container').addEventListener('click', (event) => { + if(event.target.closest('.branch-btn')){ + showTasksOfBranch(event.target.closest('.branch-btn'), 'edit_data','task_list') + } + }) + + document.getElementById('intern_search_field').addEventListener('input', (event) => { + let container = document.getElementById('interns_list_container'), + inputField = document.getElementById('intern_search_field'); + if(event.keyCode === 13) + { + for(let i = 0;i < container.children.length; i++){ + if(container.children[i].style.display != 'none'){ + container.children[i].click() + break; + } + } + } + else + allInterns.forEach((intern) => { + if (intern.children[1].textContent.toLowerCase().indexOf(inputField.value.toLowerCase().trim()) > -1) { + intern.style.display = ""; + } else { + intern.style.display = "none"; + } + }) + }) + + document.getElementById('post_update_btn').addEventListener('click',() => { + let topic = document.getElementById('update_topic').value.trim(), + description = document.getElementById('update_description').value.trim(), + parent = document.getElementById('update_container'); + if(Object.keys(iList).includes(myFloID)) + topic.value = RIBC.getTaskDetails(currentTaskObj.project, currentTaskObj.pBranch, currentTaskObj.task).taskTitle; + if(topic !== '' && description !== ''){ + RIBC.postInternUpdate({topic: topic,description: description}) + .then((result) => { + updateFeed(parent, 8) + showMessage('', 'Update posted') + hidePopup('post_update') + }) + .catch((error) => { + showMessage('error', error) + }) + } + else{ + showMessage('error', 'Please enter topic and description') + } + }) + + document.getElementById('update_panel_btn').addEventListener('click', showUpdatePanel) + + let projectExplorer = document.getElementById('project_explorer'); + projectExplorer.children[1].children[1].innerHTML = ``; + projectExplorer.children[1].children[3].innerHTML = ``; + if(Object.keys(iList).includes(myFloID) && !floGlobals.subAdmins.includes(myFloID)){ + for(i = 0; i < newPList.length; i++){ + frag.appendChild(render.projectCard(RIBC.getProjectDetails(newPList[i]).projectName, newPList[i])) + } + projectExplorer.children[1].children[1].appendChild(frag) + pList = pList.filter(val => !newPList.includes(val)); + } + for(i = 0; i < pList.length; i++){ + frag.appendChild(render.projectCard(RIBC.getProjectDetails(pList[i]).projectName, pList[i])) + } + projectExplorer.children[1].children[3].appendChild(frag) + + let allProjects = projectExplorer.children[1].querySelectorAll('.project-card'); + projectExplorer.children[1].addEventListener('click', (event) => { + if(event.target.closest('.project-card')){ + showProjectInfo(event.target.closest('.project-card'), 'right') + } + }) + projectExplorer.children[2].addEventListener('click', (event) => { + if(event.target.closest('.branch-btn')) + showTasksOfBranch(event.target.closest('.branch-btn'), 'project_explorer', 'explorer_task_list') + if(event.target.closest('.apply-btn')){ + requestForTask(event.target.closest('.apply-btn')) + } + }) + if(JSON.parse(localStorage.getItem('watchList')).length){ + showProjectMap(JSON.parse(localStorage.getItem('watchList'))[0], 'status_map') + } + else{ + document.getElementById('status_map').innerHTML = '

No project added to watch list.

' + } + if(JSON.parse(localStorage.getItem('watchList')).length < 2) + disableBtn('next_proj') + + history.pushState(appState, null, null) + + document.getElementById('all_interns_btn').addEventListener('click', () => { + appState.btn = ''; + appState.page = 'show_all'; + appState.offsprings = 'interns'; + appState.type = 'innerPage'; + showPage('', 'show_all', 'interns', 'innerPage') + if(lastState !== appState.page) + history.pushState(appState, null, null) + lastState = appState.page; + }) + document.getElementById('all_projects_btn').addEventListener('click', () => { + appState.btn = ''; + appState.page = 'project_explorer'; + appState.offsprings = 'explorer'; + appState.type = 'innerPage'; + showPage('', 'project_explorer', 'explorer', 'innerPage') + if(window.innerWidth < 640) + showListCont('left') + if(lastState !== appState.page) + history.pushState(appState, null, null) + lastState = appState.page; + }) + document.getElementById('top_nav').addEventListener('click', (event) => { + let trgt = event.target.closest('.nav-btn'); + if(trgt){ + appState.btn = trgt.id; + appState.offsprings = ''; + appState.type = ''; + if(trgt.id === 'dashboard_btn'){ + showPage(trgt.id, 'dashboard') + appState.page = 'dashboard'; + currentProject = dashboardProject; + if(JSON.parse(localStorage.getItem('watchList')).length) + showProjectMap(JSON.parse(localStorage.getItem('watchList'))[0], 'status_map') + } + else if(trgt.id === 'admin_panel_btn'){ + showPage(trgt.id, 'admin_panel') + appState.page = 'admin_panel'; + + } + else if(trgt.id === 'settings_btn'){ + showPage(trgt.id, 'settings_page') + appState.page = 'settings_page'; + } + else if(trgt.id === 'top_update_btn'){ + appState.btn = ''; + showPage('', 'show_all', 'updates', 'innerPage') + appState.page = 'show_all'; + appState.offsprings = 'updates'; + appState.type = 'innerPage'; + } + if(lastState !== appState.page) + history.pushState(appState, null, null) + lastState = appState.page; + } + }) + document.getElementById('bottom_nav').addEventListener('click', (event) => { + let trgt = event.target.closest('.nav-btn'); + if(trgt){ + appState.btn = trgt.id; + appState.offsprings = ''; + appState.type = ''; + if(trgt.id === 'bottom_dashboard_btn'){ + showPage(trgt.id, 'dashboard') + appState.page = 'dashboard'; + currentProject = dashboardProject; + if(JSON.parse(localStorage.getItem('watchList')).length) + showProjectMap(JSON.parse(localStorage.getItem('watchList'))[0], 'status_map') + } + else if(trgt.id === 'bottom_admin_btn'){ + showPage(trgt.id, 'admin_panel') + appState.page = 'admin_panel'; + } + else if(trgt.id === 'bottom_update_btn'){ + showPage(trgt.id, 'show_all', 'updates', 'innerPage') + appState.page = 'show_all'; + appState.offsprings = 'updates'; + appState.type = 'innerPage'; + trgt.classList.add('update-mi') + trgt.addEventListener('animationend', () => { + trgt.classList.remove('update-mi') + }) + trgt.addEventListener('webkitAnimationEnd', () => { + trgt.classList.remove('update-mi') + }) + } + else if(trgt.id === 'bottom_setting_btn'){ + showPage(trgt.id, 'settings_page') + appState.page = 'settings_page'; + } + if(lastState !== appState.page) + history.pushState(appState, null, null) + lastState = appState.page; + } + }) + let greetings = getInternDetails(myFloID)[0] !== undefined ? `Hi, ${getInternDetails(myFloID)[0].split(':')[1]}.

${myFloID}

` : `Hi, there!

${myFloID}

` + document.getElementById('username').innerHTML = greetings; + + console.log(typeOfUser) + } + // functions that run when page loads + +