| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 * @param {Event} message_event A message event. message_event.data contains | 164 * @param {Event} message_event A message event. message_event.data contains |
| 165 * the data sent from the NaCl module. | 165 * the data sent from the NaCl module. |
| 166 */ | 166 */ |
| 167 function handleMessage(message_event) { | 167 function handleMessage(message_event) { |
| 168 if (typeof message_event.data === 'string') { | 168 if (typeof message_event.data === 'string') { |
| 169 for (var type in defaultMessageTypes) { | 169 for (var type in defaultMessageTypes) { |
| 170 if (defaultMessageTypes.hasOwnProperty(type)) { | 170 if (defaultMessageTypes.hasOwnProperty(type)) { |
| 171 if (startsWith(message_event.data, type + ':')) { | 171 if (startsWith(message_event.data, type + ':')) { |
| 172 func = defaultMessageTypes[type]; | 172 func = defaultMessageTypes[type]; |
| 173 func(message_event.data.slice(type.length + 1)); | 173 func(message_event.data.slice(type.length + 1)); |
| 174 return; |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 } | 177 } |
| 177 } | 178 } |
| 178 | 179 |
| 179 if (typeof window.handleMessage !== 'undefined') { | 180 if (typeof window.handleMessage !== 'undefined') { |
| 180 window.handleMessage(message_event); | 181 window.handleMessage(message_event); |
| 181 } | 182 } |
| 182 } | 183 } |
| 183 | 184 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 var config = configs.indexOf(searchVars.config) !== -1 ? | 286 var config = configs.indexOf(searchVars.config) !== -1 ? |
| 286 searchVars.config : configs[0]; | 287 searchVars.config : configs[0]; |
| 287 var pathFormat = body.dataset.path; | 288 var pathFormat = body.dataset.path; |
| 288 var path = pathFormat.replace('{tc}', tc).replace('{config}', config); | 289 var path = pathFormat.replace('{tc}', tc).replace('{config}', config); |
| 289 | 290 |
| 290 loadFunction(body.dataset.name, tc, path, body.dataset.width, | 291 loadFunction(body.dataset.name, tc, path, body.dataset.width, |
| 291 body.dataset.height); | 292 body.dataset.height); |
| 292 } | 293 } |
| 293 } | 294 } |
| 294 }); | 295 }); |
| OLD | NEW |