OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var examples = [ | 5 var examples = [ |
6 {name: 'bullet', text: 'Bullet Physics'}, | 6 {name: 'bullet', text: 'Bullet Physics'}, |
7 {name: 'earth', text: 'Raycasted Earth'}, | 7 {name: 'earth', text: 'Raycasted Earth'}, |
8 {name: 'lua', text: 'Lua Interpreter'}, | 8 {name: 'lua', text: 'Lua Interpreter'}, |
9 {name: 'life', text: 'Game of Life'}, | 9 {name: 'life', text: 'Game of Life'}, |
10 {name: 'voronoi', text: 'Voronoi Simulation'}, | 10 {name: 'voronoi', text: 'Voronoi Simulation'}, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 131 } |
132 | 132 |
133 function createIframe(src) { | 133 function createIframe(src) { |
134 var oldIframeEl = iframeEl; | 134 var oldIframeEl = iframeEl; |
135 | 135 |
136 iframeEl = document.createElement('iframe'); | 136 iframeEl = document.createElement('iframe'); |
137 iframeEl.setAttribute('frameborder', '0'); | 137 iframeEl.setAttribute('frameborder', '0'); |
138 iframeEl.setAttribute('width', '100%'); | 138 iframeEl.setAttribute('width', '100%'); |
139 iframeEl.setAttribute('height', '100%'); | 139 iframeEl.setAttribute('height', '100%'); |
140 iframeEl.src = src; | 140 iframeEl.src = src; |
141 iframeEl.setAttribute('hidden'); | 141 iframeEl.setAttribute('hidden', ''); |
142 iframeEl.onload = function() { | 142 iframeEl.onload = function() { |
143 if (oldIframeEl) | 143 if (oldIframeEl) |
144 oldIframeEl.parentNode.removeChild(oldIframeEl); | 144 oldIframeEl.parentNode.removeChild(oldIframeEl); |
145 iframeEl.removeAttribute('hidden'); | 145 iframeEl.removeAttribute('hidden'); |
146 } | 146 } |
147 document.querySelector('section').appendChild(iframeEl); | 147 document.querySelector('section').appendChild(iframeEl); |
148 } | 148 } |
149 | 149 |
150 function pushState(exampleName) { | 150 function pushState(exampleName) { |
151 window.history.pushState(exampleName, '', '/demo/' + exampleName); | 151 window.history.pushState(exampleName, '', '/demo/' + exampleName); |
152 } | 152 } |
153 | 153 |
154 function replaceState(exampleName) { | 154 function replaceState(exampleName) { |
155 window.history.replaceState(exampleName, '', '/demo/' + exampleName); | 155 window.history.replaceState(exampleName, '', '/demo/' + exampleName); |
156 } | 156 } |
157 | 157 |
158 function replaceHomeState() { | 158 function replaceHomeState() { |
159 window.history.replaceState('home', '', '/demo'); | 159 window.history.replaceState('home', '', '/demo'); |
160 } | 160 } |
161 | 161 |
162 function showOldChromeErrorMessage() { | 162 function showOldChromeErrorMessage() { |
163 document.getElementById('old-chrome').removeAttribute('hidden'); | 163 document.getElementById('old-chrome').removeAttribute('hidden'); |
164 } | 164 } |
165 | 165 |
166 function showNotChromeErrorMessage() { | 166 function showNotChromeErrorMessage() { |
167 document.getElementById('not-chrome').removeAttribute('hidden'); | 167 document.getElementById('not-chrome').removeAttribute('hidden'); |
168 } | 168 } |
OLD | NEW |