* 更新popup page的北京时间,剩余时间和设定后台的时间
(standerTime)
| 195 | * 更新popup page的北京时间,剩余时间和设定后台的时间 |
| 196 | */ |
| 197 | function updateTime(standerTime) { |
| 198 | var timer = setInterval(function () { |
| 199 | standerTime += 1000; |
| 200 | $("#standTime").text(formatDateTime(standerTime)); |
| 201 | $("span[datafld='leftTime']").each(function () { |
| 202 | $(this).text(getLeftTime(parseInt($(this).attr("killTime"))-standerTime+1000)); |
| 203 | }); |
| 204 | }, 1000); |
| 205 | if(oldTimer != null) { |
| 206 | clearInterval(oldTimer); |
| 207 | } |
| 208 | |
| 209 | //更新Background的时间 开始 |
| 210 | var port = chrome.extension.connect({ |
| 211 | name: "update standerTime" |
| 212 | }); |
| 213 | port.postMessage(standerTime); |
| 214 | port.onMessage.addListener(function(msg) { |
| 215 | console.log("后台反馈:" + msg); |
| 216 | }); |
| 217 | //更新Background的时间 结束 |
| 218 | oldTimer = timer; |
| 219 | } |
| 220 | |
| 221 | |
| 222 | function getLeftTime(leftTime) { |
no test coverage detected