您的位置:首页 > 其它

统计京东通信当前当页通话记录总时间脚本

2017-04-07 12:38 190 查看
用以解决京东通信无法统计既定时间段内通话总分钟数的问题





目前只能按照一页一页的统计,如果要统计下一页,需要跳到第二页后手动再执行一次方法,2333333

//方法调用
statisticalTatalTimeRecord();

function statisticalTatalTimeRecord(){
//总分钟数
var totalMinute = 0;
//总秒数
var totalSecond = 0;
//统计次数
var recordCount = 0;
$.each($($("table")[1]).find("tr"), function(){
var $this = $(this);
//获取时间段
var timePeriod = $($this.find("td")[3]);

//检查是否为正常数据段
if (0 != timePeriod.length) {
//时间段(分)截取索引
var timeMinuteIndex = timePeriod.text().indexOf("分");
//时间段(秒)截取索引
var timeSecondIndex = timePeriod.text().indexOf("秒");

//无秒数的则不进行统计
if (-1 != timeSecondIndex) {
//当前秒数--正则替换其中数字
var nowSecond = Number.parseInt(timePeriod.text().substr(timeMinuteIndex + 1, timeSecondIndex).replace(/[^0-9]/ig,""), 10);
//递增秒数--大于60秒则递增分钟数
totalSecond += nowSecond;
if (60 <= totalSecond) {
totalMinute++;
totalSecond = totalSecond - 60;
}

//递增当前分钟数
if (-1 != timeMinuteIndex) {
//当前分钟--正则替换其中数字
var nowMinute = Number.parseInt(timePeriod.text().substr(0, timeMinuteIndex).replace(/[^0-9]/ig,""), 10);
totalMinute += nowMinute;
}

//递增统计次数
++recordCount;
}
}
});

console.log("总消耗时间:" + totalMinute + "分" + totalSecond + "秒");
console.log("统计条数:" + recordCount);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: