2 * Emulator, which manages the device interacations
4 if (typeof _BRIDGE_REF == "undefined" || !_BRIDGE_REF) {
7 parent: window.parent || false,
8 nokia: window.parent.NOKIA || false,
12 _BRIDGE_REF.namespace = function(name){
13 var parts = name.split('.');
14 var current = _BRIDGE_REF;
15 for (var key in parts) {
16 if (!current[parts[key]]) {
17 current[parts[key]] = {};
19 current = current[parts[key]];
24 * _BRIDGE_REF.helper functions
26 _BRIDGE_REF.namespace('helper.loadScript');
27 _BRIDGE_REF.helper = {
28 path: document.location.pathname,
29 loadScript: function(path){
30 var head = document.getElementsByTagName("head")[0] || document.documentElement;
31 var script = document.createElement("script");
33 script.type = "text/javascript";
35 head.appendChild(script);
38 addEvent: function(obj, type, fn){
39 if (obj.addEventListener) {
40 obj.addEventListener(type, fn, false);
43 if (obj.attachEvent) {
44 obj["e" + type + fn] = fn;
45 obj[type + fn] = function(){
46 obj["e" + type + fn](window.event);
48 obj.attachEvent("on" + type, obj[type + fn]);
52 getElementsLengthInObject : function(items){
60 getBatteryStrength : function(){
65 if (!typeof window.console) {
66 _BRIDGE_REF.helper.loadScript("preview/script/lib/console.js");
76 _BRIDGE_REF.helper.loadScript("preview/script/lib/widget.js");
77 _BRIDGE_REF.helper.loadScript("preview/script/lib/systeminfo.js");
78 _BRIDGE_REF.helper.loadScript("preview/script/lib/menu.js");
79 _BRIDGE_REF.helper.loadScript("preview/script/lib/menuItem.js");
80 _BRIDGE_REF.helper.loadScript("preview/script/lib/console.js");
82 // Inject SAPI scripts
83 if (_BRIDGE_REF.nokia) {
84 var wrtVersion = _BRIDGE_REF.nokia.helper.readCookie('_WRT_VERSION');
85 if ((typeof wrtVersion == 'undefined') || (wrtVersion == 'WRT 1.1')) {
86 _BRIDGE_REF.nokia.version = 'WRT 1.1';
87 _BRIDGE_REF.nokia.helper.createCookie('_WRT_VERSION', 'WRT 1.1');
88 _BRIDGE_REF.helper.loadScript("preview/script/lib/device.js");
91 _BRIDGE_REF.nokia.version = 'WRT 1.0';
95 _BRIDGE_REF.helper.loadScript("preview/script/lib/device.js");
99 window native functions over-riding
101 if ( (typeof window.frameElement != 'undefined') && (typeof _BRIDGE_REF.nokia != 'undefined') && window !== window.parent) {
103 window.alert = function(msg){
104 return window.parent.alert(msg);
108 window.confirm = function(msg){
109 return window.parent.confirm(msg);
113 window.prompt = function(msg, str){
114 return window.parent.prompt(msg, str)
118 // make TRUE loader.js script loaded
119 window.parent.NOKIA.scriptsLoaded.loader = true;