var spaceDev = { layLoadIndex: {}, // 加载层标记 tipTimeOutObj: {} // 头部tip关闭定时器对象 }; $(function() { // 初始化时间 $("#toolDate").html(getNowFormatDate("simple")); //九宫格里面的格子点击事件,切换iframe的路径 $("#grid li").click(function() { menuClick($(this)); }) $("#grid li").mouseenter(function() { var anim = $(this).attr("anim") || "layui-anim-scale"; $(this).find(".grid-icon").addClass("layui-anim " + anim); }) $("#grid li").mouseleave(function() { var anim = $(this).attr("anim") || "layui-anim-scale"; $(this).find(".grid-icon").removeClass("layui-anim " + anim); }) $(".logo").click(function() { $("#content-iframe").attr("src", "/devService?action=welcome"); $("#grid li").removeClass("current"); }) // 等头像加载完成后添加头像边框 $("#user-icon").onload = loadIconBorder(); }) function menuClick(obj) { var menu_url = $(obj).attr("menu_url"); if (menu_url == undefined || menu_url.length == 0) { var msg = $(obj).attr("menu_msg"); msg = (msg && msg.length != 0) ? msg : "未填写 MSG 属性"; tip.warning(msg) return false; } $("#content-iframe").attr("src", menu_url); $("#grid li").removeClass("current"); $(obj).addClass("current"); showLoadLayer(); } function getNowFormatDate(type) { var date = new Date(); var seperator1 = "-"; var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var mydate = new Date(); var myddy = mydate.getDay(); //获取存储当前日期 var weekday = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]; var currentdate; if (type == "simple") { currentdate = month + "月" + strDate + "日  " + weekday[myddy]; } else { currentdate = year + "年" + month + "月" + strDate + "日  " + weekday[myddy]; } return currentdate; } function loadIconBorder() { setTimeout(function() { var icon = $("#user-icon"); var randomNum = iconIndex || Math.floor(Math.random() * 62); var b_p = "", t = 3, l = 21, s = 146; if (randomNum == 0) { b_p = "icon_border_bruin.png"; t = 0; l = 30; s = 120; } else if (randomNum == 1) { b_p = "icon_border_flower.png"; t = icon.offset().top - 56; l = icon.offset().left - 20; s = 120; } else { if (randomNum > 10 && randomNum.toString().startsWith("4")) { randomNum = "A" + randomNum.toString().substring(1); } b_p = "bili_" + randomNum + ".png"; } var icon_border = '
'; $(".login-message").append(icon_border); }, 500) } function showLoadLayer(msg) { msg = msg || '数据加载中,请稍后'; var layerIndex = layer.msg(msg, { time: 0, anim: -1, isOutAnim: false, icon: 16, shade: [0.1, '#fff'] }); spaceDev.layLoadIndex = layerIndex; } function hideLoadLayer() { layer.close(spaceDev.layLoadIndex); } function tips(msg, type, time) { var tipDiv = $("#tip-div"); $(tipDiv).removeClass("animated fadeInDownBig"); $(tipDiv).hide(); clearTimeout(spaceDev.tipTimeOutObj); time = time || 3000; msg = msg.replace(new RegExp(//g, "gm"), "<"); $("#sui-msg-div").attr("class", "sui-msg msg-" + type) $("#sui-msg-div-con").html(msg); $(tipDiv).addClass("animated fadeInDownBig"); var left = (topWin.innerWidth - $(tipDiv).width()) / 2; $(tipDiv).css("left", left + 'px'); $("#tip-div").show(); spaceDev.tipTimeOutObj = setTimeout(function() { if (!$("#tip-div").is(":hidden")) { $(tipDiv).removeClass("animated fadeInDownBig"); $("#tip-div").fadeOut(300); } }, time); } function fullScreen() { var el = document.documentElement; var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen; if (typeof rfs != "undefined" && rfs) { rfs.call(el); }; $(".fa-battery-2").show(); $(".fa-battery").hide(); } function exitScreen() { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } if (typeof cfs != "undefined" && cfs) { cfs.call(el); } $(".fa-battery-2").hide(); $(".fa-battery").show(); }