diff --git a/frontend-js/src/main/js/Configuration.js b/frontend-js/src/main/js/Configuration.js index 9f82288d7a04801007b5dd080b52edddab3c26d6..2a9cd677f17118edd3cc19e8ed614231c670e067 100644 --- a/frontend-js/src/main/js/Configuration.js +++ b/frontend-js/src/main/js/Configuration.js @@ -35,46 +35,6 @@ function Configuration(data) { Configuration.prototype = Object.create(ObjectWithListeners.prototype); Configuration.prototype.constructor = Configuration; -/** - * Load configuration from file. - */ -Configuration.prototype.loadFromFile = function(fileName, callBackFunction) { - var self = this; - - var txtFile = new XMLHttpRequest(); - txtFile.open("GET", fileName, true); - txtFile.onreadystatechange = function() { - // Makes sure the document is ready to parse. - if (txtFile.readyState === 4) { - // Makes sure it's found the file. - if (txtFile.status === 200) { - allText = txtFile.responseText; - // Will separate each line into an array - textLines = txtFile.responseText.split("\n"); - - // name of the map is the filename wthout path and extension - self.MAP_NAME = textLines[0].replace(/^.*[\\\/]/, '').split(".")[0]; - self.TILE_SIZE = parseInt(textLines[3]); - self.PICTURE_SIZE = parseInt(textLines[4]); - self.MIN_ZOOM = 2; - self.MAX_ZOOM = self.MIN_ZOOM + parseInt(textLines[2]); - // read information about all maps connected with current project - mapCounter = parseInt(textLines[5]); - for (var i = 0; i < mapCounter; i++) { - mapDesc = { - id : textLines[6 + i * 2], - title : textLines[6 + i * 2 + 1] - }; - self.MAPS.push(mapDesc); - } - callBackFunction(); - self.callListeners("onreload"); - } - } - }; - txtFile.send(null); -}; - /** * Updates configuration data from object passed from server side. * diff --git a/frontend-js/src/test/js/Configuration-test.js b/frontend-js/src/test/js/Configuration-test.js index 70fef03c3d148246d1a8ebcfb6b15c2cf47360b0..ece19bf7eee4f2f3f764f5cfc79f42ecc27d5251 100644 --- a/frontend-js/src/test/js/Configuration-test.js +++ b/frontend-js/src/test/js/Configuration-test.js @@ -7,6 +7,13 @@ describe('configuration', function() { assert.ok(conf.SUBMODELS); assert.equal(conf.getId(), null); }); + + it('constructor from json', function() { + var json = "{\"idObject\": 19}" + var conf = new Configuration(json); + assert.ok(conf.SUBMODELS); + assert.equal(conf.getId(), 19); + }); it('Configuration onreload listener', function() { var conf = new Configuration();