OSDN Git Service

報告書の「マス」を「経路」に直す
[kancollesniffer/KancolleSniffer.git] / LogViewer / tags.tag
index 7d1077c..4c2eb4c 100644 (file)
@@ -51,29 +51,9 @@ var val = sessionStorage.getItem('logRange');
 opts.logRange.val = val === null ? 2 : +val;
 
 this.init = function() {
-    $('#term_from').datetimepicker({
-        onShow: function() {
-            self.datetimepickerOpen = true;
-        },
-        onClose: function() {
-            if (!self.datetimepickerOpen)
-                return;
-            self.datetimepickerOpen = false;
-            if (opts.logRange.val === 4)
-                opts.observable.trigger("logRangeChanged");
-        }
-    });
-    $('#term_to').datetimepicker({
-        onShow: function() {
-            self.datetimepickerOpen = true;
-        },
-        onClose: function() {
-            if (!self.datetimepickerOpen)
-                return;
-            self.datetimepickerOpen = false;
-            if (opts.logRange.val === 4)
-                opts.observable.trigger("logRangeChanged");
-        }
+    self.initPicker('#term_from', '#term_to', function() {
+        if (opts.logRange.val === 4)
+            opts.observable.trigger( "logRangeChanged");
     });
 };
 
@@ -94,14 +74,17 @@ this.rangeTabChange = function(e) {
 <thead>
 <tr></tr>
 </thead>
+<tfoot>
+<tr></tr>
+</toot>
 </table>
 </div>
 
 <script>
 this.tables = [
-"<th>日付</th><th>海域</th><th>マップ</th><th>マス</th><th>ボス</th><th>ランク</th><th>ドロップ艦種</th><th>ドロップ艦娘", // ドロップ
-"<th>日付</th><th style=\"min-width: 3.2em;\">海域</th><th>マップ</th><th>マス</th><th>ボス</th><th>ランク</th><th>艦隊行動</th><th>味方陣形</th><th>敵陣形</th><th style=\"min-width: 3.2em;\">敵艦隊</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>大破艦</ht><th style=\"min-width: 2.2em;\">敵艦1</th><th>敵艦1HP</th><th style=\"min-width: 2.2em;\">敵艦2</th><th>敵艦2HP</th><th style=\"min-width: 2.2em;\">敵艦3</th><th>敵艦3HP</th><th style=\"min-width: 2.2em;\">敵艦4</th><th>敵艦4HP</th><th style=\"min-width: 2.2em;\">敵艦5</th><th>敵艦5HP</th><th style=\"min-width: 2.2em;\">敵艦6</th><th>敵艦6HP</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>海域</th><th>マップ</th><th>経路</th><th>ボス</th><th>ランク</th><th>ドロップ艦種</th><th>ドロップ艦娘", // ドロップ
+"<th>日付</th><th style=\"min-width: 3.2em;\">海域</th><th>マップ</th><th>経路</th><th>ボス</th><th>ランク</th><th>艦隊行動</th><th>味方陣形</th><th>敵陣形</th><th style=\"min-width: 3.2em;\">敵艦隊</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 style=\"min-width: 2.2em;\">敵艦1</th><th>敵艦1HP</th><th style=\"min-width: 2.2em;\">敵艦2</th><th>敵艦2HP</th><th style=\"min-width: 2.2em;\">敵艦3</th><th>敵艦3HP</th><th style=\"min-width: 2.2em;\">敵艦4</th><th>敵艦4HP</th><th style=\"min-width: 2.2em;\">敵艦5</th><th>敵艦5HP</th><th style=\"min-width: 2.2em;\">敵艦6</th><th>敵艦6HP</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>日付</th><th>開発装備</th><th>種別</th><th>燃料</th><th>弾薬</th><th>鋼材</th><th>ボーキ</th><th>秘書艦</th><th>司令部Lv</th>", // 開発
 "<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>", // 建造
 "<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>", // 改修
@@ -119,9 +102,6 @@ this.jsons = [
 ];
 
 this.on("mount", function() {
-    var records = this.root.querySelectorAll("tr");
-    for (var i = 0; i < records.length; i++)
-        records[i].innerHTML = this.tables[i];
     this.init();
 });
 
@@ -139,34 +119,85 @@ opts.observable.on("logRangeChanged", function() {
 
 this.init = function() {
     for (var t = 0; t < this.tables.length; t++) {
-        var opts = {
-            destroy: true,
-            deferRender: true,
-            stateSave: true,
-            order: [[0, "desc"]],
-            pageLength: 50,
-            lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
-            drawCallback: function() {
-                $('#loading').hide();
-            }
-        };
-        if (t === 0) {
-            opts.columns = [{data: 0}, {data: 1}, {data: 39}, {data: 2}, {data: 3}, {data: 4}, {data: 9}, {data: 10}];
-        } else if (t === 1) {
-            var entries = [];
-            for (var i = 0; i < 38; i++) {
-                if (i === 2)
-                    entries.push({data: 39});
-                if (i === 9 || i === 10)
-                    continue;
-                if (i === 23)
-                    entries.push({data: 38});
-                entries.push({data: i});
-            }
-            opts.columns = entries;
+        var table = $('#log' + t);
+        self.setHeaderAndFooter(table, self.tables[t]);
+        var dTable = table.DataTable(self.tableOptions(t));
+        self.searchSetup(dTable);
+    }
+};
+
+this.tableOptions = function(tableId) {
+    var opts = {
+        destroy: true,
+        deferRender: true,
+        stateSave: true,
+        order: [[0, "desc"]],
+        pageLength: 50,
+        lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
+        drawCallback: function() {
+            $('#loading').hide();
+        }
+    };
+    if (tableId === 0) {
+        opts.columns = self.dropColumns();
+    } else if (tableId === 1) {
+        opts.columns = self.sortieColumns();
+    }
+    return opts;
+};
+
+this.dropColumns = function() {
+    return [{data: 0}, {data: 1}, {data: 40}, {data: 2}, {data: 3}, {data: 4}, {data: 9}, {data: 10}];
+};
+
+this.sortieColumns = function() {
+    var entries = [];
+    for (var i = 0; i < 38; i++) {
+        if (i === 2)
+            entries.push({data: 40});
+        if (i === 9 || i === 10)
+            continue;
+        if (i === 23) {
+            entries.push({data: 38});
+            entries.push({data: 39});
         }
-        $('#log' + t).dataTable(opts);
+        entries.push({data: i});
     }
+    return entries;
+};
+
+this.setHeaderAndFooter = function(table, header) {
+    table.find("thead tr").first().html(header);
+    var footer = table.find("tfoot tr");
+    table.find("th").each(function(index) {
+        footer.append(
+            '<th style="padding: 1px"><input style="min-width: 100%" size="1" type="search" placeholder="Search ' +
+            $(this).text() + '"/></th>');
+    });
+};
+
+this.searchSetup = function(dTable) {
+    self.setupCellSearch(dTable);
+    self.setupGlobalSearch(dTable);
+};
+
+this.setupCellSearch = function(dTable) {
+    dTable.columns().every(function() {
+        var that = this;
+        that.search(""); // reset
+        $('input', this.footer()).on("input search", function() {
+            that.search(this.value, true, false).draw();
+        });
+    });
+};
+
+this.setupGlobalSearch = function(dTable) {
+    var searchLabel = $(dTable.table().container()).find(".dataTables_filter label").first();
+    searchLabel.html('Search: <input type="search">');
+    searchLabel.children("input").first().on("input search", function() {
+        dTable.search(this.value, true, false).draw();
+    });
+    dTable.search(""); // reset
 };
 
 this.show = function() {
@@ -183,15 +214,15 @@ this.show = function() {
         query += from.valueOf();
         break;
     case 1:
-        from = now.clone().startOf('week').hours(5);
-        if (now.hour() < 5 && now.days() === 1)
+        from = now.clone().day(1).startOf('day').hours(5);
+        if (now.day() === 0 || now.day() === 1 && now.hour() < 5)
             from.subtract(1, 'weeks');
         query += from.valueOf();
         break;
     case 2:
         if (now.hours() >= 22 &&
-            now.dates() === now.clone().endOf('month').date()) {
-            from = now.clone().hours(22);
+            now.date() === now.clone().endOf('month').date()) {
+            from = now.clone().startOf('day').hours(22);
         } else {
             from = now.clone().startOf('month').subtract(1, 'days').hours(22);
         }
@@ -306,29 +337,9 @@ this.useDatePicker = function() {
 var self = this;
 
 this.init = function() {
-    $('#chart_from').datetimepicker({
-        onShow: function() {
-            self.datetimepickerOpen = true;
-        },
-        onClose: function() {
-            if (!self.datetimepickerOpen)
-                return;
-            self.datetimepickerOpen = false;
-            if (self.useDatePicker())
-                opts.observable.trigger("chartSpecChanged");
-        }
-    });
-    $('#chart_to').datetimepicker({
-        onShow: function() {
-            self.datetimepickerOpen = true;
-        },
-        onClose: function() {
-            if (!self.datetimepickerOpen)
-                return;
-            self.datetimepickerOpen = false;
-            if (self.useDatePicker())
-                opts.observable.trigger("chartSpecChanged");
-        }
+    self.initPicker('#chart_from', '#chart_to', function() {
+        if (self.useDatePicker())
+            opts.observable.trigger("chartSpecChanged");
     });
 };
 
@@ -861,7 +872,7 @@ $(window).resize(function() {
 </select>
 <table id="achivement_table" class="display compact cell-border">
 <thead>
-<tr><th>日付</th><th>戦果</th><th>EO</th><th>月毎</th></tr>
+<tr><th>日付</th><th>戦果</th><th>月毎</th><th>EO</th><th>月毎(EO込)</th></tr>
 </thead>
 </table>
 <div id="achivementChart" style="margin: 1em;"></div>
@@ -918,6 +929,7 @@ this.calcResult = function(data) {
     var lastDate = moment(0);
     var lastExp = -1;
     var nextDate = moment(0);
+    var lastEmit = moment(0);
     for (var i = 0; i < data.length; i++) {
         var row = data[i];
         var date = this.parseDate(row[0]);
@@ -937,13 +949,16 @@ this.calcResult = function(data) {
             }
             if (nextDate.valueOf() !== 0) {
                 var d = isNewDate ? nextDate.subtract(1, 'days') : endOfMonth;
+                lastEmit = isNewDate ? d : moment(0);
                 var m = d.format("YYYY-MM");
                 if (!this.result[m])
                     this.result[m] = [];
+                var perMonth = (lastExp - monthExp) / expPerAch + carryOverAch;
                 this.result[m].push([
                     d.format("YYYY-MM-DD"),
-                    ((lastExp - prevExp) / expPerAch).toFixed(1), dayEo,
-                    ((lastExp - monthExp) / expPerAch + monthEo + carryOverAch + carryOverEo).toFixed(1)
+                    ((lastExp - prevExp) / expPerAch).toFixed(1),
+                    perMonth.toFixed(1), dayEo,
+                    (perMonth + monthEo + carryOverEo).toFixed(1)
                 ]);
             }
             prevExp = lastExp === -1 ? exp : lastExp;
@@ -967,7 +982,7 @@ this.calcResult = function(data) {
                 if (!this.result[m])
                     this.result[m] = [];
                 this.result[m].push([endOfMonth.format("YYYY-MM 引継"),
-                    carryOverAch.toFixed(1), carryOverEo.toFixed(1), (carryOverAch + carryOverEo).toFixed(1)]);
+                    carryOverAch.toFixed(1), carryOverAch.toFixed(1), carryOverEo.toFixed(1), (carryOverAch + carryOverEo).toFixed(1)]);
             }
             dayEo = 0;
             nextDate = date.clone().hour(2).startOf('hour');
@@ -984,6 +999,12 @@ this.calcResult = function(data) {
         lastDate = date;
         lastExp = exp;
     }
+    if (lastEmit.valueOf() !== 0) {
+        var eom = endOfMonth.format("YYYY-MM");
+        var ave = (perMonth - carryOverAch) / lastEmit.date();
+        var estimate = perMonth + ave * (endOfMonth.date() - lastEmit.date());
+        this.result[eom].push([endOfMonth.format("YYYY-MM-DD 予測"), ave.toFixed(1) + " 平均", estimate.toFixed(1) + " 予測", monthEo + " 合計", (estimate + monthEo).toFixed(1) + " 予測"]);
+    }
 };
 
 this.calcChartData = function() {
@@ -996,15 +1017,16 @@ this.calcChartData = function() {
         data.push(["日付", "戦果", "EO", "月毎"]);
         for (var i = 0; i < result.length; i++) {
             var row = result[i];
+            if (row[0].match(/予測/))
+                continue;
             if (row[0].match(/引継/)) {
-                eo = row[2] - 0;
-                data.push([0, row[1], row[2], row[3]]);
+                eo = row[3] - 0;
+                data.push([0, row[1], row[3], row[4]]);
                 continue;
             }
             d = moment(row[0], "YYYY-MM-DD").date();
-            eo += row[2];
-            var ach = (row[3] - eo).toFixed(1);
-            data.push([d, ach, eo, row[3]]);
+            eo += row[3];
+            data.push([d, row[2], eo, row[4]]);
         }
         var endOfMonth = moment(month, "YYYY-MM").endOf("month").date();
         while (d < endOfMonth) {
@@ -1149,33 +1171,9 @@ opts.observable.on("mainTabChanged", function(idx) {
 });
 
 this.init = function() {
-    this.initDatePicker();
-};
-
-this.initDatePicker = function() {
-    $('#sortie_stat_from').datetimepicker({
-        onShow: function() {
-            self.datetimepickerOpen = true;
-        },
-        onClose: function() {
-            if (!self.datetimepickerOpen)
-                return;
-            self.datetimepickerOpen = false;
-            if (self.type === "range")
-                self.show();
-        }
-    });
-    $('#sortie_stat_to').datetimepicker({
-        onShow: function() {
-            self.datetimepickerOpen = true;
-        },
-        onClose: function() {
-            if (!self.datetimepickerOpen)
-                return;
-            self.datetimepickerOpen = false;
-            if (self.type === "range")
-                self.show();
-        }
+    self.initPicker('#sortie_stat_from', '#sortie_stat_to', function() {
+        if (self.type === "range")
+            self.show();
     });
 };
 
@@ -1274,6 +1272,13 @@ this.gatherData = function(data) {
                     if (name === "合計")
                         to.stat["合計 - ボス"] = initStat();
                 }
+                if ((b === 0 || b === 2) && isStart) {
+                    if (mo.start === "-")
+                        mo.start = 0;
+                    mo.start++;
+                }
+                if (/^基地航空隊/.test(row[11]))
+                    continue;
                 mo["R"] += resR;
                 mo[res]++;
                 if (item) {
@@ -1281,11 +1286,6 @@ this.gatherData = function(data) {
                         mo[item] = 0;
                     mo[item]++;
                 }
-                if ((b === 0 || b === 2) && isStart) {
-                    if (mo.start === "-")
-                        mo.start = 0;
-                    mo.start++;
-                }
             }
         }
     }