X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=inline;f=gallery%2Fnumber-format.js;h=cc3d22fcbe9f20141fcb221ae69956b224c16425;hb=ad9515f810131991ff323f6437623cc15a36c492;hp=6a20e3c57b29ca045a3d14c7fa265db13a615b17;hpb=795b16307db2a673ba7aa3452f6f6b0e93baeb3a;p=dygraphs.git diff --git a/gallery/number-format.js b/gallery/number-format.js index 6a20e3c..cc3d22f 100644 --- a/gallery/number-format.js +++ b/gallery/number-format.js @@ -1,3 +1,4 @@ +/*global Gallery,Dygraph,data */ Gallery.register( 'number-format', { @@ -15,33 +16,33 @@ Gallery.register( " variety of precisions.
" + "Precision to use (1 to 21):" + - "
" + + " " + "" + ""; }, run: function() { // Helper functions for generating an HTML table for holding the test // results. - createRow = function(columnType, columns) { + var createRow = function(columnType, columns) { var row = document.createElement('tr'); for (var i = 0; i < columns.length; i ++) { var th = document.createElement(columnType); var text = document.createTextNode(columns[i]); th.appendChild(text); row.appendChild(th); - }; + } return row; }; - createHeaderRow = function(columns) { + var createHeaderRow = function(columns) { return createRow('th', columns); }; - createDataRow = function(columns) { + var createDataRow = function(columns) { return createRow('td', columns); }; - createTable = function(headerColumns, dataColumnsList) { + var createTable = function(headerColumns, dataColumnsList) { var table = document.createElement('table'); table.appendChild(createHeaderRow(headerColumns)); for (var i = 0; i < dataColumnsList.length; i++) { @@ -50,11 +51,11 @@ Gallery.register( return table; }; - window.updateTable = function() { + var updateTable = function() { var headers = ['Dygraph.floatFormat()', 'toPrecision()', 'Dygraph.floatFormat()', 'toPrecision()']; var numbers = []; - var p = parseInt(document.getElementById('p_input').value); + var p = parseInt(document.getElementById('p_input').value, 10); for (var i = -10; i <= 10; i++) { var n = Math.pow(10, i); @@ -66,7 +67,7 @@ Gallery.register( // Check exact values of 0. numbers.push([Dygraph.floatFormat(0.0, p), - 0.0.toPrecision(p)]); + (0.0).toPrecision(p)]); var elem = document.getElementById('content'); elem.innerHTML = ''; @@ -74,6 +75,7 @@ Gallery.register( }; document.getElementById('p_input').value = '4'; + document.getElementById('p_input').onchange = updateTable; updateTable(); } });