text: window.addEventListener("load",(function(){!function(){"use strict";var appEditor={users:{},records:{}};function chkPermission(e){"PERMISSION_DENIED"===e.code&&signOutOfApp()}function signOutOfApp(){firebase.auth().signOut()}function docEl(id){return document.getElementById(id)}function showEl(elId){docEl(elId).className=docEl(elId).className.replace(/(?:^|\s)nodisplay(?!\S)/g,"")}function emptyContent(parentEl){for(;parentEl.hasChildNodes();){for(;parentEl.lastChild.hasChildNodes();)parentEl.lastChild.removeChild(parentEl.lastChild.lastChild);parentEl.removeChild(parentEl.lastChild)}}function isObjEmpty(obj){return null===obj||("object"!=typeof obj||0===Object.keys(obj).length)}function chkForOpts(){firebase.database().ref("studentUser").once("value").then((function(snapshot){appEditor.users=snapshot.val()||{},firebase.database().ref("activities").once("value").then((function(snapshot){appEditor.records=snapshot.val()||{},buildUserRecords()}))}),(function(e){chkPermission(e)}))}function buildUserRecords(){var userKeys=Object.keys(appEditor.users),container=docEl("manageOpts"),frag=document.createDocumentFragment(),userDiv,recFrag;emptyContent(container),userKeys.forEach((function(uid){recFrag=createTableForRecords(uid),(userDiv=document.createElement("div")).className="btn btn-block btn-whiteBlue",userDiv.dataset.uid=uid,userDiv.textContent=appEditor.users[uid].uName+" ("+appEditor.users[uid].email+")",null!==recFrag&&(frag.appendChild(userDiv),frag.appendChild(recFrag))})),container.appendChild(frag),showEl("manageOpts")}function toTime(num,isSec){var unit=isSec?1e3*num:num,limit=~(4*!!isSec),format=new Date(unit).toISOString().slice(11,limit),parts;return unit>=864e5?((parts=format.split(/:(?=\d{2}:)/))[0]-=-24*(unit/864e5|0),parts.join(":")):format}function formatFrag(frag){return""==frag?"null":""+frag}function createTableForRecords(uid){var rcrds=appEditor.records[uid],keys,props,headers,len,frag,tbl,tblBody,tblTr,tblHdr,tblTh,tblTd,i,dt;if(null==rcrds)return null;for(keys=Object.keys(rcrds),rcrds=keys.map((function(el){return rcrds[el]})).sort((function(a,b){return b.timestamp-a.timestamp})),headers=["Teacher","Class","ID","Activity","Score","Duration","Date & Time"],len=(props=["tchr","clss","frag","activity","score","duration","timestamp"]).length,frag=document.createDocumentFragment(),tbl=document.createElement("TABLE"),tblHdr=document.createElement("THEAD"),tblBody=document.createElement("TBODY"),tblTr=document.createElement("TR"),tbl.className="table table-condensed table-striped",i=0;i<len;i++)(tblTh=document.createElement("TH")).textContent=headers[i],tblTr.appendChild(tblTh);return tblHdr.appendChild(tblTr),tbl.appendChild(tblHdr),rcrds.forEach((function(elem){for(tblTr=document.createElement("TR"),i=0;i<len;i++){if(tblTd=document.createElement("TD"),"timestamp"===props[i]){try{dt=new Date(elem[props[i]]).toISOString()}catch(e){tblTd.textContent=""}tblTd.textContent=dt}else tblTd.textContent="duration"===props[i]?toTime(elem[props[i]],!1):"frag"===props[i]?formatFrag(elem[props[i]]):elem[props[i]];tblTr.appendChild(tblTd)}tblBody.appendChild(tblTr)})),tbl.appendChild(tblBody),frag.appendChild(tbl),frag}firebase.auth().onAuthStateChanged((function(user){user?(docEl("usrPhoto").src=user.photoURL,chkForOpts()):window.location="../index.html"}))}()}));