<%@page import="qflag.ucstar.seatmonitor.manager.SeatMonitorManager"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<html>
<head>
<link href="js/css/footable-0.1.css" rel="stylesheet" type="text/css" />
<link href="js/css/footable.sortable-0.1.css" rel="stylesheet"
    type="text/css" />
<link href="js/css/footable.paginate.css" rel="stylesheet"
    type="text/css" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/footable.js" type="text/javascript"></script>
<script src="js/footable.sortable.js" type="text/javascript"></script>
<script src="js/footable.paginate.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function() { //ajax定时刷新table
        run(); //加载页面时启动定时器
        chat();
        function chat() { // var dateObj = new Date();
            $
                    .post(
                            'seatMonitorData.jsp?action=getData',
                            {},
                            function(data) {
                                //alert('1');
                                var jsonStr = eval("(" + data + ")");
                                if (jsonStr != undefined && jsonStr.length > 0) {
                                    for ( var i = 0; i < jsonStr.length; i++) { //双次迭代出数组 以及数组里面的json数组
                                        var t5 = jsonStr[i].curstatus;
                                        var jsontr = jsonStr[i].seatid;
                                        var jsontr1 = jsonStr[i].children;
                                        var time4 = jsonStr[i].statustime;
                                        if(!time4.length > 0 ){
                                            var time4 = '0';
                                            
                                        }
                                        if (jsontr1 != undefined
                                                && jsontr1.length > 0) {
                                            for ( var y = 0; y < jsontr1.length; y++) {
                                                var time1 = jsontr1[y].chattime;

var time2 = jsontr1[y].rspstime;

var time3 = jsontr1[y].waittime;

}
                                        } else {
                                            var time1 = '0';

var time2 = '0';

var time3 = '0';

}
                                        var time = parseFloat(time1) / 1000; //日期转换                //毫秒转换为 时/分/秒
                                        if (null != time && "" != time) {
                                            if (time > 60 && time < 60 * 60) {
                                                time = parseInt(time / 60.0)
                                                        + "分钟"
                                                        + parseInt((parseFloat(time / 60.0) - parseInt(time / 60.0)) * 60)
                                                        + "秒";
                                            } else if (time >= 60 * 60
                                                    && time < 60 * 60 * 24) {
                                                time = parseInt(time / 3600.0)
                                                        + "小时"
                                                        + parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)
                                                        + "分钟"
                                                        + parseInt((parseFloat((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60) - parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)) * 60)
                                                        + "秒";
                                            } else {
                                                time = parseInt(time) + "秒";
                                            }
                                        } else {
                                            time = "0 时 0 分0 秒";
                                        }

var time2s = parseFloat(time2) / 1000; //日期转换
                                        if (null != time2s && "" != time2s) {
                                            if (time2s > 60 && time2s < 60 * 60) {
                                                time2s = parseInt(time2s / 60.0)
                                                        + "分钟"
                                                        + parseInt((parseFloat(time2s / 60.0) - parseInt(time2s / 60.0)) * 60)
                                                        + "秒";
                                            } else if (time2s >= 60 * 60
                                                    && time2s < 60 * 60 * 24) {
                                                time2s = parseInt(time2s / 3600.0)
                                                        + "小时"
                                                        + parseInt((parseFloat(time2s / 3600.0) - parseInt(time2s / 3600.0)) * 60)
                                                        + "分钟"
                                                        + parseInt((parseFloat((parseFloat(time2s / 3600.0) - parseInt(time2s / 3600.0)) * 60) - parseInt((parseFloat(time2s / 3600.0) - parseInt(time2s / 3600.0)) * 60)) * 60)
                                                        + "秒";
                                            } else {
                                                time2s = parseInt(time2s) + "秒";
                                            }
                                        } else {
                                            time2s = "0 时 0 分0 秒";
                                        }

var time3s = parseFloat(time3) / 1000; //日期转换
                                    
                                        if (null != time3s && "" != time3s) {
                                            if (time3s > 60 && time3s < 60 * 60) {
                                                time3s = parseInt(time3s / 60.0)
                                                        + "分钟"
                                                        + parseInt((parseFloat(time3s / 60.0) - parseInt(time3s / 60.0)) * 60)
                                                        + "秒";
                                            } else if (time3s >= 60 * 60
                                                    && time3s < 60 * 60 * 24) {
                                                time3s = parseInt(time3s / 3600.0)
                                                        + "小时"
                                                        + parseInt((parseFloat(time3s / 3600.0) - parseInt(time3s / 3600.0)) * 60)
                                                        + "分钟"
                                                        + parseInt((parseFloat((parseFloat(time3s / 3600.0) - parseInt(time3s / 3600.0)) * 60) - parseInt((parseFloat(time3s / 3600.0) - parseInt(time3s / 3600.0)) * 60)) * 60)
                                                        + "秒";
                                            } else {
                                                time3s = parseInt(time3s) + "秒";
                                            }
                                        } else {
                                            time3s = "0 时 0 分0 秒";
                                        }

var time4s = parseFloat(time4) / 1000; //日期转换
                                    
                                        if (null != time4s && "" != time4s) {
                                            if (time4s > 60 && time4s < 60 * 60) {
                                                time4s = parseInt(time4s / 60.0)
                                                        + "分钟"
                                                        + parseInt((parseFloat(time4s / 60.0) - parseInt(time4s / 60.0)) * 60)
                                                        + "秒";
                                            } else if (time4s >= 60 * 60
                                                    && time4s < 60 * 60 * 24) {
                                                time4s = parseInt(time4s / 3600.0)
                                                        + "小时"
                                                        + parseInt((parseFloat(time4s / 3600.0) - parseInt(time4s / 3600.0)) * 60)
                                                        + "分钟"
                                                        + parseInt((parseFloat((parseFloat(time4s / 3600.0) - parseInt(time4s / 3600.0)) * 60) - parseInt((parseFloat(time4s / 3600.0) - parseInt(time4s / 3600.0)) * 60)) * 60)
                                                        + "秒";
                                            } else {
                                                time4s = parseInt(time4s) + "秒";
                                            }
                                        } else {
                                            time4s = "0 时 0 分0 秒";
                                        }
                                    
                                        if (t5 != null && t5 != '') {
                                            if (t5 == "online") {
                                                v5 = '<font size="+1" ace="黑体" color="#FF00FF"> 就绪</font>';
                                            } else if (t5 == "busy") {
                                                v5 = ' 未就绪';
                                            } else if (t5 == "away") {
                                                v5 = ' 休息';
                                            }
                                        }
                                        if (!$("#" + jsontr).length > 0) {
                                            var tr = '<tr id='+jsontr+'><td>'
                                                    + jsonStr[i].seatid
                                                    + '</td>';
                                            tr += '<td> ' + time + '</td>';
                                            tr += '<td> ' + time2s + '</td>';
                                            tr += '<td> ' + time3s + '</td>';
                                            tr += '<td>' + v5 + '</td>';
                                            tr += '<td> ' + time4s + '</td>';
                                            tr += '<td>'
                                                    + jsonStr[i].curservice
                                                    + '</td>';
                                            tr += '<td>'
                                                    + jsonStr[i].servicecount
                                                    + '</td>';
                                            tr += '</tr>';
                                            $("#time5").append(tr);
                                        } else {
                                            $("#time5").empty();
                                            var tr = '<tr id='+jsontr+'><td>'
                                                    + jsonStr[i].seatid
                                                    + '</td>';
                                            tr += '<td> ' + time + '</td>';
                                            tr += '<td> ' + time2s + '</td>';
                                            tr += '<td> ' + time3s + '</td>';
                                            tr += '<td>' + v5 + '</td>';
                                            tr += '<td> ' + time4s + '</td>';
                                            tr += '<td>'
                                                    + jsonStr[i].curservice
                                                    + '</td>';
                                            tr += '<td>'
                                                    + jsonStr[i].servicecount
                                                    + '</td>';
                                            tr += '</tr>';
                                            $("#time5").append(tr);
                                        }
                                    }

} else { //退出则清空缓存数据
                                    $("#time5").empty();
                                }
                            });
        }
        var interval;
        function run() {
            interval = setInterval(chat, "5000");
        }

});
</script>
</head>
<body leftmargin=0 topmargin=0 marginheight=0 weightmargin=0>
    <div id="time">
        <table class="footable" align="center" >
            <thead style="background:#D5E1F2">
                <tr>
                    <th>坐席工号</th>
                    <th>会话时长</th>
                    <th>响应时长</th>
                    <th>等待回复时长</th>
                    <th>当前状态</th>
                    <th>持续时长</th>
                    <th>当前服务数量</th>
                    <th>总服务数</th>
                </tr>
                
            </thead>
            <tbody id="time5" align="center"></tbody>
        </table>
    </div>
