4 Gallery
.entryOrder
= [];
5 Gallery
.runningDemo
= null;
8 * Shortcut for creating HTML associated with a parent.
10 Gallery
.create
= function(type
, parent
, className
) {
11 var elem
= document
.createElement(type
);
12 parent
.appendChild(elem
);
14 elem
.className
= className
;
19 Gallery
.start
= function() {
20 google
.load('visualization', '1', {'packages':['annotatedtimeline']});
21 Gallery
.toc
= document
.getElementById("toc");
22 Gallery
.workarea
= document
.getElementById("workarea");
23 Gallery
.workareaChild
= Gallery
.create("div", Gallery
.workarea
);
24 Gallery
.workarea
.style
.visibility
= "hidden";
25 for (var idx
in Gallery
.entryOrder
) {
26 var id
= Gallery
.entryOrder
[idx
];
27 var demo
= Gallery
.entries
[id
];
29 var div
= Gallery
.create("div", Gallery
.toc
, "entry");
31 var innerDiv
= Gallery
.create("div", div
, "");
33 // Storing extra data in the demo object.
35 demo
.innerDiv
= innerDiv
;
37 innerDiv
.textContent
= demo
.name
;
38 div
.onclick
= function(demo
, id
) { return function() {
39 if (Gallery
.runningDemo
!= null) {
40 Gallery
.runningDemo
.innerDiv
.className
= "";
41 if (Gallery
.runningDemo
.clean
!= null) {
42 Gallery
.runningDemo
.clean(Gallery
.workareaChild
);
45 Gallery
.workarea
.style
.visibility
= "visible";
46 document
.getElementById("title").textContent
= demo
.title
? demo
.title
: "";
47 demo
.innerDiv
.className
= "selected";
48 Gallery
.workareaChild
.id
= id
;
50 Gallery
.workareaChild
.innerHTML
='';
52 demo
.setup(Gallery
.workareaChild
);
54 demo
.run(Gallery
.workareaChild
);
55 Gallery
.runningDemo
= demo
;
61 window
.onhashchange
= Gallery
.setHash
;("hashchange", Gallery
.hashChange
, false);
64 Gallery
.register
= function(id
, demo
) {
65 if (Gallery
.entries
[id
]) {
66 throw id
+ " already registered";
68 Gallery
.entries
[id
] = demo
;
69 Gallery
.entryOrder
.push(id
);
72 Gallery
.hashChange
= function(event
) {
74 var id
= location
.hash
.substring(1) + "-toc";
75 var elem
= document
.getElementById(id
);