git @ Cat's Eye Technologies Lexeduct / de2c751
optionsInput is gone now and it sort of actually works! Chris Pressey 6 years ago
1 changed file(s) with 9 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
6060 var process = function() {
6161 var t = transformer['identity'].makeTransformer({});
6262 for (var i = 0; i < transformerSlots.length; i++) {
63 console.log(uneval(transformerSlots[i]));
6364 var transformerName = transformerSlots[i].name;
6465 var selectedParams = transformerSlots[i].selectedParams;
6566 var t2 = transformer[transformerName].makeTransformer(selectedParams);
8182 });
8283 yoob.makeLineBreak(transformersPanel);
8384
84 var updateParametersPanel = function(panel, parameters) {
85 var updateParametersPanel = function(slot, panel) {
86 var parameters = transformer[slot.name].parameters;
8587 panel.innerHTML = ""; // delete any previous controls
8688 for (var key in parameters) {
8789 if (parameters.hasOwnProperty(key)) {
9092 var input = yoob.makeTextInput(panel, 24);
9193 input.style.width = "50%";
9294 // TODO: populate it with the default
95 // TODO: and assign it to slot.selectedParams[key]
9396 input.onchange = function() {
94 alert('TODO: update transformerSlots.selectedParameters or smth here');
97 slot.selectedParams[key] = input.value;
9598 if (liveMode) {
9699 process();
97100 }
108111 yoob.makeLineBreak(transformersPanel);
109112 var parametersPanel = yoob.makeDiv(transformersPanel);
110113
111 var getSelectedParams = function(panel) {
112 // TODO FIXME
113 return parseOptions(transformerSlots[i].optionsInput.value);
114 };
115
116114 select.onchange = function(e) {
117 updateParametersPanel(parametersPanel);
118115 transformerSlots[index].name = select.options[select.selectedIndex].value;
119 transformerSlots[index].selectedParams = getSelectedParams(parametersPanel);
116 updateParametersPanel(transformerSlots[index], parametersPanel);
120117 if (liveMode) {
121118 process();
122119 }
123120 };
124121
125 //------------ deprecated...
126 var optionsInput = yoob.makeTextInput(transformersPanel, 24);
127 optionsInput.onchange = function(e) {
128 if (liveMode) {
129 process();
130 }
131 };
132 optionsInput.title = "Options";
133 yoob.makeLineBreak(transformersPanel);
134 //------------
135
136122 return {
123 name: 'identity',
124 selectedParams: {},
137125 select: select,
138 optionsInput: optionsInput,
139126 parametersPanel: parametersPanel
140127 };
141128 };
142129
143130 for (var i = 0; i < MAX_TRANSFORMER_SLOTS; i++) {
144 var slot = makeTransformerSlot(transformersPanel, index);
131 var slot = makeTransformerSlot(transformersPanel, i);
145132 transformerSlots.push(slot);
146133 }
147134