Skip to content

Commit

Permalink
Fix for saving and loading python files
Browse files Browse the repository at this point in the history
  • Loading branch information
mklomp committed May 24, 2024
1 parent f07e633 commit 586b073
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions vue-frontend/src/components/ControlButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,23 @@ export default {
openFileWindow(){
this.$refs.file_input.value = null;
if (this.$parent.language == 'blockly') {
this.$refs.file_input.accept = ".xml";
} else {
this.$refs.file_input.accept = ".py";
}
this.$refs.file_input.click()
},
upload(){
var fr=new FileReader();
fr.onload = () => {
console.log(fr.result)
this.$store.dispatch('setBlockly', fr.result)
if (this.$parent.language == 'blockly') {
this.$store.dispatch('setBlockly', fr.result)
} else {
this.$store.dispatch('setCode', fr.result)
}
}
if(this.$refs.file_input.files.length > 0){
Expand All @@ -98,8 +106,13 @@ export default {
},
download(){
var text = localStorage.getItem("blockly");
var filename = "mirte.xml";
if (this.$parent.language == 'blockly') {
var text = localStorage.getItem("blockly");
var filename = "mirte.xml";
} else {
var text = this.$store.getters.getCode;
var filename = "mirte.py";
}
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
Expand Down

0 comments on commit 586b073

Please sign in to comment.