-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjavascriptConsoleWp7.js
More file actions
33 lines (30 loc) · 1.11 KB
/
javascriptConsoleWp7.js
File metadata and controls
33 lines (30 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Author: Ethan Lo
* This snippet will send javascript console.log statements to the native layer.
* https://github.com/arkitex
*
* Including JSON is optional. Get it here: https://github.com/douglascrockford/JSON-js
*/
if (!window.console) {
var outputFunction = function(type, logMessage) {
if (typeof logMessage === "object") {
if (typeof JSON === "undefined" ) {
top.external.notify("JSON is not defined");
} else {
top.external.notify(type + JSON.stringify(logMessage));
}
} else {
top.external.notify(type + logMessage);
}
};
var logFunction = function(logMessage) { outputFunction("LOG: ", logMessage); };
var debugFunction = function(logMessage) { outputFunction("DEBUG: ", logMessage); };
var errorFunction = function(logMessage) { outputFunction("ERROR: ", logMessage); };
var infoFunction = function(logMessage) { outputFunction("INFO: ", logMessage); };
var warnFunction = function(logMessage) { outputFunction("WARN: ", logMessage); };
window.console = { log:logFunction
, debug:debugFunction
, error:errorFunction
, info:infoFunction
, warn:warnFunction };
}