Skip to content

Commit

Permalink
Fixing whitespace conformity on engine.js
Browse files Browse the repository at this point in the history
  • Loading branch information
anubisthejackle committed Jul 17, 2014
1 parent d164d1d commit 33e9772
Showing 1 changed file with 65 additions and 91 deletions.
156 changes: 65 additions & 91 deletions script/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -339,58 +345,26 @@
}
}
}
}
});
},

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'),
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();
},

});
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?'),
Expand All @@ -412,7 +386,7 @@
}
});
},

deleteSave: function(noReload) {
if(typeof Storage != 'undefined' && localStorage) {
var prestige = Prestige.get();
Expand All @@ -424,7 +398,7 @@
location.reload();
}
},

share: function() {
Events.startEvent({
title: _('Share'),
Expand Down Expand Up @@ -472,7 +446,7 @@
width: '400px'
});
},

findStylesheet: function(title) {
for(var i=0; i<document.styleSheets.length; i++) {
var sheet = document.styleSheets[i];
Expand All @@ -482,15 +456,15 @@
}
return null;
},

isLightsOff: function() {
var darkCss = Engine.findStylesheet('darkenLights');
if ( darkCss != null && !darkCss.disabled ) {
return true;
}
return false;
},

turnLightsOff: function() {
var darkCss = Engine.findStylesheet('darkenLights');
if (darkCss == null) {
Expand All @@ -506,67 +480,67 @@
$('.lightsOff').text(_('lights off.'));
}
},

// Gets a guid
getGuid: function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
},

activeModule: null,

travelTo: function(module) {
if(Engine.activeModule != module) {
var currentIndex = Engine.activeModule ? $('.location').index(Engine.activeModule.panel) : 1;
$('div.headerButton').removeClass('selected');
module.tab.addClass('selected');

var slider = $('#locationSlider');
var stores = $('#storesContainer');
var panelIndex = $('.location').index(module.panel);
var diff = Math.abs(panelIndex - currentIndex);
slider.animate({left: -(panelIndex * 700) + 'px'}, 300 * diff);

if($SM.get('stores.wood') != undefined) {
// FIXME Why does this work if there's an animation queue...?
stores.animate({right: -(panelIndex * 700) + 'px'}, 300 * diff);
}

Engine.activeModule = module;

module.onArrival(diff);

if(Engine.activeModule == Room || Engine.activeModule == Path) {
// Don't fade out the weapons if we're switching to a module
// where we're going to keep showing them anyway.
if (module != Room && module != Path) {
$('div#weapons').animate({opacity: 0}, 300);
}
}

if(module == Room || module == Path) {
$('div#weapons').animate({opacity: 1}, 300);
}

Notifications.printQueue(module);

}
},

/* Move the stores panel beneath top_container (or to top: 0px if top_container
* either hasn't been filled in or is null) using transition_diff to sync with
* the animation in Engine.travelTo().
*/
moveStoresView: function(top_container, transition_diff) {
var stores = $('#storesContainer');

// If we don't have a storesContainer yet, leave.
if(typeof(stores) === 'undefined') return;

if(typeof(transition_diff) === 'undefined') transition_diff = 1;

if(top_container === null) {
stores.animate({top: '0px'}, {queue: false, duration: 300 * transition_diff});
}
Expand All @@ -583,28 +557,28 @@
});
}
},

log: function(msg) {
if(this._log) {
console.log(msg);
}
},

updateSlider: function() {
var slider = $('#locationSlider');
slider.width((slider.children().length * 700) + 'px');
},

updateOuterSlider: function() {
var slider = $('#outerSlider');
slider.width((slider.children().length * 700) + 'px');
},

getIncomeMsg: function(num, delay) {
return _("{0} per {1}s", (num > 0 ? "+" : "") + num, delay);
//return (num > 0 ? "+" : "") + num + " per " + delay + "s";
},

keyDown: function(e) {
if(!Engine.keyPressed && !Engine.keyLock) {
Engine.pressed = true;
Expand All @@ -614,7 +588,7 @@
}
return !(jQuery.inArray(window.event.keycode, [37,38,39,40]));
},

keyUp: function(e) {
Engine.pressed = false;
if(Engine.activeModule.keyUp) {
Expand Down Expand Up @@ -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){
Expand All @@ -707,23 +681,23 @@
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) {
localStorage.lang = lang;
}
}
};

function eventNullifier(e) {
return $(e.target).hasClass('menuBtn');
}

function eventPassthrough(e) {
return true;
}

})();

//create jQuery Callbacks() to handle object events
Expand Down

0 comments on commit 33e9772

Please sign in to comment.