var results = new Array(); var resultsIndex = 0; var initial_decks = initial_card; var additional_decks = additional_card; var deckCount = 0; var initial_voi; var handCount = 0; var startTime = 0; var endTime = 0; var elapsedTime = 0; var resultString; var colorString = "border-color:red"; var relString; var scaleString; function newSession(){ handCount = 0; var deck_str = $("#session_select option:selected").attr("value"); deckCount = parseInt(deck_str); if(voiScale()) scaleString = "Hard Scale"; else scaleString = "Soft Scale"; results[resultsIndex++] = "Deck " + (deckCount+1) + " " + scaleString; document.getElementById('session').setAttribute("disabled","true"); document.getElementById('scores').removeAttribute("disabled"); dealHand(); } function printResults(){ resultString =""; for(var i = 0; i < results.length; i++) resultString += results[i] + "\n"; console.log(resultString); } function beginTest(){ var session_str; var i; for ( i = 0; i < initial_decks.length; i++ ){ session_str += ""; } document.getElementById('session_select').innerHTML = session_str; document.getElementById('testContainer').removeAttribute("hidden"); document.getElementById('submissionContainer').setAttribute("hidden",true); } function exitTest(){ results[resultsIndex-1] = ""; beginResults(); } function editDemo(){ document.getElementById('demographics').removeAttribute("hidden"); document.getElementById('demoBtn').setAttribute("hidden",true); } function beginResults(){ printResults(); document.getElementById('submissionContainer').removeAttribute("hidden"); document.getElementById('results').removeAttribute("hidden"); document.getElementById('demographics').setAttribute("hidden",true); document.getElementById('testContainer').setAttribute("hidden",true); document.getElementById('resultsText').innerHTML =resultString; moveToResults (); } function endSession(){ results[resultsIndex++] = "\n"; $(".fade").fadeIn(500); $(".fadeLabel").fadeIn(500); window.alert("Thank you for finishing Session " + (deckCount + 1) + ". " + "If you have not completed all sessions, please use the Session drop down box on the right to select a new session to complete when you are ready." + "You may also return to the website at a later time to complete the remaining sessions," + "but you will be asked to submit demographic information again so your previous results can be linked to the additional results." + "If you have completed all session please press the Exit button."+ "This was a test run and I appreciate your time."); document.getElementById('counter').setAttribute("value","0"); document.getElementById('session').removeAttribute("disabled"); document.getElementById('scores').setAttribute("disabled", "true"); document.getElementById('div1').innerHTML = ""; document.getElementById('div2').innerHTML =""; } function nextHand(){ endTime = new Date(); elapsedTime = Math.round((endTime.getTime() - startTime.getTime())/1000); gatherRankedSequence(); dealHand(); } function resetHand(){ handCount--; resultsIndex--; dealHand(); } function gatherRankedSequence(){ var sequenceStr = "Adjusted VoI : "; sequenceStr += document.getElementById("voi_value").getAttribute("value"); sequenceStr += " number of sec " + elapsedTime; results[resultsIndex++] = sequenceStr; } function gatherOriginalSequence(){ var sequenceStr = "Intel Card Set : "; sequenceStr += initial_decks[deckCount][handCount] + " " + additional_decks[deckCount][handCount][0] + " Complement Factor: " + additional_decks[deckCount][handCount][1] + " Initial VoI: " + document.getElementById("voi_value").getAttribute("value");; results[resultsIndex++] = sequenceStr; } function dealHand(){ if(handCount >= initial_decks[deckCount].length) { endSession(); } else{ var initial_hand; var additional_hand; var new_voi; var old_voi; initial_hand = initial_decks[deckCount][handCount]; additional_hand = additional_decks[deckCount][handCount]; if(voiScale()){ if (handCount >= 0) new_voi = VoI_Calculation( allCards[(initial_hand-1)]); else new_voi = 5; old_voi = document.getElementById("voi_value").getAttribute("value"); document.getElementById("voi_value").setAttribute("value", new_voi); if (new_voi > old_voi) document.getElementById("voi_slider").stepUp((new_voi - old_voi)/.1); else document.getElementById("voi_slider").stepDown((old_voi - new_voi)/.1); } else{ new_voi = 5; old_voi = document.getElementById("voi_value").getAttribute("value"); document.getElementById("voi_value").setAttribute("value", new_voi); console.log(new_voi); console.log(old_voi); if (new_voi > old_voi) document.getElementById("voi_slider").stepUp((new_voi - old_voi)/.1); else document.getElementById("voi_slider").stepDown((old_voi - new_voi)/.1); } document.getElementById('div1').innerHTML = ""; document.getElementById('div2').innerHTML = ""; $(".fade").fadeIn(); gatherOriginalSequence(); handCount++; var counterString = handCount + " of " + initial_card[deckCount].length; document.getElementById('counter').setAttribute("value",counterString); startTime = new Date(); } } function moveToResults (){window.location.hash="RESULTS";} function loadFile(){ //reader.open('get', 'cards.js', true); } $(function () { setTimeout(function () { $("#justinevoi").fadeOut("slow", function () { $("#demographics").show(); }); }, 1000); }); //