From e38e86fd2e02a71c2381473ddf3843b26082ce31 Mon Sep 17 00:00:00 2001 From: Richard Urbanec Date: Thu, 27 Sep 2018 14:53:04 +0200 Subject: [PATCH 1/2] delete redundant Utils.canReadGameFiles Delete redundant Utils.canReadGameFiles. What it does is: Take already loaded scripts and try to load the last one again. However, if that script cannot be loaded, then rpg_core.js couldn't be loaded either, so the only thing this function will tell us is what we already know. --- js/rpg_core/Utils.js | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/js/rpg_core/Utils.js b/js/rpg_core/Utils.js index ccfda839..c512b410 100644 --- a/js/rpg_core/Utils.js +++ b/js/rpg_core/Utils.js @@ -99,27 +99,6 @@ Utils.isAndroidChrome = function() { return !!(agent.match(/Android/) && agent.match(/Chrome/)); }; -/** - * Checks whether the browser can read files in the game folder. - * - * @static - * @method canReadGameFiles - * @return {Boolean} True if the browser can read files in the game folder - */ -Utils.canReadGameFiles = function() { - var scripts = document.getElementsByTagName('script'); - var lastScript = scripts[scripts.length - 1]; - var xhr = new XMLHttpRequest(); - try { - xhr.open('GET', lastScript.src); - xhr.overrideMimeType('text/javascript'); - xhr.send(); - return true; - } catch (e) { - return false; - } -}; - /** * Makes a CSS color string from RGB values. * From 473919501e82aff5b108542fc841829526292d89 Mon Sep 17 00:00:00 2001 From: Richard Urbanec Date: Thu, 27 Sep 2018 14:54:36 +0200 Subject: [PATCH 2/2] deleted SceneManager.checkFileAccess Deleted SceneManager.checkFileAccess for redundancy. --- js/rpg_managers/SceneManager.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/js/rpg_managers/SceneManager.js b/js/rpg_managers/SceneManager.js index 5b1f13ce..618f052c 100644 --- a/js/rpg_managers/SceneManager.js +++ b/js/rpg_managers/SceneManager.js @@ -45,7 +45,6 @@ SceneManager.run = function(sceneClass) { SceneManager.initialize = function() { this.initProgressWatcher(); this.initGraphics(); - this.checkFileAccess(); this.initAudio(); this.initInput(); this.initNwjs(); @@ -91,12 +90,6 @@ SceneManager.checkWebGL = function() { } }; -SceneManager.checkFileAccess = function() { - if (!Utils.canReadGameFiles()) { - throw new Error('Your browser does not allow to read local files.'); - } -}; - SceneManager.initAudio = function() { var noAudio = Utils.isOptionValid('noaudio'); if (!WebAudio.initialize(noAudio) && !noAudio) {