diff -ru a/index.html b/index.html --- a/index.html 2026-05-23 04:00:00.000000000 +0000 +++ b/index.html 2026-05-23 04:00:00.000000000 +0000 @@ -16,12 +16,7 @@ - - + @@ -39,6 +34,14 @@ lang = localStorage.lang; } catch(e) {} } + // FredyGames: on the Portuguese pages of the site, start in Brazilian Portuguese + if(!lang){ + try { + if(window.top !== window && /^\/pt-br\//.test(window.top.location.pathname)) { + lang = 'pt_br'; + } + } catch(e) {} + } // if a language different than english requested, load all translations if(lang && lang != 'en'){ document.write(' - - - -
diff -ru a/lib/base64.js b/lib/base64.js --- a/lib/base64.js 2026-05-23 04:00:00.000000000 +0000 +++ b/lib/base64.js 2026-05-23 04:00:00.000000000 +0000 @@ -1,141 +1,31 @@ -/** -* -* Base64 encode / decode -* http://www.webtoolkit.info/ -* -**/ +/* + * Base64 of UTF-8 text, used by A Dark Room to export and import saves. + * + * FredyGames: replaces the original lib/base64.js (from webtoolkit.info, under that site's own terms rather than a free + * licence) with the browser's own btoa/atob. Same interface: Base64.encode(text), Base64.decode(base64). + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ var Base64 = { - // private property - _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - - // public method for encoding - encode : function (input) { - var output = ""; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0; - - input = Base64._utf8_encode(input); - - while (i < input.length) { - - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - - output = output + - this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + - this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); - - } - - return output; - }, - - // public method for decoding - decode : function (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - + encode: function (input) { + var bytes = new TextEncoder().encode(input); + var binary = ''; + for (var i = 0; i < bytes.length; i++) { + binary += String.fromCharCode(bytes[i]); } - - output = Base64._utf8_decode(output); - - return output; - + return btoa(binary); }, - // private method for UTF-8 encoding - _utf8_encode : function (string) { - string = string.replace(/\r\n/g,"\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - - var c = string.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - + decode: function (input) { + var binary = atob(input.replace(/[^A-Za-z0-9\+\/\=]/g, '')); + var bytes = new Uint8Array(binary.length); + for (var i = 0; i < binary.length; i++) { + bytes[i] = binary.charCodeAt(i); } - - return utftext; - }, - - // private method for UTF-8 decoding - _utf8_decode : function (utftext) { - var string = ""; - var i = 0; - var c = c2 = 0; - - while ( i < utftext.length ) { - - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - - } - - return string; + return new TextDecoder().decode(bytes); } -} +}; diff -ru a/script/engine.js b/script/engine.js --- a/script/engine.js 2026-05-23 04:00:00.000000000 +0000 +++ b/script/engine.js 2026-05-23 04:00:00.000000000 +0000 @@ -1,7 +1,6 @@ (function() { var Engine = window.Engine = { - SITE_URL: encodeURIComponent("http://adarkroom.doublespeakgames.com"), VERSION: 1.3, MAX_STORE: 99999999999999, SAVE_DISPLAY: 30 * 1000, @@ -149,12 +148,6 @@ .appendTo(menu); $('') - .addClass('appStore menuBtn') - .text(_('get the app.')) - .click(Engine.getApp) - .appendTo(menu); - - $('') .addClass('lightsOff menuBtn') .text(_('lights off.')) .click(Engine.turnLightsOff) @@ -174,12 +167,6 @@ $('') .addClass('menuBtn') - .text(_('share.')) - .click(Engine.share) - .appendTo(menu); - - $('') - .addClass('menuBtn') .text(_('save.')) .click(Engine.exportImport) .appendTo(menu); @@ -265,8 +252,9 @@ return ( location.search.indexOf( 'ignorebrowser=true' ) >= 0 || ( typeof Storage != 'undefined' && !oldIE ) ); }, + // FredyGames: no redirect to mobileWarning.html (app store links); the game also runs on a touch screen. isMobile: function() { - return ( location.search.indexOf( 'ignorebrowser=true' ) < 0 && /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test( navigator.userAgent ) ); + return false; }, saveGame: function() { @@ -429,7 +417,9 @@ if(typeof Storage != 'undefined' && localStorage) { var prestige = Prestige.get(); window.State = {}; - localStorage.clear(); + // FredyGames: the site's other games keep their saves in the same browser storage, so + // remove only this game's save instead of clearing everything (was localStorage.clear()). + localStorage.removeItem('gameState'); Prestige.set(prestige); } if(!noReload) { @@ -437,85 +427,6 @@ } }, - getApp: function() { - Events.startEvent({ - title: _('Get the App'), - scenes: { - start: { - text: [_('bring the room with you.')], - buttons: { - 'ios': { - text: _('ios'), - nextScene: 'end', - onChoose: function () { - window.open('https://itunes.apple.com/app/apple-store/id736683061?pt=2073437&ct=adrproper&mt=8'); - } - }, - 'android': { - text: _('android'), - nextScene: 'end', - onChoose: function() { - window.open('https://play.google.com/store/apps/details?id=com.yourcompany.adarkroom'); - } - }, - 'close': { - text: _('close'), - nextScene: 'end' - } - } - } - } - }); - }, - - share: function() { - Events.startEvent({ - title: _('Share'), - scenes: { - start: { - text: [_('bring your friends.')], - buttons: { - 'facebook': { - text: _('facebook'), - nextScene: 'end', - onChoose: function() { - window.open('https://www.facebook.com/sharer/sharer.php?u=' + Engine.SITE_URL, 'sharer', 'width=626,height=436,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no'); - } - }, - 'google': { - text:_('google+'), - nextScene: 'end', - onChoose: function() { - window.open('https://plus.google.com/share?url=' + Engine.SITE_URL, 'sharer', 'width=480,height=436,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no'); - } - }, - 'twitter': { - text: _('twitter'), - nextScene: 'end', - onChoose: function() { - window.open('https://twitter.com/intent/tweet?text=A%20Dark%20Room&url=' + Engine.SITE_URL, 'sharer', 'width=660,height=260,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no'); - } - }, - 'reddit': { - text: _('reddit'), - nextScene: 'end', - onChoose: function() { - window.open('http://www.reddit.com/submit?url=' + Engine.SITE_URL, 'sharer', 'width=960,height=700,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no'); - } - }, - 'close': { - text: _('close'), - nextScene: 'end' - } - } - } - } - }, - { - width: '400px' - }); - }, - findStylesheet: function(title) { for(var i=0; i