From f08aafa72acf138421a8e5061fd78e240576181b Mon Sep 17 00:00:00 2001 From: Muhammad Fikri Date: Wed, 21 Sep 2011 11:49:09 +0700 Subject: [PATCH 1/3] add loading status --- web/viewer.css | 5 +++++ web/viewer.html | 3 ++- web/viewer.js | 11 +++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/web/viewer.css b/web/viewer.css index d1f725a02..5b83c142a 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -271,3 +271,8 @@ canvas { page-break-after: always; } } + +#loading { + margin:100px 0; + text-align:center; +} diff --git a/web/viewer.html b/web/viewer.html index a53593df3..13d19fb6c 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -89,7 +89,8 @@ - + +
Loading... 0%
diff --git a/web/viewer.js b/web/viewer.js index 520cf4efa..87ed2b54f 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -110,13 +110,15 @@ var PDFView = { var xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.mozResponseType = xhr.responseType = 'arraybuffer'; - xhr.expected = (document.URL.indexOf('file:') === 0) ? 0 : 200; + xhr.expected = (document.URL.indexOf('file:') === 0) ? 0 : 200; + xhr.onprogress=PDFView.progressLevel; xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === xhr.expected) { var data = (xhr.mozResponseArrayBuffer || xhr.mozResponse || xhr.responseArrayBuffer || xhr.response); - + + document.getElementById('loading').style.display="none"; PDFView.load(data, scale); } }; @@ -124,6 +126,11 @@ var PDFView = { xhr.send(null); }, + progressLevel: function(evt) { + var p=Math.round((evt.loaded / evt.total)*100); + document.getElementById('loading').innerHTML = 'Loading... '+p+'%'; + }, + navigateTo: function(dest) { if (typeof dest === 'string') dest = this.destinations[dest]; From 34b64160175b80f68e125b7d83759b0c036cbbe8 Mon Sep 17 00:00:00 2001 From: Muhammad Fikri Date: Wed, 21 Sep 2011 19:25:29 +0700 Subject: [PATCH 2/3] fix indentations and style nits --- web/viewer.css | 4 ++-- web/viewer.html | 2 +- web/viewer.js | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/web/viewer.css b/web/viewer.css index 5b83c142a..cda191a76 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -273,6 +273,6 @@ canvas { } #loading { - margin:100px 0; - text-align:center; + margin: 100px 0; + text-align: center; } diff --git a/web/viewer.html b/web/viewer.html index 13d19fb6c..ecb869668 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -90,7 +90,7 @@ -
Loading... 0%
+
Loading... 0%
diff --git a/web/viewer.js b/web/viewer.js index 87ed2b54f..1a218c6dc 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -111,14 +111,14 @@ var PDFView = { xhr.open('GET', url); xhr.mozResponseType = xhr.responseType = 'arraybuffer'; xhr.expected = (document.URL.indexOf('file:') === 0) ? 0 : 200; - xhr.onprogress=PDFView.progressLevel; + xhr.onprogress = PDFView.progressLevel; xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === xhr.expected) { var data = (xhr.mozResponseArrayBuffer || xhr.mozResponse || xhr.responseArrayBuffer || xhr.response); - document.getElementById('loading').style.display="none"; + document.getElementById('loading').style.display = "none"; PDFView.load(data, scale); } }; @@ -127,8 +127,8 @@ var PDFView = { }, progressLevel: function(evt) { - var p=Math.round((evt.loaded / evt.total)*100); - document.getElementById('loading').innerHTML = 'Loading... '+p+'%'; + var p = Math.round((evt.loaded / evt.total) * 100); + document.getElementById('loading').innerHTML = 'Loading... ' + p + '%'; }, navigateTo: function(dest) { From 14bbd82ce53e861333a107c82fe5f8145f6fd284 Mon Sep 17 00:00:00 2001 From: Muhammad Fikri Date: Wed, 21 Sep 2011 21:05:40 +0700 Subject: [PATCH 3/3] fix indentation again --- web/viewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/viewer.js b/web/viewer.js index 1a218c6dc..72b540664 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -118,7 +118,7 @@ var PDFView = { var data = (xhr.mozResponseArrayBuffer || xhr.mozResponse || xhr.responseArrayBuffer || xhr.response); - document.getElementById('loading').style.display = "none"; + document.getElementById('loading').style.display = "none"; PDFView.load(data, scale); } };