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 3 // found in the LICENSE file. 4 5 // Called by the common.js module. 6 function moduleDidLoad() { 7 // The module is not hidden by default so we can easily see if the plugin 8 // failed to load. 9 common.hideModule(); 10 } 11 12 // Called by the common.js module. 13 function attachListeners() { 14 document.getElementById('button').addEventListener('click', loadUrl); 15 } 16 17 function loadUrl() { 18 common.naclModule.postMessage('getUrl:url_loader_success.html'); 19 } 20 21 // Called by the common.js module. 22 function handleMessage(message_event) { 23 var logEl = document.getElementById('output'); 24 // Find the first line break. This separates the URL data from the 25 // result text. Note that the result text can contain any number of 26 // '\n' characters, so split() won't work here. 27 var url = message_event.data; 28 var result = ''; 29 var eolPos = message_event.data.indexOf('\n'); 30 if (eolPos != -1) { 31 url = message_event.data.substring(0, eolPos); 32 if (eolPos < message_event.data.length - 1) { 33 result = message_event.data.substring(eolPos + 1); 34 } 35 } 36 logEl.textContent += 'FULLY QUALIFIED URL: ' + url + '\n'; 37 logEl.textContent += 'RESULT:\n' + result + '\n'; 38 } 39