Make the Javascript more modern and/or actually working.
Chris Pressey
5 years ago
0 | 0 | /* |
1 | * This file is part of yoob.js version 0.12 | |
1 | * This file is part of yoob.js version 0.13-PRE | |
2 | 2 | * Available from https://github.com/catseye/yoob.js/ |
3 | 3 | * This file is in the public domain. See http://unlicense.org/ for details. |
4 | 4 | */ |
209 | 209 | }; |
210 | 210 | textInput.onchange = function(e) { |
211 | 211 | var v = parseInt(textInput.value, 10); |
212 | if (v !== NaN) { | |
212 | if (!isNaN(v)) { | |
213 | 213 | slider.value = "" + v; |
214 | 214 | fun(v); |
215 | 215 | } |
257 | 257 | }; |
258 | 258 | textInput.onchange = function(e) { |
259 | 259 | var v = parseInt(textInput.value, 10); |
260 | if (v !== NaN) { | |
260 | if (!isNaN(v)) { | |
261 | 261 | slider.value = "" + v; |
262 | 262 | callback(v); |
263 | 263 | } |
267 | 267 | if (withButtons) { |
268 | 268 | decButton = yoob.makeButton(container, "-", function() { |
269 | 269 | var v = parseInt(textInput.value, 10); |
270 | if (v !== NaN && v > min_) { | |
270 | if ((!isNaN(v)) && v > min_) { | |
271 | 271 | v--; |
272 | 272 | textInput.value = "" + v; |
273 | 273 | slider.value = "" + v; |
276 | 276 | }); |
277 | 277 | incButton = yoob.makeButton(container, "+", function() { |
278 | 278 | var v = parseInt(textInput.value, 10); |
279 | if (v !== NaN && v < max_) { | |
279 | if ((!isNaN(v)) && v < max_) { | |
280 | 280 | v++; |
281 | 281 | textInput.value = "" + v; |
282 | 282 | slider.value = "" + v; |
302 | 302 | |
303 | 303 | yoob.makeSVGElem = function(svg, tag, cfg) { |
304 | 304 | var elem = document.createElementNS(svg.namespaceURI, tag); |
305 | for (var key in cfg) { | |
306 | if (cfg.hasOwnProperty(key)) { | |
307 | elem.setAttribute(key, cfg[key]); | |
308 | } | |
309 | } | |
305 | Object.keys(cfg).forEach(function(key) { | |
306 | elem.setAttribute(key, cfg[key]); | |
307 | }); | |
310 | 308 | svg.appendChild(elem); |
311 | 309 | return elem; |
312 | 310 | }; |