Refactoring Code for Javascript Code

This commit is contained in:
Luis Fernando Molina committed 2019-12-06 18:06:56 +01:00
1 parent 849d6b8a51
commit 58d48edfa6
14 files changed
+25 -29

No files matched your search

@@ -501,7 +501,7 @@ function newChainAttachDetach () {
completeDetachment(node, rootNodes)
return
}
case 'Code': {
case 'Javascript Code': {
node.payload.parentNode.code = undefined
completeDetachment(node, rootNodes)
return
@@ -1100,7 +1100,7 @@ function newChainAttachDetach () {
completeAttachment(node, rootNodes)
}
break
case 'Code': {
case 'Javascript Code': {
node.payload.parentNode = attachToNode
node.payload.chainParent = attachToNode
node.payload.parentNode.code = node
@@ -227,7 +227,7 @@ function newNodeChildren () {
case 'Condition': {
return countChildrenCondition(parentNode, childNode)
}
case 'Code': {
case 'Javascript Code': {
return countChildrenCode(parentNode, childNode)
}
default: {
@@ -372,7 +372,7 @@ function newNodeDeleter () {
deleteCondition(rootNode, rootNodes)
break
}
case 'Code': {
case 'Javascript Code': {
deleteCode(rootNode, rootNodes)
break
}
@@ -7,7 +7,7 @@ function newOnFocus () {
function getNodeThatIsOnFocus (node) {
if (node === undefined) { return }
switch (node.type) {
case 'Code':
case 'Javascript Code':
{
if (node.payload.uiObject.isOnFocus === true) {
return node
@@ -7,7 +7,7 @@ function newProtocolNode () {
function getProtocolNode (node, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) {
if (node === undefined) { return }
switch (node.type) {
case 'Code':
case 'Javascript Code':
{
let object = {
type: node.type,
@@ -7,7 +7,7 @@ function newShortcutKeys () {
function getNodeByShortcutKey (node, searchingKey) {
if (node === undefined) { return }
switch (node.type) {
case 'Code':
case 'Javascript Code':
{
if (node.payload.uiObject.shortcutKey === searchingKey) {
return node
@@ -110,9 +110,9 @@ function newUiObjectsFromNodes () {
function createUiObjectFromNode (node, parentNode, chainParent, positionOffset) {
switch (node.type) {
case 'Code':
case 'Javascript Code':
{
createUiObject(false, 'Code', node.name, node, parentNode, chainParent, 'Code', positionOffset)
createUiObject(false, 'Javascript Code', node.name, node, parentNode, chainParent, 'Javascript Code', positionOffset)
return
}
case 'Condition':
@@ -2033,7 +2033,7 @@ function newUiObjectsFromNodes () {
node.code = {
code: DEFAULT_CODE_TEXT
}
createUiObject(true, 'Code', '', node.code, node, node)
createUiObject(true, 'Javascript Code', '', node.code, node, node)
}
return node.code
@@ -2099,7 +2099,7 @@ function newUiObjectsFromNodes () {
}
situation.conditions.push(condition)
createUiObject(true, 'Condition', condition.name, condition, situation, situation, 'Condition')
createUiObject(true, 'Code', '', condition.code, condition, condition, 'Code')
createUiObject(true, 'Javascript Code', '', condition.code, condition, condition, 'Javascript Code')
return condition
}
+1 -2
View File
@@ -71,7 +71,7 @@ function newCodeEditor () {
let textArea = document.getElementById('textArea')
textArea.style.display = 'none'
thisObject.payload.node.code = textArea.value
if (thisObject.payload.node.type !== 'Code' && thisObject.payload.node.type !== 'Formula') {
if (thisObject.payload.node.type !== 'Javascript Code' && thisObject.payload.node.type !== 'Formula') {
try {
let code = JSON.parse(thisObject.payload.node.code)
} catch (err) {
@@ -220,4 +220,3 @@ function newCodeEditor () {
}
}
}
+1 -2
View File
@@ -71,7 +71,7 @@ function newConditionEditor () {
let textArea = document.getElementById('textArea')
textArea.style.display = 'none'
thisObject.payload.node.code = textArea.value
if (thisObject.payload.node.type !== 'Code' && thisObject.payload.node.type !== 'Formula') {
if (thisObject.payload.node.type !== 'Javascript Code' && thisObject.payload.node.type !== 'Formula') {
try {
let code = JSON.parse(thisObject.payload.node.code)
} catch (err) {
@@ -220,4 +220,3 @@ function newConditionEditor () {
}
}
}
+1 -2
View File
@@ -71,7 +71,7 @@ function newConfigEditor () {
let textArea = document.getElementById('textArea')
textArea.style.display = 'none'
thisObject.payload.node.code = textArea.value
if (thisObject.payload.node.type !== 'Code' && thisObject.payload.node.type !== 'Formula') {
if (thisObject.payload.node.type !== 'Javascript Code' && thisObject.payload.node.type !== 'Formula') {
try {
let code = JSON.parse(thisObject.payload.node.code)
} catch (err) {
@@ -220,4 +220,3 @@ function newConfigEditor () {
}
}
}
+1 -2
View File
@@ -71,7 +71,7 @@ function newFormulaEditor () {
let textArea = document.getElementById('textArea')
textArea.style.display = 'none'
thisObject.payload.node.code = textArea.value
if (thisObject.payload.node.type !== 'Code' && thisObject.payload.node.type !== 'Formula') {
if (thisObject.payload.node.type !== 'Javascript Code' && thisObject.payload.node.type !== 'Formula') {
try {
let code = JSON.parse(thisObject.payload.node.code)
} catch (err) {
@@ -220,4 +220,3 @@ function newFormulaEditor () {
}
}
}
+2 -2
View File
@@ -550,7 +550,7 @@ function newUiObject () {
compatibleType = '->' + 'Situation' + '->'
compatibleSubType = undefined
break
case 'Code':
case 'Javascript Code':
compatibleType = '->' + 'Condition' + '->' + 'Procedure Initialization' + '->' + 'Procedure Loop' + '->' + 'Plotter Module' + '->' + 'Plotter Panel' + '->'
compatibleSubType = undefined
break
@@ -609,7 +609,7 @@ function newUiObject () {
if (thisObject.payload.node.type === 'Take Profit' && nearbyNode.takeProfit !== undefined) { continue }
if (thisObject.payload.node.type === 'Formula' && nearbyNode.formula !== undefined) { continue }
if (thisObject.payload.node.type === 'Next Phase Event' && nearbyNode.nextPhaseEvent !== undefined) { continue }
if (thisObject.payload.node.type === 'Code' && nearbyNode.code !== undefined) { continue }
if (thisObject.payload.node.type === 'Javascript Code' && nearbyNode.code !== undefined) { continue }
/* Here we check if the subtypes are compatible. */
if (nearbyNode.subType !== undefined && compatibleSubType !== undefined) {
if (compatibleSubType.indexOf('->' + nearbyNode.subType + '->') < 0) {
+7 -7
View File
@@ -1067,7 +1067,7 @@ function newUiObjectConstructor () {
actionFunction: payload.onMenuItemClick,
label: 'Add Code',
visible: true,
relatedUiObject: 'Code',
relatedUiObject: 'Javascript Code',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
@@ -1116,7 +1116,7 @@ function newUiObjectConstructor () {
actionFunction: payload.onMenuItemClick,
label: 'Add Code',
visible: true,
relatedUiObject: 'Code',
relatedUiObject: 'Javascript Code',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
@@ -1633,7 +1633,7 @@ function newUiObjectConstructor () {
actionFunction: payload.onMenuItemClick,
label: 'Add Code',
visible: true,
relatedUiObject: 'Code',
relatedUiObject: 'Javascript Code',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
@@ -1695,7 +1695,7 @@ function newUiObjectConstructor () {
actionFunction: payload.onMenuItemClick,
label: 'Add Code',
visible: true,
relatedUiObject: 'Code',
relatedUiObject: 'Javascript Code',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
@@ -4601,7 +4601,7 @@ function newUiObjectConstructor () {
actionFunction: payload.onMenuItemClick,
label: 'Add Code',
visible: true,
relatedUiObject: 'Code',
relatedUiObject: 'Javascript Code',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
@@ -4640,7 +4640,7 @@ function newUiObjectConstructor () {
)
break
}
case 'Code': {
case 'Javascript Code': {
uiObject.codeEditor = newCodeEditor()
uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction
uiObject.codeEditor.initialize()
@@ -5003,7 +5003,7 @@ function newUiObjectConstructor () {
level_5()
break
}
case 'Code': {
case 'Javascript Code': {
level_5()
break
}
+1 -1
View File
@@ -86,7 +86,7 @@ function newDesignerSpace () {
['Next Phase Event', 'pantone'],
['Situation', 'pyramid'],
['Condition', 'testing'],
['Code', 'html'],
['Javascript Code', 'html'],
['Team', 'team'],
['Sensor Bot', 'bot-sensor'],
['Indicator Bot', 'bot-indicator'],