X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=gallery%2Fannotation.js;h=e0e03194cd9bc56cb29f513a611ca0195ff56ef1;hb=866ceb258a016484e30d2c7f96cb6cbb9ff05c8c;hp=c520090599f10fc2075bf20e558089d07ba2ddf1;hpb=795b16307db2a673ba7aa3452f6f6b0e93baeb3a;p=dygraphs.git diff --git a/gallery/annotation.js b/gallery/annotation.js index c520090..e0e0319 100644 --- a/gallery/annotation.js +++ b/gallery/annotation.js @@ -4,13 +4,13 @@ Gallery.register( name: 'Annotations', title: 'Dynamic Annotations Demo', setup: function(parent) { - parent.innerHTML = - "

Click any point to add an annotation to it or click 'Add Annotation'.

" + - "" + - "" + - "
" + - "
" + - "
"; + parent.innerHTML = [ + "

Click any point to add an annotation to it or click 'Add Annotation'.

", + "", + "", + "
", + "
", + "
" ].join("\n"); }, run: function() { @@ -79,7 +79,7 @@ Gallery.register( } ); g.setAnnotations(annotations); - window.add = function() { + document.getElementById('add').onclick = function() { var x = last_ann + 2; var annnotations = g.annotations(); annotations.push( { @@ -92,10 +92,11 @@ Gallery.register( last_ann = x; g.setAnnotations(annotations); } - - window.bottom = function(el) { - var to_bottom = true; - if (el.value != 'Shove to bottom') to_bottom = false; + + 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++) { @@ -104,9 +105,9 @@ Gallery.register( g.setAnnotations(anns); if (to_bottom) { - el.value = 'Lift back up'; + bottom.textContent = 'Lift back up'; } else { - el.value = 'Shove to bottom'; + bottom.textContent = 'Shove to bottom'; } }