From 85e441390c5d59b5d9e11a66f5defdd752196a71 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Fri, 10 Mar 2017 13:29:11 +0000 Subject: [PATCH] Minified version to match full --- lib/ice-coder.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 4c51274..6f5ec00 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -4054,7 +4054,7 @@ var ICEcoder = { // Reset the auto-logout timer top.ICEcoder.resetAutoLogoutTimer(); - // Detect if we type s,n,a,k,e keys, if so start snake game + // Detect if we type s,n,a,k,e keys with content saved, if so start snake game if (!top.ICEcoder.last5Keys) {top.ICEcoder.last5Keys = [];} top.ICEcoder.last5Keys.push(key); if (top.ICEcoder.last5Keys.length == 6) { @@ -4062,7 +4062,24 @@ var ICEcoder = { } if (top.ICEcoder.last5Keys.join() == "83,78,65,75,69") { setTimeout(function() { - top.ICEcoder.startSnake(); + // Undo back to pre 'snake' word + cM = ICEcoder.getcMInstance(); + var undoCounts = 0; + var startCG = cM.changeGeneration(); + while (cM.changeGeneration() > startCG-5) { + cM.undo(); + undoCounts++; + } + // If we have content saved + if (top.ICEcoder.savedPoints[top.ICEcoder.selectedTab-1] == cM.changeGeneration()) { + // Start snake game + top.ICEcoder.startSnake(); + // If we don't, redo snake word + } else { + for (var i=1; i<=undoCounts; i++) { + cM.redo(); + } + } },0); }