OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Javascript module pattern: | 5 // Javascript module pattern: |
6 // see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces | 6 // see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces |
7 // In essence, we define an anonymous function which is immediately called and | 7 // In essence, we define an anonymous function which is immediately called and |
8 // returns a new object. The new object contains only the exported definitions; | 8 // returns a new object. The new object contains only the exported definitions; |
9 // all other definitions in the anonymous function are inaccessible to external | 9 // all other definitions in the anonymous function are inaccessible to external |
10 // code. | 10 // code. |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 * @param {Event} message_event A message event. message_event.data contains | 178 * @param {Event} message_event A message event. message_event.data contains |
179 * the data sent from the NaCl module. | 179 * the data sent from the NaCl module. |
180 */ | 180 */ |
181 function handleMessage(message_event) { | 181 function handleMessage(message_event) { |
182 if (typeof message_event.data === 'string') { | 182 if (typeof message_event.data === 'string') { |
183 for (var type in defaultMessageTypes) { | 183 for (var type in defaultMessageTypes) { |
184 if (defaultMessageTypes.hasOwnProperty(type)) { | 184 if (defaultMessageTypes.hasOwnProperty(type)) { |
185 if (startsWith(message_event.data, type + ':')) { | 185 if (startsWith(message_event.data, type + ':')) { |
186 func = defaultMessageTypes[type]; | 186 func = defaultMessageTypes[type]; |
187 func(message_event.data.slice(type.length + 1)); | 187 func(message_event.data.slice(type.length + 1)); |
| 188 return; |
188 } | 189 } |
189 } | 190 } |
190 } | 191 } |
191 } | 192 } |
192 | 193 |
193 if (typeof window.handleMessage !== 'undefined') { | 194 if (typeof window.handleMessage !== 'undefined') { |
194 window.handleMessage(message_event); | 195 window.handleMessage(message_event); |
195 } | 196 } |
196 } | 197 } |
197 | 198 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 var config = configs.indexOf(searchVars.config) !== -1 ? | 300 var config = configs.indexOf(searchVars.config) !== -1 ? |
300 searchVars.config : configs[0]; | 301 searchVars.config : configs[0]; |
301 var pathFormat = body.dataset.path; | 302 var pathFormat = body.dataset.path; |
302 var path = pathFormat.replace('{tc}', tc).replace('{config}', config); | 303 var path = pathFormat.replace('{tc}', tc).replace('{config}', config); |
303 | 304 |
304 loadFunction(body.dataset.name, tc, path, body.dataset.width, | 305 loadFunction(body.dataset.name, tc, path, body.dataset.width, |
305 body.dataset.height); | 306 body.dataset.height); |
306 } | 307 } |
307 } | 308 } |
308 }); | 309 }); |
OLD | NEW |