forked from jmoenig/Snap
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCharles_Changes_To_IDE_Morph.js
37 lines (35 loc) · 1.32 KB
/
Charles_Changes_To_IDE_Morph.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
IDE_Morph.prototype.droppedBinary = function (anArrayBuffer, name, aFile) {
// dynamically load ypr->Snap!
var ypr = document.getElementById('ypr'),
myself = this,
suffix = name.substring(name.length - 3);
if (suffix.toLowerCase() === 'ypr') {
console.log(suffix);
function loadYPR(buffer, lbl) {
var reader = new sb.Reader(),
pname = lbl.split('.')[0]; // up to period
reader.onload = function (info) {
myself.droppedText(new sb.XMLWriter().write(pname, info));
};
reader.readYPR(new Uint8Array(buffer));
}
if (!ypr) {
ypr = document.createElement('script');
ypr.id = 'ypr';
ypr.onload = function () {loadYPR(anArrayBuffer, name); };
document.head.appendChild(ypr);
ypr.src = 'ypr.js';
} else {
loadYPR(anArrayBuffer, name);
}
} else if (suffix.toLowerCase() === 'zip' ||
suffix.toLowerCase() === 'smod') {
var mdl = new ModuleLoader(this);
var zip = new JSZip(anArrayBuffer);
mdl.open(zip, {base64: false});
}
// here is the case to import rw files
else if (suffix.toLowerCase() == '.rw'){
myself.droppedRWFile(aFile);
}
};