{"size": 7416, "ext": "js", "max_stars_repo_path": "PoliChallenge/Site/Game/game-min.js", "max_stars_repo_name": "spiri91/PoliChallenge", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "PoliChallenge/Site/Game/game-min.js", "max_issues_repo_name": "spiri91/PoliChallenge", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "PoliChallenge/Site/Game/game-min.js", "max_forks_repo_name": "spiri91/PoliChallenge", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 7416.0, "max_line_length": 7416, "alphanum_fraction": 0.7505393743}
"use strict";var gameState={inProgress:!1,score:0};!function(e,t,n,o,a,r,i,s){let m={distance:$("#distance"),score:$("#score"),tip:$("#tip"),startBtn:$("#start"),teamNameTxt:$("#teamName"),teamSelectionContainer:$("#teamNameSelection"),mainBody:$("#mainBody"),pulsatingElement:$("#searchForIT"),tipContainer:$("#tipContainer"),bottomBar:$("#bottomBar"),choseTeamNameBanner:$("#choseTeamNameBanner"),gameBody:$("#gameBody"),teamNameLabel:$("#teamNameLabel"),warmColdMessageContainer:$("#warmColdMessageContainer"),warmColdMessageText:$("#warmColdMessageText"),fireIcon:$("#fireIcon"),snowIcon:$("#snowIcon"),moveNextBtn:$("#moveNextBtn"),showMapBtn:$("#showMapBtn"),timeLeftContainer:$("#timeLeftContainer")},l=[],c=[];var u,f="",d=new RegExp("^[a-zA-Z0-9]*$");let w=s.game.ENTRY_POINT;var g=function(e){if(gameState.inProgress)return;if(0===l.length)return E(gameState.score),void(g=h());T(),n.showElement(m.warmColdMessageContainer),S(),n.showElement(m.showMapBtn),function(e){return function(e){!u||e<=u?(m.warmColdMessageContainer.css("background-color","#e2585a"),n.setTextOf(m.warmColdMessageText,"getting warmer..."),n.showElement(m.fireIcon),n.hideElement(m.snowIcon)):(m.warmColdMessageContainer.css("background-color","#56C3F0"),n.setTextOf(m.warmColdMessageText,"getting colder..."),n.showElement(m.snowIcon),n.hideElement(m.fireIcon)),u=e}(e),window.debugModeOn?window.checkDistanceValue:e<s.game.DISTANCE_TO_OBJECTIVE_WHEN_GAME_STARTS}(function(e){if(window.debugModeOn)return window.getDistanceValue;let o={latitude:e.coords.latitude,longitude:e.coords.longitude},a=t.getDistance(w,o);return function(e){n.setTextOf(m.distance,e)}(a),a}(e))&&function(){n.hideElement(m.tipContainer),n.hideElement(m.pulsatingElement),A(),n.hideElement(m.showMapBtn),n.hideElement(m.warmColdMessageContainer);let e=function(e){return c.filter(t=>t.for===e.key)}(p());gamePlay.start(e)}()},E=function(){E=(()=>{}),n.showSpinner().then(()=>{let e=r.createHiScore({key:i.generate(),teamName:f,score:gameState.score,date:new Date});return r.post(r.entities.hiScores,e,"")}).then(n.hideSpinner)},h=function(){n.confirm(s.game.END_GAME_MESSAGE,()=>location.reload()),h=(()=>{})};function T(){let e=l[0];if(!e)return;let t=e.observations;w.latitude=e.latitude,w.longitude=e.longitude,n.setTextOf(m.tip,t),n.showElement(m.tipContainer),n.showElement(m.pulsatingElement)}function p(){return l.shift()}function C(){l=a.shuffle(o.get(o.names.places)),function(){if(!l||0===l.length)throw n.error("Server unavaible :("),new Error("no places have been retrieved from the DB")}(),function(){let e=s.game.ENTRY_POINT;l.unshift(e)}(),c=o.get(o.names.questions)}function N(){n.error(s.game.LOCATION_DISABLED_MESSAGE)}function B(){T(),n.setTextOf(m.teamNameLabel,f),n.hideElement(m.timeLeftContainer),e.watchPosition(g,N)}function O(e){let t=n.valueOf(m.teamNameTxt);1===t.length&&function(){m.teamNameTxt.tooltip();m.teamNameTxt.tooltip("show");setTimeout(()=>{m.teamNameTxt.tooltip("dispose"),()=>{}},s.game.SHOW_TOOLTIP_TIME_FOR_TEAM_NAME)}(),t.length>3?(n.enableElements([m.startBtn]),function(e){13===e.keyCode&&m.startBtn.click()}(e)):n.disableElements([m.startBtn])}function x(){m.moveNextBtn.tooltip(),m.moveNextBtn.tooltip("show"),setTimeout(()=>{m.moveNextBtn.tooltip("dispose"),x=(()=>{})},s.game.SHOW_TOOLTIP_TIME_FOR_MOVE_NEXT_PLACE)}function S(){n.showElement(m.moveNextBtn),x()}function v(){!function(){let e=n.valueOf(m.teamNameTxt).toUpperCase(),t=o.get(o.names.scores);if(!t)return;if(-1==(t=t.map(e=>e.teamName.toUpperCase())).indexOf(e))return;throw n.warning("Team name already taken :("),m.teamNameTxt.focus(),new Error("Bad team name")}(),C(),n.hideElement(m.choseTeamNameBanner),n.setOpacityOfElement(m.bottomBar,1),S(),n.hideElement(m.teamSelectionContainer),n.showElement(m.mainBody),n.showElement(m.pulsatingElement),f=n.valueOf(m.teamNameTxt),B()}function M(){n.hideElement(m.choseTeamNameBanner),n.hideElement(m.bottomBar),n.hideElement(m.showMapBtn)}function _(){setTimeout(()=>{n.showElement(m.bottomBar),n.showElement(m.showMapBtn)},800)}function I(){p(),T()}function b(e){var t=(e.clipboardData||e.originalEvent.clipboardData||window.clipboardData).getData("text");return!!d.test(t)||(e.preventDefault(),!1)}function L(e){var t=String.fromCharCode(e.charCode?e.charCode:e.which);return!!d.test(t)||(e.preventDefault(),!1)}function A(){n.hideElement(m.moveNextBtn)}n.disableElements([m.startBtn]),m.teamNameTxt.keyup(O),m.teamNameTxt.keypress(L),m.teamNameTxt.on("paste",b),m.teamNameTxt.focus(M),m.teamNameTxt.blur(_),m.startBtn.click(v),m.moveNextBtn.click(I),m.showMapBtn.click(window.myMap),n.hideElement(m.mainBody),A(),n.hideElement(m.pulsatingElement),n.setOpacityOfElement(m.bottomBar,.5),n.showElement(m.choseTeamNameBanner),$(window).scroll(()=>{$(window).scrollTop()<15?m.bottomBar.fadeIn():m.bottomBar.fadeOut()}),m.gameBody.css("visibility","visible"),0==navigator.onLine&&n.hideElement(m.showMapBtn),window.showTipAndPulsatingElementForNextPlace=T}(geo,geolib,_,storage,dealer,repo,guidGenerator,constants);var gamePlay=function(e,t,n){let o={score:$("#score")},a={qContainer:$("#questionsContainer"),statement:$("#statement"),answer1:$("#answer1"),answer2:$("#answer2"),answer3:$("#answer3"),answer4:$("#answer4"),wrongAnsweredQuestionCount:$("#wrAnsQ"),timeLeftContainer:$("#timeLeftContainer"),timeLeft:$("#timeLeft")};let r=0,i=[],s={},m=n.game.TIME_LEFT,l=()=>{};function c(){0==m?(t.warning(n.game.TIMES_UP_MESSAGE),u()):(m--,t.setTextOf(a.timeLeft,m+"sec"))}function u(){if(r===n.game.ALLOWED_WRONG_ANSWERED_QUESTIONS||0===i.length)return gameState.inProgress=!1,t.hideElement(a.qContainer),t.hideElement(a.timeLeftContainer),void clearInterval(l);s=i.shift(),m=n.game.TIME_LEFT,function(){let n=s,o=[n.answer1,n.answer2,n.answer3,n.correctAnswer];!function(e,n){(function(e,n){t.setTextOf(a.statement,e),t.setTextOf(a.answer1,n[0]),t.setTextOf(a.answer2,n[1]),t.setTextOf(a.answer3,n[2]),t.setTextOf(a.answer4,n[3])})(e,n),t.showElement(a.qContainer)}(n.statement,e.shuffle(o))}()}function f(e){var i;!function(e){return e===s.correctAnswer}((i=e,[].slice.call(i.originalEvent.currentTarget.children).filter(e=>"a"==e.localName)[0].innerText))?(r++,t.warning(n.game.WRONG_ANSWER_MESSAGE),navigator.vibrate(210)):(gameState.score+=n.game.ANSWERED_QUESTION_POINTS,t.success(n.game.CORRECT_ANSWER_MESSAGE)),t.setTextOf(o.score,gameState.score),t.setTextOf(a.wrongAnsweredQuestionCount,r),u()}return a.answer1.parent().click(f),a.answer2.parent().click(f),a.answer3.parent().click(f),a.answer4.parent().click(f),{start:function(e){gameState.inProgress=!0,r=0,t.setTextOf(a.wrongAnsweredQuestionCount,r),i=e,t.showElement(a.timeLeftContainer),m=n.game.TIME_LEFT,l=setInterval(c,1e3),u()},moveNext:u}}(dealer,_,constants),infoWindow=null,map=null;function myMap(){var e=document.getElementById("le_map"),t={center:new google.maps.LatLng(44.26,26.03),zoom:16};map=new google.maps.Map(e,t),infoWindow=new google.maps.InfoWindow,(myMap=(()=>{navigator.geolocation.getCurrentPosition(function(e){var t={lat:e.coords.latitude,lng:e.coords.longitude};infoWindow.setPosition(t),infoWindow.setContent("You are here."),infoWindow.open(map),map.setCenter(t)},function(){handleLocationError(!0,infoWindow,map.getCenter())})}))()}function handleLocationError(e,t,n){t.setPosition(n),t.setContent(e?"Error: The Geolocation service failed.":"Error: Your browser doesn't support geolocation."),t.open(map)}