From 33e9772a1a12bc75527cbbd388875e09feef2f21 Mon Sep 17 00:00:00 2001 From: Travis Weston Date: Wed, 16 Jul 2014 23:45:48 -0400 Subject: [PATCH] Fixing whitespace conformity on engine.js --- script/engine.js | 152 ++++++++++++++++++++--------------------------- 1 file changed, 63 insertions(+), 89 deletions(-) diff --git a/script/engine.js b/script/engine.js index d9ba9e5..9e3d34c 100644 --- a/script/engine.js +++ b/script/engine.js @@ -316,13 +316,19 @@ } }); }, - - export64: function() { - Engine.saveGame(); + + generateExport64: function(){ var string64 = Base64.encode(localStorage.gameState); string64 = string64.replace(/\s/g, ''); string64 = string64.replace(/\./g, ''); string64 = string64.replace(/\n/g, ''); + + return string64; + }, + + export64: function() { + Engine.saveGame(); + var string64 = Engine.generateExport64(); Engine.enableSelection(); Events.startEvent({ title: _('Export'), @@ -339,58 +345,26 @@ } } } - } - }); - }, + }); + Engine.autoSelect('#description textarea') + }, - generateExport64: function(){ - var string64 = Base64.encode(localStorage.gameState); - string64 = string64.replace(/\s/g, ''); - string64 = string64.replace(/\./g, ''); - string64 = string64.replace(/\n/g, ''); + import64: function(string64) { + Engine.disableSelection(); + string64 = string64.replace(/\s/g, ''); + string64 = string64.replace(/\./g, ''); + string64 = string64.replace(/\n/g, ''); + var decodedSave = Base64.decode(string64); + localStorage.gameState = decodedSave; + location.reload(); + }, - return string64; - }, - - export64: function() { - Engine.saveGame(); - var string64 = Engine.generateExport64(); - Engine.enableSelection(); - Events.startEvent({ - title: _('Export'), - scenes: { - start: { - text: [_('save this.')], - textarea: string64, - buttons: { - 'done': { - text: _('got it'), - nextScene: 'end', - onChoose: Engine.disableSelection - } - } - } - } - }); - Engine.autoSelect('#description textarea') - }, - - import64: function(string64) { - Engine.disableSelection(); - string64 = string64.replace(/\s/g, ''); - string64 = string64.replace(/\./g, ''); - string64 = string64.replace(/\n/g, ''); - var decodedSave = Base64.decode(string64); - localStorage.gameState = decodedSave; - location.reload(); - }, - event: function(cat, act) { if(typeof ga === 'function') { ga('send', 'event', cat, act); } }, - + confirmDelete: function() { Events.startEvent({ title: _('Restart?'), @@ -412,7 +386,7 @@ } }); }, - + deleteSave: function(noReload) { if(typeof Storage != 'undefined' && localStorage) { var prestige = Prestige.get(); @@ -424,7 +398,7 @@ location.reload(); } }, - + share: function() { Events.startEvent({ title: _('Share'), @@ -472,7 +446,7 @@ width: '400px' }); }, - + findStylesheet: function(title) { for(var i=0; i 0 ? "+" : "") + num, delay); //return (num > 0 ? "+" : "") + num + " per " + delay + "s"; }, - + keyDown: function(e) { if(!Engine.keyPressed && !Engine.keyLock) { Engine.pressed = true; @@ -614,7 +588,7 @@ } return !(jQuery.inArray(window.event.keycode, [37,38,39,40])); }, - + keyUp: function(e) { Engine.pressed = false; if(Engine.activeModule.keyUp) { @@ -653,52 +627,52 @@ break; } } - + return false; }, - + swipeLeft: function(e) { if(Engine.activeModule.swipeLeft) { Engine.activeModule.swipeLeft(e); } }, - + swipeRight: function(e) { if(Engine.activeModule.swipeRight) { Engine.activeModule.swipeRight(e); } }, - + swipeUp: function(e) { if(Engine.activeModule.swipeUp) { Engine.activeModule.swipeUp(e); } }, - + swipeDown: function(e) { if(Engine.activeModule.swipeDown) { Engine.activeModule.swipeDown(e); } }, - + disableSelection: function() { document.onselectstart = eventNullifier; // this is for IE document.onmousedown = eventNullifier; // this is for the rest }, - + enableSelection: function() { document.onselectstart = eventPassthrough; document.onmousedown = eventPassthrough; }, - + autoSelect: function(selector) { $(selector).focus().select(); }, - + handleStateUpdates: function(e){ - - }, + }, + switchLanguage: function(dom){ var lang = $(this).val(); if(document.location.href.search(/[\?\&]lang=[a-z]+/) != -1){ @@ -707,7 +681,7 @@ document.location.href = document.location.href + ( (document.location.href.search(/\?/) != -1 )?"&":"?") + "lang="+lang; } }, - + saveLanguage: function(){ var lang = decodeURIComponent((new RegExp('[?|&]lang=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null; if(lang && typeof Storage != 'undefined' && localStorage) { @@ -715,15 +689,15 @@ } } }; - + function eventNullifier(e) { return $(e.target).hasClass('menuBtn'); } - + function eventPassthrough(e) { return true; } - + })(); //create jQuery Callbacks() to handle object events