5 <title>各種報告書 - KancolleSniffer</title>
7 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
8 <script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.7/js/jquery.dataTables.min.js"></script>
9 <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.7/css/jquery.dataTables.min.css">
10 <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.min.js"></script>
11 <script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.js"></script>
12 <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.css">
13 <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js"></script>
14 <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
15 <link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
16 <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/i18n/datepicker-ja.min.js"></script>
19 font-family:'Lucida Grande','Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
23 .tab {overflow: hidden; list-style-type: none; margin: 0em 0em 2em 1em; padding: 0em;}
24 .tab li {background: #eee; padding: 0.3em 1.5em; float: left; margin-right: 2px;}
25 .tab1 li {padding: 0.3em 1em;}
26 .tab li.select {background: #ccc;}
27 .contents {list-style-type: none; margin: 0em; padding: 0em;}
28 .hide {display: none;}
29 .c3 .tick {font-family:'Lucida Grande','Hiragino Kaku Gothic ProN', Meiryo, sans-serif; font-size: 12px;}
30 .c3-legend-item {font-family:'Lucida Grande','Hiragino Kaku Gothic ProN', Meiryo, sans-serif; font-size: 14px;}
49 var query = "?from=" + moment().subtract(1, 'months').valueOf();
50 if ($('input[name=term]:eq(1)').prop('checked')) {
51 from = $('#term_from').datepicker("getDate");
52 to = $('#term_to').datepicker("getDate");
54 query = "?from=" + from.valueOf();
56 query += "&to=" + (to.valueOf() + 3600 * 24 * 1000);
68 var url = jsons[selectedTable] + query;
69 $('#log' + selectedTable).DataTable().ajax.url(url).load();
76 for (var t = 0; t < tables; t++) {
83 lengthMenu: [[50, 100, 200, -1],[50, 100, 200, "All"]],
84 drawCallback: function () {
89 opts.columns = [{data: 0}, {data: 1}, {data: 2}, {data: 3}, {data: 4}, {data: 9}, {data: 10}];
92 for (i = 0; i < 38; i++) {
93 if (i == 9 || i == 10)
95 entries.push({data: i})
97 opts.columns = entries;
99 $('#log' + t).dataTable(opts);
103 const timeFormat = "YYYY-MM-DD HH:mm:ss";
104 function parseDate(d)
106 return moment(d, timeFormat);
111 return d.format(timeFormat);
116 return tick - tick % (3600 * 24000) - 3600 * 4000;
119 var selectedTable = 0;
120 var seqChartRange = 0;
121 var diffChartRange = 0;
123 var showChart = false;
124 var currentPickedData;
126 function drawChart(data)
129 $('#loading').show();
130 $.get("./資材ログ.json?time=" + Date.now(), function (data) { drawChart(data);}, "json");
133 if (chartType == 0) {
134 var picked = pickChartData(data.data, seqChartRange);
135 var header = ["日付","燃料","弾薬","鋼材","ボーキ","高速建造材","高速修復材","開発資材","改修資材"];
136 picked.data.unshift(header);
137 drawSeqChart(picked);
138 currentPickedData = picked;
140 var picked = pickDiffChartData(data.data, diffChartRange);
141 var header = ["日付","燃料","弾薬","鋼材","ボーキ"];
142 picked.data.unshift(header);
143 drawDiffChart(picked)
144 currentPickedData = picked;
148 function redrawChart()
150 if (!currentPickedData)
152 $('#loading').show();
153 setTimeout(function() {
155 drawSeqChart(currentPickedData);
157 drawDiffChart(currentPickedData);
162 $(window).resize(function() {
165 timer = setTimeout(function() {
173 var pxPerEm = Number($('#chart').css('fontSize').match(/(\d*(\.\d*)?)px/)[1]);
175 height: Math.max($(document).height() - 15 * pxPerEm, 400),
176 width: Math.max($(document).width() - 6 * pxPerEm, 800)
180 function drawSeqChart(picked)
183 var chart = c3.generate({
191 xFormat: '%Y-%m-%d %X',
208 show: $('#tooltip').prop('checked')
220 format: function (x) { return moment(x).format("MM-DD HH:mm"); },
228 onrendered: function () { $('#loading').hide(); }
232 function pickChartData(data, range)
237 var first = moment(data[0][0]).valueOf();
238 var last = moment(data[data.length - 1][0]).valueOf();
239 var interval, tickInterval, lastTick;
240 const oneDay = 3600 * 24 * 1000;
243 first = moment(last).subtract(24, 'hours').valueOf();
246 first = moment(last).subtract(7, 'days').valueOf();
249 first = moment(last).subtract(1, 'months').valueOf();
252 first = moment(last).subtract(3, 'months').valueOf();
255 first = moment(data[0][0]).valueOf();
258 fromDate = $('#chart_from').datepicker("getDate");
259 toDate = $('#chart_to').datepicker("getDate");
260 if (fromDate == null || toDate == null)
261 return { data: [], tick: [], grid: [] };
262 from = fromDate.valueOf() + 3600 * 5000;
263 to = toDate.valueOf() + oneDay + 3600 * 5000;
264 first = Math.max(first, from);
265 last = Math.min(last, to);
268 if (last <= first + oneDay) {
270 tickInterval = 3600 * 1000;
271 lastTick = last - last % tickInterval;
272 } else if (last <= first + oneDay * 21) {
274 tickInterval = oneDay;
275 lastTick = to5am(last);
276 } else if (last <= first + oneDay * 63) {
277 interval = 3600 * 2000;
278 tickInterval = oneDay * 7;
279 lastTick = to5am(moment(last).day(1).valueOf());
280 } else if (last <= first + oneDay * 126) {
281 interval = 3600 * 12000;
282 tickInterval = oneDay * 14;
283 lastTick = to5am(moment(last).day(1).valueOf());
285 interval = 3600 * 24000;
286 tickInterval = oneDay * 28;
287 lastTick = to5am(moment(last).day(1).valueOf());
290 for (var i = data.length - 1; i >= 0; i--) {
292 var date = parseDate(row[0]).valueOf();
295 var v = date - date % interval;
296 if (last_data != v) {
297 newdata.unshift(row);
305 for (var tick = lastTick; tick > last_data; tick -= tickInterval)
307 var str = toString(moment(tick));
309 grid.unshift({value: str});
311 return { data: newdata, tick: ticks, grid: grid };
314 function drawDiffChart(picked)
317 var chart = c3.generate({
325 xFormat: '%Y-%m-%d %X',
334 groups: [["燃料", "弾薬", "鋼材", "ボーキ"]]
342 show: $('#tooltip').prop('checked')
359 format: function (x) { return moment(x).format("MM-DD HH:mm"); },
364 onrendered: function () { $('#loading').hide(); }
368 function pickDiffChartData(data, range)
373 var first = moment(data[0][0]).valueOf();
374 var last = moment(data[data.length - 1][0]).valueOf();
375 var interval, tickInterval, lastTick;
376 const oneDay = 3600 * 24 * 1000;
379 first = moment(last).subtract(1, 'months').valueOf();
382 first = moment(last).subtract(3, 'months').valueOf();
385 first = moment(last).subtract(6, 'months').subtract(1, 'weeks').valueOf();
388 first = moment(data[0][0]).valueOf();
391 fromDate = $('#chart_from').datepicker("getDate");
392 toDate = $('#chart_to').datepicker("getDate");
393 if (fromDate == null || toDate == null)
394 return { data: [], tick: [], grid: [] };
395 from = fromDate.valueOf() + 3600 * 5000;
396 to = toDate.valueOf() + oneDay + 3600 * 5000;
397 first = Math.max(first, from);
398 last = Math.min(last, to);
401 if (last <= first + oneDay * 2 * 31) {
403 tickInterval = oneDay * 2;
404 lastTick = to5am(last);
406 } else if (last <= first + oneDay * 3 * 31) {
408 tickInterval = oneDay * 7;
409 lastTick = to5am(last);
412 interval = oneDay * 7;
413 tickInterval = oneDay * 28;
414 lastTick = to5am(moment(last).day(1).valueOf());
416 if (last <= first + oneDay * 6 * 38){
417 tickInterval = oneDay * 14;
421 var last_date = lastTick;
423 for (var i = data.length - 1; i >= 0; i--) {
425 var date = parseDate(row[0]).valueOf();
426 if (date > first && date <= last) {
431 if (date <= last_date) {
432 var newrow = [prev_row[0]];
433 for (var r = 1; r < 5; r++) {
434 newrow.push(prev_row[r] - row[r] )
436 newdata.unshift(newrow);
437 last_date = last_date - interval;
444 if (tickInterval >= oneDay * 7)
445 lastTick = moment(lastTick).day(1).hour(5).minute(0).valueOf();
446 for (var tick = lastTick; tick > last_date; tick -= tickInterval)
448 var str = toString(moment(tick));
450 grid.unshift({value: str});
452 return { data: newdata, tick: ticks, grid: grid, width: barWidth };
455 function setSortieStat(data) {
457 $('#loading').show();
458 var from = moment().subtract(1, 'months').valueOf();
459 $.get("./海戦・ドロップ報告書.json?time=" + Date.now() + "&from=" + from, function (data) { setSortieStat(data.data);}, "json");
467 var initStat = function () { return {start:"-", S:0, A:0, B:0, C:0, D:0, R:0} };
469 r.day.begin = moment(now).hour(5).minute(0);
470 if (now.hour() < 5) {
471 r.day.begin.subtract(1, 'days');
473 r.week.begin = moment(now).day(1).hour(5).minute(0);
474 if (now.day() == 0 || now.day() == 1 && now.hour() < 5) {
475 r.week.begin.subtract(1, 'weeks');
477 r.month.begin = moment(now).date(1).hour(5).minute(0);
478 if (now.date() == 1 && now.hours() < 5) {
479 r.month.begin.subtract(1, 'months');
481 for (var i = 0; i < data.length; i++) {
483 var date = moment(row[0]);
485 var isBoss = row[3].indexOf("ボス") != -1;
486 var isStart = row[3].indexOf("出撃") != -1;
488 for (var j = 23; j < row.length; j++) {
489 if (/^輸送/.test(row[j]) && /^0\//.test(row[j + 1]))
495 for (var term in r) {
497 if (to.begin.isAfter(date))
499 for (var b = 0; b < 4; b++) {
500 var name = b < 2 ? "合計" : map;
501 if (b == 1 || b == 3) {
504 name = name + " - ボス";
506 var mo = to.stat[name];
508 mo = to.stat[name] = initStat();
510 to.stat["合計 - ボス"] = initStat();
514 if ((b == 0 || b == 2) && isStart)
526 for (map in r[term].stat)
530 var e = r[term].stat[map];
534 boss = map + " - ボス";
535 e = r[term].stat[boss];
542 var dt = $("#sortie_stat_" + term).DataTable();
544 dt.rows.add(table).draw();
546 $('#loading').hide();
549 function initSortieStat()
551 var terms = ['day', 'week', 'month'];
552 for (var i = 0; i < terms.length; i++) {
553 $("#sortie_stat_" + terms[i]).dataTable({
557 columns: terms[i] != 'month' ? [
579 function selectTopTab(i)
586 } else if (i == chart) {
589 } else if (i == chart + 1) {
596 var tab = $('.tab0 li');
597 tab.removeClass('select');
598 tab.eq(i).addClass('select');
599 $('.contents .hide').hide();
600 $('.contents .hide').eq(i).show();
603 function initAction()
605 $('.tab0 li').click(function() {
606 var tab = $('.tab0 li');
607 var i = tab.index(this)
609 sessionStorage.setItem('prevTab', i);
611 $('#range_seq li').click(function() {
612 var tab = $('#range_seq li');
613 var i = tab.index(this);
617 tab.removeClass('select');
618 tab.eq(i).addClass('select');
619 sessionStorage.setItem('prevSeqRange', i);
621 $('#range_diff li').click(function() {
622 var tab = $('#range_diff li');
623 var i = tab.index(this);
627 tab.removeClass('select');
628 tab.eq(i).addClass('select');
629 sessionStorage.setItem('prevDiffRange', i);
631 $('input[name="chart_type"]:radio').change(function() {
632 if ($(this).val() == 0) {
633 $("#range_seq").show();
634 $("#range_diff").hide();
637 $("#range_seq").hide();
638 $("#range_diff").show();
642 sessionStorage.setItem('chartType', $(this).val());
644 $('#tooltip').change(function() {
649 function initTableDatePicker()
651 $('#term_from').datepicker({
652 defaultDate: moment().subtract(1, 'months').toDate(),
653 onClose: function() {$('input[name=term]').val(['1'])}
655 $('#term_to').datepicker({
656 onClose: function() {$('input[name=term]').val(['1'])}
658 $('#term_apply').click(showLog);
661 function initChartDatePicker()
663 $('#chart_from').datepicker({
664 onClose: function() {if (useChartDatePicker()) drawChart();}
666 $('#chart_to').datepicker({
667 onClose: function() {if (useChartDatePicker()) drawChart();}
671 function useChartDatePicker()
673 return (chartType == 0 && seqChartRange == 5) ||
674 (chartType == 1 && diffChartRange == 4);
678 $.fn.dataTable.ext.errMode = 'throw';
680 initTableDatePicker();
681 initChartDatePicker();
682 $('table').addClass('display compact cell-border');
685 var type = sessionStorage.getItem('chartType');
686 chartType = type == null ? 0 : +type;
687 var range = sessionStorage.getItem('prevSeqRange');
688 seqChartRange = range == null ? 0 : +range;
689 range = sessionStorage.getItem('prevDiffRange');
690 seqDiffRange = range == null ? 0 : +range;
691 $('input[name="chart_type"]:radio').eq(chartType).prop("checked", true);
692 if (chartType == 0) {
693 $('#range_seq').show()
694 $('#range_diff').hide()
696 $('#range_seq').hide()
697 $('#range_diff').show()
699 $('#range_diff li').removeClass('select');
700 $('#range_diff li').eq(diffChartRange).addClass('select');
701 $('#range_seq li').removeClass('select');
702 $('#range_seq li').eq(seqChartRange).addClass('select');
703 var prev = sessionStorage.getItem('prevTab');
704 selectTopTab(prev == null ? 0 : +prev);
708 <div id="loading"><img src="https://kancollesniffer.osdn.jp/ajax-loader.gif" alt="読み込み中..."></div>
710 <ul class="tab tab0">
724 <label><input type="radio" name="term" value="0" checked="checked">直近一か月</label>
725 <label><input type="radio" name="term" value="1">期間指定: </label>
726 <input type="text" id="term_from" style="width: 7em">~<input type="text" id="term_to" style="width: 7em">
727 <input type="button" id="term_apply" value="適用">
731 <ul class="contents">
735 <tr><th>日付</th><th>海域</th><th>マス</th><th>ボス</th><th>ランク</th><th>ドロップ艦種</th><th>ドロップ艦娘</th></tr>
742 <tr><th>日付</th><th>海域</th><th>マス</th><th>ボス</th><th>ランク</th><th>艦隊行動</th><th>味方陣形</th><th>敵陣形</th><th>敵艦隊</th><th>味方艦1</th><th>味方艦1HP</th><th>味方艦2</th><th>味方艦2HP</th><th>味方艦3</th><th>味方艦3HP</th><th>味方艦4</th><th>味方艦4HP</th><th>味方艦5</th><th>味方艦5HP</th><th>味方艦6</th><th>味方艦6HP</th><th>敵艦1</th><th>敵艦1HP</th><th>敵艦2</th><th>敵艦2HP</th><th>敵艦3</th><th>敵艦3HP</th><th>敵艦4</th><th>敵艦4HP</th><th>敵艦5</th><th>敵艦5HP</th><th>敵艦6</th><th>敵艦6HP</th><th>味方制空値</th><th>敵制空値</th><th>制空状態</th></tr>
749 <tr><th>日付</th><th>結果</th><th>遠征</th><th>燃料</th><th>弾薬</th><th>鋼材</th><th>ボーキ</th><th>開発資材</th><th>高速修復材</th><th>高速建造材</th></tr>
756 <tr><th>日付</th><th>開発装備</th><th>種別</th><th>燃料</th><th>弾薬</th><th>鋼材</th><th>ボーキ</th><th>秘書艦</th><th>司令部Lv</th></tr>
763 <tr><th>日付</th><th>種類</th><th>名前</th><th>艦種</th><th>燃料</th><th>弾薬</th><th>鋼材</th><th>ボーキ</th><th>開発資材</th><th>空きドック</th><th>秘書艦</th><th>司令部Lv</th></tr>
770 <tr><th>日付</th><th>改修装備</th><th>レベル</th><th>成功</th><th>確実化</th><th>消費装備</th><th>消費数</th><th>燃料</th><th>弾薬</th><th>鋼材</th><th>ボーキ</th><th>開発資材</th><th>改修資材</th><th>秘書艦</th><th>二番艦</th></tr>
777 <tr><th>日付</th><th>燃料</th><th>弾薬</th><th>鋼材</th><th>ボーキ</th><th>高速建造材</th><th>高速修復材</th><th>開発資材</th><th>改修資材</th></tr>
782 <form id="chart_type">
783 <div style="margin: 0px 0px 0.5em 1em;">
784 <label><input type="radio" name="chart_type" value="0" checked="checked">連続</label>
785 <label><input type="radio" name="chart_type" value="1">差分</label>
788 <ul class="tab tab1" id="range_seq" style="float: left; margin-right: 0.2em">
796 <ul class="tab tab1" id="range_diff" style="float: left; margin-right: 0.2em">
803 <div style="padding: 0.2em 0em;">
804 <input type="text" id="chart_from" style="width: 7em">~<input type="text" id="chart_to" style="width: 7em">
805 <label><input type="checkbox" id="tooltip" value="" style="margin-left: 2em;">ツールチップ</label>
807 <div id="chart" style="clear: both; margin: 1em;"></div>
811 <table id="sortie_stat_day">
813 <tr><th>マップ</th><th>出撃</th><th>S</th><th>A</th><th>B</th><th>C</th><th>D以下</th><th>輸送船</th></tr>
818 <table id="sortie_stat_week">
820 <tr><th>マップ</th><th>出撃</th><th>S</th><th>A</th><th>B</th><th>C</th><th>D以下</th><th>輸送船</th></tr>
824 <table id="sortie_stat_month">
826 <tr><th>マップ</th><th>出撃</th><th>S</th><th>A</th><th>B</th><th>C</th><th>D以下</th></tr>