From 1ef115e16759318027e7dbf7b81af281e6bae67d Mon Sep 17 00:00:00 2001 From: Kevin Dungs Date: Sat, 2 Aug 2014 10:26:28 +0200 Subject: [PATCH] Implement basic JSON file loading functionality. --- js/game.js | 23 +++++++++++++++++------ json/discoveries.json | 11 +++++++++++ json/workers.json | 8 ++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 json/discoveries.json create mode 100644 json/workers.json diff --git a/js/game.js b/js/game.js index 9617372..fb5c6cd 100644 --- a/js/game.js +++ b/js/game.js @@ -1,14 +1,25 @@ 'use strict'; (function () { + var loadJsonFile = function(filename) { + var res; + $.ajax({ + async: false, + url : filename, + success : function(data) { + res = data; + } + }); + return res; + } + var discoveries = loadJsonFile('json/discoveries.json'); + var workers = loadJsonFile('json/workers.json'); + + console.log(discoveries); + console.log(workers); var app = angular.module('particleClicker', []); })(); -var discoveries = [ - { - name: 'W-Boson', - description: 'Some nice description.' - } -]; + diff --git a/json/discoveries.json b/json/discoveries.json new file mode 100644 index 0000000..ba4b3f0 --- /dev/null +++ b/json/discoveries.json @@ -0,0 +1,11 @@ +[ + { + "name": "W-Boson", + "description": "The W-Boson is the carrier boson of the weak force.", + "research": { + "reputation": 1, + "cost": 100 + }, + "histogram": {} + } +] diff --git a/json/workers.json b/json/workers.json new file mode 100644 index 0000000..504768d --- /dev/null +++ b/json/workers.json @@ -0,0 +1,8 @@ +[ + { + "name": "PhD Student", + "description": "Basically a slave just with fewer rights.", + "loan": 100, + "rate": 1 + } +]