index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. var spaceDev = {
  2. layLoadIndex: {}, // 加载层标记
  3. tipTimeOutObj: {} // 头部tip关闭定时器对象
  4. };
  5. $(function() {
  6. // 初始化时间
  7. $("#toolDate").html(getNowFormatDate("simple"));
  8. //九宫格里面的格子点击事件,切换iframe的路径
  9. $("#grid li").click(function() {
  10. menuClick($(this));
  11. })
  12. $("#grid li").mouseenter(function() {
  13. var anim = $(this).attr("anim") || "layui-anim-scale";
  14. $(this).find(".grid-icon").addClass("layui-anim " + anim);
  15. })
  16. $("#grid li").mouseleave(function() {
  17. var anim = $(this).attr("anim") || "layui-anim-scale";
  18. $(this).find(".grid-icon").removeClass("layui-anim " + anim);
  19. })
  20. $(".logo").click(function() {
  21. $("#content-iframe").attr("src", "/devService?action=welcome");
  22. $("#grid li").removeClass("current");
  23. })
  24. // 等头像加载完成后添加头像边框
  25. $("#user-icon").onload = loadIconBorder();
  26. })
  27. function menuClick(obj) {
  28. var menu_url = $(obj).attr("menu_url");
  29. if (menu_url == undefined || menu_url.length == 0) {
  30. var msg = $(obj).attr("menu_msg");
  31. msg = (msg && msg.length != 0) ? msg : "未填写 MSG 属性";
  32. tip.warning(msg)
  33. return false;
  34. }
  35. $("#content-iframe").attr("src", menu_url);
  36. $("#grid li").removeClass("current");
  37. $(obj).addClass("current");
  38. showLoadLayer();
  39. }
  40. function getNowFormatDate(type) {
  41. var date = new Date();
  42. var seperator1 = "-";
  43. var year = date.getFullYear();
  44. var month = date.getMonth() + 1;
  45. var strDate = date.getDate();
  46. if (month >= 1 && month <= 9) {
  47. month = "0" + month;
  48. }
  49. if (strDate >= 0 && strDate <= 9) {
  50. strDate = "0" + strDate;
  51. }
  52. var mydate = new Date();
  53. var myddy = mydate.getDay(); //获取存储当前日期
  54. var weekday = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  55. var currentdate;
  56. if (type == "simple") {
  57. currentdate = month + "月" + strDate + "日&nbsp;&nbsp;" + weekday[myddy];
  58. } else {
  59. currentdate = year + "年" + month + "月" + strDate + "日&nbsp;&nbsp;" + weekday[myddy];
  60. }
  61. return currentdate;
  62. }
  63. function loadIconBorder() {
  64. setTimeout(function() {
  65. var icon = $("#user-icon");
  66. var randomNum = iconIndex || Math.floor(Math.random() * 62);
  67. var b_p = "",
  68. t = 3,
  69. l = 21,
  70. s = 146;
  71. if (randomNum == 0) {
  72. b_p = "icon_border_bruin.png";
  73. t = 0;
  74. l = 30;
  75. s = 120;
  76. } else if (randomNum == 1) {
  77. b_p = "icon_border_flower.png";
  78. t = icon.offset().top - 56;
  79. l = icon.offset().left - 20;
  80. s = 120;
  81. } else {
  82. if (randomNum > 10 && randomNum.toString().startsWith("4")) {
  83. randomNum = "A" + randomNum.toString().substring(1);
  84. }
  85. b_p = "bili_" + randomNum + ".png";
  86. }
  87. var icon_border = '<div class="layui-anim layui-anim-fadein" style="width: ' + s + 'px; height: ' + s + 'px;' +
  88. 'position: absolute; background: url(/dev/images/icon-border/' + b_p + ') no-repeat; ' +
  89. 'background-size: ' + s + 'px ' + s + 'px; top:' + t + 'px; left: ' + l + 'px"></div>';
  90. $(".login-message").append(icon_border);
  91. }, 500)
  92. }
  93. function showLoadLayer(msg) {
  94. msg = msg || '数据加载中,请稍后';
  95. var layerIndex = layer.msg(msg, {
  96. time: 0,
  97. anim: -1,
  98. isOutAnim: false,
  99. icon: 16,
  100. shade: [0.1, '#fff']
  101. });
  102. spaceDev.layLoadIndex = layerIndex;
  103. }
  104. function hideLoadLayer() {
  105. layer.close(spaceDev.layLoadIndex);
  106. }
  107. function tips(msg, type, time) {
  108. var tipDiv = $("#tip-div");
  109. $(tipDiv).removeClass("animated fadeInDownBig");
  110. $(tipDiv).hide();
  111. clearTimeout(spaceDev.tipTimeOutObj);
  112. time = time || 3000;
  113. msg = msg.replace(new RegExp(/</g, "gm"), "&gt;").replace(new RegExp(/>/g, "gm"), "&lt;");
  114. $("#sui-msg-div").attr("class", "sui-msg msg-" + type)
  115. $("#sui-msg-div-con").html(msg);
  116. $(tipDiv).addClass("animated fadeInDownBig");
  117. var left = (topWin.innerWidth - $(tipDiv).width()) / 2;
  118. $(tipDiv).css("left", left + 'px');
  119. $("#tip-div").show();
  120. spaceDev.tipTimeOutObj = setTimeout(function() {
  121. if (!$("#tip-div").is(":hidden")) {
  122. $(tipDiv).removeClass("animated fadeInDownBig");
  123. $("#tip-div").fadeOut(300);
  124. }
  125. }, time);
  126. }
  127. function fullScreen() {
  128. var el = document.documentElement;
  129. var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen;
  130. if (typeof rfs != "undefined" && rfs) {
  131. rfs.call(el);
  132. };
  133. $(".fa-battery-2").show();
  134. $(".fa-battery").hide();
  135. }
  136. function exitScreen() {
  137. if (document.exitFullscreen) {
  138. document.exitFullscreen();
  139. } else if (document.mozCancelFullScreen) {
  140. document.mozCancelFullScreen();
  141. } else if (document.webkitCancelFullScreen) {
  142. document.webkitCancelFullScreen();
  143. } else if (document.msExitFullscreen) {
  144. document.msExitFullscreen();
  145. }
  146. if (typeof cfs != "undefined" && cfs) {
  147. cfs.call(el);
  148. }
  149. $(".fa-battery-2").hide();
  150. $(".fa-battery").show();
  151. }