-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
60 lines (51 loc) · 2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Upload Image</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="jquery.storage.js"></script>
</head>
<body>
<script>
let counter = 0;
// This runs every x seconds and checks if a file have been uplaoded.
myInt = setInterval(function() {
x = document.getElementById("file-input");
var files = x.files;
var preview = document.querySelector('img');
var file = document.querySelector('input[type=file]').files[0];
var reader = new FileReader();
reader.onloadend = function() {
preview.src = reader.result;
}
if (file) {
reader.readAsDataURL(file);
} else {
preview.src = "";
}
if (files.length != 0) {
if (counter == 0) {
console.log("Do nothing");
counter = counter + 1;
} else {
$.sessionStorage('chosenImg', document.getElementById("photoImg").src);
console.log("chosenImg have been send on to the next html page with source: " + document.getElementById("photoImg").src);
clearInterval(myInt);
window.location.href = "crop.html";
}
} else {
console.log("not lets go");
}
}, 200);
</script>
<h1 class="panel-header-title">Upload your image!<h1/>
<a href="#" class="btn" id="btn">
<input id="file-input" type="file"/>
</a>
<img src="" id="photoImg" height="200" alt="Image preview..." hidden>
</body>
</html>