main.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. var DialogObject = {
  2. Open: function (container) {
  3. var total_height = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  4. $(".clearn").show().css("height", total_height + "px");
  5. container.show();
  6. var left = parseInt(container.width() / 2);
  7. left = -left;
  8. var top = parseInt(container.height() / 2);
  9. top = -top;
  10. container.css({
  11. "margin-left": left + "px",
  12. "margin-top": top + "px"
  13. });
  14. }
  15. }
  16. var mainObject = {
  17. init: function () {
  18. $("#stress_person_content").load("/static/module/childmodule/sub_bureau/stress_person.html",function (){
  19. //加载完后的处理
  20. });
  21. $(".monitor_person_info").load("/static/module/childmodule/sub_bureau/basic_person.html",function (){
  22. //加载完后的处理
  23. });
  24. var main_width = $(".monitor_center").width();
  25. var screen_width = document.documentElement.clientWidth;
  26. var wRate = (main_width / screen_width).toFixed(2);
  27. var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
  28. var setRootFontsize = function () {
  29. document.documentElement.style.fontSize = (wRate * 8) + "px";
  30. }
  31. if (document.addEventListener) {
  32. window.addEventListener(resizeEvt, setRootFontsize, false);
  33. document.addEventListener("DOMContentLoaded", setRootFontsize, false);
  34. }
  35. var screen_height = document.documentElement.clientHeight;
  36. $(".monitor_content").height(screen_height - 70);
  37. $(".monitor_content>div:first").show();
  38. var content_height = screen_height - 115;
  39. $(".body_content>div").height(content_height);
  40. var one_height = Math.ceil(content_height * 0.25);
  41. $(".side_left>div:first").height(one_height);
  42. var device_area = one_height - 160 - 32;
  43. //计算设备统计内容垂直居中
  44. $("#device_area").css("margin-top", Math.ceil(device_area / 2) + "px");
  45. var two_height = Math.ceil(content_height * 0.24);
  46. $(".side_left>div").eq(1).height(two_height);
  47. //计算数据统计内容垂直居中
  48. var margin_top = (two_height - 190) / 2 + 10;
  49. $(".total_field:first").css("margin-top", margin_top + "px");
  50. var three_height = content_height - one_height - two_height - 40;
  51. $(".side_left>div:last").height(three_height);
  52. $(".place_area").height(three_height - 50);
  53. $(".header_bar>span").off("click").on("click", function () {
  54. var container = $(this);
  55. var flag = container.attr("flag");
  56. var className = container.attr("class");
  57. if (className != "control_active" && flag != "control_active") {
  58. DialogObject.Open($("#dialog_common"));
  59. var title = "";
  60. if (flag == "control_center")
  61. title = "布控设置";
  62. else if (flag == "accompany_analyze") {
  63. title = "伴随分析人像设置"
  64. } else if (flag == "collision_analysis") {
  65. title = "碰撞分析人像设置"
  66. }
  67. $("#dialog_common .layout_title").html(title);
  68. }
  69. });
  70. //全局关闭窗口事件
  71. $(".layout_close").off("click").on("click", function () {
  72. var container = $(this).parents(".layout_dialog");
  73. container.hide();
  74. if (container.css("z-index") == 10000)
  75. $(".clearn").hide();
  76. });
  77. //设备统计
  78. mainObject.GetDeviceInfo();
  79. },
  80. //获取设备统计
  81. GetDeviceInfo: function () {
  82. $.getJSON(Global.AccessUrl + "/api/screen/device", {}, function (returnData) {
  83. if (returnData["returncode"] == 200) {
  84. var data = returnData["data"], row = null, total = 0, online = 0, html = "";
  85. for (var i = 0; i < data.length; i++) {
  86. row = data[i];
  87. total = row["total"];
  88. online = row["online"];
  89. total = total == null ? 0 : parseInt(total);
  90. online = online == null ? 0 : parseInt(online);
  91. if (row["identifying"] == "device") {
  92. $("#device_number").html(online + "/" + total);
  93. if (online < total) {
  94. $(".scout_progress").css("width", (online / total * 100) + "%");
  95. html = "<div class='offline_warning'></div><span class='offline_warning_text'>离线" + (total - online) + "台</span>";
  96. $("#offline_device").html(html);
  97. }
  98. } else if (row["identifying"] == "camera") {
  99. $("#camera_number").html(online + "/" + total);
  100. if (online < total) {
  101. $(".camera_progress").css("width", (online / total * 100) + "%");
  102. html = "<div class='offline_warning'></div><span class='offline_warning_text'>离线" + (total - online) + "台</span>";
  103. $("#offline_camera").html(html);
  104. }
  105. } else if (row["identifying"] == "door") {
  106. $("#door_number").html(online + "/" + total);
  107. if (online < total) {
  108. $(".door_progress").css("width", (online / total * 100) + "%");
  109. html = "<div class='offline_warning'></div><span class='offline_warning_text'>离线" + (total - online) + "台</span>";
  110. $("#offline_door").html(html);
  111. }
  112. }
  113. }
  114. }
  115. });
  116. },
  117. //获取监控人员列表
  118. ShowPersonInfo: function (personid) {
  119. $(".body_center").hide();
  120. $(".monitor_person_info").show();
  121. },
  122. AlwaysTimer: function () {
  123. var time = new Date();
  124. var year = time.getFullYear();
  125. var month = time.getMonth() + 1;
  126. var date = time.getDate();
  127. var hour = time.getHours();
  128. var minutes = time.getMinutes();
  129. var seconds = time.getSeconds();
  130. month = month < 10 ? "0" + month : month;
  131. date = date < 10 ? "0" + date : date;
  132. if (hour < 10) {
  133. hour = "0" + hour;
  134. }
  135. if (minutes < 10) {
  136. minutes = "0" + minutes;
  137. }
  138. if (seconds < 10) {
  139. seconds = "0" + seconds;
  140. }
  141. $(".week").html(year + "年" + month + "月" + date + "日 " + mainObject.GetWeek());
  142. $(".hour_minute").html(hour + ":" + minutes + ":" + seconds);
  143. setTimeout('mainObject.AlwaysTimer()', 1000);
  144. },
  145. GetWeek: function () {
  146. var time = new Date();
  147. var day = time.getDay();
  148. var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  149. return weeks[day];
  150. }
  151. }