/* Copyright 2020 The DedeBIZ.COM Authors. All rights reserved. license that can be found in the LICENSE file. */ // 滚动到页面顶部 function gotop() { $('html, body').animate({ scrollTop: 0 }, 'slow'); } //读写cookie函数 function GetCookie(c_name) { if (document.cookie.length > 0) { c_start = document.cookie.indexOf(c_name + "=") if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) { c_end = document.cookie.length; } return unescape(document.cookie.substring(c_start, c_end)); } } return null } function SetCookie(c_name, value, expiredays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + expiredays); document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()); //使设置的有效时间正确。增加toGMTString() } //------------------------------------------------------------------------------------------- // 全局消息提示框 //------------------------------------------------------------------------------------------- //生成一个随机ID function guid() { function S4() { return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); } return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4()); } //函数会返回一个modalID,通过这个ID可自已定义一些方法 //这里用到了一个展开语法 //https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Spread_syntax function ShowMsg(content, ...args) { title = "系统提示"; if (typeof content == "undefined") content = ""; modalID = guid(); var footer = ``; var noClose = false; if (args.length == 1) { // 存在args参数 if (typeof args[0].title !== 'undefined' && args[0].title != "") { title = args[0].title; } if (typeof args[0].footer !== 'undefined' && args[0].footer != "") { footer = args[0].footer; } if (typeof args[0].noClose !== 'undefined' && args[0].noClose == true) { noClose = true; } } String.prototype.replaceAll = function (s1, s2) { return this.replace(new RegExp(s1, "gm"), s2); } footer = footer.replaceAll("~modalID~", modalID); content = content.replaceAll("~modalID~", modalID); var modal = `