diff options
author | Thomas Felber <felber@student.tugraz.at> | 2015-04-10 05:23:28 -0700 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2015-07-13 09:48:46 +0200 |
commit | 21298359e6fe6eec9a4083f8ed8c23e88338b5ff (patch) | |
tree | 0ace5670472af797424f766dc7df306e395bb9bd /pdf-as-web/src/main/webapp/assets/js/dragNdrop.js | |
parent | f2b754b03a2c1c4ff20c2c34387ecfcdc3ce1c16 (diff) | |
download | pdf-as-4-21298359e6fe6eec9a4083f8ed8c23e88338b5ff.tar.gz pdf-as-4-21298359e6fe6eec9a4083f8ed8c23e88338b5ff.tar.bz2 pdf-as-4-21298359e6fe6eec9a4083f8ed8c23e88338b5ff.zip |
added html, css, js
Diffstat (limited to 'pdf-as-web/src/main/webapp/assets/js/dragNdrop.js')
-rw-r--r-- | pdf-as-web/src/main/webapp/assets/js/dragNdrop.js | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js b/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js new file mode 100644 index 00000000..040b61d0 --- /dev/null +++ b/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js @@ -0,0 +1,112 @@ + +$(document).ready(function() { + registerEventListeners(); +}); + +function registerEventListeners() { + $(document).bind("dragover", function(evt) { + evt.preventDefault(); + }); + + $(document).bind("drop", function(evt) { + evt.preventDefault(); + }); + + $("#dropzone").bind("dragenter", function(evt) { + evt.preventDefault(); + evt.stopPropagation(); + highlightDropzone(); + }); + + $("#dropzone").bind("dragover", function(evt) { + evt.preventDefault(); + evt.stopPropagation(); + }); + + $("#dropzone").bind("dragleave", function(evt) { + evt.preventDefault(); + evt.stopPropagation(); + unhighlightDropzone(); + }); + + $("#dropzone").bind("dragend", function(evt) { + evt.preventDefault(); + evt.stopPropagation(); + unhighlightDropzone(); + }); + + $("#dropzone").bind("drop", function(evt) { + evt.preventDefault(); + evt.stopPropagation(); + unhighlightDropzone(); + + var files = evt.originalEvent.dataTransfer.files; + if(files == null) { + return; + } + + previewFile(files[0]); + }); +} + +function previewFile(file) { + var fr = new FileReader(); + + fr.onload = function(file) { + var buffer = fr.result; + /*var int8View = new Uint8Array(buffer); + var output = document.getElementById("output"); + output.innerHTML = + int8View[0].toString(16) + + int8View[1].toString(16) + + int8View[2].toString(16) + + int8View[3].toString(16);*/ + displaypdf(buffer); + }; + + clearContentDiv(); + fr.readAsDataURL(file); +} + +function sign() { + /*var fd = new FormData(); + fd.append("pdf-file", files[0]); + fd.append("source", "internal"); + fd.append("connector", "mobilebku"); + + $.ajax({ + url: "Sign", + data: fd, + processData: false, + contentType: false, + type: "POST", + success: function(response) { + $("html").empty(); + $("html").html(response); + } + });*/ +} + +function highlightDropzone() { + $("#dropzone").css("background", "#D8FFD8"); +} + +function unhighlightDropzone() { + $("#dropzone").css("background", "#E8F4FF"); +} + +function displaypdf(datauri) { + $("#content").append("<img src='assets/img/signature.png' alt='Signature' id='signature' draggable='true' style='position: absolute'>"); + $("#content").append("<iframe src=" + datauri + " width='800px' height='868px'></iframe>"); + + $("#signature").draggable({ + drag: function() { + + }, + containment: "parent" + }); +} + +function clearContentDiv() { + $("#content").empty(); +} |