// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification // for details on configuring this project to bundle and minify static web assets. // Write your JavaScript code. //#region dataTable 預設 $(function () { $.extend(true, $.fn.dataTable.defaults, { "paging": true, "lengthChange": false, "searching": false, "ordering": true, "info": true, "autoWidth": false, "responsive": true, "language": { "emptyTable": "無資料...", "processing": "處理中...", "loadingRecords": "載入中...", "lengthMenu": "顯示 _MENU_ 項結果", "zeroRecords": "沒有符合的結果", "info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項", "infoEmpty": "顯示第 0 至 0 項結果,共 0 項", "infoFiltered": "(從 _MAX_ 項結果中過濾)", "infoPostFix": "", "search": "搜尋:", "paginate": { "first": "第一頁", "previous": "上一頁", "next": "下一頁", "last": "最後一頁" }, "aria": { "sortAscending": ": 升冪排列", "sortDescending": ": 降冪排列" } } }); //驗證是否為空白 jQuery.validator.addMethod("filterspace", function (value, element) { var str = value; var result = false; if (str.length > 0) { if ($.trim(str) != '') { result = true; } else { result = false; } } return result; }, "不可填入空白"); }); //#endregion $(function () { $.ajaxSetup({ //headers: { // Authorization: 'Basic ' + localStorage.getItem('JWT-Authorization'), // 'Access-Control-Allow-Origin': "*" //}, beforeSend: function (xhr) { xhr.setRequestHeader("Authorization", 'Bearer ' + localStorage.getItem('JWT-Authorization')); }, xhrFields: { withCredentials: true }, //contentType: "application/json; charset=utf-8", //完成请求后触发。即在success或error触发后触发 complete: function (XMLHttpRequest, status) { if ('400' == XMLHttpRequest.status) { window.location.href = "/Login/Index"; } }, //}) }); var top_menu; function GetMenu(baseApiUrl) { var url = baseApiUrl + 'api/GetMenu'; $.ajax({ type: "POST", url: url, data: null, success: function (rel) { //rel = JSON.stringify(rel); if (rel.code != "0000") { if (rel.code == "9999") { toast_error(rel.msg); } else { toast_warning(rel.msg); } return; } else { top_menu = rel; //console.log(top_menu); $('.search > .nav').empty(); top_menu.data.forEach(function (building_item) { var html = `` $('.search > .nav').append(html); }); $('.search > .nav').append(``); } if (rel.str_jwt != null) { localStorage.setItem('JWT-Authorization', rel.str_jwt); } }, error: function (xhr, textStatus, thrownError) { alert(textStatus); } }); } //var fileReader = new FileReader(); //let json = JSON.stringify(); //const blob = new Blob("response.json", { type: "application/json" }); //fileReader.readAsText(blob); //fileReader.onload = function () { // console.log("讀取結果:", this.result);//當讀取完成之後會回撥這個函式,然後此時檔案的內容儲存到了result中。直接操作即可。 // console.log("讀取結果轉為JSON:"); // let json = JSON.parse(this.result); // console.log(json.name); // console.log(json.age); //} function readTextFile(file, callback) { var rawFile = new XMLHttpRequest(); rawFile.overrideMimeType("application/json"); rawFile.open("GET", file, true); rawFile.onreadystatechange = function () { if (rawFile.readyState === 4 && rawFile.status == "200") { callback(rawFile.responseText); } } rawFile.send(null); } //usage: //readTextFile("/js/response.json", function (text) { // top_menu = JSON.parse(text); // console.log(top_menu); // $('.search > .nav').empty(); // top_menu.data.forEach(function (building_item) { // var html = `` // // $('.search > .nav').append(html); // }); // $('.search > .nav').append(``); // }); //} var selected_building; function ChangeSideMenu(building_guid,e) { selected_building = top_menu.data.filter(building => building.building_guid == building_guid)[0]; $('.search > .nav').find('.nav-item').removeClass('active'); $(e).parent('li').addClass("active"); $('#js-nav-menu').navigationDestroy(); $('#js-nav-menu').empty(); selected_building.main_system.forEach(function (main_system_item) { var sub_html = ''; main_system_item.sub_system.forEach(function (sub_system_item) { sub_html += `
  • ${sub_system_item.full_name}
  • `; }); var html = `
  • ${main_system_item.full_name}
  • `; $('#js-nav-menu').append(html); }); $('#js-nav-menu').append(`

  • 告警記錄
  • 歷史數據
  • 報表下載
  • 操作記錄
  • `); $('#js-nav-menu').navigation({ accordion: myapp_config.navAccordion, speed: myapp_config.navSpeed, closedSign: '', openedSign: '', initClass: myapp_config.navInitalized }); } var selected_mainsystem; function GetmaintoSub(main) { selected_mainsystem = selected_building.main_system.filter(mainsystem => mainsystem.main_system_guid == main)[0]; //console.log(selected_mainsystem); } var selected_subsystem; function GetsubtoFloor(subsystem, e) { $(e).parent().parent().parent().find('.active').removeClass('active'); $(e).parents('li').addClass('active'); $(e).addClass('active'); selected_subsystem = selected_mainsystem.sub_system.filter(sub_system => sub_system.sub_system_guid == subsystem)[0]; //console.log(selected_subsystem); var floor_html = ''; $('#navbarColor02').empty(); if (selected_subsystem.drawing != 1) { floor_html += ``; } if (selected_subsystem.floors.length > 0) { if (selected_subsystem.planimetric_click == 1) { selected_subsystem.floors.forEach(function (floor_item) { if (selected_subsystem.drawing == 1) { if (selected_subsystem.planimetric_floor_guid == floor_item.floor_guid) { floor_html += ``; } else { floor_html += ``; } } else { floor_html += ``; } }) } } var htnl = ` `; $('#navbarColor02').append(htnl); } function GetFloortoDrawing(floorguid,e) { }