Commit 127ac924ccb4787225fe03e62b6563549b84a0f5

Authored by Unknown
1 parent 0c5d2c32

Suppression home.js

Showing 1 changed file with 0 additions and 101 deletions   Show diff stats
PFE06/src/main/resources/static/js/home.js deleted
... ... @@ -1,101 +0,0 @@
1   -$(document).ready(function() {
2   -
3   -/********** Drop Zone **********/
4   -
5   - var formData = new FormData();
6   - var dropZone = document.querySelector("#drop-zone");
7   - dropZone.style.cursor = "pointer";
8   - var file = document.getElementById("filesExplorer");
9   - var fileProgress = document.getElementById("file-progress");
10   - var readyToSend = false;
11   -
12   - dropZone.addEventListener('click', function() {
13   - delete formData;
14   - formData = new FormData();
15   - file.click();
16   - })
17   -
18   - file.addEventListener('change', function() {
19   - dropZone.innerHTML = this.files[0].name;
20   - formData.append("file", this.files[0]);
21   - readyToSend = true;
22   - }, false)
23   -
24   - dropZone.addEventListener('drop', function(e) {
25   - e.preventDefault();
26   - delete formData;
27   - formData = new FormData();
28   - dropZone.style.borderWidth = '2px';
29   - var files = e.dataTransfer.files;
30   -
31   - if(files.length > 1) {
32   - $("#warningFilesNumber").modal()
33   - return;
34   - }
35   - dropZone.innerHTML = files[0].name;
36   - formData.append("file", files[0]);
37   - readyToSend = true;
38   - }, false)
39   -
40   - dropZone.addEventListener('dragenter', function(e) {
41   - console.log("Enter");
42   - dropZone.style.borderWidth = '5px';
43   - }, false);
44   -
45   - dropZone.addEventListener('dragleave', function(e) {
46   - console.log("Leave");
47   - dropZone.style.borderWidth = '2px';
48   - }, false);
49   -
50   - dropZone.addEventListener('dragover', function(e) {
51   - e.preventDefault();
52   - }, false);
53   -
54   - document.getElementById("sendButton").addEventListener('click', function() {
55   - var modalContent = document.getElementById("modal-content");
56   - var modalTitle = document.getElementById("modal-title");
57   - if(readyToSend) {
58   - var request = new XMLHttpRequest();
59   - request.open("POST", "/file");
60   -
61   - request.upload.onloadstart = function(e) {
62   - fileProgress.style.display = 'block';
63   - fileProgress.style.width = 0 + "px"
64   - fileProgress.innerHTML = "0%";
65   - }
66   -
67   - request.upload.onprogress = function(e) {
68   - var p = 100 - ((e.total - e.loaded) / e.total * 100);
69   - fileProgress.style.width = Math.ceil(p) + "%"
70   - fileProgress.innerHTML = Math.ceil(p) + "%";
71   - }
72   -
73   - request.upload.onloadend = function(e) {
74   - fileProgress.style.width = 100 + "%"
75   - fileProgress.innerHTML = "100%";
76   - var modalButton = document.getElementById("modal-button");
77   -
78   - modalButton.addEventListener('click', function(e) {
79   - location.reload();
80   - })
81   -
82   - modalContent.innerHTML = "Upload terminé !";
83   - modalTitle.innerHTML = "Félicitations";
84   - $("#warningFilesNumber").modal()
85   - }
86   -
87   - request.onreadystatechange = function() {
88   - if(this.readyState === XMLHttpRequest.DONE && this.status === 200) {
89   - formData = new FormData();
90   - }
91   - }
92   -
93   - request.send(formData);
94   -
95   - }
96   - else {
97   - modalContent.innerHTML = "Veuillez choisir un fichier !";
98   - }
99   - })
100   -
101   -} );