Minify toe data files

This commit is contained in:
Codrin Pavel
2020-05-28 15:29:58 +03:00
parent dd4aad283a
commit eb44f0e7da
73 changed files with 269 additions and 29 deletions
+20 -21
View File
@@ -60,20 +60,33 @@ var toe = new Vue({
)
});
var orderedMatches = aFilteredMatches.sort(function(a, b) {
var orderedMatches = aFilteredMatches.sort(function (a, b) {
return b.enemypower - a.enemypower;
});
return orderedMatches;
}
},
filters: {
humanDate: function (timestamp) {
return new Date(timestamp * 1000).toLocaleString(undefined, { year: 'numeric', month: 'long', day: 'numeric' });
},
humanPlayer: function(id) {
console.log(id)
var player;
if (id == 7737454) player = 'Zero';
else if (id == 3244200) player = 'OPM';
else if (id == 3075580) player = 'Other OPM';
return player;
}
}
});
$(function(){
function getData(fileindex) {
var nextfile = fileindex + 1;
$.get('../toe/' + fileindex + '.json', function (data) {
$(function () {
if ($('#toe').length) {
$.get('../assets/json/toedata.combined.min.json', function (data) {
var matches = data.results[0].result.response.results;
for (match in matches) {
@@ -88,20 +101,6 @@ $(function(){
toe.matches.push(matches[match]);
}
})
.done(function () {
getData(nextfile);
$('.loadingbar').css({
'width': fileindex + '%'
});
})
.fail(function () {
$('.loadingbar').css('width', '100%').delay(150).fadeOut(150);
});
}
if ($('#toe').length) {
getData(1);
});
}
});
+4 -4
View File
@@ -53,7 +53,7 @@
<table>
<thead>
<tr>
<th width="85">Power</th>
<th width="100">Power</th>
<th width="249">Attackers</th>
<th width="249">Defenders</th>
<th>Defense score</th>
@@ -62,8 +62,8 @@
<tbody>
<tr v-for="(match, index) in filteredMatches" v-bind:class="{missed : match.defenceScoreEarned < 50}">
<td>
<strong>{{ match.enemypower }}</strong>
<td :title="match.defBattle.startTime | humanDate">
<strong>{{ match.enemypower }}</strong><br/>
</td>
<td>
@@ -79,7 +79,7 @@
:src="'../assets/img/Titans/'+ titan.id + '.png'" />
</td>
<td>
<td :title="match.defBattle.userId | humanPlayer">
<strong v-bind:class="match.defenceScoreEarned == 50 ? 'green' : 'red'">{{ match.defenceScoreEarned }}</strong>
</td>
</tr>
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+53 -3
View File
@@ -14,6 +14,8 @@ var runSequence = require('run-sequence');
var sass = require('gulp-ruby-sass');
var uglify = require('gulp-uglify');
var merge = require('gulp-merge-json');
var paths = require('./_assets/gulp_config/paths');
@@ -108,6 +110,52 @@ gulp.task('build:images:local', function() {
});
/**
* Concatenate TOE JSON files
*/
gulp.task('build:toejson', function() {
gulp.src('_toe/*.json')
.pipe(merge({
fileName: 'toedata.combined.min.json',
jsonSpace: '',
edit: (parsedJson, file) => {
var matches = parsedJson.results[0].result.response.results;
delete parsedJson.results[0].result.quests;
delete parsedJson.results[0].result.response.place;
for(match in matches) {
// create a unique id to prevent merging objects together
var newId = Date.now() * matches[match].defBattle.seed * Math.floor(Math.random() * 100000);
matches[newId] = matches[match];
delete matches[match];
var thisMatch = matches[newId];
// get rid of unused data
delete thisMatch.battle;
delete thisMatch.defenceTeam;
delete thisMatch.rivalTeam;
delete thisMatch.reward;
delete thisMatch.attackScore;
delete thisMatch.scoreEarned;
delete thisMatch.attackScoreEarned;
delete thisMatch.defBattle.typeId;
delete thisMatch.defBattle.progress;
delete thisMatch.defBattle.result;
}
return parsedJson;
}
}))
.pipe(gulp.dest('assets/json'))
.pipe(gulp.dest('_site/assets/json'))
.on('error', gutil.log);
});
/*
* Clean task
*/
@@ -141,9 +189,10 @@ gulp.task('build:local', function(callback) {
runSequence(
'clean',
'build:jekyll:local',
['build:scripts:local',
['build:toejson',
'build:scripts:local',
'build:images:local',
'build:styles:local' ],
'build:styles:local'],
callback);
});
@@ -165,7 +214,8 @@ gulp.task('build', function(callback) {
runSequence(
'clean',
'build:jekyll',
['build:scripts',
['build:toejson',
'build:scripts',
'build:images',
'build:styles'],
callback);
+187
View File
@@ -4286,6 +4286,158 @@
}
}
},
"gulp-json-minify": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/gulp-json-minify/-/gulp-json-minify-1.2.2.tgz",
"integrity": "sha512-8acCNnGiDELUh9qqZVm57eu4KVclibiVM7hXxeMn3nsdcQtEWfHUSpcxvrqTVCL5MchErGMDDDSxmcF6RTFcJQ==",
"dev": true,
"requires": {
"node-json-minify": "^1.0.0",
"through2": "^2.0.3"
}
},
"gulp-jsoncombine": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/gulp-jsoncombine/-/gulp-jsoncombine-1.0.4.tgz",
"integrity": "sha1-5RAomwKoHUBR/JOUnGufFWT7V6c=",
"dev": true,
"requires": {
"plugin-error": "^0.1.2",
"through": "*",
"vinyl": "^2.1.0"
},
"dependencies": {
"arr-diff": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz",
"integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=",
"dev": true,
"requires": {
"arr-flatten": "^1.0.1",
"array-slice": "^0.2.3"
}
},
"arr-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz",
"integrity": "sha1-IPnqtexw9cfSFbEHexw5Fh0pLH0=",
"dev": true
},
"array-slice": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz",
"integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=",
"dev": true
},
"clone": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
"integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=",
"dev": true
},
"clone-stats": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz",
"integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=",
"dev": true
},
"extend-shallow": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz",
"integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=",
"dev": true,
"requires": {
"kind-of": "^1.1.0"
}
},
"kind-of": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz",
"integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=",
"dev": true
},
"plugin-error": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz",
"integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=",
"dev": true,
"requires": {
"ansi-cyan": "^0.1.1",
"ansi-red": "^0.1.1",
"arr-diff": "^1.0.1",
"arr-union": "^2.0.1",
"extend-shallow": "^1.1.2"
}
},
"replace-ext": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.1.tgz",
"integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==",
"dev": true
},
"vinyl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
"integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==",
"dev": true,
"requires": {
"clone": "^2.1.1",
"clone-buffer": "^1.0.0",
"clone-stats": "^1.0.0",
"cloneable-readable": "^1.0.0",
"remove-trailing-separator": "^1.0.1",
"replace-ext": "^1.0.0"
}
}
}
},
"gulp-merge-json": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/gulp-merge-json/-/gulp-merge-json-2.1.1.tgz",
"integrity": "sha512-VhvAlcf+dcCb94j/2yDPWxJ3X7x4P/Xwcrv1dhjYuRgvADwFJmaQwl4zbuq+GDZvzMacbVncWtEdsETpUSkhYw==",
"dev": true,
"requires": {
"json5": "^2.1.3",
"lodash.mergewith": "^4.6.1",
"plugin-error": "^1.0.1",
"through": "^2.3.8",
"vinyl": "^2.1.0"
},
"dependencies": {
"clone": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
"integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=",
"dev": true
},
"clone-stats": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz",
"integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=",
"dev": true
},
"replace-ext": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.1.tgz",
"integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==",
"dev": true
},
"vinyl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
"integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==",
"dev": true,
"requires": {
"clone": "^2.1.1",
"clone-buffer": "^1.0.0",
"clone-stats": "^1.0.0",
"cloneable-readable": "^1.0.0",
"remove-trailing-separator": "^1.0.1",
"replace-ext": "^1.0.0"
}
}
}
},
"gulp-notify": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/gulp-notify/-/gulp-notify-3.2.0.tgz",
@@ -5522,6 +5674,23 @@
"dev": true,
"optional": true
},
"json5": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz",
"integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==",
"dev": true,
"requires": {
"minimist": "^1.2.5"
},
"dependencies": {
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
}
}
},
"jsonfile": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.1.tgz",
@@ -5744,6 +5913,12 @@
"lodash.isarray": "^3.0.0"
}
},
"lodash.mergewith": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz",
"integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==",
"dev": true
},
"lodash.restparam": {
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz",
@@ -6107,6 +6282,12 @@
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==",
"dev": true
},
"node-json-minify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-json-minify/-/node-json-minify-1.0.0.tgz",
"integrity": "sha1-e7NDL5ZYtr6x2ZP9XVOzyinQ15w=",
"dev": true
},
"node-notifier": {
"version": "5.4.3",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.4.3.tgz",
@@ -8197,6 +8378,12 @@
"object-path": "^0.9.0"
}
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
"dev": true
},
"through2": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
+3
View File
@@ -21,6 +21,9 @@
"gulp-clean-css": "^3.10.0",
"gulp-concat": "^2.6.1",
"gulp-imagemin": "^4.0.0",
"gulp-json-minify": "^1.2.2",
"gulp-jsoncombine": "^1.0.4",
"gulp-merge-json": "^2.1.1",
"gulp-notify": "^3.2.0",
"gulp-postcss": "^8.0.0",
"gulp-ruby-sass": "^3.0.0",