8191c70d453dbbc4a7e49208a2343a26fbfb6a8c.svn-base 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /**
  2. * Created by zhumingyue on 2016/2/27.
  3. */
  4. var pos = {afterX:0,afterY:0,nowX:0,nowY:0,divX:0,divY:0};
  5. var un = "";
  6. var su = null;
  7. $(function(){
  8. // setWH();
  9. // $(window).resize(function(){
  10. //// setWH();
  11. // });
  12. // $("body").mouseover(function(){
  13. // $(".search_emer_video").show();
  14. // });
  15. //
  16. // $("body").mouseout(function(){
  17. // $(".search_emer_video").hide();
  18. // });
  19. su = new SearchUtil();
  20. });
  21. $(function(){
  22. initTree();
  23. if(myBrowser().brow == "IE"){
  24. LoginServer();
  25. }else{
  26. alert("变电站视频只能使用IE浏览器");
  27. };
  28. $(".show_bar").toggle(
  29. function(){ $("#sideBar").slideUp(0); },
  30. function(){ $("#sideBar").slideDown(0); }
  31. );
  32. var h = $(".layout_content").height();
  33. setMainBoxTree(h);
  34. });
  35. $(window).unload(function(){
  36. exit();
  37. });
  38. function login(){
  39. var user_name = $("#user_input").val();
  40. var pwd = $("#pwd_input").val();
  41. if(user_name=="请输入用户名" || user_name=="" || user_name==undefined || user_name==null){
  42. alert("请输入用户名!");
  43. return;
  44. };
  45. if(pwd=="" || pwd==undefined || pwd==null){
  46. alert("请输入密码!");
  47. return;
  48. };
  49. var url = $.pathname() + "/ws/cockpit/CockpitService/getSyncConfigNup";
  50. var data = su.getJsonData(url,{user_name:un});
  51. if(data){
  52. ocx.LoginServer(data.ip,data.port,user_name,pwd,data.mode);
  53. }else{
  54. alert("IP端口获取错误!");
  55. };
  56. };
  57. function exit(){
  58. if(un!=""){
  59. var url = $.pathname() + "/ws/cockpit/CockpitService/exitTvUser";
  60. var res = su.getJsonData(url,{user_name:un});
  61. };
  62. };
  63. function initComplete(){
  64. var layout=$("#layout1").layout({ leftWidth: 400 });
  65. layout.setRightCollapse(true);
  66. layout.onHeightChanged(function(){
  67. });
  68. };
  69. $(window).resize(function(){
  70. setWH();
  71. });
  72. function resolveUrl(){
  73. var encondeCondition=window.location.search;
  74. var condition= decodeURI(decodeURI(encondeCondition.substring(1,encondeCondition.length)));
  75. var conditionArr=condition.split("&");
  76. var condJson={};
  77. for(var item in conditionArr){
  78. var temArr=conditionArr[item].split("=");
  79. condJson[temArr[0]]=temArr[1];
  80. }
  81. userInfo = condJson;
  82. return condJson;
  83. };
  84. /**
  85. * 登录
  86. */
  87. function LoginServer(){
  88. var url = $.pathname() + "/ws/cockpit/CockpitService/getSyncConfig";
  89. $.post(url,function(res){
  90. if(res.stat=="success"){
  91. var data = res.res;
  92. un = data.name;
  93. ocx.LoginServer(data.ip,data.port,data.name,data.pwd,data.mode);
  94. }else if(res.stat=="full"){
  95. alert("用户已满,请等待!");
  96. }else{
  97. alert("登录失败!");
  98. };
  99. // ocx.LoginServer(data.ip,data.port,"tang","009cd3e062b7ae641621d234be10df3a",data.mode);
  100. },'json');
  101. }
  102. function setWH(){
  103. var winHei = $(window).height();
  104. var winWid = $(window).width();
  105. $("#layout1").height(winHei-30);
  106. $("#layout1").width(winWid);
  107. $(".l-layout-content").height(winHei-60);
  108. $(".layout_content").height(winHei-60);
  109. $(".main_box_tree").height(winHei-200);
  110. };
  111. function activityPanl(){
  112. $(".top_bar").css("height","100%");
  113. $(".bottom_bar").css("height","0");
  114. $("#con_panl").addClass("con_panl");
  115. };
  116. function removeActivity(){
  117. $(".top_bar").css("height","45%");
  118. $(".bottom_bar").css("height","55%");
  119. $("#con_panl").removeClass("con_panl");
  120. };
  121. /* 树形菜单和拖动框初始化 */
  122. function initTree(){
  123. var deptId = resolveUrl()["dept_id"];
  124. var setting = {
  125. async: {
  126. enable: true,
  127. dataType: 'JSON',
  128. //返回的JSON数据的名字
  129. dataName: 'treeNodes',
  130. contentType: "application/json",
  131. url:'/nwyj/ws/cockpit/CockpitService/getSync',
  132. otherParam:{"deptId":deptId},
  133. autoParam: ["id", "name", "name=reName"]
  134. }
  135. };
  136. zTree = $.fn.zTree.init($("#dept_tree"), setting);
  137. };
  138. function customHeightSet(contentHeight){
  139. $(".layout_content").height(contentHeight-30);
  140. };
  141. function setMainBoxTree(h){
  142. $(".main_box_tree").height(h-170);
  143. };
  144. /* 监听鼠标是否移动 */
  145. function showcoords(e,obj){
  146. var e = window.event || e;
  147. pos.nowX = e.clientX;
  148. pos.nowY = e.clientY;
  149. }
  150. function changeXY(){
  151. if(pos.afterX==pos.nowX && pos.afterY==pos.nowY){
  152. $("#m_img").slideUp(0);
  153. $("#s_img").slideUp(0);
  154. }else{
  155. pos.afterX = pos.nowX;
  156. pos.afterY = pos.nowY;
  157. }
  158. };
  159. /* 拖动控制栏 */
  160. function cl(x,y){
  161. pos.divX = x ;
  162. pos.divY = y ;
  163. $(document).bind('mousemove',function(e){
  164. con_panl_move(event,this);
  165. });
  166. };
  167. function al(){
  168. $(document).unbind('mousemove');
  169. };
  170. function con_panl_move(e,obj){
  171. var e = window.event || e;
  172. var x = e.clientX - pos.divX;
  173. var y = e.clientY - pos.divY;
  174. $("#x").val("X:" + x);
  175. $("#y").val("Y:" + y);
  176. $("#con_panl").css({left:x+"px",top:y+"px"});
  177. }
  178. /* 分屏 */
  179. function splic_video(){
  180. var splitNum = $("#steps_split option:selected").val();
  181. SetWinNum(splitNum);
  182. }
  183. /* 分屏 */
  184. function SetWinNum(winnum){
  185. ocx.SetWndNum(winnum);
  186. }
  187. /* 打开视频 */
  188. function openVideo(CameraID){
  189. if(CameraID==""||CameraID==undefined||CameraID==null){
  190. CameraID = $.trim($("#vid").val());
  191. }
  192. if(CameraID=="请输入视频ID"||CameraID==""){ return; }
  193. //var CameraID=$("#vid").val();
  194. //$(".titleBar").html(CameraID);
  195. setVideoId(CameraID);
  196. var nSelWndNo = 0;
  197. nSelWndNo = ocx.GetSelWndIndex();
  198. ocx.OpenVideo(CameraID,nSelWndNo );
  199. }
  200. /**
  201. * 设置视频ID
  202. */
  203. function setVideoId(CameraID){
  204. $("#vid").removeAttr("watermark").attr("value",CameraID);
  205. };
  206. /* 关闭 */
  207. function closeVideo(){
  208. var nSelWndNo = 0;
  209. nSelWndNo = ocx.GetSelWndIndex();
  210. ocx.CloseVideo(nSelWndNo);
  211. }
  212. /* 抓图 */
  213. function capturePicture(){
  214. ocx.CapturePicture("d:\\1111111.bmp");
  215. }
  216. /* 录屏 */
  217. function startRecord(){
  218. ocx.StartRecord("d:\\22222222.dav");
  219. }
  220. /* 停止录屏 */
  221. function stopRecord(){
  222. ocx.StopRecord();
  223. }
  224. /* 操控 */
  225. function PTZControl(cmd,stop){
  226. var step = $("#steps").val();//步长设置
  227. // var step = window.frames["con_panl"].$("#steps").val();
  228. ocx.PTZControl(cmd,step,stop);
  229. }