</body>
</html>

【jQuery】: 定时刷新页面的更多相关文章

  1. php+ajax+jquery 定时刷新页面数据

    testajax.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: ...

  2. JS定时刷新页面及跳转页面

    JS定时刷新页面及跳转页面 Javascript 返回上一页1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); 2. history ...

  3. JSP简单练习-定时刷新页面

    <%@ page contentType="text/html; charset=gb2312" %> <%@ page import="java.ut ...

  4. Angular 定时器$timeout和$interval关于定时刷新页面和发送请求的用法

    项目中有用到定时器定时刷新页面的数据,在网上查看了一些资料,整理了一下,备忘. $timeout 用法如下:$timeout(fn,[delay],[invokeApply]); fn:一个将被延迟执 ...

  5. 定时刷新页面SetInterval 和setTimeout -时间间隔可以动态设定

    JS里设定延时: 使用SetInterval和设定延时函数setTimeout 很类似.setTimeout 运用在延迟一段时间,再进行某项操作. setTimeout("function& ...

  6. js定时刷新页面.

    //页面定时刷新.2017.09.27 $(document).ready(function () { self.setInterval(function () { var d = new Date( ...

  7. http-equiv="Refresh" 实现定时刷新页面

    ***.html自动跳转文件代码如下: <HTML> <HEAD><META http-equiv="Refresh" content="5 ...

  8. Vue使用定时器定时刷新页面

    1. 需求说明 在前端开发中,往往会遇到页面需要实时刷新数据的情况,给用户最新的数据展示. 2. 逻辑分析 如果需要数据实时更新,我们自然是需要使用定时器,不断的调用接口数据,会相对的消耗内存. 3. ...

  9. Ajax实现定时刷新页面

    function deleteValue(){ var refresh = function() { $.ajax({   type:'post',   url:'/Application/index ...

随机推荐

  1. VS2010快捷键大全

    VS2010版快捷键 Ctrl+E,D ----格式化全部代码 Ctrl+E,F ----格式化选中的代码 CTRL + SHIFT + B生成解决方案 CTRL + F7 生成编译 CTRL + O ...

  2. js传递参数中包含+号时的处理方法

    encodeURI(url).replace(/\+/g, '%2B') 例子: $scope.getAnesthesiawaystatistical = function (annual, anes ...

  3. Java为什么会引入及如何使用Unsafe

    综述 sun.misc.Unsafe至少从2004年Java1.4开始就存在于Java中了.在Java9中,为了提高JVM的可维护性,Unsafe和许多其他的东西一起都被作为内部使用类隐藏起来了.但是 ...

  4. linux 下的clock_gettime() 获取精确时间函数

    #include <time.h> int clock_gettime(clockid_t clk_id, struct timespec* tp); clock_gettime() 函数 ...

  5. testng 控制case运行顺序

    Testing.xml 文档结构: <test name="xxxx" preserve-order="false"> <!-- 参数定义的方 ...

  6. python __init__.py用途

    转自http://www.cnpythoner.com/post/2.html Python中的Module是比较重要的概念.常见的情况是,事先写好一个.py文 件,在另一个文件中需要import时, ...

  7. 【原创】No matching distribution found for Twisted>=10.0.0 (from scrapy)

    系统  Ubuntu14.04 python  2.7.11 运行  pip install scrapy  报错: No matching distribution found for Twiste ...

  8. [原创] ubuntu下安装scrapy报错 error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    Ubuntu14.04在virtualenv下安装scrapy报错,Failed building wheel for cffi,lxml,cryptography 等. error: command ...

  9. 第五百八十二天 how can I 坚持

    好吧,是我错了,昨天,做好自己就行了,别人怎么样是别人的事,永远保持一颗单纯向上的心. 时间过得真快,明天又周六了.. 睡觉.

  10. ITop

    iTop,即IT运营门户(IT Operation Portal),是一个开源web应用程序,用于IT环境的日常运营.它基于ITIL最佳实践,而又不拘泥于任何具体流程.它很灵活,可以适应不管是非正 式 ...