MCPcopy Create free account
hub / github.com/AlexNisnevich/untrusted / preprocess

Function preprocess

scripts/codeEditor.js:43–125  ·  view source on GitHub ↗
(codeString)

Source from the content-addressed store, hash-verified

41 // preprocesses code,determines the location
42 // of editable lines and sections, loads properties
43 function preprocess(codeString) {
44 editableLines = [];
45 editableSections = {};
46 endOfStartLevel = null;
47 startOfStartLevel = null;
48 var propertiesString = '';
49
50 var lineArray = codeString.split("\n");
51 var inEditableBlock = false;
52 var inPropertiesBlock = false;
53
54 for (var i = 0; i < lineArray.length; i++) {
55 var currentLine = lineArray[i];
56
57 // process properties
58 if (currentLine.indexOf(symbols.begin_properties) === 0) {
59 lineArray.splice(i,1); // be aware that this *mutates* the list
60 i--;
61 inPropertiesBlock = true;
62 } else if (currentLine.indexOf(symbols.end_properties) === 0) {
63 lineArray.splice(i,1);
64 i--;
65 inPropertiesBlock = false;
66 } else if (inPropertiesBlock) {
67 lineArray.splice(i,1);
68 i--;
69 propertiesString += currentLine;
70 }
71 // process editable lines and sections
72 else if (currentLine.indexOf(symbols.begin_line) === 0) {
73 lineArray.splice(i,1);
74 i--;
75 inEditableBlock = true;
76 } else if (currentLine.indexOf(symbols.end_line) === 0) {
77 lineArray.splice(i,1);
78 i--;
79 inEditableBlock = false;
80 }
81 // process start of startLevel()
82 else if (currentLine.indexOf(symbols.start_start_level) === 0) {
83 lineArray.splice(i,1);
84 startOfStartLevel = i;
85 i--;
86 }
87 // process end of startLevel()
88 else if (currentLine.indexOf(symbols.end_start_level) === 0) {
89 lineArray.splice(i,1);
90 endOfStartLevel = i;
91 i--;
92 }
93 // everything else
94 else {
95 if (inEditableBlock) {
96 editableLines.push(i);
97 } else {
98 // check if there are any editable sections
99 var sections = [];
100 var startPoint = null;

Callers 1

CodeEditorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected