Merge pull request #540 from loot/misc-tidying

Misc tidying
This commit is contained in:
Oliver Hamlet
2016-01-31 08:53:22 +00:00
10 changed files with 73 additions and 50 deletions
+6 -1
View File
@@ -20,4 +20,9 @@ rules:
strict:
- 2
- global
guard-for-in: 0
guard-for-in: 1
no-param-reassign:
- 2
- props: false
arrow-body-style: 1
max-len: 1
+2 -8
View File
@@ -1,16 +1,10 @@
{
"name": "report",
"version": "0.7.0",
"description": "Load order optimisation tool",
"main": "report.html",
"license": "GPL",
"name": "LOOT",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
"bower_components"
],
"dependencies": {
"polymer": "Polymer/polymer#~0.5.0",
+1 -1
View File
@@ -15,7 +15,7 @@
"devDependencies": {
"bower": "^1.7.1",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^2.0.0",
"eslint-config-airbnb": "^4.0.0",
"fs-extra": "^0.26.2",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
+13 -4
View File
@@ -41,7 +41,7 @@ function compress(sourcePath, destPath) {
'a',
'-r',
destPath,
'.' + path.sep + path.join(sourcePath, '*'),
path.join('.', sourcePath, '*'),
]);
}
@@ -192,13 +192,22 @@ vulcanize(rootPath);
const releasePaths = helpers.getAppReleasePaths(rootPath);
for (let i = 0; i < releasePaths.length; ++i) {
if (releasePaths[i].label) {
createAppArchive(rootPath, releasePaths[i].path, tempPath, path.join(rootPath, 'build', 'LOOT ' + gitDesc + ' (' + releasePaths[i].label + ').7z'));
const filename = `LOOT ${gitDesc} (${releasePaths[i].label}).7z`;
createAppArchive(rootPath,
releasePaths[i].path,
tempPath,
path.join(rootPath, 'build', filename));
} else {
createAppArchive(releasePaths[i].path, path.join(rootPath, 'build', 'LOOT ' + gitDesc + '.7z'));
createAppArchive(releasePaths[i].path,
path.join(rootPath, 'build', `LOOT ${gitDesc}.7z`));
}
}
const binaryPaths = helpers.getApiBinaryPaths(rootPath);
for (let i = 0; i < binaryPaths.length; ++i) {
createApiArchive(rootPath, binaryPaths[i].path, tempPath, path.join(rootPath, 'build', 'LOOT API ' + gitDesc + ' (' + binaryPaths[i].label + ').7z'));
const filename = `LOOT API ${gitDesc} (${binaryPaths[i].label}).7z`;
createApiArchive(rootPath,
binaryPaths[i].path,
tempPath,
path.join(rootPath, 'build', filename));
}
+25 -18
View File
@@ -7,6 +7,21 @@ const fs = require('fs');
const helpers = require('./helpers');
const vulcanize = require('vulcanize');
let rootPath = '.';
if (process.argv.length > 2) {
rootPath = process.argv[2];
}
function mkdir(dir) {
try {
fs.mkdirSync(dir);
} catch (e) {
if (e.code !== 'EEXIST') {
console.log(e);
}
}
}
function runVulcanize(err) {
if (err) {
console.error(err);
@@ -15,29 +30,21 @@ function runVulcanize(err) {
vulcanize.processDocument();
}
let rootPath = '.';
if (process.argv.length > 2) {
rootPath = process.argv[2];
}
function vulcanizeRelease(releasePath) {
const inputPath = path.join(rootPath, 'src', 'gui', 'html', 'index.html');
const outputPath = path.join(releasePath.path, 'resources', 'ui', 'index.html');
helpers.getAppReleasePaths(rootPath).forEach((releasePath) => {
const outputPath = path.join(releasePath.path, 'resources', 'ui');
// Makes sure output directory exists first.
try {
fs.mkdirSync(outputPath);
} catch (e) {
if (e.code !== 'EEXIST') {
console.log(e);
}
}
// Make sure output directory exists first.
mkdir(path.dirname(outputPath));
vulcanize.setOptions({
inline: true,
excludes: {
styles: ['css/theme.css'],
},
output: path.join(outputPath, 'index.html'),
input: path.join(rootPath, 'src', 'gui', 'html', 'index.html'),
output: outputPath,
input: inputPath,
}, runVulcanize);
})
}
helpers.getAppReleasePaths(rootPath).forEach(vulcanizeRelease);
+5 -3
View File
@@ -13,9 +13,9 @@
getElementInTableRowTemplate(rowTemplateId, elementClass) {
const select = document.querySelector('link[rel="import"][href$="editable-table.html"]');
if (select) {
return select.import.querySelector('#' + rowTemplateId).content.querySelector('.' + elementClass);
return select.import.querySelector(`#${rowTemplateId}`).content.querySelector(`.${elementClass}`);
}
return document.querySelector('#' + rowTemplateId).content.querySelector('.' + elementClass);
return document.querySelector(`#${rowTemplateId}`).content.querySelector(`.${elementClass}`);
},
show(elementId) {
@@ -34,7 +34,9 @@
for (let i = 0; i < table.tBodies[0].rows.length; ++i) {
const folderElements = table.tBodies[0].rows[i].getElementsByClassName('folder');
if (folderElements.length === 1) {
table.setReadOnly(table.tBodies[0].rows[i], ['delete'], folderElements[0].value === gameFolder);
table.setReadOnly(table.tBodies[0].rows[i],
['delete'],
folderElements[0].value === gameFolder);
}
}
},
+8 -4
View File
@@ -33,15 +33,18 @@
return false;
}
if (this.conflictingPluginNames.length !== 0 && this.conflictingPluginNames.indexOf(plugin.name) === -1) {
if (this.conflictingPluginNames.length !== 0
&& this.conflictingPluginNames.indexOf(plugin.name) === -1) {
return false;
}
if (this.hideMessagelessPlugins && plugin.getCardContent(this).messages.length === 0) {
if (this.hideMessagelessPlugins
&& plugin.getCardContent(this).messages.length === 0) {
return false;
}
if (this.contentSearchString.length !== 0 && !plugin.getCardContent(this).containsText(this.contentSearchString)) {
if (this.contentSearchString.length !== 0
&& !plugin.getCardContent(this).containsText(this.contentSearchString)) {
return false;
}
@@ -57,7 +60,8 @@
return false;
}
if (this.hideDoNotCleanMessages && message.content.toLowerCase().indexOf(this._doNotCleanString) !== -1) {
if (this.hideDoNotCleanMessages
&& message.content.toLowerCase().indexOf(this._doNotCleanString) !== -1) {
return false;
}
+1 -1
View File
@@ -99,7 +99,7 @@
}
/* Pad CRC string to 8 characters. */
return ('00000000' + this._crc.toString(16).toUpperCase()).slice(-8);
return (`00000000${this._crc.toString(16).toUpperCase()}`).slice(-8);
}
get tags() {
+1 -1
View File
@@ -28,7 +28,7 @@
persistent: false,
onSuccess: resolve,
onFailure: (errorCode, errorMessage) => {
reject(new Error('Error code: ' + errorCode + '; ' + errorMessage));
reject(new Error(`Error code: ${errorCode}; ${errorMessage}`));
},
});
});
+11 -9
View File
@@ -3,7 +3,9 @@
(function exportModule(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['bower_components/Jed/jed', 'bower_components/jed-gettext-parser/jedGettextParser'], factory);
define(['bower_components/Jed/jed',
'bower_components/jed-gettext-parser/jedGettextParser'],
factory);
} else {
// Browser globals
root.loot = root.loot || {};
@@ -19,11 +21,11 @@
load() {
const defaultTranslationData = {
'messages': {
messages: {
'': {
'domain': 'messages',
'lang': 'en',
'plural_forms': 'nplurals=2; plural=(n != 1);',
domain: 'messages',
lang: 'en',
plural_forms: 'nplurals=2; plural=(n != 1);',
},
},
};
@@ -34,7 +36,7 @@
translationDataPromise = Promise.resolve(defaultTranslationData);
} else {
translationDataPromise = new Promise((resolve, reject) => {
const url = 'loot://l10n/' + this.locale + '/LC_MESSAGES/loot.mo';
const url = `loot://l10n/${this.locale}/LC_MESSAGES/loot.mo`;
const xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.responseType = 'arraybuffer';
@@ -53,12 +55,12 @@
}
return translationDataPromise.catch((error) => {
console.log('Error loading translation data: ' + error.message); // eslint-disable-line no-console
console.log(`Error loading translation data: ${error.message}`); // eslint-disable-line no-console
return defaultTranslationData;
}).then((result) => {
this.jed = new Jed({
'locale_data': result,
'domain': 'messages',
locale_data: result,
domain: 'messages',
});
});
}