Skip to content

Commit 430dce2

Browse files
committed
Merge branch 'master' into release
2 parents f8b0078 + de7e79f commit 430dce2

34 files changed

+797
-605
lines changed

.jshintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
, "define": true
1010
, "require": true
1111
, "requirejs": true
12+
, "Promise": true
1213
}
1314
, "laxcomma": true
1415
, "laxbreak": true
1516
, "multistr": true
16-
, "eqnull": true
17+
, "eqeqeq": true
1718
, "smarttabs": true
1819
, "globalstrict": true
1920
, "jquery": true

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ npm start
1414
```
1515
Then you will be able to access the game at <http://127.0.0.1:3000/geofs.php>
1616

17-
**Quick Update** Due to a jQuery code in-game, please type in `require(['ui/main']);` in the console after game loads.
18-
1917
----
2018
#### Quick Optimization
2119
First, make sure that you have run `npm install`.
2220

2321
If so, open a terminal/command prompt in this directory, then do
2422
```
25-
node node_modules/requirejs/bin/r.js -o build-config.js
23+
node_modules/requirejs/bin/r.js -o build.json
2624
```
2725
Then you will be able to see the optimized file in *build* as **fmc.min.js**
2826

build-config.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

build.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{ "baseUrl": "./source"
2+
, "name": "../node_modules/requirejs/require"
3+
, "include": "init"
4+
, "mainConfigFile": "./source/config.js"
5+
, "out": "./build/fmc.min.js"
6+
, "optimize": "uglify2"
7+
}

compile/.jshintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{ "globals":
22
{ "module": true },
3-
"node": true
3+
"node": true,
4+
"predef": [ "-Promise" ],
5+
"varstmt": true,
6+
"esnext": 6
47
}

compile/ATS.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
'use strict';
22

3-
var Promise = require('bluebird');
4-
var fs = Promise.promisifyAll(require('fs'));
5-
var path = require('path');
3+
const Promise = require('bluebird');
64

7-
var FILE_NAME = path.join(__dirname, require('./constants').ROOT_FOLDER + 'ATS.txt');
5+
const fs = Promise.promisifyAll(require('fs'));
6+
const path = require('path');
87

9-
var ATS = {};
8+
const FILE_NAME = path.join(__dirname, `${require('./utils').ROOT_FOLDER}ATS.txt`);
9+
10+
let ATS = {};
11+
12+
module.exports = new Promise(resolve => {
13+
fs.readFileAsync(FILE_NAME, 'utf-8').then(parseFile).then(writeFile).then(resolve);
14+
});
1015

11-
fs.readFileAsync(FILE_NAME, 'utf-8').then(parseFile).then(writeFile);
1216

1317

1418
// --
1519
function parseFile (fileContent) {
20+
console.log('Parsing airways data');
21+
1622
fileContent = fileContent.split('\r\n\r\n');
1723

18-
for (var blocks = 0; blocks < fileContent.length - 1; blocks++) {
19-
var fixesList = [];
24+
for (let blocks = 0; blocks < fileContent.length - 1; blocks++) {
25+
let fixesList = [];
2026
fileContent[blocks] = fileContent[blocks].split('\r\n');
2127

22-
for (var lines = 0; lines < fileContent[blocks].length; lines++) {
28+
for (let lines = 0; lines < fileContent[blocks].length; lines++) {
2329
fileContent[blocks][lines] = fileContent[blocks][lines].split(',');
2430

2531
// Ignores the first line (descriptor) when adding fixes

compile/SID.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,80 @@
11
'use strict';
22

3-
var Promise = require('bluebird');
4-
var fs = Promise.promisifyAll(require('fs'));
5-
var path = require('path');
3+
const Promise = require('bluebird');
4+
5+
const fs = Promise.promisifyAll(require('fs'));
6+
const path = require('path');
67

78
require('graceful-fs').gracefulify(fs);
89

9-
var PATH = path.join(__dirname, require('./constants').ROOT_FOLDER + 'proc/');
10-
var RWY_REGEXP = /^\d\d[LCR]?$/;
10+
const PATH = path.join(__dirname, `${require('./utils').ROOT_FOLDER}proc/`);
11+
const RWY_REGEXP = /^\d\d[LCR]?$/;
1112

12-
var waypoints = require('./compiled-data/waypoints.json');
13-
var navaids = require('./compiled-data/navaids.json');
13+
const waypoints = require('./compiled-data/waypoints.json');
14+
const navaids = require('./compiled-data/navaids.json');
15+
const fileList = require('./utils').readDir(PATH);
1416

15-
var promises = [];
16-
var fileList = require('./constants').readDir(PATH);
17-
var SID = {};
17+
let promises = [], SID = {};
1818

19-
fileList.forEach(function (file) {
20-
promises.push(new Promise(function (resolve, reject) {
21-
var airportName = file.substring(0, file.indexOf('.txt'));
19+
fileList.forEach(file => {
20+
promises.push(new Promise(resolve => {
21+
const airportName = file.substring(0, file.indexOf('.txt'));
2222

2323
fs.readFileAsync(PATH + file, 'utf-8')
24-
.then(function (data) { parseFile(data, airportName); })
24+
.then(data => parseFile(data, airportName))
2525
.then(resolve);
2626
}));
2727
});
2828

29-
Promise.all(promises).then(writeFile);
29+
// new Promise(resolve => {
30+
// console.log('Parsing SID data');
31+
// Promise.all(promises).then(writeFile).then(resolve);
32+
// });
33+
34+
module.exports = {
35+
promises: promises,
36+
writeFile: writeFile
37+
};
3038

3139
// Callback functions
3240
function parseFile (fileContent, airportName) {
3341
// Splits each block (may contain SID, STAR, Final...)
34-
var temp = fileContent.split('\r\n\r\n');
42+
let temp = fileContent.split('\r\n\r\n');
3543
temp.shift();
3644
fileContent = []; // Empties fileContent for SID filters
3745

3846
// Filters SID blocks and pushes to fileContent
39-
temp.forEach(function (block) {
47+
temp.forEach(block => {
4048
if (block.indexOf('SID') === 0) fileContent.push(block);
4149
});
4250

4351
if (fileContent.length === 0) return;
4452

4553
SID[airportName] = [];
4654

47-
for (var blocks = 0; blocks < fileContent.length; blocks++) {
55+
for (let blocks = 0; blocks < fileContent.length; blocks++) {
4856
// Splits each SID block by line (SID line)
4957
fileContent[blocks] = fileContent[blocks].split('\r\n');
5058

51-
var obj = {
59+
let obj = {
5260
name: undefined,
5361
runway: undefined,
5462
waypoints: []
5563
};
5664

57-
for (var lines = 0; lines < fileContent[blocks].length; lines++) {
65+
for (let lines = 0; lines < fileContent[blocks].length; lines++) {
5866
// Splits each SID line by element
5967
fileContent[blocks][lines] = fileContent[blocks][lines].split(',');
6068

61-
var potentialWaypoint = fileContent[blocks][lines][1];
69+
const potentialWaypoint = fileContent[blocks][lines][1];
6270
if (lines > 0 && (waypoints[potentialWaypoint] || navaids[potentialWaypoint])) {
6371
obj.waypoints.push(fileContent[blocks][lines][1].trim());
64-
65-
// SID[airportName][SID[airportName].length - 1].waypoints.push({
66-
// fix: fileContent[blocks][lines][1],
67-
// altRes: 0 ? undefined : fileContent[blocks][lines][13],
68-
// spdRes: 0 ? undefined : fileContent[blocks][lines][11]
69-
// });
7072
}
7173
}
7274

73-
var descriptor = fileContent[blocks][0];
74-
var name = String(descriptor[1]).trim();
75-
var runway = String(descriptor[2]).trim();
75+
const descriptor = fileContent[blocks][0];
76+
const name = String(descriptor[1]).trim();
77+
const runway = String(descriptor[2]).trim();
7678

7779
if (name) obj.name = name;
7880
if (RWY_REGEXP.test(runway)) obj.runway = runway;

compile/STAR.js

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,81 @@
11
'use strict';
22

3-
var Promise = require('bluebird');
4-
var fs = Promise.promisifyAll(require('fs'));
5-
var path = require('path');
3+
const Promise = require('bluebird');
4+
5+
const fs = Promise.promisifyAll(require('fs'));
6+
const path = require('path');
67

78
require('graceful-fs').gracefulify(fs);
89

9-
var PATH = path.join(__dirname, require('./constants').ROOT_FOLDER + 'proc/');
10-
var RWY_REGEXP = /^\d\d[LCR]?$/;
10+
const PATH = path.join(__dirname, `${require('./utils').ROOT_FOLDER}proc/`);
11+
const RWY_REGEXP = /^\d\d[LCR]?$/;
1112

12-
var waypoints = require('./compiled-data/waypoints.json');
13-
var navaids = require('./compiled-data/navaids.json');
13+
const waypoints = require('./compiled-data/waypoints.json');
14+
const navaids = require('./compiled-data/navaids.json');
15+
const fileList = require('./utils').readDir(PATH);
1416

15-
var promises = [];
16-
var fileList = require('./constants').readDir(PATH);
17-
var STAR = {};
17+
let promises = [], STAR = {};
1818

19-
fileList.forEach(function (file) {
20-
promises.push(new Promise(function (resolve, reject) {
21-
var airportName = file.substring(0, file.indexOf('.txt'));
19+
fileList.forEach(file => {
20+
promises.push(new Promise(resolve => {
21+
const airportName = file.substring(0, file.indexOf('.txt'));
2222

2323
fs.readFileAsync(PATH + file, 'utf-8')
24-
.then(function (data) { parseFile(data, airportName); })
24+
.then(data => parseFile(data, airportName))
2525
.then(resolve);
2626
}));
2727
});
2828

29-
Promise.all(promises).then(writeFile);
29+
module.exports = {
30+
promises: promises,
31+
writeFile: writeFile
32+
};
33+
// new Promise(resolve => {
34+
// console.log('Parsing STAR data');
35+
// Promise.all(promises).then(writeFile).then(resolve);
36+
// });
3037

3138
// Callback functions
3239
function parseFile (fileContent, airportName) {
3340
// Splits each block (may contain SID, STAR, Final...)
34-
var temp = fileContent.split('\r\n\r\n');
41+
let temp = fileContent.split('\r\n\r\n');
3542
temp.shift();
3643
fileContent = []; // Empties fileContent for STAR filters
3744

3845
// Filters STAR blocks and pushes to fileContent
39-
temp.forEach(function (block) {
46+
temp.forEach(block => {
4047
if (block.indexOf('STAR') === 0) fileContent.push(block);
4148
});
4249

4350
if (fileContent.length === 0) return;
4451

4552
STAR[airportName] = [];
4653

47-
for (var blocks = 0; blocks < fileContent.length; blocks++) {
54+
for (let blocks = 0; blocks < fileContent.length; blocks++) {
4855
// Splits each STAR block by line (STAR line)
4956
fileContent[blocks] = fileContent[blocks].split('\r\n');
5057

51-
var obj = {
58+
let obj = {
5259
name: undefined,
5360
runway: undefined,
5461
transition: undefined,
5562
connecting: undefined,
5663
waypoints: []
5764
};
5865

59-
for (var lines = 0; lines < fileContent[blocks].length; lines++) {
66+
for (let lines = 0; lines < fileContent[blocks].length; lines++) {
6067
// Splits each STAR line by element
6168
fileContent[blocks][lines] = fileContent[blocks][lines].split(',');
6269

63-
var potentialWaypoint = fileContent[blocks][lines][1];
70+
const potentialWaypoint = fileContent[blocks][lines][1];
6471
if (lines > 0 && (waypoints[potentialWaypoint] || navaids[potentialWaypoint])) {
6572
obj.waypoints.push(fileContent[blocks][lines][1].trim());
6673
}
6774
}
6875

69-
var descriptor = fileContent[blocks][0];
70-
var name = String(descriptor[1]).trim();
71-
var runway = String(descriptor[2]).trim();
76+
const descriptor = fileContent[blocks][0];
77+
const name = String(descriptor[1]).trim();
78+
const runway = String(descriptor[2]).trim();
7279

7380
if (name) obj.name = name;
7481
if (RWY_REGEXP.test(runway)) obj.runway = runway;

0 commit comments

Comments
 (0)