From d882833202fdb30aa7de20c1784f1af2693ab752 Mon Sep 17 00:00:00 2001 From: ysandler Date: Sat, 9 Sep 2017 16:01:25 -0500 Subject: [PATCH] fix: fixed redirect and reload --- app.js | 2 +- dev/app.js | 26 +++++++++++++++++++++++--- dev/index.html | 5 +++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 1c1dd6e..05a0289 100644 --- a/app.js +++ b/app.js @@ -1 +1 @@ -(function(a,b){'function'==typeof define&&'object'==typeof define.amd&&define.amd?define(function(){return b(a)}):'object'==typeof module&&module&&module.exports?module.exports=b(a):a.Levenshtein=b(a)})(this,function(){function b(g,h){var j,k;for(j=-1,k=g.length;++jc;c++)a+=b.charAt(Math.floor(Math.random()*b.length));return a}function formatIP(a){let b=a;return b=b.slice(0,2)+'.'+b.slice(2),b=b.slice(0,6)+'.'+b.slice(6),b=b.slice(0,9)+'.'+b.slice(9),b}function randomInRange(a,b,c){return 1*(Math.random()*(b-a)+a).toFixed(c)}function createEntryHTML(a){let{value:b,status:c,machineType:d,hostName:f,lastResponse:g,systemLocation:h}=a,j=formatIP(b),k=' '+formatIP(b)+' '+c+' '+f+' '+d+' '+g+'MS '+h.long+'_'+h.lat+' ';return k}function createEntryHTMLArray(a){let b=[];return a.forEach(function(c){b.push(createEntryHTML(c))},this),b}function createRandomName(){let a='',b='0123456789QWERTYUIOP_-ASDFGHJKLZXCVBNM';for(var c=0;10>c;c++)a+=b.charAt(Math.floor(Math.random()*b.length));return a}function createEntryArray(){let a=[];for(i=0;27>i;i++)a.push(new Entry);return a}function concatEntryHTMLArray(a){let b='';return a.forEach(function(c){b+=c},this),b}function renderEntries(a){document.getElementById('entry_table').innerHTML=a}function extractIpAddressFromElement(a){return ipAddress=a.getAttribute('data-ip-value'),ipAddress}function selectTargetIpAddress(a){let b=a[randomInRange(0,a.length-1,0)].value;return b}function compareIpAddress(a){let b=new Levenshtein(a,targetIpAddress),c=10-b.distance;return c}function beginRound(){document.getElementById('entry_table').innerHTML='',ipAttempts=[];let a=createEntryArray(),b=createEntryHTMLArray(a),c=concatEntryHTMLArray(b),d=document.getElementsByClassName('entry');targetIpAddress=selectTargetIpAddress(a),renderEntries(c),assignClickEvent(d),renderSuccessPrecentage(100*score/winScore),renderAttempts(),console.log(targetIpAddress)}function beginClicked(){let a=document.getElementById('messege');a.innerHTML='',a.className='hidden',timeInterval=setInterval(countDown,10),beginRound()}function assignClickEvent(a){for(i=0;iwinScore-1?gameWin():beginRound()}function wrongEntrySelected(a,b){let c=extractIpAddressFromElement(a);++lockoutHits,saveAttempt(c),renderAttempts(),console.log(c+' was incorrect. Tries left: '+(lockoutMax-lockoutHits)),console.log(b+' characters were correct. Try Again!')}function renderSuccessPrecentage(a){let b=document.getElementById('precentage');b.innerHTML=Math.floor(a)+'%'}function renderLockout(){let a=document.getElementById('lockout');for(a.innerHTML='',i=0;i X '}function saveAttempt(a){ipAttempts.push(a)}function renderAttempts(){let a=document.getElementById('attempts_table');a.innerHTML='',ipAttempts.forEach(function(b){a.innerHTML+=''+formatIP(b)+' '+compareIpAddress(b)+' similar chars'},this)}function checkStatus(){lockoutHits>=lockoutMax&&gameLose()}function gameLose(){let a=document.getElementsByClassName('entry');lose=!0,timerElement.innerHTML=0,clearInterval(timeInterval),Array.prototype.forEach.call(a,function(c){c.className='entry error'},this)}function gameWin(){let a=document.querySelector('[data-ip-value="'+targetIpAddress+'"]');win=!0,a.className='win',clearInterval(timeInterval),timerElement.innerHTML=0,console.log('Game Win')}function countDown(){0c;c++)a+=b.charAt(Math.floor(Math.random()*b.length));return a}function formatIP(a){let b=a;return b=b.slice(0,2)+'.'+b.slice(2),b=b.slice(0,6)+'.'+b.slice(6),b=b.slice(0,9)+'.'+b.slice(9),b}function randomInRange(a,b,c){return 1*(Math.random()*(b-a)+a).toFixed(c)}function createEntryHTML(a){let{value:b,status:c,machineType:d,hostName:f,lastResponse:g,systemLocation:h}=a,j=formatIP(b),k=' '+formatIP(b)+' '+c+' '+f+' '+d+' '+g+'MS '+h.long+'_'+h.lat+' ';return k}function createEntryHTMLArray(a){let b=[];return a.forEach(function(c){b.push(createEntryHTML(c))},this),b}function createRandomName(){let a='',b='0123456789QWERTYUIOP_-ASDFGHJKLZXCVBNM';for(var c=0;10>c;c++)a+=b.charAt(Math.floor(Math.random()*b.length));return a}function createEntryArray(){let a=[];for(i=0;27>i;i++)a.push(new Entry);return a}function concatEntryHTMLArray(a){let b='';return a.forEach(function(c){b+=c},this),b}function renderEntries(a){document.getElementById('entry_table').innerHTML=a}function extractIpAddressFromElement(a){return ipAddress=a.getAttribute('data-ip-value'),ipAddress}function selectTargetIpAddress(a){let b=a[randomInRange(0,a.length-1,0)].value;return b}function compareIpAddress(a){let b=new Levenshtein(a,targetIpAddress),c=10-b.distance;return c}function beginRound(){document.getElementById('entry_table').innerHTML='',ipAttempts=[];let a=createEntryArray(),b=createEntryHTMLArray(a),c=concatEntryHTMLArray(b),d=document.getElementsByClassName('entry');targetIpAddress=selectTargetIpAddress(a),renderEntries(c),assignClickEvent(d),renderSuccessPrecentage(100*score/winScore),renderAttempts(),console.log(targetIpAddress)}function beginClicked(){let a=document.getElementById('messege');a.innerHTML='',a.className='hidden',timeInterval=setInterval(countDown,10),beginRound()}function assignClickEvent(a){for(i=0;iwinScore-1?gameWin():beginRound()}function wrongEntrySelected(a,b){let c=extractIpAddressFromElement(a);++lockoutHits,saveAttempt(c),renderAttempts(),console.log(c+' was incorrect. Tries left: '+(lockoutMax-lockoutHits)),console.log(b+' characters were correct. Try Again!')}function renderSuccessPrecentage(a){let b=document.getElementById('precentage');b.innerHTML=Math.floor(a)+'%'}function renderLockout(){let a=document.getElementById('lockout');for(a.innerHTML='',i=0;i X '}function saveAttempt(a){ipAttempts.push(a)}function renderAttempts(){let a=document.getElementById('attempts_table');a.innerHTML='',ipAttempts.forEach(function(b){a.innerHTML+=''+formatIP(b)+' '+compareIpAddress(b)+' similar chars'},this)}function renderEndGame(){document.getElementById('entry_table').innerHTML='';let a=document.getElementById('messege');a.innerHTML='

You have found her! It was not easy, but your diligence paid off. Continue to send an anonyms tip to the F.B.I.

',a.className=''}function checkStatus(){lockoutHits>=lockoutMax&&gameLose()}function gameLose(){let a=document.getElementsByClassName('entry');lose=!0,timerElement.innerHTML=0,clearInterval(timeInterval),Array.prototype.forEach.call(a,function(c){c.className='entry error'},this),setTimeout(function(){window.location.reload(!0)},4e3)}function gameWin(){let a=document.querySelector('[data-ip-value="'+targetIpAddress+'"]');win=!0,a.className='win',clearInterval(timeInterval),timerElement.innerHTML=0,renderEndGame(),console.log('Game Win')}function countDown(){0= lockoutMax){ gameLose(); @@ -282,6 +291,11 @@ function gameLose(){ Array.prototype.forEach.call(entryElements, function(e) { e.className = "entry error" }, this); + + + setTimeout(function(){ + window.location.reload(true) + }, 4000); } function gameWin(){ @@ -292,6 +306,8 @@ function gameWin(){ clearInterval(timeInterval); timerElement.innerHTML = 0; + renderEndGame(); + console.log("Game Win"); } @@ -304,3 +320,7 @@ function countDown(){ gameLose(); } } + +function redirectToFoundation(){ + window.open('http://waynefdn.org/', '_blank') +} diff --git a/dev/index.html b/dev/index.html index df7dac8..3102650 100644 --- a/dev/index.html +++ b/dev/index.html @@ -4,7 +4,7 @@ Lost - + @@ -79,6 +79,7 @@ - + + \ No newline at end of file