manto07m преди 3 години
родител
ревизия
a6edcaa3f6
променени са 2 файла, в които са добавени 153 реда и са изтрити 169 реда
  1. 147 166
      script/js/c3.js
  2. 6 3
      script/js/main.js

+ 147 - 166
script/js/c3.js

@@ -10,9 +10,9 @@ var C3Json = $.getJSON("/BIM-Monitor/assets/json/c3-monitorList.json", function
 var R03Json = $.getJSON("/BIM-Monitor/assets/json/r03-monitorList.json", function (json) {
     sites["r03"] = json;
 });
-var lastNode;
-$.ajaxSettings.async = true;
 
+$.ajaxSettings.async = true;
+var lastNode;
 var errorArray = [];
 var switchNumber = 0;
 passString('OW');
@@ -22,14 +22,39 @@ var isAll = true;
 var isCompare = false;
 var saveCheckCompare = "";
 
+
+$(document).ready(function() {
+    
+    GetCheckAllAJAXValue();
+    LoadPage();
+
+    $(".monitor").on('click', function() {
+        let option = $(this).attr("monitor");
+        isAll = true;
+        isCompare = false;
+        passString(option);
+        document.getElementById("monitorName").innerHTML = option + "監測儀器";
+        if (lastNode != null) {
+            lastNode.style = "color:#abb4be;";
+        }
+        document.getElementById("errorCheck").checked = false;
+        document.getElementById("compareCheck").checked = false;
+
+        lastNode = document.getElementById(option).parentNode;
+        lastNode.style = "color:#0088cc;";
+
+        LoadPage();
+    });
+})
+
 //Pass monitor equipment's name to index.php select form
 function passString(option) {
     window.localStorage.setItem("option", option);
 }
 
+//unity給一個wellname(string)
 function GetWellName(wellName) {
     showWell(wellName, true);
-
 }
 
 function submitForm() {
@@ -38,24 +63,128 @@ function submitForm() {
 
 function GetWellNameList(wellNameList) {
     window.localStorage.setItem("wellNameList", wellNameList);
-
 }
+
+
+
 //display well name and send its name to showWell function
-function displayWellInfo2() {
+function displayWellInfo2(equipment) {
+    $.ajaxSettings.async = false;
     $.ajax({
-        url: '/BIM-Monitor/script/php/getWellName.php',
-        complete: function (response) {
-            console.log("Get well name: ");
-            console.log(response);
-            if (response.responseText != "") {
-                showWell(response.responseText, false);
+        url: '/BIM-Monitor/script/php/getEquipmentName.php',
+        type: "GET",
+        data: {
+            equipment: equipment,
+        }
+    }).success(function(data){
+        GetWellNameList(data);
+    }).error(function (error) {
+        console.log("錯誤");
+    });
+    $.ajaxSettings.async = true;
+}
+var sparklinePieData = [];
+
+function LoadPage() {
+
+    var option = window.localStorage.getItem("option");
+    displayWellInfo2(option);
+
+    $('#' + window.localStorage.getItem("option")).removeClass('hidden').removeAttr('disabled');
+
+    document.getElementById("monitorSelect2").innerHTML = "選擇觀測儀器";
+
+    if (option == "ELP" || option == "OW")
+        document.getElementById("displayCompareChart").style.display = 'block';
+    else
+        document.getElementById("displayCompareChart").style.display = 'none';
+
+    if (option == "HM" || option == "SIS" || option == "RS" || option == "VG" || option == "SID") {
+        //myGameInstance.SendMessage("Monitor", "ChangeTransparent");
+        //myGameInstance.SendMessage("Monitor", "RemoveModel", "true");
+    } else {
+        //myGameInstance.SendMessage("Monitor", "ChangeWhite");
+        //myGameInstance.SendMessage("Monitor", "RemoveModel", "false");
+    }
+
+    if (option != "ELP" && option != "SIS" && option != "SID") {
+        document.getElementById("phase").style.display = "none";
+    } else {
+        document.getElementById("phase").style.display = "block";
+    }
+
+    var wellTBALocal = getCheckValue();
+    var dataValue = option;
+    for (i = 0; i < wellTBALocal.length; i++) {
+        dataValue = dataValue.concat(',', wellTBALocal[i]);
+
+    }
+
+    //myGameInstance.SendMessage("Monitor", "AddDataTable", dataValue);
+    //myGameInstance.SendMessage("Monitor", "Initialization");
+    var wellNameList = window.localStorage.getItem("wellNameList");
+    var wellNameListsLocal = wellNameList.split(",");
 
+    var order = new Array(wellNameListsLocal.length);
+    for (i = 0; i < wellNameListsLocal.length; i++) {
+        order[i] = wellNameListsLocal[i].match(/\d+/g);
+    }
+    for (i = 0; i < order.length; i++) {
+        for (j = 0; j < order.length; j++) {
+            if (order[j] > order[j + 1]) {
+                let temp = order[j];
+                order[j] = order[j + 1];
+                order[j + 1] = temp;
+                let temp2 = wellNameListsLocal[j];
+                wellNameListsLocal[j] = wellNameListsLocal[j + 1];
+                wellNameListsLocal[j + 1] = temp2;
             }
-        },
-        error: function () {
+        }
+    }
+    wellNameLists = wellNameListsLocal;
+    wellTBA = wellTBALocal;
+
+    SetList();
+    ResetCamera();
+    showWell(wellNameLists[0], false);
+}
+
+//get well info from sql server
+function showWell(str, changeCamera) {
+    var strLocal = "";
+    var executed = false;
+    var xhttp;
+    isCompare = false;
+    document.getElementById("compareCheck").checked = false;
+    if (str == "") {
+        document.getElementById("dataTable").innerHTML = "";
+        return;
+    }
+    strLocal = str;
+
+    document.getElementById("monitorSelect2").innerHTML = strLocal;
+    xhttp = new XMLHttpRequest();
+    xhttp.onreadystatechange = function () {
+        if (this.readyState == 4 && this.status == 200) {
+
+            document.getElementById("tableName").innerHTML = strLocal + "資料表";
+            saveCheckCompare = strLocal + "資料表";
+            displayChart(str, "myChart");
+            reset();
+            //myGameInstance.SendMessage("MainCamera", "GetDataFromWebGL", str);
+
+            if (!changeCamera) {
+                ResetCamera();
+            }
+
+            document.getElementById("dataTable").innerHTML = this.responseText;
+            $('#dataTable').DataTable();
 
         }
-    });
+    };
+    xhttp.open("GET", "/BIM-Monitor/script/php/getData2.php?q=" + str, true);
+    xhttp.send();
+
 }
 var sparklinePieData = [];
 
@@ -227,7 +356,6 @@ function uploadCSV() {
 
         }
     }).done(function (data) {
-        console.log(data);
         var stack_bar_top = {
             "dir1": "down",
             "dir2": "right",
@@ -261,62 +389,7 @@ function uploadCSV() {
     });
 
 }
-//get well info from sql server
-function showWell(str, changeCamera) {
-    var strLocal = "";
-    var executed = false;
-    var xhttp;
-    isCompare = false;
-    document.getElementById("compareCheck").checked = false;
-    if (str == "") {
-        document.getElementById("dataTable").innerHTML = "";
-        return;
-    }
-    strLocal = str;
-    /*if(str.includes("ELP")){
-    	if(str.includes("A")){
-    		strLocal = str + ',' + str.replace('A','-1A');
-    	}else{
-    		strLocal = str + ',' + str + '-1';
-    	}
-    }	*/
-    document.getElementById("monitorSelect2").innerHTML = strLocal;
-    xhttp = new XMLHttpRequest();
-    xhttp.onreadystatechange = function () {
-        if (this.readyState == 4 && this.status == 200) {
-            if (str.includes("HM") && !str.includes("HM-"))
-                str = str.replace("HM", "HM-");
-
-
-            document.getElementById("tableName").innerHTML = strLocal + "資料表";
-            saveCheckCompare = strLocal + "資料表";
-            displayChart(str, "myChart");
-
-            reset();
-            console.log("Show well: " + str);
-
-            //SIS SID TI RS... don't have models yet, so I can't set the main camera to selected equipment yet
-
-
-            if (str.includes("HM")) {
-                str = str.replace("HM-", "HM");
-            }
-            myGameInstance.SendMessage("MainCamera", "GetDataFromWebGL", str);
-
-            if (!changeCamera) {
-                ResetCamera();
-            }
-            //Display data in datatable form
-
-            document.getElementById("dataTable").innerHTML = this.responseText;
-            $('#dataTable').DataTable();
 
-        }
-    };
-    xhttp.open("GET", "/BIM-Monitor/script/php/getData2.php?q=" + str, true);
-    xhttp.send();
-
-}
 
 //Display chart
 function displayChart(str, elementID) {
@@ -331,7 +404,7 @@ function displayChart(str, elementID) {
                 var c_wellName = v_variables[0];
                 var c_m_date = v_variables[1].split(" ");
                 var c_m_value = v_variables[2].split(" ");
-                //console.log(c_m_value);
+
                 //Start to make the chart
                 if (isCompare) {
                     displayCompareChart();
@@ -410,7 +483,6 @@ function displayChart(str, elementID) {
 }
 
 function displayCompareChart() {
-    console.log("displayCompareChart");
     var option = window.localStorage.getItem("option");
     var m_date = [];
     var label = [];
@@ -450,7 +522,7 @@ function displayCompareChart() {
 
 //Reset the camera
 function ResetCamera() {
-    myGameInstance.SendMessage("MainCamera", "ResetCamera");
+    //myGameInstance.SendMessage("MainCamera", "ResetCamera");
 }
 
 
@@ -493,10 +565,6 @@ function SetList() {
                 createA.style = "color:red;";
                 createButton.setAttribute('class', "mb-xs mt-xs mr-xs btn btn-danger modal-dismiss");
                 isError = true;
-
-                //console.log(" wellNameLists:" + wellNameLists[i]);
-                //console.log(" wellTBA:" + wellTBA[j]);
-
             }
         }
         createA.setAttribute('onclick', "showWell('" + wellNameLists[i] + "',true)");
@@ -504,7 +572,6 @@ function SetList() {
         createButton.setAttribute('type', "button");
 
         if (isAll || (!isAll && isError)) {
-            //console.log(isError);
             createA.appendChild(createAText);
             createButton.appendChild(createButtonText);
             option.appendChild(createA);
@@ -518,72 +585,10 @@ function SetList() {
 }
 
 function UpdateGPS(GPS) {
-    myGameInstance.SendMessage("PlayerArmature", "UpdateGPS", GPS);
+    //myGameInstance.SendMessage("PlayerArmature", "UpdateGPS", GPS);
 }
 
-function LoadPage() {
-    var option = window.localStorage.getItem("option");
-    //Display the selected equipment
 
-    $('#' + window.localStorage.getItem("option")).removeClass('hidden').removeAttr('disabled');
-    //console.log("Choosed option: " + window.localStorage.getItem("option"));
-
-    document.getElementById("monitorSelect2").innerHTML = "選擇觀測儀器";
-
-    if (option == "ELP" || option == "OW")
-        document.getElementById("displayCompareChart").style.display = 'block';
-    else
-        document.getElementById("displayCompareChart").style.display = 'none';
-
-    if (option == "HM" || option == "SIS" || option == "RS" || option == "VG" || option == "SID") {
-        myGameInstance.SendMessage("Monitor", "ChangeTransparent");
-        myGameInstance.SendMessage("Monitor", "RemoveModel", "true");
-    } else {
-        myGameInstance.SendMessage("Monitor", "ChangeWhite");
-        myGameInstance.SendMessage("Monitor", "RemoveModel", "false");
-    }
-
-    if (option != "ELP" && option != "SIS" && option != "SID") {
-        document.getElementById("phase").style.display = "none";
-    } else {
-        document.getElementById("phase").style.display = "block";
-    }
-
-    var wellTBALocal = getCheckValue();
-    var dataValue = option;
-    for (i = 0; i < wellTBALocal.length; i++) {
-        dataValue = dataValue.concat(',', wellTBALocal[i]);
-
-    }
-
-    myGameInstance.SendMessage("Monitor", "AddDataTable", dataValue);
-    myGameInstance.SendMessage("Monitor", "Initialization");
-    var wellNameList = window.localStorage.getItem("wellNameList");
-    var wellNameListsLocal = wellNameList.split(",");
-    var order = new Array(wellNameListsLocal.length);
-    for (i = 0; i < wellNameListsLocal.length; i++) {
-        order[i] = wellNameListsLocal[i].match(/\d+/g);
-    }
-    for (i = 0; i < order.length; i++) {
-        for (j = 0; j < order.length; j++) {
-            if (order[j] > order[j + 1]) {
-                let temp = order[j];
-                order[j] = order[j + 1];
-                order[j + 1] = temp;
-                let temp2 = wellNameListsLocal[j];
-                wellNameListsLocal[j] = wellNameListsLocal[j + 1];
-                wellNameListsLocal[j + 1] = temp2;
-            }
-        }
-    }
-    wellNameLists = wellNameListsLocal;
-    wellTBA = wellTBALocal;
-
-    SetList();
-
-    ResetCamera();
-    showWell(wellNameLists[0], false);
-}
 
 
 function forLoopSMOption() {
@@ -738,7 +743,6 @@ function init(c_wellName, c_m_date, c_m_value, elementID) {
     for (j = 0; j < c_m_value.length; j++) {
         if (c_m_value[j] == "") {
             c_m_value[j] = null;
-            //console.log(c_m_value[j]);
         }
     }
 
@@ -866,7 +870,6 @@ function init2(c_wellName, c_m_date, c_m_value, c2_wellName, c2_m_date, c2_m_val
     for (j = 0; j < c_m_value.length; j++) {
         if (c_m_value[j] == "") {
             c_m_value[j] = null;
-            //console.log(c_m_value[j]);
         }
     }
 
@@ -874,7 +877,7 @@ function init2(c_wellName, c_m_date, c_m_value, c2_wellName, c2_m_date, c2_m_val
         window.chart.destroy();
     }
     c_m_value.forEach(function (item, index, array) {
-        //console.log(item, index);
+
     });
     window.chart = new Chart(ctx, {
         type: 'line',
@@ -1013,7 +1016,6 @@ function initSISSID(c_m_date, c_m_depth, c_m_value, elementID, str) {
     for (j = 0; j < c_m_value.length; j++) {
         if (c_m_value[j] == "") {
             c_m_value[j] = null;
-            //console.log(c_m_value[j]);
         }
     }
 
@@ -1075,7 +1077,6 @@ function initSISSID(c_m_date, c_m_depth, c_m_value, elementID, str) {
 
 function init6(c_wellName, c_m_date, c_m_value, c2_wellName, c2_m_value, c3_wellName, c3_m_value, c4_wellName, c4_m_value, c5_wellName, c5_m_value, c6_wellName, c6_m_value, elementID) {
     var ctx = document.getElementById(elementID).getContext("2d");
-
     let warning = [];
     if (c_wellName.includes("RS")) {
         for (i = 0; i < c_m_date.length; i++) {
@@ -1258,23 +1259,3 @@ function reset() {
     //table.style.width = "100%";
     myNode.appendChild(table);
 }
-
-$(document).ready(function() {
-    $(".monitor").on('click', function() {
-        let option = $(this).attr("monitor");
-        isAll = true;
-        isCompare = false;
-        passString(option);
-        document.getElementById("monitorName").innerHTML = option + "監測儀器";
-        if (lastNode != null) {
-            lastNode.style = "color:#abb4be;";
-        }
-        document.getElementById("errorCheck").checked = false;
-        document.getElementById("compareCheck").checked = false;
-
-        lastNode = document.getElementById(option).parentNode;
-        lastNode.style = "color:#0088cc;";
-
-        LoadPage();
-    });
-})

+ 6 - 3
script/js/main.js

@@ -1,13 +1,16 @@
-var lastNode;
 var errorTable;
-var sites;
+var sites = {};
 $.ajaxSettings.async = false;
 var jqxhr = $.getJSON("/BIM-Monitor/assets/errorTable.json", function (json) {
     errorTable = json;
 });
 var C3Json = $.getJSON("/BIM-Monitor/assets/json/c3-monitorList.json", function (json) {
-    sites = json;
+    sites["c3"] = json;
 });
+var R03Json = $.getJSON("/BIM-Monitor/assets/json/r03-monitorList.json", function (json) {
+    sites["r03"] = json;
+});
+
 $.ajaxSettings.async = true;
 
 var errorArray = [];