0
當我更新清單的版本時,默認頁面顯示一個顯示0-100%的微調,然後顯示成功消息。但是,第一次用戶從未達到100%。它停在那裏。它不執行下一個功能,它是更新內容。以下是我的代碼:使用清單,第一次用戶永遠不會通過「進度」功能
<script>
var opts = {
lines: 13, // The number of lines to draw
length: 11, // The length of each line
width: 5, // The line thickness
radius: 17, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 0, // The rotation offset
color: '#FFF', // #rgb or #rrggbb
speed: 1, // Rounds per second
trail: 10, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: 'auto', // Top position relative to parent in px
left: 'auto' // Left position relative to parent in px
};
var overlay;
var spinner;
var target;
window.applicationCache.addEventListener('checking', function (event) {
console.log("Checking for updates.");
console.log("inside checking event, appcache status : %s", applicationCache.status);
}, false);
window.applicationCache.addEventListener('downloading', function (event) {
target = document.createElement("div");
document.body.appendChild(target);
spinner = new Spinner(opts).spin(target);
overlay = iosOverlay({
text: "0%",
spinner: spinner
});
}, false);
window.applicationCache.addEventListener('progress', function (event) {
var per = event.loaded.toString()/event.total.toString();
var totalPercentage = Math.round(per * 100);
Math.round
overlay.update({
text: totalPercentage + "%",
spinner: spinner
});
}, false);
window.applicationCache.addEventListener('updateready', function (e) {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
window.setTimeout(function() {
overlay.update({
icon: "loader/img/check.png",
text: "Success"
});
}, 2e3);
window.setTimeout(function() {
window.location.reload();
}, 3e3);
}
}, false);
</script>
僅供參考如果清單文件已更新且應用程序緩存更新爲第二次,第三次或更多時間 – 2016-09-20 22:49:24