|
1 // for console support |
|
2 if ((typeof window.parent.console == 'undefined') || ( (/AppleWebKit/i.test(navigator.userAgent)) && !(/Version/i.test(navigator.userAgent))) ){ |
|
3 window.console = { |
|
4 |
|
5 sprintf: function(args){ |
|
6 if (typeof args == 'undefined') { |
|
7 return null; |
|
8 } |
|
9 |
|
10 if (args.length < 1) { |
|
11 return null; |
|
12 }; |
|
13 |
|
14 if (typeof args[0] != 'string') { |
|
15 return null; |
|
16 } |
|
17 |
|
18 if (typeof RegExp == 'undefined') { |
|
19 return null; |
|
20 } |
|
21 |
|
22 if (args.length == 1) { |
|
23 return args[0]; |
|
24 } |
|
25 |
|
26 |
|
27 var str = args[0]; |
|
28 var newString = args[0]; |
|
29 var arr = new Array(); |
|
30 var exp = new RegExp(/[^%](%)([a-zA-Z])/g); |
|
31 var match = null; |
|
32 var lastMatch = 0; |
|
33 var argPos = 1; |
|
34 while (match = exp.exec(str) && argPos < args.length) { |
|
35 if (str[exp.lastIndex - 1] == "%") { |
|
36 |
|
37 } |
|
38 else |
|
39 if (str[exp.lastIndex - 1] == "d") { |
|
40 arr.push(str.substring(lastMatch, exp.lastIndex - 2)); |
|
41 arr.push(args[argPos++]); |
|
42 } |
|
43 else |
|
44 if (str[exp.lastIndex - 1] == "i") { |
|
45 arr.push(str.substring(lastMatch, exp.lastIndex - 2)); |
|
46 arr.push(args[argPos++]); |
|
47 } |
|
48 else |
|
49 if (str[exp.lastIndex - 1] == "f") { |
|
50 arr.push(str.substring(lastMatch, exp.lastIndex - 2)); |
|
51 arr.push(args[argPos++]); |
|
52 } |
|
53 else |
|
54 if (str[exp.lastIndex - 1] == "s") { |
|
55 arr.push(str.substring(lastMatch, exp.lastIndex - 2)); |
|
56 arr.push(args[argPos++]); |
|
57 } |
|
58 else |
|
59 if (str[exp.lastIndex - 1] != "%") { |
|
60 arr.push(str.substring(lastMatch, exp.lastIndex - 2)); |
|
61 arr.push("\""); |
|
62 arr.push(args[argPos++]); |
|
63 arr.push("\""); |
|
64 } |
|
65 lastMatch = exp.lastIndex; |
|
66 } |
|
67 if (lastMatch < str.length) { |
|
68 arr.push(str.substring(lastMatch, str.length)); |
|
69 } |
|
70 while (argPos < args.length) { |
|
71 arr.push(" "); |
|
72 arr.push(args[argPos++]); |
|
73 } |
|
74 return arr.join("").replace(/\%\%/g,"%"); |
|
75 }, |
|
76 error: function(){ |
|
77 var errorStr = console.sprintf(arguments); |
|
78 if (errorStr) { |
|
79 _BRIDGE_REF.nokia.layout.log('error', errorStr); |
|
80 } |
|
81 }, |
|
82 info: function(){ |
|
83 var errorStr = console.sprintf(arguments); |
|
84 if (errorStr) { |
|
85 _BRIDGE_REF.nokia.layout.log('info', errorStr); |
|
86 } |
|
87 }, |
|
88 warn: function(){ |
|
89 var errorStr = console.sprintf(arguments); |
|
90 if (errorStr) { |
|
91 _BRIDGE_REF.nokia.layout.log('warn', errorStr); |
|
92 } |
|
93 }, |
|
94 log: function(){ |
|
95 var errorStr = console.sprintf(arguments); |
|
96 if (errorStr) { |
|
97 _BRIDGE_REF.nokia.layout.log('log', errorStr); |
|
98 } |
|
99 }, |
|
100 debug: function(){ |
|
101 var errorStr = console.sprintf(arguments); |
|
102 if (errorStr) { |
|
103 _BRIDGE_REF.nokia.layout.log('debug', errorStr); |
|
104 } |
|
105 }, |
|
106 assert: function(){ |
|
107 var errorStr = console.sprintf(arguments); |
|
108 if (errorStr) { |
|
109 // @todo |
|
110 } |
|
111 } |
|
112 } |
|
113 |
|
114 // enable the Console. |
|
115 _BRIDGE_REF.nokia.layout._console_enabled = true; |
|
116 _BRIDGE_REF.nokia.layout.render(); |
|
117 |
|
118 } |
|
119 |
|
120 // make TRUE console.js script loaded |
|
121 window.parent.NOKIA.scriptsLoaded.console = true; |