var YourTeam = YourTeam || {}; YourTeam.Utility = YourTeam.Utility || {}; class UrlHelper { constructor() { } /* @deprecated since version 0.2 * @description get the param value * @param {String} sName url param name * @return {String} * @author Darren Chen * @date 2018/04/18 */ param = function (sName) { this._sName = sName; let sReg = new RegExp("(^|&)" + _sName + "=([^&]*)(&|$)"); //創建一個含有目標参数的正則表達式對象 let sMatchTarget = window.location.search.substr(1).match(sReg); //匹配目標参數 if (sMatchTarget !== null) { return unescape(sMatchTarget[2]); } return null; //返回参數值 } /* @deprecated since version 0.2 * @description get the param value form the page`s url * @param {String} sName url param name * @param {String} sPageName url page name * @return {String} * @author Darren Chen * @date 2018/04/18 */ paramForPage = function (sName, sPageName) { this.prototype = fnGetUrlParam; let str = this.prototype(sName); this._sPageName = sPageName; if (str !== null && window.location.href.indexOf(_sPageName) !== -1) { return str; } //if (location.pathname) { // var sReg = new RegExp("(^|&)" + sName + "=([^&]*)(&|$)"); //創建一個含有目標参数的正則表達式對象 // var sMatchTarget = window.location.search.substr(1).match(sReg); //匹配目標参數 // if (sMatchTarget !== null && window.location.href.indexOf(sPageName) !== -1) { // return unescape(sMatchTarget[2]); // } //} return null; //返回参數值 } } YourTeam.Utility.Url = YourTeam.Utility.Url || UrlHelper; class UIOperat { constructor() { } /* @deprecated since version 0.1 * @description disabled all element in the page (close out some element) * @param {Array} aOutElementId close out element array * @return * @author Darren Chen * @date 2018/04/22 */ disabledAllElement = function (aOutElementId) { let aElement = document.getElementsByTagName("input"); fnSetAllElementDisabled(aElement, aOutElementId); aElement = document.getElementsByTagName("textarea"); fnSetAllElementDisabled(aElement, aOutElementId); aElement = document.getElementsByTagName("select"); fnSetAllElementDisabled(aElement, aOutElementId); aElement = document.getElementsByTagName("button"); fnSetAllElementDisabled(aElement, aOutElementId); //aElement = document.getElementsByTagName("label"); //for (var i = 0; i < aElement.length; i++) { // for (var ii = 0; ii < aOutElementId.length; ii++) { // if (aElement[i] != aOutElementId[ii]) // aElement[i].setAttribute("style", "pointer-events:none;display:block;"); // } //} } /* @deprecated since version 0.1 * @description set all element disabled (close out some element) * @param {Array} aElement element array * @param {Array} aOutElementId close out element array * @return * @author Darren Chen * @date 2018/04/22 */ setAllElementDisabled = function (aElement, aOutElementId) { for (let i = 0; i < aElement.length; i++) { for (let ii = 0; ii < aOutElementId.length; ii++) { if (aElement[i] !== aOutElementId[ii]) aElement[i].disabled = true; } } } /* @deprecated since version 0.1 * @description get checked checkboxs (array) for this project * @param {string} checkBoxName the delete checkbox`s element name * @return * @author Darren Chen * @date 2018/07/24 */ getCheckedArray(checkBoxName = "id") { return $('input:checkbox[name=' + checkBoxName + ']:checked').map(function () { return $(this).val(); }).get(); } } YourTeam.Utility.UIOperat = YourTeam.Utility.UIOperat || UIOperat; class UIData { constructor() { } /* @deprecated since version 0.1 * @description get checked checkboxs * @param {String} checkBoxName the delete checkbox`s element name * @return ex."551,676,991,188,457,125" * @author Darren Chen * @date 2018/07/24 */ checkBoxValueJoin = function (checkBoxName) { return $('input:checkbox[name=' + checkBoxName + ']:checked').map(function () { return $(this).val(); }).get().join(','); } /* @deprecated since version 0.1 * @description get checked checkboxs * @param {String} checkBoxName the delete checkbox`s element name * @return ex."551,676,991,188,457,125" * @author Darren Chen * @date 2018/07/24 */ checkBoxValueArray = function (checkBoxName) { let ary = []; $('input:checkbox[name=' + checkBoxName + ']:checked').each(function (index, element) { ary.push($(element).val()); }); return ary; } /* @deprecated since version 0.1 * @description Convrt Int To Float * @param {String} number ori number * @param {String} keepNum keep number after . * @return {String} * @author Darren Chen * @date 2019/12/31 */ convrtIntToFloat = function (number, keepNum) { let zeroNumber = fnPaddingRight("1", keepNum + 1, "0"); zeroNumber = parseInt(zeroNumber); return Math.round(parseFloat(number) * zeroNumber) / zeroNumber; } /* @deprecated since version 0.1 * @description The string Padding Left char * @param {String} str ori string * @param {Number} lenght will get string`s lenght * @param {String} add char * @return {String} * @author Darren Chen * @date 2019/12/31 */ paddingLeft = function (str, lenght, char) { if (str.length >= lenght) return str; else return fnPaddingLeft(char + str, lenght); } /* @deprecated since version 0.1 * @description The string Padding Right char * @param {String} str ori string * @param {Number} lenght will get string`s lenght * @param {String} add char * @return {String} * @author Darren Chen * @date 2019/12/31 */ paddingRight = function (str, lenght, char) { if (str.length >= lenght) return str; else return fnPaddingRight(str + char, lenght); } } YourTeam.Utility.UIData = YourTeam.Utility.UIData || UIData; class CookieHelper { constructor() { } /* @deprecated since version 0.1 * @description Create a simple cookie (The duration is preset to 2 days) * @param {String} name name with the cookie * @param {String} value value with the cookie * @return * @author Darren Chen * @date 2018/07/24 */ create = function (name, value) { let expires = new Date(); //有效時間保存 2 天 2*24*60*60*1000 expires.setTime(expires.getTime() + 172800000); document.cookie = name + "=" + escape(value) + ";expires=" + expires.toGMTString(); } /* @deprecated since version 0.1 * @description Get the cookie value by cookie name * @param {String} name name with the cookie * @return {String} * @author Darren Chen * @date 2018/07/24 */ get(name) { let arg = escape(name) + "="; let nameLen = arg.length; let cookieLen = document.cookie.length; let i = 0; while (i < cookieLen) { let j = i + nameLen; if (document.cookie.substring(i, j) === arg) return this.getByIndex(j); i = document.cookie.indexOf(" ", i) + 1; if (i === 0) break; } return null; } /* @deprecated since version 0.1 * @description Get the cookie value by index * @param {Number} index name with the cookie * @return {String} * @author Darren Chen * @date 2018/07/24 */ getByIndex(startIndex) { let endIndex = document.cookie.indexOf(";", startIndex); if (endIndex === -1) endIndex = document.cookie.length; return unescape(document.cookie.substring(startIndex, endIndex)); } /* @deprecated since version 0.1 * @description Remove the cookie by cookie name * @param {String} name name with the cookie * @return {Boolean} * @author Darren Chen * @date 2021/05/27 */ remove(name) { document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"; if (this.get(name) === null || this.get(name) === "undefined") { return true; } return false; } } YourTeam.Utility.Cookie = YourTeam.Utility.Cookie || CookieHelper; var mathHelperRandomNotRepeatNum = []; class MathHelper { constructor() { } /* * @deprecated since version 0.1 * @description 取得隨機值 * @param {Number} min 最小值 * @param {Number} max 最大值 * @returns {Number} */ random(min, max) { return Math.floor(Math.random() * max) + min; } /* * @deprecated since version 0.1 * @description 取得GUID * @param {String} str 分隔符號,預設值'-'。 * @param {Boolean} isUpperCase 是否大寫,預設值true。 * @returns {String} */ guid(str = null, isUpperCase = true) { let strGuid = 'xxxxxxxx-xxxx-0xxx-yxyx-xxxxxxxxxxxx'; if (str) { strGuid = strGuid.replace('-', str); } strGuid = strGuid.replace(/[xy]/g, function (c) { var string = Math.random() * 16 | 0, v = c === 'x' ? string : (string & 0x3 | 0x8); return string.toString(16); }); if (isUpperCase) { strGuid.toUpperCase(); } return strGuid; } /* * @deprecated since version 0.1 * @description 四捨五入取小數點後2位 * @param {Number} num 數值 * @returns {Number} */ roundRight2p(num) { return +(Math.round(num + "e+2") + "e-2"); } /* * @deprecated since version 0.1 * @description 四捨五入取小數點後2位 * @param {Number} num 數值 * @returns {Number} */ roundRight2p2(num) { let m = Number((Math.abs(num) * 100).toPrecision(15)); return Math.round(m) / 100 * Math.sign(num); } } YourTeam.Utility.Math = YourTeam.Utility.Math || MathHelper; class DateHelper { constructor() { } /* * @deprecated since version 0.1 * @description 取得現在時間(yyyy-MM-dd) * @param {Boolean} isTwYear it`s Taiwan year? * @returns {String} */ getNow = function (isTwYear = false) { let d = new Date(); let year = isTwYear ? d.getFullYear() - 1911 : d.getFullYear(); let month = d.getMonth() + 1; let day = d.getDate(); let now = year + '-' + (month < 10 ? '0' : '') + month + '-' + (day < 10 ? '0' : '') + day; return now; } /* * @deprecated since version 0.1 * @description 取得日期時間(2020/02/02 PM 18:05:25) * @param {Boolean} isTwYear it`s Taiwan year? * @param {String} dateInterval 最小值 * @param {Boolean} isPadZero 最大值 * @param {Number} timeTagType 時間前戳標記 1:AM/PM 2:上午/下午 * @returns {String} */ getNowHaveTimeTag = function (isTwYear = false, dateInterval = '/', isPadZero = true, timeTagType = 1) { let now = new Date(); let years = isTwYear ? now.getFullYear() - 1911 : now.getFullYear(); let months = now.getMonth(); let days = now.getDay(); let hours = now.getHours(); let minutes = now.getMinutes(); let seconds = now.getSeconds(); let dateValue = years; let timeValue = ((hours >= 12) ? "下午 " : "上午 "); if (timeTagType === 2) timeValue = ((hours >= 12) ? "AM " : "PM "); if (isPadZero) { dateValue += (dateInterval + ((months < 10) ? "0" : "") + months); dateValue += (dateInterval + ((days < 10) ? "0" : "") + days); timeValue += ((hours > 12) ? "0" + (hours - 12) : hours); timeValue += ((minutes < 10) ? ":0" : ":") + minutes; timeValue += ((seconds < 10) ? ":0" : ":") + seconds; } else { dateValue += (dateInterval + months); dateValue += (dateInterval + days); timeValue += ((hours > 12) ? hours - 12 : hours); timeValue += minutes; timeValue += seconds; } return dateValue + " " + timeValue; } /* * @deprecated since version 0.1 * @description 取得日期時間(2020/02/02 18:05:25) * @param {Boolean} isTwYear it`s Taiwan year? * @param {String} dateInterval 日期間隔字元 * @param {Boolean} isPadZero 是否補0 * @returns {String} 回傳時間字串 */ getNowChangeInterval = function (isTwYear = false, dateInterval = '/', isPadZero = true) { let today = new Date(); let year = isTwYear ? today.getFullYear() - 1911 : today.getFullYear(); let currentDateTime = year + dateInterval + ((isPadZero && today.getMonth() + 1 < 10) ? '0' : '') + (today.getMonth() + 1) + dateInterval + ((isPadZero && today.getDate() < 10) ? '0' : '') + today.getDate() + ' ' + ((isPadZero && today.getHours() < 10) ? '0' : '') + today.getHours() + ':' + ((isPadZero && today.getMinutes() < 10) ? '0' : '') + today.getMinutes(); return currentDateTime; } /* * @deprecated since version 0.1 * @description 取得加減的日期時間(2020/02/02 18:05:25) * @param {Boolean} isTwYear it`s Taiwan year? * @param {String} dateInterval 日期間隔字元 * @param {Boolean} isPadZero 是否補0 * @returns {String} 回傳時間字串 */ getChangeDateTime(isTwYear = false, dateInterval = '/', addYears = 0, addMonths = 0, addDays = 0, isPadZero = true) { let today = new Date(); let year = isTwYear ? today.getFullYear() - 1911 : today.getFullYear(); if (addYears > year || addMonths > today.getMonth() || addDays > today.getDate()) { return false; } let date = (year + addYears) + dateInterval + ((isPadZero && today.getMonth() + addMonths + 1 < 10) ? '0' : '') + (today.getMonth() + addMonths + 1) + dateInterval + ((isPadZero && today.getDate() + addDays < 10) ? '0' : '') + (today.getDate() + addDays); return date; } /* * @deprecated since version 0.1 * @description 取得禮拜/週幾(禮拜五) * @param {String} dayPreString 前置詞 (禮拜/週/周) * @returns {String} 回傳時間字串 */ getWeekDay(dayPreString = "") { let day = ""; let day_list = ['日', '一', '二', '三', '四', '五', '六']; let today = new Date(); let dayGet = today.getDay(); // or "new Date().getDay()"; if (dayPreString === "") { day = "(" + day_list[dayGet] + ")"; } else { day = dayPreString + day_list[dayGet]; } return day; } /* * @deprecated since version 0.1 * @description 取得月份天數 * @param {Number} year 年份 (def null) * @param {Number} month 月份 (def null) * @returns {Number} 回傳月份天數 */ getMonthDayCount(year=null,month=null) { let myYear = year; let myMonth = month; let myDate,myDayCount; if (!myYear) { myYear = new Date().getFullYear(); } if (!myMonth) { myMonth = new Date().getMonth(); } //宣告日期物件 myDate = new Date(myYear, myMonth+1, 0); //取得天數 myDayCount = myDate.getDate(); return daycount; } /* * @deprecated since version 0.1 * @description 取得月份最後一天的日期字串 * @param {Number} year 年份 (def null) * @param {Number} month 月份 (def null) * @returns {String} 回傳月份天數字串 */ getMonthLastDateStr(year = null, month = null) { let myYear = year; let myMonth = month; let daycount; if (!myYear) { myYear = new Date().getFullYear(); } if (!myMonth) { myMonth = new Date().getMonth(); } daycount = this.getMonthDayCount(year, month); let myMonthLastDate = myYear + "/" + (myMonth < 10) ? "0" : "" + myMonth + "/" + (daycount < 10) ? "0" : "" + daycount; return myMonthLastDate; } } YourTeam.Utility.DateHelper = YourTeam.Utility.DateHelper || DateHelper; class File { constructor() { } readAndPreviewImages(files, containerId, imgWidth = null, imgHeight = null, frontHtml = null, backHtml = null, funDoSomeThing = null, limitMaxSize = null, limitMinSize = 0,limitFun = null) { let htmlImg = ""; let container = document.getElementById(containerId); let width = imgWidth ? imgWidth + "px" : "auto"; let height = imgHeight ? imgHeight + "px" : "auto"; let myMath = new YourTeam.Utility.Math(); let myFile = new YourTeam.Utility.File(); let strExtName = "", strOrgName = ""; if (files.length > 0) { for (let i = 0; i < files.length; i++) { let file = files[i]; if (limitMaxSize != null) { if (file.size / 1024 < limitMinSize || file.size / 1024 > limitMaxSize) { limitFun ? limitFun() : ""; return false } } htmlImg = ""; let guid = myMath.guid().replace(' ', ''); file.guid = guid; if (/\.(jpe?g|png|gif)$/i.test(file.name)) { let reader = new FileReader(); reader.addEventListener("load", function () { let image = new Image(); let src = this.result; image.src = this.result; image.onload = function () { strExtName = myFile.getFileExtension(file.name); strOrgName = (strExtName === null || strExtName === "") ? file.name : file.name.replace('.' + strExtName, ''); htmlImg = frontHtml + '' + backHtml; container.insertAdjacentHTML("afterBegin", htmlImg); //$("[name=" + removeClickTagName + "]").on("click", function (e) { // e.preventDefault(); // $(this).closest(removeTag).remove(); //}); if (i === files.length - 1 && funDoSomeThing) { funDoSomeThing(); } } }); reader.readAsDataURL(file); } else { if (showAlert) { showAlert("danger", "只支援圖片格式"); } else { alert("只支援圖片格式"); } } } } else { let file = files; if (limitMaxSize != null) { if (file.size / 1024 < limitMinSize || file.size / 1024 > limitMaxSize) { limitFun ? limitFun() : ""; return false } } htmlImg = ""; let guid = myMath.guid().replace(' ', ''); file.guid = guid; if (/\.(jpe?g|png|gif)$/i.test(file.name)) { let reader = new FileReader(); reader.addEventListener("load", function () { let image = new Image(); let src = this.result; image.src = this.result; image.onload = function () { strExtName = myFile.getFileExtension(file.name); strOrgName = (strExtName === null || strExtName === "") ? file.name : file.name.replace('.' + strExtName, ''); htmlImg = frontHtml + '' + backHtml; container.insertAdjacentHTML("afterBegin", htmlImg); //$("[name=" + removeClickTagName + "]").on("click", function (e) { // e.preventDefault(); // $(this).closest(removeTag).remove(); //}); if (funDoSomeThing) { funDoSomeThing(); } } }); reader.readAsDataURL(file); } else { if (showAlert) { showAlert("danger", "只支援圖片格式"); } else { alert("只支援圖片格式"); } } } } readAndPreviewFiles(files, containerId, imgWidth = null, imgHeight = null, frontHtml = null, backHtml = null, funDoSomeThing = null) { let htmlImg = ""; let container = document.getElementById(containerId); let width = imgWidth ? imgWidth + "px" : "128px"; let height = imgHeight ? imgHeight + "px" : "86px"; let myMath = new YourTeam.Utility.Math(); let myFile = new YourTeam.Utility.File(); let strExtName = "", strOrgName = "", strSaveName = ""; if (files.length) { for (let i = 0; i < files.length; i++) { let file = files[i]; htmlImg = ""; let guid = myMath.guid().replace(' ', ''); file.guid = guid; //alert(/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(file.name)); if (/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(file.name)) { if (file.size == 0) { //檔案大小為0時不會產生base64,需防呆 showAlert("danger", "無法上傳大小為0的檔案"); return false; } //先新增a標籤 在套上src 可能解決多檔案上傳時無法讀取到最後上傳檔案的問題 strSaveName = guid; strExtName = myFile.getFileExtension(file.name); strOrgName = (strExtName === null || strExtName === "") ? file.name : file.name.replace('.' + strExtName, ''); htmlImg = frontHtml + '' + strOrgName + '.' + strExtName + '' + backHtml; container.insertAdjacentHTML("afterBegin", htmlImg); let reader = new FileReader(); reader.addEventListener("load", function (event) { $($(container).find("a")[i]).attr("href", this.result); if (i === files.length - 1 && funDoSomeThing) { funDoSomeThing(); } }); reader.readAsDataURL(file); } else { if (showAlert) { showAlert("danger", "只支援文件格式"); } else { alert("只支援文件格式"); } } } } else { let file = files; htmlImg = ""; let guid = myMath.guid().replace(' ', ''); file.guid = guid; //alert(/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(file.name)); if (/\.(xls?x|doc?x|ptt?x|pdf|zip|rar|7zip|txt|odt|xml|rtf|ods|odp|pps?x)$/i.test(file.name)) { if (file.size == 0) { //檔案大小為0時不會產生base64,需防呆 showAlert("danger", "無法上傳大小為0的檔案"); return false; } //先新增a標籤 在套上src 可能解決多檔案上傳時無法讀取到最後上傳檔案的問題 strSaveName = guid; strExtName = myFile.getFileExtension(file.name); strOrgName = (strExtName === null || strExtName === "") ? file.name : file.name.replace('.' + strExtName, ''); htmlImg = frontHtml + '' + strOrgName + '.' + strExtName + '' + backHtml; container.insertAdjacentHTML("afterBegin", htmlImg); let reader = new FileReader(); reader.addEventListener("load", function (event) { $($(container).find("a")).attr("href", this.result); if (funDoSomeThing) { funDoSomeThing(); } }); reader.readAsDataURL(file); } else { if (showAlert) { showAlert("danger", "只支援文件格式"); } else { alert("只支援文件格式"); } } } } async getBase64Image(path, callback) { //生成canvas var canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); var img = new Image(); img.src = path; img.setAttribute("crossOrigin", "Anonymous"); img.onload = await function () { return new Promise((resolve) => { //默認按比例壓縮 var w = this.width, h = this.height; var quality = 0.95; // 默認圖片質量為0.7 // 創建屬性節點 canvas.setAttribute("width", w); canvas.setAttribute("height", h); ctx.drawImage(this, 0, 0, w, h); // quality值越小,所繪制出的圖像越模糊 var base64 = canvas.toDataURL('image/jpeg', quality); // 回調函數返回base64的值 callback(base64); resolve(); }) }; } getFileExtension(filename) { return filename.slice((filename.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase(); } } YourTeam.Utility.File = YourTeam.Utility.File || File; /* @deprecated since version 0.1 * @description jQuery Ajax Cors Setings (JSONP) * @return * @author Darren Chen * @date 2018/07/24 */ ///// //var script = document.createElement("script"); //Make a script DOM node //script.src = "/Scripts/YourTeam/js/yourteam.jq.ajax.cors.js"; //Set it's src to the provided URL //document.head.appendChild(script); //Add it to the end of the head section of the page (could change 'head' to 'body' to add it to the end of the body section instead) ///* @deprecated since version 0.2 //* @description get the param value //* @param {String} sName url param name //* @return {String} //* @author Darren Chen //* @date 2018/04/18 //*/ //function fnGetUrlParam(sName) { // this._sName = sName; // let sReg = new RegExp("(^|&)" + _sName + "=([^&]*)(&|$)"); //創建一個含有目標参数的正則表達式對象 // let sMatchTarget = window.location.search.substr(1).match(sReg); //匹配目標参數 // if (sMatchTarget !== null) { // return unescape(sMatchTarget[2]); // } // return null; //返回参數值 //} ///* @deprecated since version 0.2 //* @description get the param value form the page`s url //* @param {String} sName url param name //* @param {String} sPageName url page name //* @return {String} //* @author Darren Chen //* @date 2018/04/18 //*/ //function fnGetUrlParamForPage(sName, sPageName) { // this.prototype = fnGetUrlParam; // let str = this.prototype(sName); // this._sPageName = sPageName; // if (str !== null && window.location.href.indexOf(_sPageName) !== -1) { // return str; // } // //if (location.pathname) { // // var sReg = new RegExp("(^|&)" + sName + "=([^&]*)(&|$)"); //創建一個含有目標参数的正則表達式對象 // // var sMatchTarget = window.location.search.substr(1).match(sReg); //匹配目標参數 // // if (sMatchTarget !== null && window.location.href.indexOf(sPageName) !== -1) { // // return unescape(sMatchTarget[2]); // // } // //} // return null; //返回参數值 //} ///* @deprecated since version 0.1 //* @description disabled all element in the page (close out some element) //* @param {Array} aOutElementId close out element array //* @return //* @author Darren Chen //* @date 2018/04/22 //*/ //function fnDisabledAllElement(aOutElementId) { // let aElement = document.getElementsByTagName("input"); // fnSetAllElementDisabled(aElement, aOutElementId); // aElement = document.getElementsByTagName("textarea"); // fnSetAllElementDisabled(aElement, aOutElementId); // aElement = document.getElementsByTagName("select"); // fnSetAllElementDisabled(aElement, aOutElementId); // aElement = document.getElementsByTagName("button"); // fnSetAllElementDisabled(aElement, aOutElementId); // //aElement = document.getElementsByTagName("label"); // //for (var i = 0; i < aElement.length; i++) { // // for (var ii = 0; ii < aOutElementId.length; ii++) { // // if (aElement[i] != aOutElementId[ii]) // // aElement[i].setAttribute("style", "pointer-events:none;display:block;"); // // } // //} //} ///* @deprecated since version 0.1 //* @description set all element disabled (close out some element) //* @param {Array} aElement element array //* @param {Array} aOutElementId close out element array //* @return //* @author Darren Chen //* @date 2018/04/22 //*/ //function fnSetAllElementDisabled(aElement, aOutElementId) { // for (let i = 0; i < aElement.length; i++) { // for (let ii = 0; ii < aOutElementId.length; ii++) { // if (aElement[i] !== aOutElementId[ii]) // aElement[i].disabled = true; // } // } //} ///* @deprecated since version 0.1 //* @description get checked checkboxs //* @param {String} checkBoxName the delete checkbox`s element name //* @return //* @author Darren Chen //* @date 2018/07/24 //*/ //function fnGetCheckedValue(checkBoxName) { // return $('input:checkbox[name=' + checkBoxName + ']:checked').map(function () { // return $(this).val(); // }).get().join(','); //} ///* @deprecated since version 0.1 //* @description Create a simple cookie (The duration is preset to 2 days) //* @param {String} name name with the cookie //* @param {String} value value with the cookie //* @return //* @author Darren Chen //* @date 2018/07/24 //*/ //function fnCreateCookie(name, value) { // let expires = new Date(); // //有效時間保存 2 天 2*24*60*60*1000 // expires.setTime(expires.getTime() + 172800000); // document.cookie = name + "=" + escape(value) + ";expires=" + expires.toGMTString(); //} ///* @deprecated since version 0.1 //* @description Get the cookie value by cookie name //* @param {String} name name with the cookie //* @return //* @author Darren Chen //* @date 2018/07/24 //*/ //function fnGetCookie(name) { // let arg = escape(name) + "="; // let nameLen = arg.length; // let cookieLen = document.cookie.length; // let i = 0; // while (i < cookieLen) { // let j = i + nameLen; // if (document.cookie.substring(i, j) === arg) return getCookieValueByIndex(j); // i = document.cookie.indexOf(" ", i) + 1; // if (i === 0) break; // } // return null; //} ///* @deprecated since version 0.1 //* @description Get the cookie value by index //* @param {Number} index name with the cookie //* @return //* @author Darren Chen //* @date 2018/07/24 //*/ //function fnGetCookieValueByIndex(startIndex) { // let endIndex = document.cookie.indexOf(";", startIndex); // if (endIndex === -1) endIndex = document.cookie.length; // return unescape(document.cookie.substring(startIndex, endIndex)); //} ///* //* @deprecated since version 0.1 //* @description 取得隨機值 //* @param {Number} min 最小值 //* @param {Number} max 最大值 //* @returns {Number} //*/ //function fnGetRandom(min, max) { // return Math.floor(Math.random() * max) + min; //} ///* // * @deprecated since version 0.1 // * @description 取得現在時間(yyyy-MM-dd) // * @param {Boolean} isTwYear it`s Taiwan year? // * @returns {String} // */ //function fnGetNow(isTwYear = false) { // let d = new Date(); // let year = isTwYear ? d.getFullYear() - 1911 : d.getFullYear(); // let month = d.getMonth() + 1; // let day = d.getDate(); // let now = year + '-' + // (month < 10 ? '0' : '') + month + '-' + // (day < 10 ? '0' : '') + day; // return now; //} ///* // * @deprecated since version 0.1 // * @description 取得日期時間(2020/02/02 PM 18:05:25) // * @param {Boolean} isTwYear it`s Taiwan year? // * @param {String} dateInterval 最小值 // * @param {Boolean} isPadZero 最大值 // * @param {Number} timeTagType 時間前戳標記 1:AM/PM 2:上午/下午 // * @returns {String} // */ //function fnShowDateTimeNow(isTwYear = false, dateInterval = '/', isPadZero = true, timeTagType = 1) { // let now = new Date(); // let years = isTwYear ? now.getFullYear() - 1911 : now.getFullYear(); // let months = now.getMonth(); // let days = now.getDay(); // let hours = now.getHours(); // let minutes = now.getMinutes(); // let seconds = now.getSeconds(); // let dateValue = years; // let timeValue = ((hours >= 12) ? "下午 " : "上午 "); // if (timeTagType === 2) timeValue = ((hours >= 12) ? "AM " : "PM "); // if (isPadZero) { // dateValue += (dateInterval + ((months < 10) ? "0" : "") + months); // dateValue += (dateInterval + ((days < 10) ? "0" : "") + days); // timeValue += ((hours > 12) ? "0" + (hours - 12) : hours); // timeValue += ((minutes < 10) ? ":0" : ":") + minutes; // timeValue += ((seconds < 10) ? ":0" : ":") + seconds; // } // else { // dateValue += (dateInterval + months); // dateValue += (dateInterval + days); // timeValue += ((hours > 12) ? hours - 12 : hours); // timeValue += minutes; // timeValue += seconds; // } // return dateValue + " " + timeValue; //} ///* // * @deprecated since version 0.1 // * @description 取得日期時間(2020/02/02 18:05:25) // * @param {Boolean} isTwYear it`s Taiwan year? // * @param {String} dateInterval 日期間隔字元 // * @param {Boolean} isPadZero 是否補0 // * @returns {string} 回傳時間字串 // */ //function fnGetDateTimeNow(isTwYear = false, dateInterval = '/', isPadZero = true) { // let today = new Date(); // let year = isTwYear ? today.getFullYear() - 1911 : today.getFullYear(); // let currentDateTime = // year + dateInterval + ((isPadZero && today.getMonth() + 1 < 10) ? '0' : '') + // (today.getMonth() + 1) + dateInterval + ((isPadZero && today.getDate() < 10) ? '0' : '') + // today.getDate() + ' ' + ((isPadZero && today.getHours() < 10) ? '0' : '') + // today.getHours() + ':' + ((isPadZero && today.getMinutes() < 10) ? '0' : '') + // today.getMinutes(); // return currentDateTime; //} ///* // * @deprecated since version 0.1 // * @description 取得加減的日期時間(2020/02/02 18:05:25) // * @param {Boolean} isTwYear it`s Taiwan year? // * @param {String} dateInterval 日期間隔字元 // * @param {Boolean} isPadZero 是否補0 // * @returns {string} 回傳時間字串 // */ //function fnGetDate(isTwYear = false, dateInterval = '/', addYears = 0, addMonths = 0, addDays = 0, isPadZero = true) { // let today = new Date(); // let year = isTwYear ? today.getFullYear() - 1911 : today.getFullYear(); // if (addYears > year || addMonths > today.getMonth() || addDays > today.getDate()) { // return false; // } // let date = // (year + addYears) + dateInterval + ((isPadZero && today.getMonth() + addMonths + 1 < 10) ? '0' : '') + // (today.getMonth() + addMonths + 1) + dateInterval + ((isPadZero && today.getDate() + addDays < 10) ? '0' : '') + // (today.getDate() + addDays); // return date; //} ///* // * @deprecated since version 0.1 // * @description 取得禮拜/週幾(禮拜五) // * @param {String} dayPreString 前置詞 (禮拜/週/周) // * @returns {string} 回傳時間字串 // */ //function fnGetDay(dayPreString = "") { // let day = ""; // let day_list = ['日', '一', '二', '三', '四', '五', '六']; // let today = new Date(); // let dayGet = today.getDay(); // or "new Date().getDay()"; // if (dayPreString === "") { // day = "(" + day_list[dayGet] + ")"; // } else { // day = dayPreString + day_list[dayGet]; // } // return day; //} ///* @deprecated since version 0.1 //* @description Convrt Int To Float //* @param {String} number ori number //* @param {String} keepNum keep number after . //* @return {String} //* @author Darren Chen //* @date 2019/12/31 //*/ //function fnConvrtIntToFloat(number, keepNum) { // let zeroNumber = fnPaddingRight("1", keepNum + 1, "0"); // zeroNumber = parseInt(zeroNumber); // return Math.round(parseFloat(number) * zeroNumber) / zeroNumber; //} ///* @deprecated since version 0.1 //* @description The string Padding Left char //* @param {String} str ori string //* @param {Number} lenght will get string`s lenght //* @param {String} add char //* @return {String} //* @author Darren Chen //* @date 2019/12/31 //*/ //function fnPaddingLeft(str, lenght, char) { // if (str.length >= lenght) // return str; // else // return fnPaddingLeft(char + str, lenght); //} ///* @deprecated since version 0.1 //* @description The string Padding Right char //* @param {String} str ori string //* @param {Number} lenght will get string`s lenght //* @param {String} add char //* @return {String} //* @author Darren Chen //* @date 2019/12/31 //*/ //function fnPaddingRight(str, lenght, char) { // if (str.length >= lenght) // return str; // else // return fnPaddingRight(str + char, lenght); //}