OSDN Git Service

戦果報告書で当月以外を選ぶと当月に戻れないバグを直す
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Sat, 30 Dec 2017 05:37:40 +0000 (14:37 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Mon, 1 Jan 2018 07:50:09 +0000 (16:50 +0900)
LogViewer/tags.html

index 8424f79..3c69125 100644 (file)
@@ -789,22 +789,19 @@ var self = this;
 opts.observable.on("mainTabChanged", function(idx) {
     self.update({mainTab: idx});
     if (self.mainTabs[self.mainTab] === "戦果")
-        self.show();
+        self.updateData();
 });
 
 this.months = [];
 this.selectedIndex = 0;
 
 this.monthChange = function(event) {
-    if (event.target.selectedIndex === 0) {
-        self.show();
+    this.selectedIndex = event.target.selectedIndex;
+    if (this.selectedIndex === 0) {
+        this.updateData();
         return;
     }
-    this.selectedIndex = event.target.selectedIndex;
-    var dt = $('#achivement_table').DataTable();
-    dt.clear();
-    dt.rows.add(this.result[event.target.value]).draw();
-    this.showChart(event.target.value);
+    this.show();
 };
 
 this.calcResult = function(data) {
@@ -951,13 +948,13 @@ this.showChart = function(month) {
     });
 };
 
-this.show = function(data) {
+this.updateData = function(data) {
     if (!data) {
         $('#loading').show();
         $.ajax({
             url: "./戦果.json",
             success: function(data) {
-                self.show(data.data);
+                self.updateData(data.data);
             },
             dataType: 'json',
             cache: false
@@ -974,6 +971,14 @@ this.show = function(data) {
         return -1;
     });
     this.update();
+    this.show();
+};
+
+this.show = function() {
+    if (this.result === undefined){
+        this.updateData();
+        return;
+    }
     var dt = $('#achivement_table').DataTable();
     dt.clear();
     dt.rows.add(this.result[this.months[this.selectedIndex]]).draw();