| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- //开始检测
- var flag=true;
- $(".startDate").on("click",function(){
- $(".startDate").removeClass("btn-info");
- $(".endDate").addClass("btn-info");
- if (!flag) {
- return false;
- }
- flag = false;
- //获取当前时间
- var date=new Date();
- var year=date.getFullYear(); //获取当前年份
- var mon=date.getMonth()+1; //获取当前月份
- var da=date.getDate(); //获取当前日
- var day=date.getDay(); //获取当前星期几
- var h=date.getHours(); //获取小时
- var m=date.getMinutes(); //获取分钟
- var s=date.getSeconds(); //获取秒
- $(".startDa").html(+year+'年'+mon+'月'+da+'日'+'星期'+day+' '+h+':'+m+':'+s);
- //持续时间
- var a=0;
- var Timer=setInterval(function(){
- a++;
- $(".Seconds").html(a);
- },1000)
- //停止检测
- $(".endDate").on("click",function(){
- clearInterval(Timer);
- if($(".endDate").hasClass("btn-info")){
- $(this).removeClass("btn-info");
- $(".startDate").addClass("btn-info");
- }
- flag = true;
- });
- });
-
- // 通讯
- //建立连接
- var ws=new WebSocket("ws://192.168.4.3:8089");
- function startWebSocket (){
- function startWebSocket(){
- ws.onopen = function()
- {
- console.log("建立连接");
- };
- //接收到消息的回调方法
- ws.onmessage = function(evt)
- {
- console.log(evt.data);
- };
- //连接关闭的回调方法
- ws.onclose = function(evt)
- {
- console.log("连接关闭!");
- };
- //连接发生错误的回调方法
- ws.onerror = function(evt)
- {
- //产生异常
- console.log("WebSocketError!");
- };
- }
- }
- //监听
- function Listen(AgentID){
- startWebSocket();
- if(ws.readyState==ws.OPEN){
- var obj={
- "Type":"Listen",
- "AgentID":AgentID
- }
- var a= JSON.stringify(obj);
- ws.send(a);
- ws.onmessage=function(evt){
- console.log(evt.data);
- }
- }
- }
- $("#Listen").on("click",function(){
- Listen("1");
- })
- //获取坐席状态
- function GetAgentState(AgentID){
- startWebSocket();
- if(ws.readyState==ws.OPEN){
- var obj={
- "Type":"GetAgentState",
- "AgentID":AgentID
- }
- var a= JSON.stringify(obj);
- ws.send(a);
- ws.onmessage=function(evt){
- console.log(evt.data);
- }
- }
- }
- $(".startDate").on("click",function(){
- GetAgentState("1");
- })
- //置闲
- function ForceAgentState (AgentID,AgentState){
- startWebSocket();
- if(ws.readyState==ws.OPEN){
- var obj={
- "Type":"ForceAgentState",
- "AgentID":AgentID,
- "AgentState":AgentState
- }
- var a= JSON.stringify(obj);
- ws.send(a);
- ws.onmessage=function(evt){
- console.log(evt.data);
- }
- }
-
- }
- $("#ForceAgentState").on("click",function(){
- ForceAgentState("1","0");
- })
- //代接
- function Instead (AgentID){
- startWebSocket();
- if(ws.readyState==ws.OPEN){
- var obj={
- "Type":"Instead",
- "AgentID":AgentID
- }
- var a= JSON.stringify(obj);
- ws.send(a);
- ws.onmessage=function(evt){
- console.log(evt.data);
- }
- }
- }
- $("#Instead").on("click",function(){
- Instead("1");
- });
- //强插
- function Insert(AgentID){
- startWebSocket();
- if(ws.readyState==ws.OPEN){
- var obj={
- "Type":"Insert",
- "AgentID":AgentID
- }
- var a= JSON.stringify(obj);
- ws.send(a);
- ws.onmessage=function(evt){
- console.log(evt.data);
- }
- }
- }
- $("#Insert").on("click",function(){
- Insert("1");
- });
- //拦截
- function Intercept(AgentID){
- startWebSocket();
- if(ws.readyState==ws.OPEN){
- var obj={
- "Type":"Intercept",
- "AgentID":AgentID
- }
- var a=JSON.stringify(obj);
- ws.send(a);
- ws.onmessage=function(){
- console.log(evt.data);
- }
- }
- }
- $("#Intercept").on("click",function(){
- Intercept("1");
- });
- //强拆
- function Break (AgentID){
- startWebSocket();
- if(ws.readyState==ws.OPEN){
- var obj={
- "Type":"Break",
- "AgentID":AgentID
- }
- var a=JSON.stringify(obj);
- ws.send(a);
- ws.onmessage=function(){
- console.log(evt.data);
- }
- }
- }
- $("#Break").on("click",function(){
- Break();
- })
-
-
|