let creatingVariable = false; function addVariable(variable = {name: "", type: dataTypes.String, value: ""}, id = null) { if (creatingVariable === false) { // Blocking future variable creation until finish the current creation creatingVariable = true; let html = ""; html += `
`; html += `
`; html += `
`; html += `

Adicionar variável

`; html += `
`; html += `
`; html += `
`; html += `
`; html += ` `; html += `
`; html += `
`; html += ` `; html += `
`; html += `
`; html += `
`; html += `
`; html += ` `; html += `
`; html += `
`; html += ` `; html += `
`; html += `
`; html += `
`; html += `
`; html += ` `; html += `
`; html += `
`; html += ` `; html += `
`; html += `
`; html += `
`; html += ` `; html += `
`; html += `
`; $main.append(html); } } function addVariableTocode({id = null}) { let code = ""; let variable = { name: $("#varibaleName").val(), type: $("#variableType").val(), value: $("#variableValue").val() }; let variableBarrier = getVariableTypeBarrier(variable.type); code += `${variable.type} ${variable.name} = ${variableBarrier}${variable.value}${variableBarrier}`; // Sending code to screen addCodeToScreen({id: id, code: code, variable: variable}); // Removing div form for variable creation $("#variableCreationDiv").remove(); // Enabling future variable creation creatingVariable = false; } function cancelAddVariable(id = null) { // Removing div form for variable creation $("#variableCreationDiv").remove(); if (id != null) $(`#variableDiv${id}`).show(); // Enabling future variable creation creatingVariable = false; } function editVariable(id = null, variable = {name: "", type: dataTypes.String, value: ""}) { $(`#variableDiv${id}`).hide(); addVariable(variable, id); } function deleteVariable(id = null) { if (id != null) $(`#variableDiv${id}`).remove(); } function addCodeToScreen({ id = null, code = "Some code", variable = {name: "", type: "String", value: ""} }) { let html = ``; if (id != null) { $(`#mainCode${id}`).html(`${code}`); $(`#editCode${id}`).html(``); $(`#variableDiv${id}`).show(); } else { html += `
`; html += `
`; html += `
`; html += `

Variável

`; html += `
`; html += `
`; html += `
`; html += `
${getCurrentMainLineNumber()}
`; html += `
${code}
`; html += `
`; html += `
`; html += ` `; html += `
`; html += `
`; $main.append(html); } // Increasing universal id universalId += 1; }