forked from CSDTs/CSnap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Charles_Changes_To_IDE_Morph.js
32 lines (30 loc) · 1.11 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
IDE_Morph.prototype.droppedBinary = function (anArrayBuffer, name) {
// dynamically load ypr->Snap!
var ypr = document.getElementById('ypr'),
myself = this,
suffix = name.substring(name.length - 3);
if (suffix.toLowerCase() === 'ypr') {
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});
}
};