Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1516)

Unified Diff: native_client_sdk/src/examples/common.js

Issue 13488007: [NaCl SDK] Make the SDK examples buildable as a packaged app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix license headers Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « native_client_sdk/src/build_tools/template.mk ('k') | native_client_sdk/src/examples/debugging/example.dsc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/examples/common.js
diff --git a/native_client_sdk/src/examples/common.js b/native_client_sdk/src/examples/common.js
index bd0a6b22a32fb48145f323f56d5cd63c15f7f2ea..319c1f2f858f0531a9ed092002c2388a14242d06 100644
--- a/native_client_sdk/src/examples/common.js
+++ b/native_client_sdk/src/examples/common.js
@@ -126,16 +126,25 @@ var common = (function () {
return s.lastIndexOf(prefix, 0) === 0;
}
+ /** Maximum length of logMessageArray. */
+ var kMaxLogMessageLength = 20;
+
+ /** An array of messages to display in the element with id "log". */
+ var logMessageArray = [];
+
/**
- * Add a message to an element with id "log", separated by a <br> element.
+ * Add a message to an element with id "log".
*
* This function is used by the default "log:" message handler.
*
* @param {string} message The message to log.
*/
function logMessage(message) {
- var logEl = document.getElementById('log');
- logEl.innerHTML += message + '<br>';
+ logMessageArray.push(message);
+ if (logMessageArray.length > kMaxLogMessageLength)
+ logMessageArray.shift();
+
+ document.getElementById('log').textContent = logMessageArray.join('');
console.log(message)
}
@@ -236,6 +245,7 @@ var common = (function () {
domContentLoaded: domContentLoaded,
createNaClModule: createNaClModule,
hideModule: hideModule,
+ logMessage: logMessage,
updateStatus: updateStatus
};
« no previous file with comments | « native_client_sdk/src/build_tools/template.mk ('k') | native_client_sdk/src/examples/debugging/example.dsc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698