Repository: cordova-plugin-file-transfer Updated Branches: refs/heads/master 007f98692 -> 887c91750
CB-10037 Add progress indicator to file-transfer manual tests Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/887c9175 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/887c9175 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/887c9175 Branch: refs/heads/master Commit: 887c91750a28d077976bd5340f9002ab2b569da6 Parents: 007f986 Author: daserge <[email protected]> Authored: Thu Nov 19 11:31:56 2015 +0300 Committer: daserge <[email protected]> Committed: Wed Nov 25 20:10:59 2015 +0300 ---------------------------------------------------------------------- tests/tests.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/887c9175/tests/tests.js ---------------------------------------------------------------------- diff --git a/tests/tests.js b/tests/tests.js index 48361c5..bf4cc5a 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -993,9 +993,25 @@ exports.defineManualTests = function (contentEl, createActionButton) { function downloadImg(source, urlFn, element, directory) { var filename = source.substring(source.lastIndexOf("/") + 1); filename = (directory || '') + filename; + function download(fileSystem) { var ft = new FileTransfer(); console.log("Starting download"); + + var progress = document.getElementById("loadingStatus"); + progress.value = 0; + + ft.onprogress = function(progressEvent) { + if (progressEvent.lengthComputable) { + var currPercents = parseInt(100 * (progressEvent.loaded / progressEvent.total), 10); + if (currPercents > progress.value) { + progress.value = currPercents; + } + } else { + progress.value = null; + } + }; + ft.download(source, fileSystem.root.toURL() + filename, function (entry) { console.log("Download complete"); element.src = urlFn(entry); @@ -1032,6 +1048,7 @@ exports.defineManualTests = function (contentEl, createActionButton) { /******************************************************************************/ + var progress_tag = '<progress id="loadingStatus" value="0" max="100" style="width: 100%;"></progress>'; var file_transfer_tests = '<h2>Image File Transfer Tests</h2>' + '<h3>The following tests should display an image of the Apache feather in the status box</h3>' + '<div id="cdv_image"></div>' + @@ -1042,7 +1059,7 @@ exports.defineManualTests = function (contentEl, createActionButton) { '<div id="cdv_video"></div>' + '<div id="native_video"></div>'; - contentEl.innerHTML = '<div id="info"></div>' + + contentEl.innerHTML = '<div id="info"></div>' + '<br>' + progress_tag + file_transfer_tests; createActionButton('Download and display img (cdvfile)', function () { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
