TinyCircuits-Thumby-Code-Editor
TinyCircuits-Thumby-Code-Editor copied to clipboard
Cannot export to PC (button does not work) nor import
export to pc Button doesn't work (Firefox 121.0). I am a javascript dev and I have done similar things (making scripts to download files) before and would be happy to help if you need it. Os is macOS Sonama 14.1.2 (m2)
Added: used js debug skills: error is window.showSaveFilePicker is not a function
that is an experimental technology ye silly guys you gotta state that
nice open source editor, im trying to emulate the file picker right now
here is some code that patches the issue, at least on firefox
also the open button aint gonna work either. it uses the same API as the showSaveFilePicker() function (the File System API)
window.showSaveFilePicker=function(fileoptions) {
window.savefileopt = fileoptions;
return new Promise((resolve) => {
resolve({
kind: "file",
createWritable: function() {
return new Promise((resolve) => {
resolve({
write: function(blob){
var saveData = function (blob, fileName) {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = prompt("Choose a name for the download", fileName);
a.click();
window.URL.revokeObjectURL(url);
};
saveData(blob, savefileopt.suggestedName)
resolve();
},
close:function(){}
})
//fake the fake file handles fake writable
});
}
}) //fake the file handle
});
};
I put a lot of time and effort into this ( 10 minutes) so I hope to see it implemented in your code. (im not very good)
also you must do similar for the file picker (include an invisible <input> instead of an invisible <a> as that will increase compatibility by 105%.) so yeh, be sure to at least include something like this as a fallback if the function cannot be found. Thanks, buggem (Max Parry)
And even weirder I can see a catch statement for the showOpenFilePicker() call, but not the showSaveFilePicker() call. Weird, feels like someone forgot to catch for errors there. It's lucky for me though, because it led me right to the spot.
for some reason i can't get the openFilePicker call to work.
window.showOpenFilePicker = function(fileoptions) {
try {
return new Promise((resolve) => {
resolve({
fileoptions: fileoptions,
getFile: function() {
let fileoptions = this.fileoptions;
return new Promise((resolve) => {
let input = document.createElement('input');
input.type = 'file';
input.style = "display: none";
input.accept = this.fileoption.types.map(a=>a.accept).join(',')
input.onchange = e => {
resolve(e.target.files[0]);
}
input.click();
window.myFileInput = input; // for debugging
}); // our part is done, we can let the file class do the rest... woo-hoo
}
})
});
} catch(e) { console.log(e.message); }
}
my code so far
finished and working:
window.showOpenFilePicker = function(fileoptions) {
console.log("here")
window.openfileopt = fileoptions;
return new Promise((resolve) => {
alert("inside promise openfilepicker")
resolve([{
getFile: function() {
alert("got to getfile")
return new Promise((resolve) => {
let input = document.createElement('input');
input.type = 'file';
input.style = "display: none";
input.onchange = e => {
resolve(e.target.files[0]);
}
input.click();
window.myFileInput = input; // for debugging
}); // our part is done, we can let the file class do the rest... woo-hoo
}
}])
});
}
could you implement my code? will open a pull request if you want me to
congratulations, you changed your script and broke my code :) working on a fix, if you do this again ill have to create a repo for this ;) lol
umm no you didnt sorry
it was just micropython code instead of blockly code ;0
https://github.com/Buggem/sysstorapi-hack/tree/main
incase of future updates, here it is
hurry up and fix
this is just useless irl
been 4 months bro
Please can you raise a PR for review?
@ace-dent yes i can, and i will try