diff --git a/src/js/macros.js b/src/js/macros.js index 26e9e01..df6b4d3 100644 --- a/src/js/macros.js +++ b/src/js/macros.js @@ -201,18 +201,25 @@ module.exports = { const macrosList = macros.map(item => item.name); var macrosName = document.getElementById("macros-name").value; var macrosColor = document.getElementById("macros-color").value; - if (macrosList.includes(macrosName)) { + const formattedFilename = macrosName + .replace(/\\/g, "_") + .replace(/\//g, "_") + .replace(/#/g, "-") + .replace(/\?/g, "-"); + + if (macrosList.includes(formattedFilename)) { this.sameName = true; this.confirmSave = false; return; } - var file_name = this.fileName == "default" ? macrosName + ".ngc" : this.fileName; + + var file_name = this.fileName == "default" ? formattedFilename + ".ngc" : this.fileName; var file = this.newGcode; this.uploadGCode(file_name, file); - this.config.macros[this.tab - 1].name = macrosName; + this.config.macros[this.tab - 1].name = formattedFilename; this.config.macros[this.tab - 1].color = macrosColor; this.config.macros[this.tab - 1].file_name = file_name; this.confirmSave = false; diff --git a/src/pug/templates/macros.pug b/src/pug/templates/macros.pug index d45bdc2..9456c8a 100644 --- a/src/pug/templates/macros.pug +++ b/src/pug/templates/macros.pug @@ -81,7 +81,7 @@ script#macros-template(type="text/x-template") p.title Macros Name .input-container input.input-color(type="color",id="macros-color",value="#ffffff",@change="editedColor") - input.input-name(type="text",minlength='1',maxlength='20',id="macros-name" ,v-model="macrosName",@keypress="editedName") + input.input-name(type="text",minlength='1',maxlength='15',id="macros-name" ,v-model="macrosName",@keypress="editedName") p.title Macros G-Code .flex-row-container select(id="gcode-select",title="Select previously uploaded GCode programs.",selected