Add more functions to element-factory.js.
Chris Pressey
10 years ago
22 | 22 | return canvas; |
23 | 23 | }; |
24 | 24 | |
25 | yoob.makeButton = function(container, label) { | |
25 | yoob.makeButton = function(container, labelText) { | |
26 | 26 | var button = document.createElement('button'); |
27 | button.innerHTML = label; | |
27 | button.innerHTML = labelText; | |
28 | 28 | container.appendChild(button); |
29 | 29 | return button; |
30 | 30 | }; |
67 | 67 | container.appendChild(p); |
68 | 68 | return p; |
69 | 69 | }; |
70 | ||
71 | yoob.makeTextArea = function(container, cols, rows, initial) { | |
72 | var textarea = document.createElement('textarea'); | |
73 | textarea.rows = "" + rows; | |
74 | textarea.cols = "" + cols; | |
75 | if (initial) { | |
76 | container.value = initial; | |
77 | } | |
78 | container.appendChild(textarea); | |
79 | return textarea; | |
80 | }; | |
81 | ||
82 | yoob.makeLineBreak = function(container) { | |
83 | var br = document.createElement('br'); | |
84 | container.appendChild(br); | |
85 | return br; | |
86 | }; | |
87 | ||
88 | yoob.makeSelect = function(container, labelText, optionsArray) { | |
89 | var label = document.createElement('label'); | |
90 | label.innerHTML = labelText; | |
91 | container.appendChild(label); | |
92 | ||
93 | var select = document.createElement("select"); | |
94 | ||
95 | for (var i = 0; i < optionsArray.length; i++) { | |
96 | var op = document.createElement("option"); | |
97 | op.value = optionsArray[i][0]; | |
98 | op.text = optionsArray[i][1]; | |
99 | if (optionsArray[i].length > 2) { | |
100 | op.selected = optionsArray[i][2]; | |
101 | } else { | |
102 | op.selected = false; | |
103 | } | |
104 | select.options.add(op); | |
105 | } | |
106 | ||
107 | container.appendChild(select); | |
108 | return select; | |
109 | }; |