2022-11-16 14:53:22 +08:00
|
|
|
|
$(function () {
|
|
|
|
|
$(".dropdown-menu.dropdown-select-menu").each((index, value) => {
|
|
|
|
|
setDropdownItem(value)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
2022-11-16 17:23:00 +08:00
|
|
|
|
/**
|
|
|
|
|
* fn 定義 | 手動初始化 Bootstrap dropdown select
|
|
|
|
|
*/
|
2022-11-16 14:53:22 +08:00
|
|
|
|
$.fn.droSetItem = function () {
|
|
|
|
|
setDropdownItem(this);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2022-11-18 17:12:45 +08:00
|
|
|
|
/**
|
|
|
|
|
* fn 定義 | 輸出含原元素 html
|
|
|
|
|
*/
|
|
|
|
|
$.fn.outerHtml = function () {
|
|
|
|
|
return $(this).prop("outerHTML");
|
|
|
|
|
}
|
2022-11-16 14:53:22 +08:00
|
|
|
|
|
2022-12-02 15:46:37 +08:00
|
|
|
|
/**
|
|
|
|
|
* fn 定義 | Loading 操作
|
|
|
|
|
* @param {any} type - close / start / exceed , exceed => 繼續執行並可切換文字
|
|
|
|
|
* @param {any} text - 右下角 Alert 文字
|
|
|
|
|
*/
|
|
|
|
|
$.fn.Loading = function (type = "close",text) {
|
|
|
|
|
let ele = this;
|
|
|
|
|
let aleObj = $(this)[0]._aleObj;
|
|
|
|
|
|
|
|
|
|
function closeLoading() {
|
|
|
|
|
$("body").css("overflow", "auto");
|
|
|
|
|
$(aleObj.ele).YTAlert().hide();
|
|
|
|
|
$(ele).animate({ opacity: 0 }, 300, () => {
|
|
|
|
|
$(ele).hide();
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
function showLoading() {
|
|
|
|
|
$("body").css("overflow", "hidden");
|
|
|
|
|
let aleObj = YT.Alert.Tip(text || "讀取中,請稍後", "show");
|
|
|
|
|
$(ele)[0]._aleObj = aleObj;
|
|
|
|
|
$(ele).show();
|
|
|
|
|
$(ele).animate({ opacity: 1 }, 300);
|
|
|
|
|
|
|
|
|
|
$(aleObj.ele).YTAlert().text(text);
|
|
|
|
|
}
|
|
|
|
|
if (type == "close") {
|
|
|
|
|
closeLoading();
|
|
|
|
|
} else if (type == "exceed") {
|
|
|
|
|
$(aleObj.ele).YTAlert().text(text);
|
|
|
|
|
} else if (type == "start") {
|
|
|
|
|
showLoading();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.fn.YTAlert = function () {
|
|
|
|
|
let th = { element: this };
|
|
|
|
|
th.hide = function (delay = 0) {
|
|
|
|
|
let obj = this;
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
$(obj.element).fadeOut(300);
|
|
|
|
|
alertIdArray.splice($.inArray($(obj.element).prop("id"), alertIdArray), 1);
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
$(obj.element).remove();
|
|
|
|
|
}, 1000);
|
|
|
|
|
}, delay);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
th.text = function (text) {
|
|
|
|
|
let obj = this;
|
|
|
|
|
let id = $(obj.element).prop("id").split("tip-alert-")[1];
|
|
|
|
|
$(`#alert-text-${id}`).text(text);
|
|
|
|
|
}
|
|
|
|
|
return th;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-16 17:23:00 +08:00
|
|
|
|
/**
|
|
|
|
|
* 設置 bootstrap dropdown 為下拉選單
|
2022-12-02 15:46:37 +08:00
|
|
|
|
* @param {any} menuEle - .dropdown-menu element
|
2022-11-16 17:23:00 +08:00
|
|
|
|
*/
|
2022-11-16 14:53:22 +08:00
|
|
|
|
function setDropdownItem(menuEle) {
|
|
|
|
|
if ($(menuEle).find(".dropdown-item.active").length == 0) {
|
|
|
|
|
$(menuEle).find(".dropdown-item").first().addClass("active");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let actText = $(menuEle).find(".dropdown-item.active").first().text();
|
|
|
|
|
let actEleId = $(menuEle).prop("id");
|
|
|
|
|
$(`.dropdown-toggle[data-target=${actEleId}]`).text(actText);
|
2022-11-22 13:33:49 +08:00
|
|
|
|
|
|
|
|
|
/*actChaCallback($(menuEle).find(".dropdown-item.active"))*/
|
2022-11-16 14:53:22 +08:00
|
|
|
|
$(menuEle).trigger("active:change", $(menuEle).find(".dropdown-item.active"));
|
|
|
|
|
|
2022-11-16 17:23:00 +08:00
|
|
|
|
//點選選項 add active class
|
|
|
|
|
onEvent("click", ".dropdown-menu.dropdown-select-menu .dropdown-item", function () {
|
|
|
|
|
$(this).parent(".dropdown-menu.dropdown-select-menu").find(".dropdown-item").removeClass("active");
|
|
|
|
|
$(this).addClass("active");
|
|
|
|
|
setDropdownItem($(this).parent(".dropdown-menu.dropdown-select-menu"));
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-11-16 14:53:22 +08:00
|
|
|
|
|
2022-11-16 17:23:00 +08:00
|
|
|
|
/**
|
|
|
|
|
* 預設設備圖像
|
|
|
|
|
* @param {any} obj
|
|
|
|
|
*/
|
2022-11-16 14:53:22 +08:00
|
|
|
|
function defDev(obj) {
|
|
|
|
|
let defSrc = 'img/defdev.png';
|
|
|
|
|
obj.src = defSrc;
|
|
|
|
|
}
|
2022-11-17 10:49:49 +08:00
|
|
|
|
|
2022-12-02 15:46:37 +08:00
|
|
|
|
/**
|
|
|
|
|
* jquery datatable - ajax send data reset
|
|
|
|
|
* @param {any} table
|
|
|
|
|
* @param {any} sendData
|
|
|
|
|
*/
|
2022-11-18 17:12:45 +08:00
|
|
|
|
function dtAjaxResetSendData(table,sendData) {
|
|
|
|
|
table.context[0].ajax.data = function (d) {
|
|
|
|
|
d = sendData;
|
|
|
|
|
return JSON.stringify(d)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 15:46:37 +08:00
|
|
|
|
|
2022-11-18 17:12:45 +08:00
|
|
|
|
/**
|
|
|
|
|
* element 建造
|
|
|
|
|
* @param {any} text
|
|
|
|
|
* @param {any} id
|
|
|
|
|
* @param {any} name
|
|
|
|
|
* @param {any} cls
|
|
|
|
|
* @param {any} data
|
|
|
|
|
* @param {any} attr
|
|
|
|
|
*/
|
|
|
|
|
function eleBuild(text = null, id = null, name = null, cls = [], data = {}, attr = {}) {
|
|
|
|
|
cls = cls ?? [], data = data ?? {}, attr = attr ?? {};
|
|
|
|
|
id = id ? `id="${id}"` : "";
|
|
|
|
|
name = name ? `name="${name}"` : "";
|
|
|
|
|
cls = cls.length != 0 ? `class="${cls.join(' ')}"` : "";
|
|
|
|
|
data = data.length != 0 ? `${Object.keys(data).map(x => `data-${x}="${data[x]}"`).join(" ")}` : "";
|
|
|
|
|
attr = attr ? `${Object.keys(attr).map(x => `${x}="${attr[x]}"`).join(" ")}` : "";
|
|
|
|
|
let attrArr = [], attrText = "";
|
|
|
|
|
attrArr = [id, name, cls, data, attr];
|
|
|
|
|
attrText = attrArr.filter(x => x != "").join(" ");
|
|
|
|
|
text = text === null ? "" : text;
|
|
|
|
|
return { attrText: attrText, text: text };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creEle(ele, text = null, id = null, name = null, cls = [], data = {}, attr = {}) {
|
|
|
|
|
let comp = eleBuild(text, id, name, cls, data, attr);
|
|
|
|
|
return $(`<${ele} ${comp.attrText}>${comp.text}</${ele}>`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creDiv(cls = [], attr = {}, id = null, name = null, data = {}, text = null) {
|
|
|
|
|
return creEle("div", text, id, name, cls, data, attr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creBtn(text = null, id = null, name = null, cls = [], data = {}, attr = {}) {
|
|
|
|
|
return creEle("button", text, id, name, cls, data, attr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creBtnHtml(text = null, id = null, name = null, cls = [], data = {}, attr = {}) {
|
|
|
|
|
return creEle("button", text, id, name, cls, data, attr).prop("outerHTML");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creSelect(id = null, cls = [], name = null, data = {}, attr = {}, text = null) {
|
|
|
|
|
return creEle("select", text, id, name, cls, data, attr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creOption(text = null, value = null, data = {}, attr = {}, cls = [], name = null, id = null) {
|
2022-12-14 11:57:40 +08:00
|
|
|
|
value != null ? attr.value = value : attr;
|
2022-11-18 17:12:45 +08:00
|
|
|
|
return creEle("option", text, id, name, cls, data, attr);
|
2022-11-28 12:38:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-09 18:20:41 +08:00
|
|
|
|
function creImg(ele, text = null, id = null, name = null, cls = [], data = {}, attr = {}) {
|
|
|
|
|
let comp = eleBuild(text, id, name, cls, data, attr);
|
|
|
|
|
return $(`<${ele} ${comp.attrText}>${comp.text}`);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 15:46:37 +08:00
|
|
|
|
/**
|
|
|
|
|
* 根據該棟建築底下的'所有'電梯執行緒物件
|
|
|
|
|
* */
|
2022-11-28 12:38:19 +08:00
|
|
|
|
class ElevatorHandler {
|
|
|
|
|
constructor(ele, option = {}) {
|
|
|
|
|
this.ele = ele;
|
|
|
|
|
this.eleId = "";
|
|
|
|
|
this.eleWra = $("<div></div>");
|
2022-11-28 18:08:50 +08:00
|
|
|
|
this.speed = 0.3;
|
2022-11-29 12:46:19 +08:00
|
|
|
|
this.movStatus = {}; // {id:elevator01,value:0} 0=no 1=up 2=down
|
2022-12-08 17:27:32 +08:00
|
|
|
|
this.floorHeight = typeof option.fHeight == "undefined" ? 60 : option.fHeight;
|
2022-11-28 12:38:19 +08:00
|
|
|
|
this.floorWidth = typeof option.fWidth == "undefined" ? 45 : option.fWidth;
|
|
|
|
|
this.floors = typeof option.floors == "undefined" ? [{}] : option.floors;
|
2022-11-29 12:46:19 +08:00
|
|
|
|
this.elevators = typeof option.elevators == "undefined" ? [{}] : option.elevators; // {id:elevator01}
|
2022-11-28 18:08:50 +08:00
|
|
|
|
this.curElevFloor = typeof option.curElevFloor == "undefined" ? {} : option.curElevFloor;
|
|
|
|
|
this.setTimeout = null;
|
2022-11-28 12:38:19 +08:00
|
|
|
|
this.init();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 15:46:37 +08:00
|
|
|
|
// 所有電梯初始化
|
2022-11-28 12:38:19 +08:00
|
|
|
|
init = function () {
|
|
|
|
|
this.setTabWra();
|
|
|
|
|
this.setTabFloor();
|
2022-12-02 15:46:37 +08:00
|
|
|
|
// 若已有每個設備的所在樓層,則預設到該樓層位置
|
2022-11-28 18:08:50 +08:00
|
|
|
|
if (Object.keys(this.curElevFloor).length != 0) {
|
|
|
|
|
$.each(Object.keys(this.curElevFloor), (idx, elevKey) => {
|
|
|
|
|
this.setElevFloor(elevKey,this.curElevFloor[elevKey]);
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-11-28 12:38:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 設置 wrapper
|
|
|
|
|
setTabWra = function () {
|
|
|
|
|
let id = $(this.ele).prop("id");
|
|
|
|
|
this.eleId = id;
|
|
|
|
|
if ($(this.ele).parent(".elevator-table-wrapper").length != 0) {
|
|
|
|
|
$(this.ele).unwrap(".elevator-table-wrapper");
|
|
|
|
|
}
|
|
|
|
|
let wrapper = creDiv(["elevator-table-wrapper"], null, `${id}_wrapper`);
|
|
|
|
|
$(this.ele).wrap(wrapper);
|
|
|
|
|
this.eleWra = wrapper;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 設置 table 樓層
|
|
|
|
|
setTabFloor = function () {
|
|
|
|
|
let _w = this.floorWidth, _h = this.floorHeight;
|
|
|
|
|
let thead = creEle("thead"), tbody = creEle("tbody");
|
2022-11-28 18:08:50 +08:00
|
|
|
|
let _floors = this.floors, _ele = this.ele, _elevators = this.elevators;
|
2022-11-28 12:38:19 +08:00
|
|
|
|
//樓層從小到大
|
|
|
|
|
_floors = _floors.oSort("sort").reverse().map(x => x.name);
|
|
|
|
|
|
|
|
|
|
let theadTr = creEle("tr");
|
2022-11-28 18:08:50 +08:00
|
|
|
|
|
|
|
|
|
for (let e = 1; e <= _elevators.length + 2; e++) {
|
2022-11-28 12:38:19 +08:00
|
|
|
|
let th = creEle("th");
|
2022-12-02 15:46:37 +08:00
|
|
|
|
th.css({ "width": `${_w}px`, "height": `${_h}px` ,"position":"relative"});
|
2022-11-28 18:08:50 +08:00
|
|
|
|
if (e != 1 && e != _elevators.length + 2) {
|
2022-11-29 12:46:19 +08:00
|
|
|
|
let elevId = _elevators[e - 2]?.id;
|
2022-11-28 12:38:19 +08:00
|
|
|
|
// 電梯方框
|
2022-11-28 18:08:50 +08:00
|
|
|
|
let span = creEle("span", null, "elevator-item-" + (elevId), null, ["elevator-item"]);
|
2022-11-29 12:46:19 +08:00
|
|
|
|
let spanUp = creEle("span", null, null, null, ["elevator-item-toup"]);
|
|
|
|
|
let spanDown = creEle("span", null, null, null, ["elevator-item-todown"]);
|
2022-12-02 15:46:37 +08:00
|
|
|
|
span.css({ "width": `${_w - 3}px`, "height": `${_h - 3}px`, "top": `1.5px`,"left":"1.5px", "transition":`transform ${1 / this.speed}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`})
|
|
|
|
|
spanUp.css({ "width": `${_w - 3}px`, "height": `${(_h - 3) / 2}px`, "top": `1.5px`, "left": "1.5px", "transition":`transform ${1 / this.speed}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`})
|
|
|
|
|
spanDown.css({ "width": `${_w - 3}px`, "height": `${(_h - 3) / 2}px`, "top": `1.5px`, "left": "1.5px", "transition":`transform ${1 / this.speed}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`,"top":`${1.5 + (_h-3) / 2}px`})
|
2022-11-29 12:46:19 +08:00
|
|
|
|
th.append(spanUp);
|
2022-11-28 12:38:19 +08:00
|
|
|
|
th.append(span);
|
2022-11-29 12:46:19 +08:00
|
|
|
|
th.append(spanDown);
|
2022-11-28 12:38:19 +08:00
|
|
|
|
}
|
|
|
|
|
theadTr.append(th);
|
|
|
|
|
}
|
|
|
|
|
thead.css("position", "absolute");
|
|
|
|
|
thead.append(theadTr);
|
|
|
|
|
|
|
|
|
|
//樓層表格建置 tbody
|
|
|
|
|
for (let f = 1; f <= _floors.length; f++) {
|
|
|
|
|
let tr = creEle("tr");
|
2022-11-28 18:08:50 +08:00
|
|
|
|
|
|
|
|
|
for (let e = 1; e <= _elevators.length + 2; e++) {
|
2022-11-28 12:38:19 +08:00
|
|
|
|
let td = creEle("td");
|
|
|
|
|
td.css({ "width": `${_w}px`, "height": `${_h}px` });
|
|
|
|
|
if (e == 1) {
|
|
|
|
|
td.addClass("t-black")
|
|
|
|
|
td.text(_floors[f - 1]);
|
2022-11-28 18:08:50 +08:00
|
|
|
|
} else if (e == _elevators.length + 2) {
|
2022-11-28 12:38:19 +08:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
let div = creDiv(["d-flex", "justify-content-center", "align-items-end", "h-100"]);
|
2022-12-08 17:27:32 +08:00
|
|
|
|
div.append(`<i class="fal fa-door-open fs-1-2"></i>`)
|
2022-11-28 12:38:19 +08:00
|
|
|
|
td.append(div)
|
|
|
|
|
}
|
|
|
|
|
tr.append(td);
|
|
|
|
|
}
|
|
|
|
|
tbody.append(tr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(_ele).append(thead);
|
|
|
|
|
$(_ele).append(tbody);
|
|
|
|
|
|
|
|
|
|
//表格外圍無框線
|
|
|
|
|
$(_ele).find("tbody tr").each((index, tr) => {
|
|
|
|
|
|
|
|
|
|
$(tr).find("td:eq(0)").css("border-left", "0");
|
|
|
|
|
$(tr).find("td:eq(-1)").css("border-right", "0");
|
|
|
|
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
$(tr).find("td").each((index, td) => {
|
|
|
|
|
$(td).css("border-top", "0");
|
|
|
|
|
})
|
|
|
|
|
} else if (index == $("#floorTable tbody tr").length - 1) {
|
|
|
|
|
$(tr).find("td").each((index, td) => {
|
|
|
|
|
$(td).css("border-bottom", "0");
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 15:46:37 +08:00
|
|
|
|
// 設置某個電梯到某個樓層
|
2022-11-28 18:08:50 +08:00
|
|
|
|
setElevFloor = function (elevId, floId) {
|
|
|
|
|
let curFloId = this.curElevFloor[elevId];
|
|
|
|
|
let curSort = this.floors.filter(x => x.id == curFloId).map(x => x.sort)[0];
|
|
|
|
|
let tarSort = this.floors.filter(x => x.id == floId).map(x => x.sort)[0];
|
|
|
|
|
let gapFloor = tarSort - curSort;
|
2022-11-29 12:46:19 +08:00
|
|
|
|
let cssEle = [$(`#elevator-item-${elevId}`)[0], $(`#elevator-item-${elevId}`).prev("span.elevator-item-toup")[0], $(`#elevator-item-${elevId}`).next("span.elevator-item-todown")[0]]
|
|
|
|
|
if (this.movStatus[elevId] != 0) {
|
|
|
|
|
$(cssEle).css("transition", `transform ${1 / this.speed * Math.abs(gapFloor)}s cubic-bezier(0, 0, 0.62, 1) 0s`);
|
2022-11-28 18:08:50 +08:00
|
|
|
|
}
|
2022-12-02 15:46:37 +08:00
|
|
|
|
clearTimeout(this.setTimeout);
|
2022-11-28 18:08:50 +08:00
|
|
|
|
this.setTimeout = setTimeout(() => {
|
2022-11-29 12:46:19 +08:00
|
|
|
|
$(cssEle).css("transition", `transform ${1 / this.speed * Math.abs(gapFloor)}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`);
|
|
|
|
|
this.setEleUpDownStyle(elevId);
|
|
|
|
|
}, (1 / this.speed * Math.abs(gapFloor)) * 1000)
|
|
|
|
|
this.setEleUpDownStyle(elevId);
|
|
|
|
|
this.curElevFloor[elevId] = floId;
|
|
|
|
|
$(cssEle).css("transition", `transform ${1 / this.speed * Math.abs(gapFloor)}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`)
|
|
|
|
|
$(cssEle).css("transform", `translateY(${this.floorHeight * (this.floors.length - tarSort)}px)`);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 15:46:37 +08:00
|
|
|
|
// 設定現在電梯狀態 (往上/往下/停止)
|
2022-11-29 12:46:19 +08:00
|
|
|
|
setEleMovStatus = function (elevId,status) {
|
|
|
|
|
this.movStatus[elevId] = status;
|
2022-11-28 18:08:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 15:46:37 +08:00
|
|
|
|
// 電梯方框 往上或往下閃爍
|
2022-11-29 12:46:19 +08:00
|
|
|
|
setEleUpDownStyle = function (elevId) {
|
|
|
|
|
if (this.movStatus[elevId] == 1) {
|
2022-12-02 12:18:58 +08:00
|
|
|
|
$(`#elevator-item-${elevId}`).next("span.elevator-item-todown").removeClass("light-flash-c-bd")
|
2022-11-29 12:46:19 +08:00
|
|
|
|
$(`#elevator-item-${elevId}`).prev("span.elevator-item-toup").addClass("light-flash-c-bd")
|
|
|
|
|
.css("--flash-color-1", "#44ea8e").css("--flash-color-2", "rgba(255,255,255,0)");
|
|
|
|
|
} else if (this.movStatus[elevId] == 2) {
|
2022-12-02 12:18:58 +08:00
|
|
|
|
$(`#elevator-item-${elevId}`).prev("span.elevator-item-toup").removeClass("light-flash-c-bd")
|
2022-11-29 12:46:19 +08:00
|
|
|
|
$(`#elevator-item-${elevId}`).next("span.elevator-item-todown").addClass("light-flash-c-bd")
|
|
|
|
|
.css("--flash-color-1", "#44ea8e").css("--flash-color-2", "rgba(255,255,255,0)");
|
|
|
|
|
} else {
|
|
|
|
|
$(`#elevator-item-${elevId}`).prev("span.elevator-item-toup").removeClass("light-flash-c-bd");
|
|
|
|
|
$(`#elevator-item-${elevId}`).next("span.elevator-item-todown").removeClass("light-flash-c-bd");
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-28 18:08:50 +08:00
|
|
|
|
|
2022-12-02 15:46:37 +08:00
|
|
|
|
// 設定現在某個電梯所在樓層
|
2022-11-28 18:08:50 +08:00
|
|
|
|
setCurElevFloor = function (elevId,floId) {
|
|
|
|
|
this.curElevFloor[elevId] = floId;
|
|
|
|
|
}
|
2022-11-28 12:38:19 +08:00
|
|
|
|
|
2022-12-02 15:46:37 +08:00
|
|
|
|
// 重新繪製
|
2022-11-28 18:08:50 +08:00
|
|
|
|
redraw = function () {
|
|
|
|
|
$(this.ele).empty();
|
|
|
|
|
this.setTabFloor();
|
2022-11-29 12:46:19 +08:00
|
|
|
|
if (Object.keys(this.curElevFloor).length != 0) {
|
|
|
|
|
$.each(Object.keys(this.curElevFloor), (idx, elevKey) => {
|
|
|
|
|
this.setElevFloor(elevKey, this.curElevFloor[elevKey]);
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-11-28 18:08:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 16:45:20 +08:00
|
|
|
|
}
|
2022-12-09 18:20:41 +08:00
|
|
|
|
|
|
|
|
|
// 從數字週數轉為中文週數
|
|
|
|
|
function dayToChiDay(num) {
|
|
|
|
|
let chiDay = ["週日", "週一", "週二", "週三", "週四", "週五", "週六"];
|
|
|
|
|
return chiDay[num];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 取得現在或前後時間,輸出單位依據 type
|
|
|
|
|
function getTimeByType(type = null, cal = 0) {
|
|
|
|
|
let now = new Date();
|
|
|
|
|
return strToDate(now, type, cal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 取得某當下時間或前後時間,輸出單位依據 type
|
|
|
|
|
function strToDate(text, type = null, cal = 0) {
|
|
|
|
|
let calDay = function (_d, _cal) {
|
|
|
|
|
return new Date(_d.getTime() + (cal * 24 * 60 * 60 * 1000));
|
|
|
|
|
}
|
|
|
|
|
let tarDate = new Date(text);
|
|
|
|
|
let result = 0;
|
|
|
|
|
if (type == "year") {
|
|
|
|
|
result = calDay(tarDate, cal).getFullYear();
|
|
|
|
|
} else if (type == "month") {
|
|
|
|
|
result = calDay(tarDate, cal).getMonth();
|
|
|
|
|
} else if (type == "date") {
|
|
|
|
|
result = calDay(tarDate, cal).getDate();
|
|
|
|
|
} else if (type == "day") {
|
|
|
|
|
result = calDay(tarDate, cal).getDay();
|
|
|
|
|
} else {
|
|
|
|
|
result = calDay(tarDate, cal);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|