1 // Copyright (c) 2012 Google, Inc.
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * @fileoverview Javascript to run index.html.
24 * @author konigsberg@google.com (Robert Konigsberg)
31 Index
.splitVariables
= function() { // http://www.idealog.us/2006/06/javascript_to_p
.html
32 var query
= window
.location
.search
.substring(1);
34 var vars
= query
.split("&");
35 for (var i
= 0;i
< vars
.length
; i
++) {
36 var pair
= vars
[i
].split("=");
37 args
[pair
[0]] = pair
[1];
42 Index
.draw
= function(element
, data
, options
) {
43 element
.innerHTML
= "";
44 element
.removeAttribute("style");
51 // These don't work yet.
57 Index
.addMessage
= function(text
) {
58 var messages
= document
.getElementById("messages");
59 messages
.innerText
= messages
.innerText
+ text
+ "\n";
62 Index
.start
= function() {
63 var variables
= Index
.splitVariables();
64 var sampleName
= variables
["sample"];
66 sampleName
= "interestingShapes";
68 var sample
= Samples
[sampleName
];
69 var data
= sample
.data
;
70 var redraw
= function() {
71 Index
.draw(document
.getElementById("graph"), data
, palette
.read());
74 var palette
= new Palette();
75 palette
.create(document
, document
.getElementById("optionsPalette"));
76 palette
.write(sample
.options
);
77 palette
.onchange
= redraw
;
78 palette
.filterBar
.focus();
81 for (var opt
in Dygraph
.OPTIONS_REFERENCE
) {
83 var entry
= Dygraph
.OPTIONS_REFERENCE
[opt
];
84 console
.warn("missing option: " + opt
+ " of type " + entry
.type
);