Bez popisu

main备份.js 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. var ws, n = 0,
  2. timer,hidTel,hidCallID,hidActionID;
  3. var lockReconnect = false; //避免重复连接
  4. var obj = {};
  5. var directType;
  6. var sendType;
  7. var mesCont;
  8. var eorrorConnect;
  9. var cls = 0;
  10. var lasttime = new Date().getTime();
  11. var errorState;
  12. var reconnecTion;
  13. var recon;
  14. var loginOr;
  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. //自动签入
  34. //lasttime = new Date().getTime();
  35. //obj.Type = "Login";
  36. //obj.AgentType = "0";
  37. //Send(); /*2018-05-19zhangshaungnan注释*/
  38. if (errorState) {
  39. //自动签入
  40. lasttime = new Date().getTime();
  41. obj.Type = "Login";
  42. obj.AgentType = "0";
  43. Send();
  44. clearInterval(timer);
  45. //loginOr=false;
  46. errorState=false;
  47. }else{
  48. //签入
  49. Send();
  50. }
  51. };
  52. //接收到消息的回调方法
  53. ws.onmessage = function(evt) {
  54. //如果获取到消息,心跳检测重置
  55. //拿到任何消息都说明当前连接是正常的
  56. heartCheck.reset().start();
  57. var myDate = new Date();
  58. console.log(myDate + " receive " + evt.data);
  59. var data = JSON.parse(evt.data)[0];
  60. //打印日志
  61. directType="recive";
  62. sendType=data.Type; //JSON.stringify(data)
  63. mesCont=JSON.stringify(data);
  64. debuggerLog()
  65. if(data) {
  66. var rlt = data.Result;
  67. if(rlt == true) {
  68. var type = data.Type;
  69. if (eorrorConnect) {
  70. LoginBack();
  71. obj.Type = "Login";
  72. Send();
  73. eorrorConnect=false;
  74. }
  75. switch(type.toLowerCase()) {
  76. //case "heart": HeartBack(); break;//心跳
  77. case "login":
  78. LoginBack();
  79. break; //签入
  80. case "logout":
  81. LogoutBack();
  82. break; //签出
  83. case "dropcall":
  84. DropCallBack();
  85. break; //挂断
  86. case "makecall":
  87. MakeCallBack();
  88. break; //外呼
  89. case "setstate":
  90. SetState(data);
  91. break; //置忙置闲
  92. //case "saybusy": SayBusyBack(data); break;
  93. //case "sayfree": SayFreeBack(data); break;
  94. case "meeting":
  95. MeetingBack();
  96. break; //多方通话
  97. case "transfer":
  98. TransferBack();
  99. break; //转移
  100. case "hold":
  101. HoldBack();
  102. break; //保持
  103. case "retrieve":
  104. RetrieveBack();
  105. break; //接回
  106. case "incoming":
  107. IncomingBack(data);
  108. break; //来电
  109. case "subscribe":
  110. SubScribeBack();
  111. break; //监测
  112. case "subscribecancel":
  113. SubScribeCancelBack();
  114. break; //停止监测
  115. case "agentstate":
  116. AgentStateBack(data);
  117. break; //坐席状态
  118. case "linestate":
  119. LineStateBack(data);
  120. break; //线路状态
  121. case "motorsetstate":
  122. SayFreeBack();
  123. break; //班长置闲
  124. case "linestateagent":
  125. LineStateAgentBack(data);
  126. break; //线路状态通知
  127. case "callid":
  128. CallIDBack(data);
  129. break; //获取callid
  130. case "recordpath":
  131. RecordPathBack(data);
  132. break; //录音返回
  133. }
  134. } else {
  135. if(rlt == false) {
  136. if (data.Type=="AcdConnectNotify") {
  137. //LogoutBack();
  138. $(".hwzt").text('连接异常!');
  139. setTimeout(function () {
  140. // 签入
  141. obj.Type = "login";
  142. Send();
  143. }, 5000);
  144. }
  145. $(".hwzt").text('操作失败!');
  146. } else {
  147. $(".hwzt").text(rlt);
  148. //layer.confirm(rlt, {
  149. // btn: ['确定']
  150. //});
  151. }
  152. }
  153. }
  154. };
  155. //连接关闭的回调方法
  156. ws.onclose = function(evt) {
  157. var data = JSON.parse(evt.data)[0];
  158. directType="recive";
  159. sendType="close"; //JSON.stringify(data)
  160. mesCont=JSON.stringify(data);
  161. debuggerLog();
  162. if(cls == 0) {
  163. cls = 1;
  164. //console.log("连接关闭!");
  165. //layer.confirm('连接关闭!', {
  166. // btn: ['确定']
  167. //});
  168. $(".hwzt").text('连接关闭!');
  169. $("#top-search li i").removeClass("active");
  170. reconnect();
  171. }
  172. };
  173. //连接发生错误的回调方法
  174. ws.onerror = function(evt) {
  175. var data = JSON.parse(evt.data)[0];
  176. directType="recive";
  177. sendType="连接错误 "; //JSON.stringify(data)
  178. mesCont=JSON.stringify(data);
  179. debuggerLog();
  180. //产生异常
  181. $(".hwzt").text('连接出现异常!');
  182. console.log(ws);
  183. if(ws == null || ws.readyState != ws.OPEN) {
  184. console.log(new Date() + "开始重连");
  185. reconnect();
  186. }
  187. };
  188. }
  189. //重连
  190. function reconnect() {
  191. if(lockReconnect) return;
  192. lockReconnect = true;
  193. //没连接上会一直重连,设置延迟避免请求过多
  194. setTimeout(function() {
  195. directType="send";
  196. sendType="重连中 "; //JSON.stringify(data)
  197. mesCont="重连中";
  198. debuggerLog();
  199. console.log(new Date() + " " + "重连中……");
  200. createWebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  201. lockReconnect = false;
  202. }, 2000);
  203. }
  204. function debuggerLog(){
  205. $.post(huayi.config.callcenter_url + 'Log/CallOpt', {
  206. direct: directType,
  207. type: sendType,
  208. cont: mesCont,
  209. "token": $.cookie("token")
  210. }, function(result) {
  211. result = $.parseJSON(result);
  212. if(result.state.toLowerCase() == "warning") {
  213. //layer.msg("创建工单成功");
  214. }
  215. })
  216. }
  217. //异常重连
  218. function errorFun(){
  219. clearInterval(timer);
  220. var errorNum=0
  221. timer = setInterval(function() {
  222. errorNum++;
  223. if (errorNum>2) {
  224. //$("#top-search li i").removeClass("active");
  225. $(".hwzt").text('连接异常!');
  226. }else{
  227. LogoutBack();
  228. }
  229. reconnect();
  230. $(".hwzt").text('连接异常!');
  231. }, 15000);
  232. }
  233. noLine();
  234. clearInterval(recon);
  235. recon = setInterval(function () {
  236. if(loginOr){
  237. noLine();
  238. setTimeout(function () {
  239. lineState();
  240. }, 2000);
  241. }
  242. }, 1000*10);
  243. function lineState(){
  244. if (reconnecTion) {
  245. reconnecTion=false;
  246. }else{
  247. errorState=true;
  248. LogoutBack();
  249. errorFun();
  250. var numEorr=0;
  251. numEorr++;
  252. if (numEorr>2) {
  253. $("#top-search li i").removeClass("active");
  254. }
  255. $(".hwzt").text('网络异常!');
  256. }
  257. }
  258. function noLine(){
  259. $.ajax({
  260. type: "get",
  261. url: huayi.config.callcenter_url + 'UserAccount/GetNowUser',
  262. async: true,
  263. dataType: 'json',
  264. data: {
  265. "token": $.cookie("token")
  266. },
  267. success: function(data) {
  268. reconnecTion = data.data.user.F_UserCode;
  269. }
  270. });
  271. }
  272. //发送
  273. function Send() {
  274. if(ws.readyState != ws.OPEN) {
  275. errorState=true;
  276. LogoutBack();
  277. errorFun();
  278. $(".hwzt").text('连接异常!');
  279. reconnect();
  280. }
  281. if(ws.readyState == ws.OPEN) {
  282. console.log(new Date() + " send " + JSON.stringify(obj));
  283. if (obj.Type) {
  284. directType="send";
  285. sendType=obj.Type;
  286. mesCont=JSON.stringify(obj);
  287. debuggerLog()
  288. }else{
  289. directType="send";
  290. sendType="建立连接";
  291. mesCont=JSON.stringify(obj);
  292. debuggerLog()
  293. }
  294. ws.send(JSON.stringify(obj));
  295. }
  296. }
  297. //心跳检测
  298. var heartCheck = {
  299. timeout: 25000, //25秒
  300. timeoutObj: null,
  301. serverTimeoutObj: null,
  302. reset: function() {
  303. clearTimeout(this.timeoutObj);
  304. clearTimeout(this.serverTimeoutObj);
  305. return this;
  306. },
  307. start: function() {
  308. var self = this;
  309. this.timeoutObj = setTimeout(function() {
  310. //这里发送一个心跳,后端收到后,返回一个心跳消息,
  311. //onmessage拿到返回的心跳就说明连接正常
  312. obj.Type = "Heart";
  313. Send();
  314. self.serverTimeoutObj = setTimeout(function() { //如果超过一定时间还没重置,说明后端主动断开了
  315. ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  316. }, self.timeout)
  317. }, this.timeout)
  318. }
  319. }
  320. //签入
  321. function LoginBack() {
  322. $("#top-search li i").removeClass("active");
  323. $(".Logout").addClass("active");
  324. $(".SayBusy").addClass("active");
  325. $(".MakeCall").addClass("active");
  326. $(".zxzt").removeClass("br").addClass("bl");
  327. $(".fwzt").removeClass("br").addClass("bl");
  328. $(".hwzt").text('');
  329. }
  330. //签出
  331. function LogoutBack() {
  332. $("#top-search li i").removeClass("active");
  333. $(".Login").addClass("active");
  334. $(".zxzt").removeClass("bl").addClass("br");
  335. $(".fwzt").removeClass("bl").addClass("br");
  336. $(".hwzt").text('');
  337. }
  338. //来电
  339. function IncomingBack(data) {
  340. if(data.CallID!=0){
  341. var p = '<a href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID=' + data.CallID + '">来电弹屏' + data.Number + ' <i class="fa fa-times-circle"></i></a>';
  342. $(".J_menuTab").removeClass("active");
  343. var nif = '<iframe class="J_iframe J_iframeNew" name="iframe'+ data.CallID +'" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + data.Number + '&CallID=' + data.CallID + '&ActionID=' + data.ActionID + '" frameborder="0" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID=' + data.CallID + '" seamless></iframe>';
  344. $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
  345. $(".J_menuTabs .page-tabs-content").append(p);
  346. hidTel=data.Number;
  347. hidCallID=data.CallID;
  348. hidActionID=data.ActionID;
  349. }else{
  350. var timestamp = Date.parse(new Date());
  351. var p = '<a href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID='+timestamp+'">来电弹屏' + data.Number + ' <i class="fa fa-times-circle"></i></a>';
  352. $(".J_menuTab").removeClass("active");
  353. var nif = '<iframe class="J_iframe J_iframeNew" name="iframe'+timestamp+'" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + data.Number + '&CallID='+timestamp+'" frameborder="0" data-id="./callScreen/callScreen.html?tel=' + data.Number + '&CallID='+timestamp+'" seamless></iframe>';
  354. $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
  355. $(".J_menuTabs .page-tabs-content").append(p);
  356. hidTel=data.Number;
  357. hidCallID=timestamp;
  358. }
  359. }
  360. //***************************************************
  361. function CallIDBack(data) {
  362. //$(".hidCallID").val(data.CurrID);
  363. }
  364. //挂断
  365. function DropCallBack() {
  366. $("#top-search li i").removeClass("active");
  367. $(".Logout").addClass("active");
  368. $(".SayBusy").addClass("active");
  369. $(".MakeCall").addClass("active");
  370. var obj = $("iframe:visible")
  371. // if (obj.attr("data-id") == './callScreen/callScreen.html?tel=' + hidTel + '&CallID=' + hidCallID + '') {
  372. // window.frames[obj.attr("name")].$(".td-call").hide();
  373. // window.frames['iframe'+ hidCallID +''].$(".td-call").hide();
  374. // }
  375. if(window.frames['iframe'+ hidCallID +'']){
  376. window.frames['iframe'+ hidCallID +''].$(".td-call").hide();
  377. }
  378. }
  379. //线路状态通知
  380. function LineStateAgentBack(data) {
  381. var objiframe = $("iframe:visible")
  382. //0分机不可用,1空闲,2摘机等待拨号,3正在拨号,4呼出振铃,5来电振铃,6通话中,7播放忙音中,8移除IP分机,9通话保持中
  383. if(data.State == '0') {
  384. $(".hwzt").text('分机不可用'); //左下角状态显示
  385. //$(".fwzt").removeClass("br").removeClass("bl");
  386. $(".fwzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加话机状态灯
  387. $(".zxzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加坐席状态灯
  388. }
  389. if(data.State == '1') {
  390. $(".hwzt").text('空闲'); //左下角状态显示
  391. $(".fwzt").removeClass("br").addClass("bl");
  392. $(".zxzt").removeClass("br").addClass("bl");//20180509 by fanlongfei 增加坐席状态灯
  393. if(window.frames['iframe'+ hidCallID +'']){
  394. window.frames['iframe'+ hidCallID +''].clearInter();
  395. }
  396. if (hidTel && hidCallID) {
  397. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateGJ', {
  398. callid: hidTel,
  399. "token": $.cookie("token")
  400. }, function (result) {
  401. result = JSON.parse(result);
  402. if (result.state.toLowerCase() == "success") { }
  403. })
  404. }
  405. $("#top-search li i").removeClass("active");
  406. $(".Logout").addClass("active");
  407. $(".SayBusy").addClass("active");
  408. $(".MakeCall").addClass("active");
  409. if(window.frames['iframe'+ hidCallID +'']){
  410. window.frames['iframe'+ hidCallID +''].$(".td-call").hide();
  411. }
  412. }
  413. if(data.State == '2') {
  414. $(".hwzt").text('摘机等待拨号'); //左下角状态显示
  415. }
  416. if(data.State == '3') {
  417. $(".hwzt").text('正在拨号'); //左下角状态显示
  418. }
  419. if(data.State == '4') {
  420. $(".hwzt").text('呼出振铃'); //左下角状态显示
  421. }
  422. if(data.State == '5') {
  423. $(".hwzt").text('来电振铃'); //左下角状态显示
  424. //$(".fwzt").removeClass("bl").addClass("br");
  425. $(".fwzt").removeClass("br").addClass("bl");//20180509 by fanlongfei 增加话机状态灯
  426. $(".zxzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加坐席状态灯
  427. if (hidTel && hidCallID) {
  428. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZL', {
  429. callid: hidCallID,
  430. "token": $.cookie("token")
  431. }, function (result) {
  432. result = JSON.parse(result);
  433. if (result.state.toLowerCase() == "success") { }
  434. })
  435. }
  436. }
  437. if(data.State == '6') {
  438. $(".hwzt").text('通话中'); //左下角状态显示
  439. $(".fwzt").removeClass("bl").addClass("br");
  440. $(".zxzt").removeClass("bl").addClass("br");//20180509 by fanlongfei 增加坐席状态灯
  441. if(hidTel && hidCallID) {
  442. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZJ', {
  443. callid: hidCallID,
  444. "token": $.cookie("token")
  445. }, function(result) {
  446. result = JSON.parse(result);
  447. if(result.state.toLowerCase() == "success") {}
  448. })
  449. }
  450. $("#top-search li i").removeClass("active");
  451. $(".DropCall").addClass("active");
  452. $(".Hold").addClass("active");
  453. $(".Transfer").addClass("active");
  454. $(".Meeting").addClass("active");
  455. var aaa=data.CallDirection;
  456. if(data.CallDirection=="in"){
  457. // if (objiframe.attr("data-id") == './callScreen/callScreen.html?tel=' + hidTel + '&CallID=' + hidCallID + '') {
  458. setTimeout(window.frames['iframe'+ hidCallID +''].calling(),500);/*2018-05-19 zhangshuangnan 修改 ps: 因软电话设置为 自动应答 通话时间不计时问题*/
  459. // }
  460. }
  461. }
  462. if(data.State == '7') {
  463. $(".hwzt").text('播放忙音中'); //左下角状态显示
  464. }
  465. if(data.State == '8') {
  466. $(".hwzt").text('移除IP分机'); //左下角状态显示
  467. }
  468. if(data.State == '9') {
  469. $(".hwzt").text('通话保持中'); //左下角状态显示
  470. }
  471. }
  472. function toDub(i) {
  473. return i < 10 ? "0" + i : "" + i;
  474. }
  475. //外呼
  476. function MakeCallBack() {
  477. $("#top-search li i").removeClass("active");
  478. $(".DropCall").addClass("active");
  479. // alert('1');
  480. // window.frames[obj.attr("name")].calling();
  481. }
  482. //置忙置闲
  483. function SetState(obj) {
  484. if(obj.State == '5') {
  485. $(".SayBusy").removeClass("active");
  486. $(".SayFree").addClass("active");
  487. $(".zxzt").removeClass("bl").addClass("br");
  488. $(".hwzt").text('置忙');
  489. }
  490. if(obj.State == '2') {
  491. $(".SayBusy").addClass("active");
  492. $(".SayFree").removeClass("active");
  493. $(".zxzt").removeClass("br").addClass("bl");
  494. $(".hwzt").text('空闲');
  495. }
  496. }
  497. //置忙
  498. function SayBusyBack() {
  499. $(".SayBusy").removeClass("active");
  500. $(".SayFree").addClass("active");
  501. }
  502. //坐席班长置闲
  503. function SayFreeBack() {
  504. $(".SayBusy").addClass("active");
  505. $(".SayFree").removeClass("active");
  506. $(".zxzt").removeClass("br").addClass("bl"); // 2018/05/09 by fanlongfei 增加坐席状态指示
  507. $(".hwzt").text('空闲');// 2018/05/09 by fanlongfei 增加坐席状态指示
  508. }
  509. //多方通话
  510. function MeetingBack() {
  511. }
  512. //转移
  513. function TransferBack() {
  514. $("#top-search li i").removeClass("active");
  515. $(".Logout").addClass("active");
  516. $(".SayBusy").addClass("active");
  517. $(".MakeCall").addClass("active");
  518. }
  519. //保持
  520. function HoldBack() {
  521. $(".Hold").removeClass("active");
  522. $(".Retrieve").addClass("active");
  523. }
  524. //接回
  525. function RetrieveBack() {
  526. $(".Hold").addClass("active");
  527. $(".Retrieve").removeClass("active");
  528. }
  529. //监测
  530. function SubScribeBack() {
  531. $('#content-main .J_iframeNew').each(function(i,n){
  532. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  533. window.frames[$(this).attr("name")].Start();
  534. }
  535. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  536. }
  537. //取消监测
  538. function SubScribeCancelBack() {
  539. // var obj = $("iframe:visible")
  540. // if(obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  541. // window.frames[obj.attr("name")].();
  542. // }
  543. $('#content-main .J_iframeNew').each(function(i,n){
  544. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  545. window.frames[$(this).attr("name")].Stop();
  546. }
  547. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  548. }
  549. //班长监测返回状态
  550. //坐席状态
  551. function AgentStateBack(data) {
  552. $('#content-main .J_iframeNew').each(function(i,n){
  553. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  554. window.frames[$(this).attr("name")].UpdateAgentState(data.AgentID, data.State);
  555. }
  556. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  557. }
  558. //线路状态
  559. function LineStateBack(data) {
  560. $('#content-main .J_iframeNew').each(function(i,n){
  561. if($(this).attr('data-id') == "./TelCall/SeatMonitor.html"){
  562. window.frames[$(this).attr("name")].UpdateLineState(data.AgentID, data.State);
  563. }
  564. })/*2018-05-24 zhangshuangnan 修改 解决通话中时 坐席监控状态不改变的问题*/
  565. }
  566. //录音返回
  567. function RecordPathBack(data) {
  568. $(".hidCallID").val(data.CallID);
  569. //if ($(".hidTel").val() && $(".hidCallID").val()) {
  570. // $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', { callid: $(".hidCallID").val(),path:data.RecPath, "token": $.cookie("token") }, function (result) {
  571. // result = JSON.parse(result);
  572. // if (result.state.toLowerCase() == "success") {
  573. // }
  574. // })
  575. //}
  576. if(hidTel) {
  577. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', {
  578. callid: data.CallID,
  579. path: data.RecPath,
  580. "token": $.cookie("token")
  581. }, function(result) {
  582. result = JSON.parse(result);
  583. if(result.state.toLowerCase() == "success") {}
  584. })
  585. }
  586. }
  587. //获取当前的日期时间 格式“yyyy-MM-dd HH:mm:ss”
  588. function getNowFormatDate() {
  589. var date = new Date();
  590. var seperator1 = "-";
  591. var seperator2 = ":";
  592. var month = date.getMonth() + 1;
  593. var strDate = date.getDate();
  594. if(month >= 1 && month <= 9) {
  595. month = "0" + month;
  596. }
  597. if(strDate >= 0 && strDate <= 9) {
  598. strDate = "0" + strDate;
  599. }
  600. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
  601. " " + date.getHours() + seperator2 + date.getMinutes() +
  602. seperator2 + date.getSeconds();
  603. return currentdate;
  604. }