From 36f853f6b380099a378c032baf46f35d914026f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 12 Jun 2013 14:03:26 +0200 Subject: [PATCH 1/1] =?utf8?q?Ajout=20de=20quelques=20exp=C3=A9rimentation?= =?utf8?q?s=20pr=C3=A9liminaires=20pour=20int=C3=A9grer=20upload=20par=20j?= =?utf8?q?s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/fileupload.js | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 skins/fileupload.js diff --git a/skins/fileupload.js b/skins/fileupload.js new file mode 100644 index 0000000..d862ad6 --- /dev/null +++ b/skins/fileupload.js @@ -0,0 +1,54 @@ +function dragenter(evt) { + disableDefault(evt); + disablePropagation(evt); +} + +function dragover(evt) { + disableDefault(evt); + disablePropagation(evt); + evt = getEventObject(evt); + var dt = evt.dataTransfer; + dt.dropEffect = 'copy'; +} + + +function drop(evt) { + disableDefault(evt); + disablePropagation(evt); + getEventObject(evt); + var dt = evt.dataTransfer; + dt.dropEffect = 'copy'; + handleFiles(dt.files); +} + +function handleFiles(files) { + for (var i = 0; i < files.length; i++) { + var file = files[i]; + console.log(file.type); + // console.log(file); + // var imageType = /image.*/; + // + // if (!file.type.match(imageType)) { + // continue; + // } + // + // var img = document.createElement("img"); + // img.classList.add("obj"); + // img.file = file; + // preview.appendChild(img); + // + // var reader = new FileReader(); + // reader.onload = (function(aImg) { return function(e) { aImg.src = e.target.result; }; })(img); + // reader.readAsDataURL(file); + } +} + +function init() { + var dropbox = document.getElementById('dropbox'); + addListener(dropbox, 'dragenter', dragenter); + addListener(dropbox, 'dragover', dragover); + addListener(dropbox, 'drop', drop); +} + + +addListener(window, 'load', init); \ No newline at end of file -- 2.20.1