From e1e80cce232a1efbebc1e3dbe236ecf957464c68 Mon Sep 17 00:00:00 2001
From: Dan Vanderkam
";
}
document.getElementById("list").innerHTML = html;
- }
- }
+ }
+ }
);
-
+
var last_ann = 0;
annotations = [];
for (var x = 10; x < 15; x += 2) {
@@ -78,7 +78,7 @@ Gallery.register(
}
} );
g.setAnnotations(annotations);
-
+
document.getElementById('add').onclick = function() {
var x = last_ann + 2;
var annnotations = g.annotations();
@@ -91,26 +91,26 @@ Gallery.register(
} );
last_ann = x;
g.setAnnotations(annotations);
- }
+ };
var bottom = document.getElementById('bottom');
bottom.onclick = function() {
var to_bottom = bottom.textContent == 'Shove to bottom';
-
+
var anns = g.annotations();
for (var i = 0; i < anns.length; i++) {
anns[i].attachAtBottom = to_bottom;
}
g.setAnnotations(anns);
-
+
if (to_bottom) {
bottom.textContent = 'Lift back up';
} else {
bottom.textContent = 'Shove to bottom';
}
- }
-
+ };
+
var saveBg = '';
var num = 0;
g.updateOptions( {
diff --git a/gallery/avoid-min-zero.js b/gallery/avoid-min-zero.js
index 9d72980..96a3cbc 100644
--- a/gallery/avoid-min-zero.js
+++ b/gallery/avoid-min-zero.js
@@ -18,7 +18,7 @@ Gallery.register(
"2008-05-10,0\n" +
"2008-05-11,3\n" +
"2008-05-12,4\n"
- )
+ );
var g2 = new Dygraph(document.getElementById("graphd2"),
"Date,Temperature\n" +
"2008-05-07,0\n" +
@@ -30,7 +30,7 @@ Gallery.register(
{
stepPlot: true
}
- )
+ );
var g3 = new Dygraph(document.getElementById("graph3"),
"Date,Temperature\n" +
"2008-05-07,0\n" +
@@ -42,7 +42,7 @@ Gallery.register(
{
avoidMinZero: true
}
- )
+ );
var g4 = new Dygraph(document.getElementById("graphd4"),
"Date,Temperature\n" +
"2008-05-07,0\n" +
@@ -55,6 +55,6 @@ Gallery.register(
stepPlot: true,
avoidMinZero: true
}
- )
+ );
}
});
diff --git a/gallery/callbacks.js b/gallery/callbacks.js
index 8891b4c..dfa4a97 100644
--- a/gallery/callbacks.js
+++ b/gallery/callbacks.js
@@ -17,12 +17,12 @@ Gallery.register(
var showLabels = document.getElementById('showLabels');
showLabels.onclick = function() {
g.updateOptions({showLabelsOnHighlight: showLabels.checked});
- }
+ };
var s = document.getElementById("status");
var clearStatus = function() {
s.innerHTML = '';
- }
+ };
document.getElementById('clear').onclick = clearStatus;
var g = null;
diff --git a/gallery/color-cycle.js b/gallery/color-cycle.js
index 96f125c..a625d7c 100644
--- a/gallery/color-cycle.js
+++ b/gallery/color-cycle.js
@@ -17,7 +17,7 @@ Gallery.register(
['#284785', '#EE1111', '#8AE234'],
['#444444', '#888888', '#DDDDDD'],
null
- ]
+ ];
chart = new Dygraph(document.getElementById("blah"),
"X,a,b,c\n" +
"10,12345,23456,34567\n" +
diff --git a/gallery/data.js b/gallery/data.js
index 52105e4..bbccab0 100644
--- a/gallery/data.js
+++ b/gallery/data.js
@@ -2682,4 +2682,4 @@ var stockData = function() {
"2009-08-15,9135.34;9496.28;9580.63,4232.5768877934;4399.8072592826;4438.88821965029\n" +
"2009-09-15,9280.67;9712.28;9829.87,4297.2232125907;4497.07133894216;4551.51896800004\n" +
"2009-10-15,9487.67;9712.73;10092.2,4388.84340147194;4492.9525342659;4668.48924723722\n";
-}
+};
diff --git a/gallery/drawing.js b/gallery/drawing.js
index b25341b..4452967 100644
--- a/gallery/drawing.js
+++ b/gallery/drawing.js
@@ -17,25 +17,25 @@ Gallery.register(
run: function() {
var zoom = document.getElementById('tool_zoom');
- zoom.onclick = function() { change_tool(zoom) };
+ zoom.onclick = function() { change_tool(zoom); };
var pencil = document.getElementById('tool_pencil');
- pencil.onclick = function() { change_tool(pencil) };
+ pencil.onclick = function() { change_tool(pencil); };
var eraser = document.getElementById('tool_eraser');
- eraser.onclick = function() { change_tool(eraser) };
+ eraser.onclick = function() { change_tool(eraser); };
var start_date = new Date("2002/12/29").getTime();
var end_date = new Date().getTime();
var data = [];
for (var d = start_date; d < end_date; d += 604800 * 1000) {
var millis = d + 2 * 3600 * 1000;
- data.push( [ new Date(new Date(millis).strftime("%Y/%m/%d")), 50 ]);
+ data.push( [ new Date(Dygraph.dateString_(millis)), 50 ]);
}
-
+
var isDrawing = false;
var lastDrawRow = null, lastDrawValue = null;
var tool = 'pencil';
var valueRange = [0, 100];
-
+
function setPoint(event, g, context) {
var graphPos = Dygraph.findPos(g.graphDiv);
var canvasx = Dygraph.pageX(event) - graphPos.x;
@@ -54,7 +54,7 @@ Gallery.register(
closest_row = row;
}
}
-
+
if (closest_row != -1) {
if (lastDrawRow === null) {
lastDrawRow = closest_row;
@@ -69,7 +69,9 @@ Gallery.register(
var val = lastDrawValue + coeff * (row - lastDrawRow);
val = Math.max(valueRange[0], Math.min(val, valueRange[1]));
data[row][1] = val;
- if (val == null || isNaN(val)) console.log(val);
+ if (val === null || value === undefined || isNaN(val)) {
+ console.log(val);
+ }
} else if (tool == 'eraser') {
data[row][1] = null;
}
@@ -80,13 +82,13 @@ Gallery.register(
g.setSelection(closest_row); // prevents the dot from being finnicky.
}
}
-
+
function finishDraw() {
isDrawing = false;
lastDrawRow = null;
lastDrawValue = null;
}
-
+
var change_tool = function(tool_div) {
var ids = ['tool_zoom', 'tool_pencil', 'tool_eraser'];
for (var i = 0; i < ids.length; i++) {
@@ -98,7 +100,7 @@ Gallery.register(
}
}
tool = tool_div.id.replace('tool_', '');
-
+
var dg_div = document.getElementById("draw_div");
if (tool == 'pencil') {
dg_div.style.cursor = 'url(images/cursor-pencil.png) 2 30, auto';
@@ -107,9 +109,9 @@ Gallery.register(
} else if (tool == 'zoom') {
dg_div.style.cursor = 'crosshair';
}
- }
+ };
change_tool(document.getElementById("tool_pencil"));
-
+
g = new Dygraph(document.getElementById("draw_div"), data,
{
valueRange: valueRange,
@@ -160,13 +162,13 @@ Gallery.register(
var xOffset = g.toDomCoords(axis[0], null)[0];
var x = event.offsetX - xOffset;
var w = g.toDomCoords(axis[1], null)[0] - xOffset;
- var xPct = w == 0 ? 0 : (x / w);
-
+ var xPct = w === 0 ? 0 : (x / w);
+
var delta = axis[1] - axis[0];
var increment = delta * percentage;
var foo = [increment * xPct, increment * (1 - xPct)];
var dateWindow = [ axis[0] + foo[0], axis[1] - foo[1] ];
-
+
g.updateOptions({
dateWindow: dateWindow
});
diff --git a/gallery/edge-padding.js b/gallery/edge-padding.js
index deaa2fa..160f4bf 100644
--- a/gallery/edge-padding.js
+++ b/gallery/edge-padding.js
@@ -61,13 +61,15 @@ Gallery.register(
avoidMinZero: false,
xRangePad: 3,
yRangePad: 10,
- drawAxesAtZero: true})};
+ drawAxesAtZero: true});
+ };
mode[1].onchange = function() {
updateGraphOpts({
avoidMinZero: true,
xRangePad: 0,
yRangePad: null,
- drawAxesAtZero: false})};
+ drawAxesAtZero: false});
+ };
mode[0].checked = true;
mode[0].onchange();
diff --git a/gallery/gallery.js b/gallery/gallery.js
index f4b6e70..002f7ca 100644
--- a/gallery/gallery.js
+++ b/gallery/gallery.js
@@ -1,3 +1,4 @@
+/*jshint loopfunc:true */
var Gallery = {};
Gallery.entries = {};
@@ -42,9 +43,9 @@ Gallery.start = function() {
innerDiv.textContent = demo.name;
div.onclick = function(demo, id) { return function() {
- if (Gallery.runningDemo != null) {
+ if (Gallery.runningDemo !== null) {
Gallery.runningDemo.innerDiv.className = "";
- if (Gallery.runningDemo.clean != null) {
+ if (Gallery.runningDemo.clean) {
Gallery.runningDemo.clean(Gallery.workareaChild);
}
}
@@ -73,9 +74,10 @@ Gallery.start = function() {
javascriptLink.textContent = "Javascript";
var css = getCss(id);
+ var cssLink;
if (css) {
Gallery.create("span", codeSpan).textContent = " | ";
- var cssLink = Gallery.create("a", codeSpan);
+ cssLink = Gallery.create("a", codeSpan);
cssLink.textContent = "CSS";
}
@@ -93,37 +95,37 @@ Gallery.start = function() {
var html = Gallery.workareaChild.innerHTML;
// tweak for use in jsfiddle
- javascript = " $(document).ready(" + javascript + "\n);"
+ javascript = " $(document).ready(" + javascript + "\n);";
jQuery('', { name: 'html' })
- .val(html)
- .hide()
- .appendTo(jsfs);
+ .val(html)
+ .hide()
+ .appendTo(jsfs);
jQuery('', { name: 'js' })
- .val(javascript)
- .hide()
- .appendTo(jsfs);
+ .val(javascript)
+ .hide()
+ .appendTo(jsfs);
if (css) {
jQuery('', { name: 'css' })
- .val(css)
- .hide()
- .appendTo(jsfs);
- }
+ .val(css)
+ .hide()
+ .appendTo(jsfs);
+ }
jQuery('', {
type: 'text',
name: 'title',
value: 'title tbd'
})
- .hide()
- .appendTo(jsfs);
+ .hide()
+ .appendTo(jsfs);
jQuery('', {
type: 'text',
name: 'description',
value: 'desc tbd'
})
- .hide()
- .appendTo(jsfs);
+ .hide()
+ .appendTo(jsfs);
htmlLink.onclick = function() {
Gallery.textarea.show("HTML", html);
@@ -146,7 +148,7 @@ Gallery.start = function() {
Gallery.hashChange();
- window.onhashchange = Gallery.setHash;("hashchange", Gallery.hashChange, false);
+ window.onhashchange = Gallery.setHash;
};
var getCss = function(id) {
@@ -161,7 +163,7 @@ var getCss = function(id) {
var rule = rules[j];
var cssText = rule.cssText;
var key = "#workarea #" + id + " ";
- if (cssText.indexOf(key) == 0) {
+ if (cssText.indexOf(key) === 0) {
arry.push(cssText.substr(key.length));
}
}
@@ -173,7 +175,7 @@ var getCss = function(id) {
}
}
return "not found";
-}
+};
Gallery.register = function(id, demo) {
if (Gallery.entries[id]) {
@@ -185,12 +187,12 @@ Gallery.register = function(id, demo) {
Gallery.hashChange = function(event) {
if (location.hash) {
- if (location.hash.indexOf("#g/") == 0) {
+ if (location.hash.indexOf("#g/") === 0) {
var id = location.hash.substring(3) + "-toc";
var elem = document.getElementById(id);
elem.onclick();
return;
}
}
- Gallery.workareaChild.innerHTML = "Select a demo from the gallery on the left
"
+ Gallery.workareaChild.innerHTML = "Select a demo from the gallery on the left
";
};
diff --git a/gallery/highlighted-series.js b/gallery/highlighted-series.js
index 2fdd1cf..b5ac642 100644
--- a/gallery/highlighted-series.js
+++ b/gallery/highlighted-series.js
@@ -57,8 +57,8 @@ var makeGraph = function(className, numSeries, numRows, isStacked) {
highlightSeriesOpts: {
strokeWidth: 3,
strokeBorderWidth: 1,
- highlightCircleSize: 5,
- },
+ highlightCircleSize: 5
+ }
});
var onclick = function(ev) {
if (g.isSeriesLocked()) {
diff --git a/gallery/highlighted-weekends.js b/gallery/highlighted-weekends.js
index 287aee5..09e11a1 100644
--- a/gallery/highlighted-weekends.js
+++ b/gallery/highlighted-weekends.js
@@ -10,38 +10,37 @@ Gallery.register(
},
run: function() {
// Some sample data
- var data = "2011-01-01," + Math.random()*100 + "\n"
- + "2011-01-02," + Math.random()*100 + "\n"
- + "2011-01-03," + Math.random()*100 + "\n"
- + "2011-01-04," + Math.random()*100 + "\n"
- + "2011-01-05," + Math.random()*100 + "\n"
- + "2011-01-06," + Math.random()*100 + "\n"
- + "2011-01-07," + Math.random()*100 + "\n"
- + "2011-01-08," + Math.random()*100 + "\n"
- + "2011-01-09," + Math.random()*100 + "\n"
- + "2011-01-10," + Math.random()*100 + "\n"
- + "2011-01-11," + Math.random()*100 + "\n"
- + "2011-01-12," + Math.random()*100 + "\n"
- + "2011-01-13," + Math.random()*100 + "\n"
- + "2011-01-14," + Math.random()*100 + "\n"
- + "2011-01-15," + Math.random()*100 + "\n"
- + "2011-01-16," + Math.random()*100 + "\n"
- + "2011-01-17," + Math.random()*100 + "\n"
- + "2011-01-18," + Math.random()*100 + "\n"
- + "2011-01-19," + Math.random()*100 + "\n"
- + "2011-01-20," + Math.random()*100 + "\n"
- + "2011-01-21," + Math.random()*100 + "\n"
- + "2011-01-22," + Math.random()*100 + "\n"
- + "2011-01-23," + Math.random()*100 + "\n"
- + "2011-01-24," + Math.random()*100 + "\n"
- + "2011-01-25," + Math.random()*100 + "\n"
- + "2011-01-26," + Math.random()*100 + "\n"
- + "2011-01-27," + Math.random()*100 + "\n"
- + "2011-01-28," + Math.random()*100 + "\n"
- + "2011-01-29," + Math.random()*100 + "\n"
- + "2011-01-30," + Math.random()*100 + "\n"
- + "2011-01-31," + Math.random()*100 + "\n"
- ;
+ var data = "2011-01-01," + Math.random()*100 + "\n" +
+ "2011-01-02," + Math.random()*100 + "\n" +
+ "2011-01-03," + Math.random()*100 + "\n" +
+ "2011-01-04," + Math.random()*100 + "\n" +
+ "2011-01-05," + Math.random()*100 + "\n" +
+ "2011-01-06," + Math.random()*100 + "\n" +
+ "2011-01-07," + Math.random()*100 + "\n" +
+ "2011-01-08," + Math.random()*100 + "\n" +
+ "2011-01-09," + Math.random()*100 + "\n" +
+ "2011-01-10," + Math.random()*100 + "\n" +
+ "2011-01-11," + Math.random()*100 + "\n" +
+ "2011-01-12," + Math.random()*100 + "\n" +
+ "2011-01-13," + Math.random()*100 + "\n" +
+ "2011-01-14," + Math.random()*100 + "\n" +
+ "2011-01-15," + Math.random()*100 + "\n" +
+ "2011-01-16," + Math.random()*100 + "\n" +
+ "2011-01-17," + Math.random()*100 + "\n" +
+ "2011-01-18," + Math.random()*100 + "\n" +
+ "2011-01-19," + Math.random()*100 + "\n" +
+ "2011-01-20," + Math.random()*100 + "\n" +
+ "2011-01-21," + Math.random()*100 + "\n" +
+ "2011-01-22," + Math.random()*100 + "\n" +
+ "2011-01-23," + Math.random()*100 + "\n" +
+ "2011-01-24," + Math.random()*100 + "\n" +
+ "2011-01-25," + Math.random()*100 + "\n" +
+ "2011-01-26," + Math.random()*100 + "\n" +
+ "2011-01-27," + Math.random()*100 + "\n" +
+ "2011-01-28," + Math.random()*100 + "\n" +
+ "2011-01-29," + Math.random()*100 + "\n" +
+ "2011-01-30," + Math.random()*100 + "\n" +
+ "2011-01-31," + Math.random()*100 + "\n";
var g = new Dygraph(
document.getElementById("div_g"),
@@ -69,7 +68,7 @@ Gallery.register(
var w = min_data_x;
// starting on Sunday is a special case
- if (dow == 0) {
+ if (dow === 0) {
highlight_period(w,w+12*3600*1000);
}
// find first saturday
@@ -79,7 +78,7 @@ Gallery.register(
dow = d.getUTCDay();
}
// shift back 1/2 day to center highlight around the point for the day
- w -= 12*3600*1000;
+ w -= 12*3600*1000;
while (w < max_data_x) {
var start_x_highlight = w;
var end_x_highlight = w + 2*24*3600*1000;
diff --git a/gallery/independent-series.js b/gallery/independent-series.js
index cc41153..fab7d1d 100644
--- a/gallery/independent-series.js
+++ b/gallery/independent-series.js
@@ -144,16 +144,16 @@ Gallery.register(
g2 = new Dygraph(
document.getElementById('graph2'),
-'x,A,B \n' +
-'1,,3 \n' +
-'2,2, \n' +
-'3,,5 \n' +
-'4,4, \n' +
-'5,,7 \n' +
-'6,NaN, \n' +
-'8,8, \n' +
-'10,10, \n'
- , {
+ 'x,A,B \n' +
+ '1,,3 \n' +
+ '2,2, \n' +
+ '3,,5 \n' +
+ '4,4, \n' +
+ '5,,7 \n' +
+ '6,NaN, \n' +
+ '8,8, \n' +
+ '10,10, \n',
+ {
labels: ['x', 'A', 'B' ],
connectSeparatedPoints: true,
drawPoints: true
diff --git a/gallery/interaction-api.js b/gallery/interaction-api.js
index 4b85211..603dece 100644
--- a/gallery/interaction-api.js
+++ b/gallery/interaction-api.js
@@ -50,9 +50,9 @@ function offsetToPercentage(g, offsetX, offsetY) {
var h = g.toDomCoords(null, yar0[0])[1] - yOffset;
// Percentage from the left.
- var xPct = w == 0 ? 0 : (x / w);
+ var xPct = w === 0 ? 0 : (x / w);
// Percentage from the top.
- var yPct = h == 0 ? 0 : (y / h);
+ var yPct = h === 0 ? 0 : (y / h);
// The (1-) part below changes it from "% distance down from the top"
// to "% distance up from the bottom".
@@ -73,9 +73,9 @@ function dblClickV3(event, g, context) {
var yPct = percentages[1];
if (event.ctrlKey) {
- zoom(g, -.25, xPct, yPct);
+ zoom(g, -0.25, xPct, yPct);
} else {
- zoom(g, +.2, xPct, yPct);
+ zoom(g, +0.2, xPct, yPct);
}
}
@@ -164,7 +164,7 @@ function moveV4(event, g, context) {
for (var col = 1; col < 3; col++) {
// TODO(konigsberg): these will throw exceptions as data is removed.
var vals = g.getValue(row, col);
- if (vals == null) { continue; }
+ if (vals === null || vals === undefined) { continue; }
var val = vals[0];
var y = g.toDomCoords(null, val)[1];
var diff2 = Math.abs(canvasy - y);
diff --git a/gallery/interaction.js b/gallery/interaction.js
index fd50def..05b0c80 100644
--- a/gallery/interaction.js
+++ b/gallery/interaction.js
@@ -41,7 +41,7 @@ Gallery.register(
" to mark them.",
"
The same data with both one and two y-axes. Two y-axes:
" + "" + "A single y-axis:
" + @@ -11,10 +11,10 @@ Gallery.register( ""; }, run: function() { - document.getElementById('check') = function(el) { + document.getElementById('check').onchange = function(el) { g.updateOptions( { fillGraph: el.checked } ); g2.updateOptions( { fillGraph: el.checked } ); - } + }; var data = []; for (var i = 1; i <= 100; i++) { @@ -62,7 +62,7 @@ Gallery.register( labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ], labelsKMB: true, ylabel: 'Primary y-axis', - y2label: 'Secondary y-axis', + y2label: 'Secondary y-axis' } ); } diff --git a/lint.sh b/lint.sh index eb61924..cd0db4c 100755 --- a/lint.sh +++ b/lint.sh @@ -13,17 +13,12 @@ jsc_opts='maxerr:10000,devel:true,browser:true,shadow:true' rhino_opts='maxerr=10000,devel=true,browser=true,shadow=true' -if [ $# -gt 1 ]; then - echo "Usage: $0 [file.js]" - exit 1 -fi - RETURN_VALUE=0 if [ $# -eq 0 ]; then - files=$(ls dygraph*.js plugins/*.js datahandler/*.js | grep -v combined | grep -v dev.js| grep -v externs) + files=$(ls dygraph*.js plugins/*.js datahandler/*.js gallery/*.js | grep -v combined | grep -v dev.js| grep -v externs) else - files=$1 + files=$@ fi if [ -e /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc ]; then -- 2.7.4