Added wrt files, prior to converting into Qt/C++.
[ptas] / wrt / misc / rss / preview / script / lib / console.js
diff --git a/wrt/misc/rss/preview/script/lib/console.js b/wrt/misc/rss/preview/script/lib/console.js
new file mode 100644 (file)
index 0000000..8a95349
--- /dev/null
@@ -0,0 +1,121 @@
+//     for console support\r
+if (typeof window.parent.console == 'undefined') {\r
+       window.console = {\r
+       \r
+                       sprintf: function(args){\r
+                               if (typeof args == 'undefined') {\r
+                                       return null;\r
+                               }\r
+                               \r
+                               if (args.length < 1) {\r
+                                       return null;\r
+                               };\r
+                               \r
+                               if (typeof args[0] != 'string') {\r
+                                       return null;\r
+                               }\r
+                               \r
+                               if (typeof RegExp == 'undefined') {\r
+                                       return null;\r
+                               }\r
+                               \r
+                               if (args.length == 1) {\r
+                                       return args[0];\r
+                               }\r
+                               \r
+                               \r
+                               var str = args[0];\r
+                               var newString = args[0];\r
+                               var arr = new Array();\r
+                               var exp = new RegExp(/[^%](%)([a-zA-Z])/g);\r
+                               var match = null;\r
+                               var lastMatch = 0;\r
+                               var argPos = 1;\r
+                               while (match = exp.exec(str) && argPos < args.length) {\r
+                                       if (str[exp.lastIndex - 1] == "%") {\r
+                                               \r
+                                       }\r
+                                       else \r
+                                               if (str[exp.lastIndex - 1] == "d") {\r
+                                                       arr.push(str.substring(lastMatch, exp.lastIndex - 2));\r
+                                                       arr.push(args[argPos++]);\r
+                                               }\r
+                                               else \r
+                                                       if (str[exp.lastIndex - 1] == "i") {\r
+                                                               arr.push(str.substring(lastMatch, exp.lastIndex - 2));\r
+                                                               arr.push(args[argPos++]);\r
+                                                       }\r
+                                                       else \r
+                                                               if (str[exp.lastIndex - 1] == "f") {\r
+                                                                       arr.push(str.substring(lastMatch, exp.lastIndex - 2));\r
+                                                                       arr.push(args[argPos++]);\r
+                                                               }\r
+                                                               else \r
+                                                                       if (str[exp.lastIndex - 1] == "s") {\r
+                                                                               arr.push(str.substring(lastMatch, exp.lastIndex - 2));\r
+                                                                               arr.push(args[argPos++]);\r
+                                                                       }\r
+                                                                       else \r
+                                                                               if (str[exp.lastIndex - 1] != "%") {\r
+                                                                                       arr.push(str.substring(lastMatch, exp.lastIndex - 2));\r
+                                                                                       arr.push("\"");\r
+                                                                                       arr.push(args[argPos++]);\r
+                                                                                       arr.push("\"");\r
+                                                                               }\r
+                                       lastMatch = exp.lastIndex;\r
+                               }\r
+                               if (lastMatch < str.length) {\r
+                                       arr.push(str.substring(lastMatch, str.length));\r
+                               }\r
+                               while (argPos < args.length) {\r
+                                       arr.push(" ");\r
+                                       arr.push(args[argPos++]);\r
+                               }\r
+                               return arr.join("").replace(/\%\%/g,"%");\r
+                       },\r
+               error: function(){\r
+                       var errorStr = console.sprintf(arguments);\r
+                       if (errorStr) {\r
+                               _BRIDGE_REF.nokia.layout.log('error', errorStr);\r
+                       }\r
+               },\r
+               info: function(){\r
+                       var errorStr = console.sprintf(arguments);\r
+                       if (errorStr) {\r
+                               _BRIDGE_REF.nokia.layout.log('info', errorStr);\r
+                       }\r
+               },\r
+               warn: function(){\r
+                       var errorStr = console.sprintf(arguments);\r
+                       if (errorStr) {\r
+                               _BRIDGE_REF.nokia.layout.log('warn', errorStr);\r
+                       }\r
+               },\r
+               log: function(){\r
+                       var errorStr = console.sprintf(arguments);\r
+                       if (errorStr) {\r
+                               _BRIDGE_REF.nokia.layout.log('log', errorStr);\r
+                       }\r
+               },\r
+               debug: function(){\r
+                       var errorStr = console.sprintf(arguments);\r
+                       if (errorStr) {\r
+                               _BRIDGE_REF.nokia.layout.log('debug', errorStr);\r
+                       }\r
+               },\r
+               assert: function(){\r
+                       var errorStr = console.sprintf(arguments);\r
+                       if (errorStr) {\r
+                               //      @todo\r
+                       }\r
+               }\r
+       }\r
+       \r
+       //      enable the Console.\r
+       _BRIDGE_REF.nokia.layout._console_enabled = true;\r
+       _BRIDGE_REF.nokia.layout.render();\r
+\r
+}\r
+\r
+//     make TRUE console.js script loaded\r
+window.parent.NOKIA.scriptsLoaded.console = true;\r