text: window.addEventListener("load",(function(){!function(){"use strict";var colObj={time:0,tchr:"",clss:"",frag:"",voca:[],gameArr:[],current:null};function signOutOfApp(){firebase.auth().signOut()}function handlersOn(){navListenersOn(),docEl("chgSelected").addEventListener("click",updateClss,{capture:!1,passive:!0}),docEl("restart").addEventListener("click",continueGame,{capture:"false",passive:"true"})}function dragMoveListener(event){var target=event.target,x=(parseFloat(target.getAttribute("data-x"))||0)+event.dx,y=(parseFloat(target.getAttribute("data-y"))||0)+event.dy;target.style.webkitTransform=target.style.transform="translate("+x+"px, "+y+"px)",target.setAttribute("data-x",x),target.setAttribute("data-y",y)}function setInteractable(){window.interact(".drag-drop").draggable({inertia:!0,restrict:{restriction:"#exA",endOnly:!0,elementRect:{top:0,left:0,bottom:1,right:1}},autoScroll:!0,onmove:dragMoveListener})}function setCompletedCollocation(col){var container=docEl("completedcollocations"),frag=document.createDocumentFragment(),newP=document.createElement("p");"b4"===colObj.current.colPos?newP.textContent+=col+" "+colObj.current.en:newP.textContent+=colObj.current.en+" "+col,frag.appendChild(newP),container.insertBefore(frag,container.firstChild)}function promptReset(){var len;colObj.gameArr=colObj.voca.slice(0),len=colObj.gameArr.length,shuffleAnArray(colObj.gameArr),docEl("exA").style.display="none",docEl("mem-feedback").style.display="block",userScored(len)}function continueGame(){emptyContent(docEl("completedcollocations")),docEl("exA").style.display="block",docEl("mem-feedback").style.display="none",prepNextExample(),colObj.time=Date.now()}function prepNextExample(){colObj.gameArr.length?(colObj.current=colObj.gameArr.splice(0,1)[0],window.interact(".drag-drop").unset(),resetExample()):promptReset()}function resetExample(){var container=docEl("exB"),targetSpan=docEl("targetWord"),colAll=colObj.current.colOpts,colCorrect=colObj.current.colOptAns,lenAll=colAll.length,frag=document.createDocumentFragment(),i;for(emptyContent(container),targetSpan.textContent=colObj.current.en,shuffleAnArray(colAll),"b4"===colObj.current.colPos?targetSpan.className="pull-right":targetSpan.className="pull-left",i=0;i<lenAll;i++){var newDiv=document.createElement("div");newDiv.className="drag-drop",newDiv.textContent=colAll[i],-1!==colCorrect.indexOf(colAll[i])?newDiv.className+=" yes":newDiv.className+=" no",frag.appendChild(newDiv)}container.appendChild(frag),setInteractable()}function checkComplete(){var foo=docEl("exB"),count=0,i,thisChild;for(i=0;i<foo.children.length;i++)if((thisChild=foo.children[i]).classList.contains("drag-drop")&&thisChild.classList.contains("yes")&&thisChild.classList.contains("can-drop")&&count++,count>=3){addLineBreak(),prepNextExample();break}}function addLineBreak(){var container=docEl("completedcollocations"),frag=document.createDocumentFragment(),newBr=document.createElement("br");frag.appendChild(newBr),container.insertBefore(frag,container.firstChild)}function initGame(){colObj.gameArr=colObj.voca.slice(0),shuffleAnArray(colObj.gameArr),colObj.current=colObj.gameArr.splice(0,1)[0],resetExample()}function convertData(data){var colEl,colOptsArr;data.forEach((function(el){el.hasOwnProperty("col")&&((colEl={}).en=el.en,colEl.colPos=el.col.pos,colOptsArr=[el.col.dis1,el.col.dis2,el.col.dis3,el.col.ans1,el.col.ans2,el.col.ans3],colEl.colOptAns=[el.col.ans1,el.col.ans2,el.col.ans3],colEl.colOpts=shuffleAnArray(colOptsArr),colObj.voca.push(colEl))})),initGame(),colObj.time=Date.now()}function dummyLoadNoData(){var dummyObj={en:"No",colPos:"af",colOptAns:["collocations","words","data"],colOpts:["problem","wait","attempt","data","words","collocations"]};colObj.voca.push(dummyObj),initGame()}function init(){var objExists=window.localStorage.getItem("myClss"),data=JSON.parse(objExists);if(null!==data){try{colObj.tchr=data.tchr,colObj.clss=data.clss,data.hasOwnProperty("frag")&&!0===chkTrk(data.frag)&&(colObj.frag=data.frag),convertData(data.voca)}catch(e){colObj.tchr="",colObj.clss="",colObj.voca=[],dataError(),dummyLoadNoData()}docEl("slctdTchrTxt").textContent=colObj.clss+" "+colObj.tchr+" "+colObj.frag}else dataError(),dummyLoadNoData();renderNav(),handlersOn()}function userScored(scr){var score="completed: "+scr+"/"+scr,timeStamp=Date.now(),duration=timeStamp-colObj.time;postIt({a:timeStamp,b:colObj.tchr,c:colObj.clss,d:colObj.frag,e:duration,f:document.title,g:score})}function postIt(dataObj){var user=firebase.auth().currentUser,uid=user.uid,postData={email:user.email,timestamp:dataObj.a,tchr:dataObj.b,clss:dataObj.c,frag:dataObj.d,duration:dataObj.e,activity:dataObj.f,score:dataObj.g},newPostKey,updates={};updates["activities/"+uid+"/"+firebase.database().ref().child("activities/"+uid+"/").push().key]=postData,firebase.database().ref().update(updates,(function(e){e?"PERMISSION_DENIED"===e.code?signOutOfApp():window.alert("Data could not be saved.\n"+e):window.alert("Activity completed!")}))}firebase.auth().onAuthStateChanged((function(user){user?(docEl("usrPhoto").src=user.photoURL,init()):window.location="../index.html"})),window.interact(".dropzone").dropzone({accept:".yes",overlap:.75,ondropactivate:function(event){event.target.classList.add("drop-active")},ondragenter:function(event){var draggableElement=event.relatedTarget,dropzoneElement;event.target.classList.add("drop-target"),draggableElement.classList.add("can-drop")},ondragleave:function(event){event.target.classList.remove("drop-target"),event.relatedTarget.classList.remove("can-drop")},ondrop:function(event){event.relatedTarget.style.display="none",setCompletedCollocation(event.relatedTarget.textContent)},ondropdeactivate:function(event){event.target.classList.remove("drop-active"),event.target.classList.remove("drop-target"),checkComplete()}}),window.dragMoveListener=dragMoveListener}()}));