Keine Beschreibung

manage.js 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. //开始检测
  2. var flag=true;
  3. $(".startDate").on("click",function(){
  4. $(".startDate").removeClass("btn-info");
  5. $(".endDate").addClass("btn-info");
  6. if (!flag) {
  7. return false;
  8. }
  9. flag = false;
  10. //获取当前时间
  11. var date=new Date();
  12. var year=date.getFullYear(); //获取当前年份
  13. var mon=date.getMonth()+1; //获取当前月份
  14. var da=date.getDate(); //获取当前日
  15. var day=date.getDay(); //获取当前星期几
  16. var h=date.getHours(); //获取小时
  17. var m=date.getMinutes(); //获取分钟
  18. var s=date.getSeconds(); //获取秒
  19. $(".startDa").html(+year+'年'+mon+'月'+da+'日'+'星期'+day+' '+h+':'+m+':'+s);
  20. //持续时间
  21. var a=0;
  22. var Timer=setInterval(function(){
  23. a++;
  24. $(".Seconds").html(a);
  25. },1000)
  26. //停止检测
  27. $(".endDate").on("click",function(){
  28. clearInterval(Timer);
  29. if($(".endDate").hasClass("btn-info")){
  30. $(this).removeClass("btn-info");
  31. $(".startDate").addClass("btn-info");
  32. }
  33. flag = true;
  34. });
  35. });
  36. // 通讯
  37. //建立连接
  38. var ws=new WebSocket("ws://192.168.4.3:8089");
  39. function startWebSocket (){
  40. function startWebSocket(){
  41. ws.onopen = function()
  42. {
  43. console.log("建立连接");
  44. };
  45. //接收到消息的回调方法
  46. ws.onmessage = function(evt)
  47. {
  48. console.log(evt.data);
  49. };
  50. //连接关闭的回调方法
  51. ws.onclose = function(evt)
  52. {
  53. console.log("连接关闭!");
  54. };
  55. //连接发生错误的回调方法
  56. ws.onerror = function(evt)
  57. {
  58. //产生异常
  59. console.log("WebSocketError!");
  60. };
  61. }
  62. }
  63. //监听
  64. function Listen(AgentID){
  65. startWebSocket();
  66. if(ws.readyState==ws.OPEN){
  67. var obj={
  68. "Type":"Listen",
  69. "AgentID":AgentID
  70. }
  71. var a= JSON.stringify(obj);
  72. ws.send(a);
  73. ws.onmessage=function(evt){
  74. console.log(evt.data);
  75. }
  76. }
  77. }
  78. $("#Listen").on("click",function(){
  79. Listen("1");
  80. })
  81. //获取坐席状态
  82. function GetAgentState(AgentID){
  83. startWebSocket();
  84. if(ws.readyState==ws.OPEN){
  85. var obj={
  86. "Type":"GetAgentState",
  87. "AgentID":AgentID
  88. }
  89. var a= JSON.stringify(obj);
  90. ws.send(a);
  91. ws.onmessage=function(evt){
  92. console.log(evt.data);
  93. }
  94. }
  95. }
  96. $(".startDate").on("click",function(){
  97. GetAgentState("1");
  98. })
  99. //置闲
  100. function ForceAgentState (AgentID,AgentState){
  101. startWebSocket();
  102. if(ws.readyState==ws.OPEN){
  103. var obj={
  104. "Type":"ForceAgentState",
  105. "AgentID":AgentID,
  106. "AgentState":AgentState
  107. }
  108. var a= JSON.stringify(obj);
  109. ws.send(a);
  110. ws.onmessage=function(evt){
  111. console.log(evt.data);
  112. }
  113. }
  114. }
  115. $("#ForceAgentState").on("click",function(){
  116. ForceAgentState("1","0");
  117. })
  118. //代接
  119. function Instead (AgentID){
  120. startWebSocket();
  121. if(ws.readyState==ws.OPEN){
  122. var obj={
  123. "Type":"Instead",
  124. "AgentID":AgentID
  125. }
  126. var a= JSON.stringify(obj);
  127. ws.send(a);
  128. ws.onmessage=function(evt){
  129. console.log(evt.data);
  130. }
  131. }
  132. }
  133. $("#Instead").on("click",function(){
  134. Instead("1");
  135. });
  136. //强插
  137. function Insert(AgentID){
  138. startWebSocket();
  139. if(ws.readyState==ws.OPEN){
  140. var obj={
  141. "Type":"Insert",
  142. "AgentID":AgentID
  143. }
  144. var a= JSON.stringify(obj);
  145. ws.send(a);
  146. ws.onmessage=function(evt){
  147. console.log(evt.data);
  148. }
  149. }
  150. }
  151. $("#Insert").on("click",function(){
  152. Insert("1");
  153. });
  154. //拦截
  155. function Intercept(AgentID){
  156. startWebSocket();
  157. if(ws.readyState==ws.OPEN){
  158. var obj={
  159. "Type":"Intercept",
  160. "AgentID":AgentID
  161. }
  162. var a=JSON.stringify(obj);
  163. ws.send(a);
  164. ws.onmessage=function(){
  165. console.log(evt.data);
  166. }
  167. }
  168. }
  169. $("#Intercept").on("click",function(){
  170. Intercept("1");
  171. });
  172. //强拆
  173. function Break (AgentID){
  174. startWebSocket();
  175. if(ws.readyState==ws.OPEN){
  176. var obj={
  177. "Type":"Break",
  178. "AgentID":AgentID
  179. }
  180. var a=JSON.stringify(obj);
  181. ws.send(a);
  182. ws.onmessage=function(){
  183. console.log(evt.data);
  184. }
  185. }
  186. }
  187. $("#Break").on("click",function(){
  188. Break();
  189. })