コミットメタ情報

リビジョン69db1837068380491be09ae20a89047bd8b63c9b (tree)
日時2018-05-26 17:44:25
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

出撃統計でドロップアイテムの個数を表示する

変更サマリ

差分

--- a/LogViewer/tags.tag
+++ b/LogViewer/tags.tag
@@ -1085,18 +1085,18 @@ this.show = function() {
10851085 <h3>今日</h3>
10861086 <table id="sortie_stat_day">
10871087 <thead>
1088-<tr><th>マップ</th><th>出撃</th><th>S</th><th>A</th><th>B</th><th>C</th><th>D以下</th><th>輸送船</th></tr>
1088+<tr></tr>
10891089 </thead>
10901090 </table>
10911091 <h3>今週</h3>
10921092 <table id="sortie_stat_week">
10931093 <thead>
1094-<tr><th>マップ</th><th>出撃</th><th>S</th><th>A</th><th>B</th><th>C</th><th>D以下</th><th>輸送船</th></tr>
1094+<tr></tr>
10951095 </table>
10961096 <h3>今月</h3>
10971097 <table id="sortie_stat_month">
10981098 <thead>
1099-<tr><th>マップ</th><th>出撃</th><th>S</th><th>A</th><th>B</th><th>C</th><th>D以下</th></tr>
1099+<tr></tr>
11001100 </table>
11011101 </div>
11021102
@@ -1142,39 +1142,9 @@ opts.observable.on("mainTabChanged", function(idx) {
11421142 });
11431143
11441144 this.init = function() {
1145- this.initTable();
11461145 this.initDatePicker();
11471146 };
11481147
1149-this.initTable = function() {
1150- var terms = ['day', 'week', 'month', 'all'];
1151- for (var i = 0; i < terms.length; i++) {
1152- $("#sortie_stat_" + terms[i]).dataTable({
1153- paging: false,
1154- searching: false,
1155- ordering: false,
1156- columns: terms[i] !== 'month' ? [
1157- { data: "map" },
1158- { data: "start" },
1159- { data: "S" },
1160- { data: "A" },
1161- { data: "B" },
1162- { data: "C" },
1163- { data: "D" },
1164- { data: "R" }
1165- ] : [
1166- { data: "map" },
1167- { data: "start" },
1168- { data: "S" },
1169- { data: "A" },
1170- { data: "B" },
1171- { data: "C" },
1172- { data: "D" }
1173- ]
1174- });
1175- }
1176-};
1177-
11781148 this.initDatePicker = function() {
11791149 $('#sortie_stat_from').datepicker({
11801150 onClose: function() { if (self.type === "range") self.show(); }
@@ -1265,6 +1235,9 @@ this.gatherData = function(data) {
12651235 if (/^輸送/.test(row[j]) && /^0\x2f/.test(row[j + 1]))
12661236 resR++;
12671237 }
1238+ var item = /\+(.*)/.exec(row[10]);
1239+ if (item)
1240+ item = item[1];
12681241 var res = row[4];
12691242 if (res === "E")
12701243 res = "D";
@@ -1289,6 +1262,11 @@ this.gatherData = function(data) {
12891262 }
12901263 mo["R"] += resR;
12911264 mo[res]++;
1265+ if (item) {
1266+ if (!mo[item])
1267+ mo[item] = 0;
1268+ mo[item]++;
1269+ }
12921270 if ((b === 0 || b === 2) && isStart) {
12931271 if (mo.start === "-")
12941272 mo.start = 0;
@@ -1300,7 +1278,73 @@ this.gatherData = function(data) {
13001278 return r;
13011279 };
13021280
1303-this.arrangeTable = function(r) {
1281+this.isItemColumn = function(col) {
1282+ return !/^(?:map|start|[SABCDR])$/.test(col);
1283+};
1284+
1285+this.sortItemOrder = function(items) {
1286+ ["お米", "梅干", "海苔", "お茶"].reverse().forEach(function(item) {
1287+ var idx = items.indexOf(item);
1288+ if (idx !== -1) {
1289+ items.splice(idx, 1);
1290+ items.unshift(item);
1291+ }
1292+ });
1293+};
1294+
1295+this.setupTable = function(r) {
1296+ for (var term in r) {
1297+ var header = ["マップ",
1298+ "出撃",
1299+ "S",
1300+ "A",
1301+ "B",
1302+ "C",
1303+ "D以下",
1304+ "輸送船"];
1305+ var columns = [{ data: "map" },
1306+ { data: "start" },
1307+ { data: "S" },
1308+ { data: "A" },
1309+ { data: "B" },
1310+ { data: "C" },
1311+ { data: "D" },
1312+ { data: "R" }];
1313+ if (term === "monthly") {
1314+ header.pop();
1315+ columns.pop();
1316+ }
1317+ var items = Object.keys(r[term].stat["合計"]).filter(this.isItemColumn);
1318+ this.sortItemOrder(items);
1319+ items.forEach(function(item) {
1320+ header.push(item);
1321+ columns.push({data: item});
1322+ });
1323+ $("#sortie_stat_" + term + " tr").html(
1324+ header.reduce(function(acc, cur) {
1325+ return acc + "<td>" + cur + "</td>";
1326+ }, ""));
1327+ r[term].columns = columns;
1328+ }
1329+};
1330+
1331+this.fillupItemRecords = function(r) {
1332+ for (var term in r) {
1333+ for (var col in r[term].stat["合計"]) {
1334+ if (!this.isItemColumn(col))
1335+ continue;
1336+ for (var map in r[term].stat) {
1337+ if (map === "合計")
1338+ continue;
1339+ if (!r[term].stat[map][col]){
1340+ r[term].stat[map][col] = 0;
1341+ }
1342+ }
1343+ }
1344+ }
1345+};
1346+
1347+this.reorderRows = function(r) {
13041348 for (var term in r) {
13051349 if (!r.hasOwnProperty(term))
13061350 continue;
@@ -1334,13 +1378,20 @@ this.show = function(data) {
13341378 return;
13351379 }
13361380 var r = this.gatherData(data);
1337- this.arrangeTable(r);
1381+ this.setupTable(r);
1382+ this.fillupItemRecords(r);
1383+ this.reorderRows(r);
13381384 for (var term in r) {
13391385 if (!r.hasOwnProperty(term))
13401386 continue;
1341- var dt = $("#sortie_stat_" + term).DataTable();
1342- dt.clear();
1343- dt.rows.add(r[term].table).draw();
1387+ var table = $("#sortie_stat_" + term);
1388+ table.DataTable().destroy();
1389+ table.DataTable({
1390+ paging: false,
1391+ searching: false,
1392+ ordering: false,
1393+ columns: r[term].columns
1394+ }).rows.add(r[term].table).draw();
13441395 }
13451396 $('#loading').hide();
13461397 };
旧リポジトリブラウザで表示