--- filexfer.js | 20 ++++++++++++++++++++ spice.html | 7 +++++++ spice_auto.html | 7 +++++++ 3 files changed, 34 insertions(+) diff --git a/filexfer.js b/filexfer.js index 21ba350..4172916 100644 --- a/filexfer.js +++ b/filexfer.js @@ -24,3 +24,23 @@ function SpiceFileXferTask(id, file) this.file = file; } +function handle_file_dragover(e) +{ + e.stopPropagation(); + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; +} + +function handle_file_drop(e) +{ + var sc = window.spice_connection; + var files = e.dataTransfer.files; + + e.stopPropagation(); + e.preventDefault(); + for (var i = files.length - 1; i >= 0; i--) { + if (files[i].type); // do not copy a directory + sc.file_xfer_start(files[i]); + }; + +} diff --git a/spice.html b/spice.html index fc53a2a..604ced9 100644 --- a/spice.html +++ b/spice.html @@ -120,6 +120,13 @@ window.spice_connection = this; resize_helper(this); + + if (window.File && window.FileReader && window.FileList && window.Blob) { + document.getElementById('spice-area').addEventListener('dragover', handle_file_dragover, false); + document.getElementById('spice-area').addEventListener('drop', handle_file_drop, false); + } else { + console.log("File API is not supported"); + } } </script> diff --git a/spice_auto.html b/spice_auto.html index 48dcae1..dcf322e 100644 --- a/spice_auto.html +++ b/spice_auto.html @@ -156,6 +156,13 @@ window.spice_connection = this; resize_helper(this); + + if (window.File && window.FileReader && window.FileList && window.Blob) { + document.getElementById('spice-area').addEventListener('dragover', handle_file_dragover, false); + document.getElementById('spice-area').addEventListener('drop', handle_file_drop, false); + } else { + console.log("File API is not supported"); + } } connect(); -- 1.9.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel