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: 0 0 2em 1em; padding: 0;}
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: 0; padding: 0;}
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;}
46 /* global moment, c3 */
48 var oneDay = 3600 * 24 * 1000;
51 var query = "?from=" + moment().subtract(1, 'months').valueOf();
52 if ($('input[name=term]:eq(1)').prop('checked')) {
53 var from = $('#term_from').datepicker("getDate");
54 var to = $('#term_to').datepicker("getDate");
56 query = "?from=" + from.valueOf();
58 query += "&to=" + (to.valueOf() + oneDay);
70 var url = jsons[selectedTable] + query;
71 $('#log' + selectedTable).DataTable().ajax.url(url).load();
76 function initTables() {
77 for (var t = 0; t < tables; t++) {
84 lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
85 drawCallback: function () {
90 opts.columns = [{ data: 0 }, { data: 1 }, { data: 2 }, { data: 3 }, { data: 4 }, { data: 9 }, { data: 10 }];
93 for (var i = 0; i < 38; i++) {
94 if (i === 9 || i === 10)
96 entries.push({ data: i });
98 opts.columns = entries;
100 $('#log' + t).dataTable(opts);
104 var timeFormat = "YYYY-MM-DD HH:mm:ss";
105 function parseDate(d) {
106 return moment(d, timeFormat);
109 function toString(d) {
110 return d.format(timeFormat);
113 function to5am(tick) {
114 return tick - tick % (3600 * 24000) - 3600 * 4000;
117 var selectedTable = 0;
118 var seqChartRange = 0;
119 var diffChartRange = 0;
121 var showChart = false;
122 var currentPickedData;
124 function drawChart(data) {
126 $('#loading').show();
127 $.get("./資材ログ.json?time=" + Date.now(), function (d) { drawChart(d); }, "json");
131 if (chartType === 0) {
132 picked = pickChartData(data.data, seqChartRange);
133 header = ["日付", "燃料", "弾薬", "鋼材", "ボーキ", "高速建造材", "高速修復材", "開発資材", "改修資材"];
134 picked.data.unshift(header);
135 drawSeqChart(picked);
136 currentPickedData = picked;
138 picked = pickDiffChartData(data.data, diffChartRange);
139 header = ["日付", "燃料", "弾薬", "鋼材", "ボーキ"];
140 picked.data.unshift(header);
141 drawDiffChart(picked);
142 currentPickedData = picked;
146 function redrawChart() {
147 if (!currentPickedData)
149 $('#loading').show();
150 setTimeout(function () {
152 drawSeqChart(currentPickedData);
154 drawDiffChart(currentPickedData);
159 $(window).resize(function () {
162 timer = setTimeout(function () {
168 function chartSize() {
169 var pxPerEm = Number($('#chart').css('fontSize').match(/(\d*(\.\d*)?)px/)[1]);
171 height: Math.max($(document).height() - 15 * pxPerEm, 400),
172 width: Math.max($(document).width() - 6 * pxPerEm, 800)
176 function drawSeqChart(picked) {
177 var size = chartSize();
186 xFormat: '%Y-%m-%d %X',
203 show: $('#tooltip').prop('checked')
215 format: function (x) { return moment(x).format("MM-DD HH:mm"); },
223 onrendered: function () { $('#loading').hide(); }
227 function pickChartData(data, range) {
231 var first = moment(data[0][0]).valueOf();
232 var last = moment(data[data.length - 1][0]).valueOf();
233 var interval, tickInterval, lastTick;
236 first = moment(last).subtract(24, 'hours').valueOf();
239 first = moment(last).subtract(7, 'days').valueOf();
242 first = moment(last).subtract(1, 'months').valueOf();
245 first = moment(last).subtract(3, 'months').valueOf();
248 first = moment(data[0][0]).valueOf();
251 var fromDate = $('#chart_from').datepicker("getDate");
252 var toDate = $('#chart_to').datepicker("getDate");
253 if (fromDate == null || toDate == null)
254 return { data: [], tick: [], grid: [] };
255 var from = fromDate.valueOf() + 3600 * 5000;
256 var to = toDate.valueOf() + oneDay + 3600 * 5000;
257 first = Math.max(first, from);
258 last = Math.min(last, to);
261 if (last <= first + oneDay) {
263 tickInterval = 3600 * 1000;
264 lastTick = last - last % tickInterval;
265 } else if (last <= first + oneDay * 21) {
267 tickInterval = oneDay;
268 lastTick = to5am(last);
269 } else if (last <= first + oneDay * 63) {
270 interval = 3600 * 1000;
271 tickInterval = oneDay * 7;
272 lastTick = to5am(moment(last).day(1).valueOf());
273 } else if (last <= first + oneDay * 126) {
274 interval = 3600 * 6000;
275 tickInterval = oneDay * 14;
276 lastTick = to5am(moment(last).day(1).valueOf());
278 interval = 3600 * 12000;
279 tickInterval = oneDay * 28;
280 lastTick = to5am(moment(last).day(1).valueOf());
283 for (var i = data.length - 1; i >= 0; i--) {
285 var date = parseDate(row[0]).valueOf();
288 var v = date - date % interval;
289 if (lastData !== v) {
290 newdata.unshift(row);
298 for (var tick = lastTick; tick > lastData; tick -= tickInterval) {
299 var str = toString(moment(tick));
301 grid.unshift({ value: str });
303 return { data: newdata, tick: ticks, grid: grid };
306 function drawDiffChart(picked) {
307 var size = chartSize();
316 xFormat: '%Y-%m-%d %X',
325 groups: [["燃料", "弾薬", "鋼材", "ボーキ"]]
333 show: $('#tooltip').prop('checked')
350 format: function (x) { return moment(x).format("MM-DD HH:mm"); },
355 onrendered: function () { $('#loading').hide(); }
359 function pickDiffChartData(data, range) {
363 var first = moment(data[0][0]).valueOf();
364 var last = moment(data[data.length - 1][0]).valueOf();
365 var interval, tickInterval, lastTick;
366 var oneDay = 3600 * 24 * 1000;
369 first = moment(last).subtract(1, 'months').valueOf();
372 first = moment(last).subtract(3, 'months').valueOf();
375 first = moment(last).subtract(6, 'months').subtract(1, 'weeks').valueOf();
378 first = moment(data[0][0]).valueOf();
381 var fromDate = $('#chart_from').datepicker("getDate");
382 var toDate = $('#chart_to').datepicker("getDate");
383 if (fromDate == null || toDate == null)
384 return { data: [], tick: [], grid: [] };
385 var from = fromDate.valueOf() + 3600 * 5000;
386 var to = toDate.valueOf() + oneDay + 3600 * 5000;
387 first = Math.max(first, from);
388 last = Math.min(last, to);
392 if (last <= first + oneDay * 2 * 31) {
394 tickInterval = oneDay * 2;
395 lastTick = to5am(last);
397 } else if (last <= first + oneDay * 3 * 31) {
399 tickInterval = oneDay * 7;
400 lastTick = to5am(last);
403 interval = oneDay * 7;
404 tickInterval = oneDay * 28;
405 lastTick = to5am(moment(last).day(1).valueOf());
407 if (last <= first + oneDay * 6 * 38) {
408 tickInterval = oneDay * 14;
412 var lastDate = lastTick;
414 for (var i = data.length - 1; i >= 0; i--) {
416 var date = parseDate(row[0]).valueOf();
417 if (date > first && date <= last) {
422 if (date <= lastDate) {
423 var newrow = [prevRow[0]];
424 for (var r = 1; r < 5; r++) {
425 newrow.push(prevRow[r] - row[r]);
427 newdata.unshift(newrow);
428 lastDate = lastDate - interval;
435 if (tickInterval >= oneDay * 7)
436 lastTick = moment(lastTick).day(1).hour(5).minute(0).valueOf();
437 for (var tick = lastTick; tick > lastDate; tick -= tickInterval) {
438 var str = toString(moment(tick));
440 grid.unshift({ value: str });
442 return { data: newdata, tick: ticks, grid: grid, width: barWidth };
445 var sortieStatRange = 0;
447 function loadSortieData() {
449 if (sortieStatRange === 0) {
450 from = moment().subtract(1, 'months').subtract(1, 'day').valueOf();
451 to = new Date().valueOf();
453 var fromDate = $('#sortie_stat_from').datepicker("getDate");
454 var toDate = $('#sortie_stat_to').datepicker("getDate");
455 if (fromDate == null || toDate == null) {
459 from = fromDate.valueOf();
460 to = toDate.valueOf() + oneDay;
463 url: "./海戦・ドロップ報告書.json?from=" + from + "&to=" + to,
464 success: function (data) { setSortieStat(data.data); },
465 dataType: "json", cache: false
469 function initSortieStatResult() {
472 if (sortieStatRange === 0) {
478 r.day.begin = moment(now).hour(5).minute(0).second(0);
479 if (now.hour() < 5) {
480 r.day.begin.subtract(1, 'days');
482 r.week.begin = moment(now).day(1).hour(5).minute(0).second(0);
483 if (now.day() === 0 || now.day() === 1 && now.hour() < 5) {
484 r.week.begin.subtract(1, 'weeks');
486 if (moment(now).endOf('month').date() === now.date() &&
487 now.hour() >= 22) { // 月末22時以降
488 r.month.begin = moment(now).hour(22).minute(0).second(0);
491 moment(now).date(1).subtract(1, 'days').
492 hour(22).minute(0).second(0);
495 r = { all: { stat: {} } };
496 r.all.begin = moment(0);
501 function gatherSortieStat(data) {
502 var initStat = function () {
503 return { start: "-", S: 0, A: 0, B: 0, C: 0, D: 0, R: 0 }
505 var r = initSortieStatResult();
506 for (var i = 0; i < data.length; i++) {
508 var date = moment(row[0]);
510 var isBoss = row[3].indexOf("ボス") !== -1;
511 var isStart = row[3].indexOf("出撃") !== -1;
513 for (var j = 23; j < row.length; j++) {
514 if (/^輸送/.test(row[j]) && /^0\//.test(row[j + 1]))
520 for (var term in r) {
521 if (!r.hasOwnProperty(term))
524 if (to.begin.isAfter(date))
526 for (var b = 0; b < 4; b++) {
527 var name = b < 2 ? "合計" : map;
528 if (b === 1 || b === 3) {
531 name = name + " - ボス";
533 var mo = to.stat[name];
535 mo = to.stat[name] = initStat();
537 to.stat["合計 - ボス"] = initStat();
541 if ((b === 0 || b === 2) && isStart) {
542 if (mo.start === "-")
552 function arrangeSortieStatTable(r) {
553 for (var term in r) {
554 if (!r.hasOwnProperty(term))
558 for (var map in r[term].stat) {
559 if (!r[term].stat.hasOwnProperty(map))
563 var e = r[term].stat[map];
567 var boss = map + " - ボス";
568 e = r[term].stat[boss];
575 r[term].table = table;
579 function setSortieStat(data) {
581 $('#loading').show();
585 var r = gatherSortieStat(data);
586 arrangeSortieStatTable(r);
587 for (var term in r) {
588 if (!r.hasOwnProperty(term))
590 var dt = $("#sortie_stat_" + term).DataTable();
592 dt.rows.add(r[term].table).draw();
594 $('#loading').hide();
597 function initSortieStatTables() {
598 var terms = ['day', 'week', 'month', 'all'];
599 for (var i = 0; i < terms.length; i++) {
600 $("#sortie_stat_" + terms[i]).dataTable({
604 columns: terms[i] !== 'month' ? [
626 function selectTopTab(i) {
632 } else if (i === chart) {
635 } else if (i === chart + 1) {
642 var tab = $('.tab0 li');
643 tab.removeClass('select');
644 tab.eq(i).addClass('select');
645 $('#main_contents .hide').hide();
646 $('#main_contents .hide').eq(i).show();
649 function initAction() {
650 $('.tab0 li').click(function () {
651 var tab = $('.tab0 li');
652 var i = tab.index(this);
654 sessionStorage.setItem('prevTab', i);
656 $('#range_seq li').click(function () {
657 var tab = $('#range_seq li');
658 var i = tab.index(this);
662 tab.removeClass('select');
663 tab.eq(i).addClass('select');
664 sessionStorage.setItem('prevSeqRange', i);
666 $('#range_diff li').click(function () {
667 var tab = $('#range_diff li');
668 var i = tab.index(this);
672 tab.removeClass('select');
673 tab.eq(i).addClass('select');
674 sessionStorage.setItem('prevDiffRange', i);
676 $('input[name="chart_type"]:radio').change(function () {
677 if ($(this).val() === 0) {
678 $("#range_seq").show();
679 $("#range_diff").hide();
682 $("#range_seq").hide();
683 $("#range_diff").show();
687 sessionStorage.setItem('chartType', $(this).val());
689 $('#tooltip').change(function () {
691 sessionStorage.setItem('chartTooltip', $(this).prop("checked"));
693 $('#range_sortie_stat li').click(function () {
694 var tab = $('#range_sortie_stat li');
695 var i = tab.index(this);
697 tab.removeClass('select');
698 tab.eq(i).addClass('select');
699 if (sortieStatRange === 0) {
700 $('#sortie_stat_recent_tables').show();
701 $('#sortie_stat_all_table').hide();
703 $('#sortie_stat_recent_tables').hide();
704 $('#sortie_stat_all_table').show();
710 function initTableDatePicker() {
711 $('#term_from').datepicker({
712 defaultDate: moment().subtract(1, 'months').toDate(),
713 onClose: function () { $('input[name=term]').val(['1']) }
715 $('#term_to').datepicker({
716 onClose: function () { $('input[name=term]').val(['1']) }
718 $('#term_apply').click(showLog);
721 function initChartDatePicker() {
722 $('#chart_from').datepicker({
723 onClose: function () { if (useChartDatePicker()) drawChart(); }
725 $('#chart_to').datepicker({
726 onClose: function () { if (useChartDatePicker()) drawChart(); }
730 function useChartDatePicker() {
731 return (chartType === 0 && seqChartRange === 5) ||
732 (chartType === 1 && diffChartRange === 4);
735 function initSortieStatDatePicker() {
736 $('#sortie_stat_from').datepicker({
737 onClose: function () { if (sortieStatRange === 1) setSortieStat(); }
739 $('#sortie_stat_to').datepicker({
740 onClose: function () { if (sortieStatRange === 1) setSortieStat(); }
744 function restoreChartSettings() {
745 var type = sessionStorage.getItem('chartType');
746 chartType = type == null ? 0 : +type;
747 var tooltip = sessionStorage.getItem('chartTooltip');
748 $('#tooltip').prop('checked', tooltip === "true");
749 var range = sessionStorage.getItem('prevSeqRange');
750 seqChartRange = range == null ? 0 : +range;
751 range = sessionStorage.getItem('prevDiffRange');
752 diffChartRange = range == null ? 0 : +range;
753 $('input[name="chart_type"]:radio').eq(chartType).prop('checked', true);
754 if (chartType === 0) {
755 $('#range_seq').show();
756 $('#range_diff').hide();
758 $('#range_seq').hide();
759 $('#range_diff').show();
761 $('#range_diff li').removeClass('select');
762 $('#range_diff li').eq(diffChartRange).addClass('select');
763 $('#range_seq li').removeClass('select');
764 $('#range_seq li').eq(seqChartRange).addClass('select');
768 $.fn.dataTable.ext.errMode = 'throw';
770 initTableDatePicker();
771 initChartDatePicker();
772 initSortieStatDatePicker();
773 $('table').addClass('display compact cell-border');
775 initSortieStatTables();
776 $('#range_sortie_stat li').removeClass('select');
777 $('#range_sortie_stat li').eq(sortieStatRange).addClass('select');
778 restoreChartSettings();
779 var prev = sessionStorage.getItem('prevTab');
780 selectTopTab(prev == null ? 0 : +prev);
784 <div id="loading"><img src="https://kancollesniffer.osdn.jp/ajax-loader.gif" alt="読み込み中..."></div>
786 <ul class="tab tab0">
800 <label><input type="radio" name="term" value="0" checked="checked">直近一か月</label>
801 <label><input type="radio" name="term" value="1">期間指定: </label>
802 <input type="text" id="term_from" style="width: 7em">~<input type="text" id="term_to" style="width: 7em">
803 <input type="button" id="term_apply" value="適用">
807 <ul class="contents" id="main_contents">
811 <tr><th>日付</th><th>海域</th><th>マス</th><th>ボス</th><th>ランク</th><th>ドロップ艦種</th><th>ドロップ艦娘</th></tr>
818 <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>
825 <tr><th>日付</th><th>結果</th><th>遠征</th><th>燃料</th><th>弾薬</th><th>鋼材</th><th>ボーキ</th><th>開発資材</th><th>高速修復材</th><th>高速建造材</th></tr>
832 <tr><th>日付</th><th>開発装備</th><th>種別</th><th>燃料</th><th>弾薬</th><th>鋼材</th><th>ボーキ</th><th>秘書艦</th><th>司令部Lv</th></tr>
839 <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>
846 <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>
853 <tr><th>日付</th><th>燃料</th><th>弾薬</th><th>鋼材</th><th>ボーキ</th><th>高速建造材</th><th>高速修復材</th><th>開発資材</th><th>改修資材</th></tr>
858 <form id="chart_type">
859 <div style="margin: 0 0 0.5em 1em;">
860 <label><input type="radio" name="chart_type" value="0" checked="checked">連続</label>
861 <label><input type="radio" name="chart_type" value="1">差分</label>
864 <ul class="tab tab1" id="range_seq" style="float: left; margin-right: 0.2em">
872 <ul class="tab tab1" id="range_diff" style="float: left; margin-right: 0.2em">
879 <div style="padding: 0.2em 0;">
880 <input type="text" id="chart_from" style="width: 7em">~<input type="text" id="chart_to" style="width: 7em">
881 <label><input type="checkbox" id="tooltip" value="" style="margin-left: 2em;">ツールチップ</label>
883 <div id="chart" style="clear: both; margin: 1em;"></div>
886 <ul class="tab tab1" id="range_sortie_stat" style="float: left; margin-right: 0.2em">
890 <div style="padding: 0.2em 0;">
891 <input type="text" id="sortie_stat_from" style="width: 7em">~<input type="text" id="sortie_stat_to" style="width: 7em">
894 <div id="sortie_stat_recent_tables" style="clear: both;">
897 <table id="sortie_stat_day">
899 <tr><th>マップ</th><th>出撃</th><th>S</th><th>A</th><th>B</th><th>C</th><th>D以下</th><th>輸送船</th></tr>
904 <table id="sortie_stat_week">
906 <tr><th>マップ</th><th>出撃</th><th>S</th><th>A</th><th>B</th><th>C</th><th>D以下</th><th>輸送船</th></tr>
910 <table id="sortie_stat_month">
912 <tr><th>マップ</th><th>出撃</th><th>S</th><th>A</th><th>B</th><th>C</th><th>D以下</th></tr>
916 <div id="sortie_stat_all_table" style="display: none;">
917 <table id="sortie_stat_all">
919 <tr><th>マップ</th><th>出撃</th><th>S</th><th>A</th><th>B</th><th>C</th><th>D以下</th><th>輸送船</th></tr>