mirror of https://github.com/mosra/magnum.git
Browse Source
The page now displays download progress, last error and also hints to the user that JS console might contain something useful. NaClApplication and WindowlessNaClApplication documentation has been updated with brief "bootstrap guide".pull/278/head
6 changed files with 154 additions and 65 deletions
@ -0,0 +1,51 @@
|
||||
body { |
||||
margin: 0px; |
||||
padding: 0px; |
||||
font-family: sans-serif; |
||||
background-color: #111111; |
||||
color: #aaaaaa; |
||||
} |
||||
|
||||
h1 { |
||||
text-align: center; |
||||
font-size: 20px; |
||||
} |
||||
|
||||
#listener { |
||||
border-style: solid; |
||||
border-color: #333333; |
||||
border-width: 1px; |
||||
padding: 1px; |
||||
width: 640px; |
||||
height: 480px; |
||||
margin-left: auto; |
||||
margin-right: auto; |
||||
margin-top: 20px; |
||||
margin-bottom: 20px; |
||||
position: relative; |
||||
} |
||||
|
||||
#module { |
||||
width: 640px; |
||||
height: 480px; |
||||
z-index: 10; |
||||
} |
||||
|
||||
#status { |
||||
position: absolute; |
||||
width: 640px; |
||||
text-align: center; |
||||
top: 200px; |
||||
font-size: 30px; |
||||
font-weight: bold; |
||||
z-index: 9; |
||||
} |
||||
|
||||
#statusDescription { |
||||
position: absolute; |
||||
width: 640px; |
||||
text-align: center; |
||||
top: 250px; |
||||
font-size: 15px; |
||||
z-index: 9; |
||||
} |
||||
@ -0,0 +1,43 @@
|
||||
function setStatus(message) { |
||||
var status = document.getElementById('status'); |
||||
if(status) status.innerHTML = message; |
||||
} |
||||
|
||||
function setStatusDescription(message) { |
||||
var statusDescription = document.getElementById('statusDescription'); |
||||
if(statusDescription) statusDescription.innerHTML = message; |
||||
} |
||||
|
||||
var listener = document.getElementById('listener'); |
||||
|
||||
listener.addEventListener('loadstart', function() { |
||||
setStatus('Loading...'); |
||||
}, true); |
||||
|
||||
listener.addEventListener('progress', function(event) { |
||||
setStatus('Downloading...'); |
||||
|
||||
/* Show progress */ |
||||
if(event.lengthComputable && event.total > 0) |
||||
setStatusDescription(Math.round(event.loaded*100/event.total) + '% of ' |
||||
+ Math.round(event.total/1024) + ' kB'); |
||||
|
||||
/* Unknown total size */ |
||||
else setStatusDescription(Math.round(event.loaded/1024) + ' kB'); |
||||
|
||||
}, true); |
||||
|
||||
listener.addEventListener('error', function() { |
||||
setStatus('Loading failed'); |
||||
setStatusDescription(document.getElementById('module').lastError + '<br />Check JavaScript console for more information.'); |
||||
}, true); |
||||
|
||||
listener.addEventListener('abort', function() { |
||||
setStatus('Loading aborted'); |
||||
setStatusDescription(''); |
||||
}, true); |
||||
|
||||
listener.addEventListener('load', function() { |
||||
setStatus(''); |
||||
setStatusDescription(''); |
||||
}, true); |
||||
Loading…
Reference in new issue