git @ Cat's Eye Technologies Lexeduct / 7ec1ff8
Add defaults to parameters def'n. Initialize text from element. Chris Pressey 6 years ago
5 changed file(s) with 20 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
99 </header>
1010
1111 <div id="container"></div>
12
13 <pre style="display: none;" id="initial-text">
14 This is a text.
15 It is a text.
16 And such things.
17 </pre>
1218
1319 </body>
1420 <script src="lexeduct-browser.js"></script>
2632 var container, input, output, processButton, tranformersPanel;
2733
2834 container = document.getElementById('container');
29 input = yoob.makeTextArea(container, 40, 20, "Hello, there!\nWhat do you think?");
35 input = yoob.makeTextArea(container, 40, 20);
36 input.value = document.getElementById('initial-text').innerHTML;
3037
3138 var transformersPanel = yoob.makeDiv(container);
3239 transformersPanel.style.border = "2px solid black";
8794 panel.innerHTML = ""; // delete any previous controls
8895 for (var key in parameters) {
8996 if (parameters.hasOwnProperty(key)) {
97 var desc = parameters[key][0];
98 var def = parameters[key][1];
9099 var label = yoob.makeSpan(panel, key);
91 label.style.width = "50%";
92 var input = yoob.makeTextInput(panel, 24);
93 input.style.width = "50%";
94 // TODO: populate it with the default
95 // TODO: and assign it to slot.selectedParams[key]
100 var input = yoob.makeTextInput(panel, 24, def);
101 slot.selectedParams[key] = def;
96102 input.onchange = function() {
97103 slot.selectedParams[key] = input.value;
98104 if (liveMode) {
110116 );
111117 yoob.makeLineBreak(transformersPanel);
112118 var parametersPanel = yoob.makeDiv(transformersPanel);
113
119 parametersPanel.style.padding = "2px";
120 parametersPanel.style.border = "1px solid blue";
121 parametersPanel.style.textAlign = "right";
122
114123 select.onchange = function(e) {
115124 transformerSlots[index].name = select.options[select.selectedIndex].value;
116125 updateParametersPanel(transformerSlots[index], parametersPanel);
99 };
1010 },
1111 parameters: {
12 'chars': "The set of characters to select from"
12 'chars': ["The set of characters to select from", ""]
1313 },
1414 description: "Insert a randomly-selected character after each character"
1515 };
1313 };
1414 },
1515 parameters: {
16 'chance': "Probability (0-100) of applying to any individual character"
16 'chance': ["Probability (0-100) of applying to any individual character", "100"]
1717 },
1818 description: "Convert characters to lowercase"
1919 };
1111 };
1212 },
1313 parameters: {
14 'chars': "The set of characters to select from"
14 'chars': ["The set of characters to remove", ""]
1515 },
1616 description: "Remove all occurrences of the specified characters"
1717 };
1313 };
1414 },
1515 parameters: {
16 'chance': "Probability (0-100) of applying to any individual character"
16 'chance': ["Probability (0-100) of applying to any individual character", "100"]
1717 },
1818 description: "Convert characters to uppercase"
1919 };