虞城12345_前端

main.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. if (typeof console == "undefined") {
  2. this.console = { log: function (msg) { } };
  3. }
  4. // 如果浏览器不支持websocket,会使用这个flash自动模拟websocket协议,此过程对开发者透明
  5. WEB_SOCKET_SWF_LOCATION = "./js/websocket/WebSocketMain.swf";
  6. // 开启flash的websocket debug
  7. WEB_SOCKET_DEBUG = true;
  8. var ws, n = 0,
  9. timer;
  10. var lockReconnect = false; //避免重复连接
  11. var obj = {};
  12. var Statess;
  13. var cls = 0;
  14. var lasttime = new Date().getTime();
  15. //创建scoket连接
  16. function createWebSocket() {
  17. try {
  18. $("#top-search li i").removeClass("active");
  19. Connect();
  20. } catch (e) {
  21. reconnect();
  22. }
  23. }
  24. //连接
  25. function Connect() {
  26. ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  27. ws.onopen = function () {
  28. console.log(new Date() + " " + "建立连接");
  29. //心跳检测重置
  30. heartCheck.reset().start();
  31. cls = 0;
  32. $(".Login").addClass("active");
  33. lasttime = new Date().getTime();
  34. if ($.cookie("socket_state") != null) {
  35. SetLogin($.cookie("socket_state"));
  36. }
  37. //$(".hwzt").text('连接成功!');
  38. };
  39. //接收到消息的回调方法
  40. ws.onmessage = function (evt) {
  41. //如果获取到消息,心跳检测重置
  42. //拿到任何消息都说明当前连接是正常的
  43. heartCheck.reset().start();
  44. var myDate = new Date();
  45. console.log(myDate + " receive " + evt.data);
  46. var data = JSON.parse(evt.data)[0];
  47. //打印日志
  48. directType="recive";
  49. sendType=data.Type; //JSON.stringify(data)
  50. mesCont=JSON.stringify(data);
  51. debuggerLog();
  52. if (data) {
  53. var rlt = data.Result;
  54. if (rlt == true) {
  55. var type = data.Type;
  56. switch (type.toLowerCase()) {
  57. //case "heart": HeartBack(); break;//心跳
  58. case "login":
  59. LoginBack();
  60. break; //签入
  61. case "logout":
  62. LogoutBack();
  63. break; //签出
  64. case "dropcall":
  65. DropCallBack();
  66. break; //挂断
  67. case "makecall":
  68. MakeCallBack();
  69. break; //外呼
  70. case "setstate":
  71. SetState(data);
  72. break; //置忙置闲
  73. //case "saybusy": SayBusyBack(data); break;
  74. //case "sayfree": SayFreeBack(data); break;
  75. case "meeting":
  76. MeetingBack();
  77. break; //多方通话
  78. case "transfer":
  79. TransferBack();
  80. break; //转移
  81. case "hold":
  82. HoldBack();
  83. break; //保持
  84. case "retrieve":
  85. RetrieveBack();
  86. break; //接回
  87. case "incoming":
  88. IncomingBack(data);
  89. break; //来电
  90. case "subscribe":
  91. SubScribeBack();
  92. break; //监测
  93. case "subscribecancel":
  94. SubScribeCancelBack();
  95. break; //停止监测
  96. case "agentstate":
  97. AgentStateBack(data);
  98. break; //坐席状态
  99. case "linestate":
  100. LineStateBack(data);
  101. break; //线路状态
  102. case "motorsetstate":
  103. SayFreeBack();
  104. break; //班长置闲
  105. case "linestateagent":
  106. LineStateAgentBack(data);
  107. break; //线路状态通知
  108. //case "callid":
  109. // CallIDBack(data);
  110. // break; //获取callid
  111. //case "recordpath":
  112. // RecordPathBack(data);
  113. // break; //录音返回
  114. case "getagentlist":
  115. GetAgentListBack(data);
  116. break;//在线坐席信息
  117. }
  118. } else {
  119. if (rlt == false) {
  120. //layer.confirm('操作失败!', {
  121. // btn: ['确定']
  122. //});
  123. $(".hwzt").text('操作失败!');
  124. } else {
  125. $(".hwzt").text(rlt);
  126. //layer.confirm(rlt, {
  127. // btn: ['确定']
  128. //});
  129. }
  130. }
  131. }
  132. };
  133. //连接关闭的回调方法
  134. ws.onclose = function (evt) {
  135. var data = JSON.parse(evt.data)[0];
  136. directType="recive";
  137. sendType="close"; //JSON.stringify(data)
  138. mesCont=JSON.stringify(data);
  139. debuggerLog();
  140. if (cls == 0) {
  141. cls = 1;
  142. //console.log("连接关闭!");
  143. //layer.confirm('连接关闭!', {
  144. // btn: ['确定']
  145. //});
  146. $(".hwzt").text('连接关闭!');
  147. $("#top-search li i").removeClass("active");
  148. reconnect();
  149. }
  150. };
  151. //连接发生错误的回调方法
  152. ws.onerror = function (evt) {
  153. var data = JSON.parse(evt.data)[0];
  154. directType="recive";
  155. sendType="连接错误 "; //JSON.stringify(data)
  156. mesCont=JSON.stringify(data);
  157. debuggerLog();
  158. //产生异常
  159. $(".hwzt").text('连接出现异常!');
  160. console.log(ws);
  161. if (ws == null || ws.readyState != ws.OPEN) {
  162. console.log(new Date() + "开始重连");
  163. reconnect();
  164. }
  165. };
  166. }
  167. //重连
  168. function reconnect() {
  169. if (lockReconnect) return;
  170. lockReconnect = true;
  171. //没连接上会一直重连,设置延迟避免请求过多
  172. setTimeout(function () {
  173. directType="send";
  174. sendType="重连中 "; //JSON.stringify(data)
  175. mesCont="重连中";
  176. debuggerLog();
  177. console.log(new Date() + " " + "重连中……");
  178. createWebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  179. lockReconnect = false;
  180. }, 2000);
  181. }
  182. function debuggerLog(){
  183. $.post(huayi.config.callcenter_url + 'Log/CallOpt', {
  184. direct: directType,
  185. type: sendType,
  186. cont: mesCont,
  187. "token": $.cookie("token")
  188. }, function(result) {
  189. result = $.parseJSON(result);
  190. if(result.state.toLowerCase() == "warning") {
  191. //layer.msg("创建工单成功");
  192. }
  193. })
  194. }
  195. //发送
  196. function Send() {
  197. if (ws.readyState != ws.OPEN) {
  198. reconnect();
  199. }
  200. if (ws.readyState == ws.OPEN) {
  201. console.log(new Date() + " send " + JSON.stringify(obj));
  202. ws.send(JSON.stringify(obj));
  203. if (obj.Type) {
  204. directType="send";
  205. sendType=obj.Type;
  206. mesCont=JSON.stringify(obj);
  207. debuggerLog()
  208. }else{
  209. directType="send";
  210. sendType="建立连接";
  211. mesCont=JSON.stringify(obj);
  212. debuggerLog()
  213. }
  214. }
  215. }
  216. //心跳检测
  217. var heartCheck = {
  218. timeout: 25000, //25秒
  219. timeoutObj: null,
  220. serverTimeoutObj: null,
  221. reset: function () {
  222. clearTimeout(this.timeoutObj);
  223. clearTimeout(this.serverTimeoutObj);
  224. return this;
  225. },
  226. start: function () {
  227. var self = this;
  228. this.timeoutObj = setTimeout(function () {
  229. //这里发送一个心跳,后端收到后,返回一个心跳消息,
  230. //onmessage拿到返回的心跳就说明连接正常
  231. obj.Type = "Heart";
  232. Send();
  233. self.serverTimeoutObj = setTimeout(function () { //如果超过一定时间还没重置,说明后端主动断开了
  234. ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  235. }, self.timeout)
  236. }, this.timeout)
  237. }
  238. }
  239. //签入
  240. function LoginBack() {
  241. $("#top-search li i").removeClass("active");
  242. $(".Logout").addClass("active");
  243. $(".SayBusy").addClass("active");
  244. $(".MakeCall").addClass("active");
  245. $(".zxzt").removeClass("br").addClass("bl");
  246. $(".fwzt").removeClass("br").addClass("bl");
  247. $(".hwzt").text('');
  248. if ($.cookie("socket_state") == null) {
  249. SetStateCookie(0);
  250. }
  251. }
  252. //签出
  253. function LogoutBack() {
  254. $("#top-search li i").removeClass("active");
  255. $(".Login").addClass("active");
  256. $(".zxzt").removeClass("bl").addClass("br");
  257. $(".fwzt").removeClass("bl").addClass("br");
  258. $(".hwzt").text('');
  259. SetStateCookie(2);
  260. }
  261. //来电
  262. function IncomingBack(data) {
  263. $(".ldhm").val(data.Number);
  264. $(".hidTel").val(data.Number);
  265. $(".tel").text(data.Number);
  266. $(".ldtime").text(getNowFormatDate());
  267. $(".thsc").text("00:00");
  268. $(".hidCallID").val(data.CallID);
  269. debugger
  270. //获取电话所属地
  271. $.getJSON(huayi.config.callcenter_url + 'CallInScreen/GetPhoneLocation', {
  272. "tel": $(".hidTel").val(),
  273. "token": $.cookie("token")
  274. }, function (result) {
  275. if (result.state.toLowerCase() == "success") {
  276. $(".ldlocation").text(result.data[0].F_Name);
  277. $(".khgsd").text(result.data[0].F_Name);
  278. }
  279. })
  280. //获取客户信息
  281. $(".ttsdh").text($(".hidTel").val());
  282. $(".tsdh").val($(".hidTel").val());
  283. $.getJSON(huayi.config.callcenter_url + 'CallInScreen/GetCustomerByTel', {
  284. "tel": $(".hidTel").val(),
  285. "token": $.cookie("token")
  286. }, function (result) {
  287. if (result.state.toLowerCase() == "success") {
  288. if (result.data.length > 0) {
  289. $(".khmc").val(result.data[0].F_CustomerName);
  290. $(".tkhmc").text(result.data[0].F_CustomerName);
  291. $("#khid").val(result.data[0].F_CustomerId);
  292. $(".lxdh").val(result.data[0].F_Telephone);
  293. //$(".tsdh").val(result.data[0].F_Mobile);
  294. //$(".ttsdh").text(result.data[0].F_Mobile);
  295. $(".lxr").val(result.data[0].F_CustomerEName);
  296. $(".postcode").val(result.data[0].F_PostCode);
  297. $(".email").val(result.data[0].F_Email);
  298. }
  299. else {
  300. $(".khmc").val("");
  301. $(".tkhmc").text("");
  302. $("#khid").val("");
  303. $(".lxr").val("");
  304. $(".postcode").val("");
  305. $(".email").val("");
  306. }
  307. }
  308. })
  309. $('.maxOpen').trigger("click");
  310. $('.head-pic .lahei .la-before').show();
  311. //触发来电类型第一个 点击;
  312. $("#dicValueList li:first-child").find("label").trigger('click');
  313. $('.head-pic .lahei .la-after').hide();
  314. $(".Bacha").hide();
  315. }
  316. //挂断
  317. function DropCallBack() {
  318. $("#top-search li i").removeClass("active");
  319. $(".Logout").addClass("active");
  320. $(".SayBusy").addClass("active");
  321. $(".MakeCall").addClass("active");
  322. $(".td-call").hide();
  323. $(".hwzt").text('忙碌');
  324. $("#isml").val(1);
  325. SetStateCookie(1);
  326. obj.Type = "SayBusy";
  327. Send();
  328. //$('.ldtp-con').css("display", 'none');
  329. }
  330. function LineStateAgentBack(data) {
  331. //0分机不可用,1空闲,2摘机等待拨号,3正在拨号,4呼出振铃,5来电振铃,6通话中,7播放忙音中,8移除IP分机,9通话保持中
  332. if (data.State == '0') {
  333. $(".hwzt").text('分机不可用'); //左下角状态显示
  334. }
  335. if (data.State == '1') {
  336. $(".hwzt").text('空闲'); //左下角状态显示
  337. $(".fwzt").removeClass("br").addClass("bl");
  338. clearInterval(timer);
  339. if ($(".hidTel").val() && $(".hidCallID").val()) {
  340. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateGJ', {
  341. callid: $(".hidCallID").val(),
  342. "token": $.cookie("token")
  343. }, function (result) {
  344. result = JSON.parse(result);
  345. if (result.state.toLowerCase() == "success") { }
  346. })
  347. }
  348. $("#top-search li i").removeClass("active");
  349. $(".Logout").addClass("active");
  350. $(".SayBusy").addClass("active");
  351. $(".MakeCall").addClass("active");
  352. $(".td-call").hide();
  353. $(".Bacha").show();
  354. //$(".hidTel").val("");
  355. //$(".hidCallID").val("");
  356. }
  357. if (data.State == '2') {
  358. $(".hwzt").text('摘机等待拨号'); //左下角状态显示
  359. }
  360. if (data.State == '3') {
  361. $(".hwzt").text('正在拨号'); //左下角状态显示
  362. }
  363. if (data.State == '4') {
  364. $(".hwzt").text('呼出振铃'); //左下角状态显示
  365. }
  366. if (data.State == '5') {
  367. $(".hwzt").text('来电振铃'); //左下角状态显示
  368. $(".fwzt").removeClass("bl").addClass("br");
  369. if ($(".hidTel").val() && $(".hidCallID").val()) {
  370. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZL', {
  371. callid: $(".hidCallID").val(),
  372. "token": $.cookie("token")
  373. }, function (result) {
  374. result = JSON.parse(result);
  375. if (result.state.toLowerCase() == "success") { }
  376. })
  377. }
  378. }
  379. if (data.State == '6') {
  380. debugger
  381. $(".hwzt").text('通话中'); //左下角状态显示
  382. $(".fwzt").removeClass("bl").addClass("br");
  383. if ($(".hidTel").val() && $(".hidCallID").val()) {
  384. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZJ', {
  385. callid: $(".hidCallID").val(),
  386. "token": $.cookie("token")
  387. }, function (result) {
  388. result = JSON.parse(result);
  389. if (result.state.toLowerCase() == "success") { }
  390. })
  391. }
  392. $(".td-call").show();
  393. n = 0;
  394. $("#top-search li i").removeClass("active");
  395. $(".DropCall").addClass("active");
  396. $(".Hold").addClass("active");
  397. $(".Transfer").addClass("active");
  398. $(".Turn110").addClass("active");
  399. $(".Meeting").addClass("active");
  400. clearInterval(timer);
  401. timer = setInterval(function () {
  402. n++;
  403. var m = parseInt(n / 60 % 60);
  404. var s = parseInt(n % 60);
  405. $(".thsc").text(toDub(m) + ":" + toDub(s));
  406. }, 1000);
  407. }
  408. if (data.State == '7') {
  409. $(".hwzt").text('播放忙音中'); //左下角状态显示
  410. }
  411. if (data.State == '8') {
  412. $(".hwzt").text('移除IP分机'); //左下角状态显示
  413. }
  414. if (data.State == '9') {
  415. $(".hwzt").text('通话保持中'); //左下角状态显示
  416. }
  417. }
  418. function toDub(i) {
  419. return i < 10 ? "0" + i : "" + i;
  420. }
  421. //外呼
  422. function MakeCallBack() {
  423. $("#top-search li i").removeClass("active");
  424. $(".DropCall").addClass("active");
  425. $(".Meeting").addClass("active");
  426. }
  427. //默认记忆上次是否签入,是否置忙置闲 0表示已签入 空闲,1表示签入置忙,2表示签出
  428. function SetStateCookie(state) {
  429. $.cookie("socket_state", state);
  430. }
  431. //置忙置闲
  432. function SetState(obj) {
  433. if (obj.State == '5') {
  434. $(".SayBusy").removeClass("active");
  435. $(".SayFree").addClass("active");
  436. $(".zxzt").removeClass("bl").addClass("br");
  437. $(".hwzt").text('置忙');
  438. SetStateCookie(1);
  439. }
  440. if (obj.State == '2') {
  441. $(".SayBusy").addClass("active");
  442. $(".SayFree").removeClass("active");
  443. $(".zxzt").removeClass("br").addClass("bl");
  444. $(".hwzt").text('空闲');
  445. SetStateCookie(0);
  446. }
  447. }
  448. function SetLogin(state) {
  449. if (state == 2) { return; }
  450. if (obj.AgentID) {
  451. obj.Type = "Login";
  452. obj.AgentGroup = "364";
  453. obj.AgentType = "0";
  454. Send();
  455. }
  456. if (state == 1) {
  457. setTimeout('SayBusy()', 500);
  458. }
  459. }
  460. function SayBusy() {
  461. if (obj.AgentID) {
  462. obj.Type = "SayBusy";
  463. Send();
  464. }
  465. }
  466. //置忙
  467. function SayBusyBack() {
  468. $(".SayBusy").removeClass("active");
  469. $(".SayFree").addClass("active");
  470. }
  471. //置闲
  472. function SayFreeBack() {
  473. $(".SayBusy").addClass("active");
  474. $(".SayFree").removeClass("active");
  475. }
  476. //多方通话
  477. function MeetingBack() {
  478. }
  479. //转移
  480. function TransferBack() {
  481. $("#top-search li i").removeClass("active");
  482. $(".Logout").addClass("active");
  483. $(".SayBusy").addClass("active");
  484. $(".MakeCall").addClass("active");
  485. }
  486. //保持
  487. function HoldBack() {
  488. $(".Hold").removeClass("active");
  489. $(".Retrieve").addClass("active");
  490. }
  491. //接回
  492. function RetrieveBack() {
  493. $(".Hold").addClass("active");
  494. $(".Retrieve").removeClass("active");
  495. }
  496. //监测
  497. function SubScribeBack() {
  498. var obj = $("iframe:visible")
  499. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  500. window.frames[obj.attr("name")].Start();
  501. }
  502. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  503. window.frames[obj.attr("name")].Start();
  504. }
  505. }
  506. //取消监测
  507. function SubScribeCancelBack() {
  508. var obj = $("iframe:visible")
  509. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  510. window.frames[obj.attr("name")].Stop();
  511. }
  512. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  513. window.frames[obj.attr("name")].Stop();
  514. }
  515. }
  516. //班长监测返回状态
  517. //坐席状态
  518. function AgentStateBack(data) {
  519. var obj = $("iframe:visible")
  520. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  521. window.frames[obj.attr("name")].UpdateAgentState(data.AgentID, data.State);
  522. }
  523. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  524. window.frames[obj.attr("name")].UpdateAgentState(data.AgentID, data.State);
  525. }
  526. }
  527. //线路状态
  528. function LineStateBack(data) {
  529. var obj = $("iframe:visible")
  530. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  531. window.frames[obj.attr("name")].UpdateLineState(data.AgentID, data.State);
  532. }
  533. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  534. window.frames[obj.attr("name")].UpdateLineState(data.AgentID, data.State);
  535. }
  536. }
  537. //录音返回
  538. function RecordPathBack(data) {
  539. //if ($(".hidTel").val() && $(".hidCallID").val()) {
  540. // $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', { callid: $(".hidCallID").val(),path:data.RecPath, "token": $.cookie("token") }, function (result) {
  541. // result = JSON.parse(result);
  542. // if (result.state.toLowerCase() == "success") {
  543. // }
  544. // })
  545. //}
  546. if ($(".hidTel").val()) {
  547. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', {
  548. callid: data.CallID,
  549. path: data.RecPath,
  550. "token": $.cookie("token")
  551. }, function (result) {
  552. result = JSON.parse(result);
  553. if (result.state.toLowerCase() == "success") { }
  554. })
  555. }
  556. }
  557. //在线坐席信息
  558. function GetAgentListBack(data) {
  559. console.log(data)
  560. debugger
  561. $.ajax({
  562. type: "get",
  563. url: huayi.config.callcenter_url + "SeatMonitoring/GetAgentList",
  564. async: true,
  565. dataType: 'json',
  566. data: {
  567. "token": $.cookie("token")
  568. },
  569. success: function (result) {
  570. var user = result.data;
  571. $(user).each(function (j, m) {
  572. $(data.AgentList).each(function (k, g) {
  573. if (g.AgentID == m.UserCode) {
  574. g.userName = m.UserName;
  575. }
  576. })
  577. })
  578. $(data.AgentList).each(function (k, m) {
  579. var strr = '';
  580. switch (m.State) {
  581. case "0":
  582. strr = "离线";
  583. break; //离线
  584. case "1":
  585. break; //登录中
  586. case "2":
  587. strr = "空闲";
  588. break; //空闲
  589. case "3":
  590. strr = "通话中";
  591. break; //通话中
  592. case "4":
  593. strr = "话后处理中";
  594. break; //话后处理中
  595. case "5":
  596. strr = "忙碌";
  597. break; //小休
  598. case "6":
  599. strr = "振铃";
  600. break; //被请求
  601. case "7":
  602. strr = "注销";
  603. break; //注销
  604. }
  605. var html = '<tr fjh="' + m.AgentExten + '">' +
  606. '<td>' + (m.userName ? '' : m.userName) + '</td>' //姓名
  607. +
  608. '<td>' + m.AgentID + '</td>' //工号
  609. +
  610. '<td>' + m.AgentExten + '</td>'//分机号
  611. +
  612. '<td class=" ' + m.UserCode + 'state">' + strr + '</td>' //状态
  613. +
  614. '</tr>';
  615. $(html).appendTo("#zxTable tbody");
  616. })
  617. }
  618. });
  619. }
  620. //获取当前的日期时间 格式“yyyy-MM-dd HH:mm:ss”
  621. function getNowFormatDate() {
  622. var date = new Date();
  623. var seperator1 = "-";
  624. var seperator2 = ":";
  625. var month = date.getMonth() + 1;
  626. var strDate = date.getDate();
  627. if (month >= 1 && month <= 9) {
  628. month = "0" + month;
  629. }
  630. if (strDate >= 0 && strDate <= 9) {
  631. strDate = "0" + strDate;
  632. }
  633. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
  634. " " + date.getHours() + seperator2 + date.getMinutes() +
  635. seperator2 + date.getSeconds();
  636. return currentdate;
  637. }
  638. var iswebcloase = 1;
  639. window.onunload = function () {
  640. if (iswebcloase) {
  641. iswebcloase = 0;
  642. if (ws.readyState == ws.OPEN) {
  643. obj.Type = 'Logout';
  644. Send();
  645. ws.onclose();
  646. }
  647. }
  648. }
  649. window.onbeforeunload = function () {
  650. if (iswebcloase) {
  651. iswebcloase = 0;
  652. if (ws.readyState == ws.OPEN) {
  653. obj.Type = 'Logout';
  654. Send();
  655. ws.onclose();
  656. }
  657. }
  658. }