Skip to content

Commit

Permalink
switch amm to bin import (#1565)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragazo authored Nov 5, 2024
1 parent e0a8db1 commit 47391b8
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 47 deletions.
19 changes: 10 additions & 9 deletions dist/app.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.dot
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<script type="text/javascript" src="src/store-ext.js"></script>
<script type="text/javascript" src="src/actions-ext.js"></script>
{{ } else { }}
<script type="text/javascript" src="dist/app.min.js?v=2.4.11"></script>
<script type="text/javascript" src="dist/app.min.js?v=2.4.12"></script>
{{ } }}

</head>
Expand Down
70 changes: 36 additions & 34 deletions src/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2412,52 +2412,54 @@ IDE_Morph.prototype.droppedText = async function (aString, name, fileType) {
if (fileType.indexOf('json') !== -1 || ext === 'json') {
return this.openDataString(aString, lbl, 'json');
}

// import as plain text data
return this.openDataString(aString, lbl, 'text');
};

IDE_Morph.prototype.droppedBinary = function (anArrayBuffer, name) {
const ext = name ? name.slice(name.lastIndexOf('.') + 1).toLowerCase() : '';

if (ext === 'musicxml') {
try {
const proj = window.amm_sdk_netsblox_wasm.translate_musicxml(aString);
const proj = window.amm_sdk_netsblox_wasm.translate_musicxml(new Uint8Array(anArrayBuffer));
return this.droppedText(proj);
} catch (e) {
return world.children[0].inform('Failed to Import Project', e.message);
}
}
if (ext === 'mid' || ext === 'smf') {
} else if (ext === 'mid' || ext === 'smf') {
try {
const proj = window.amm_sdk_netsblox_wasm.translate_midi(aString);
const proj = window.amm_sdk_netsblox_wasm.translate_midi(new Uint8Array(anArrayBuffer));
return this.droppedText(proj);
} catch (e) {
return world.children[0].inform('Failed to Import Project', e.message);
}
}

// import as plain text data
return this.openDataString(aString, lbl, 'text');
};

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') {return; }

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 = this.resourceURL('src', 'ypr.js');
} else {
loadYPR(anArrayBuffer, name);
// dynamically load ypr->Snap!
var ypr = document.getElementById('ypr'),
myself = this,
suffix = name.substring(name.length - 3);

if (suffix.toLowerCase() !== 'ypr') {return; }

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 = this.resourceURL('src', 'ypr.js');
} else {
loadYPR(anArrayBuffer, name);
}
}
};

Expand Down
Loading

0 comments on commit 47391b8

Please sign in to comment.