-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrop_handler.js
45 lines (37 loc) · 990 Bytes
/
drop_handler.js
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
function drop_handler(evt){
console.log("Drop handler loaded");
evt.preventDefault();
//If dropped item aren't files, reject them
var dt = evt.dataTransfer;
if(dt.items){
console.log("item loaded")
for(var i=0; i < dt.items.length; i++){
if(dt.items[i].kind === 'file'){
var f = dt.items[i].getAsFile();
// saveAs(f, "sample.stl");
console.log("...file[" + i + "].name = " + f.name + " saved")
//load f right away to the interface
loadSTLModel(f, 'ascii')
}
}
} else {
for(var i=0; i < dt.files.length; i++){
console.log("...file[" + i + "].name = " + dt.files[i].name);
}
}
}
function dragover_handler(evt){
console.log("dragOver");
evt.preventDefault();
}
function dragend_handler(evt){
console.log("dragEnd");
var dt = evt.dataTransfer;
if(dt.items){
for(var i=0; i< dt.items.length; i++){
dt.items.remove(i);
}
} else {
evt.dataTransfer.clearData();
}
}