--- a/org.symbian.tools.wrttools.previewer/preview/css/style.css Mon Jun 28 10:47:32 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/css/style.css Tue Jun 29 13:44:16 2010 -0700
@@ -20,10 +20,9 @@
body {
-/* background-image: url(../images/Gradient0Background.png); */
- background-image: url(../images/Gradient0Background_2.png);
+/* background-image: url(../images/Gradient0Background_2.png);*/
background-repeat: repeat-x;
- background-color: gray;
+ background-color: AppWorkspace;
margin: 0px;
font-family: "Nokia Sans", "Nokia Sans SemiBold", "Arial Narrow";
padding: 0px;
@@ -582,15 +581,15 @@
margin-top: 10px;
}
-div#slider-value-panel span{
+span.readonly-field {
padding: 3px;
background:#0078A3 url(../script/jquery-ui/css/ui-darkness/images/0078a3_40x100_textures_02_glass_40.png) repeat-x scroll 0 50%;
border:1px solid #4bd94b;
color:#FFFFFF;
font-weight: bolder;
+ width: 30px
}
-
/*
Console UI
*/
@@ -725,4 +724,25 @@
top: 30%;
height: 100%;
text-align: center;
- vertical-align: middle;
\ No newline at end of file
+ vertical-align: middle;
+}
+
+#accel-data {
+ float: left;
+ margin-top: 15px;
+}
+
+#phoneposition {
+ float:left
+}
+
+#accel-data div {
+ margin-top: 10px;
+}
+
+#accel-sliders {
+ position: relative;
+ left: 0;
+ width: 100%;
+ top: 130px
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/preview/script/accelerometer.js Tue Jun 29 13:44:16 2010 -0700
@@ -0,0 +1,334 @@
+function RotationSupport(accelerationCallback) {
+ this.controls = new RotationControls(accelerationCallback);
+}
+
+function RotationControls(accelCallback) {
+ var width = 50, height = 100, depth = 10;
+ var margin = 5, bottomMargin = 15;
+ var angleX = 180;
+ var angleY = 180;
+ var angleZ = 180;
+ var accelerationCallback = accelCallback;
+
+ $("#sliderX").slider( {
+ slide : updateAngleX,
+ animate : true,
+ max : 360,
+ min : 0,
+ value : angleX
+ });
+ $("#sliderY").slider( {
+ slide : updateAngleY,
+ animate : true,
+ max : 360,
+ min : 0,
+ value : angleY
+ });
+ $("#sliderZ").slider( {
+ slide : updateAngleZ,
+ animate : true,
+ max : 360,
+ min : 0,
+ value : angleZ
+ });
+ renderUI();
+
+ function translateFace(xy, xz, yz) {
+ var px = width / 2;
+ var py = height / 2;
+ var pz = depth/2;
+ var points = [ {
+ x : px,
+ y : py,
+ z : pz
+ }, {
+ x : px,
+ y : -py,
+ z : pz
+ }, {
+ x : -px,
+ y : -py,
+ z : pz
+ }, {
+ x : -px,
+ y : py,
+ z : pz
+ } ];
+ return rotate(points, xy, xz, yz);
+ }
+
+ function translateScreen(xy, xz, yz) {
+ var px = width / 2;
+ var py = height / 2;
+ var pz = depth/2;
+ var points = [ {
+ x : px - margin,
+ y : py - bottomMargin,
+ z : pz
+ }, {
+ x : px - margin,
+ y : -py + bottomMargin,
+ z : pz
+ }, {
+ x : -px + margin,
+ y : -py + margin,
+ z : pz
+ }, {
+ x : -px + margin,
+ y : py - margin,
+ z : pz
+ } ];
+ return rotate(points, xy, xz, yz);
+ }
+
+ function translateBack(xy, xz, yz) {
+ var px = width / 2;
+ var py = height / 2;
+ var pz = -depth/2;
+ var points = [ {
+ x : px,
+ y : py,
+ z : pz
+ }, {
+ x : px,
+ y : -py,
+ z : pz
+ }, {
+ x : -px,
+ y : -py,
+ z : pz
+ }, {
+ x : -px,
+ y : py,
+ z : pz
+ } ];
+ return rotate(points, xy, xz, yz);
+ }
+
+ function translateTop(xy, xz, yz) {
+ var px = width / 2;
+ var py = height / 2;
+ var pz = depth/2;
+ var points = [ {
+ x : px,
+ y : -py,
+ z : pz
+ }, {
+ x : px,
+ y : -py,
+ z : -pz
+ }, {
+ x : px,
+ y : py,
+ z : -pz
+ }, {
+ x : px,
+ y : py,
+ z : pz
+ } ];
+ return rotate(points, xy, xz, yz);
+ }
+
+ function translateBottom(xy, xz, yz) {
+ var px = -width / 2;
+ var py = height / 2;
+ var pz = depth/2;
+ var points = [ {
+ x : px,
+ y : -py,
+ z : pz
+ }, {
+ x : px,
+ y : -py,
+ z : -pz
+ }, {
+ x : px,
+ y : py,
+ z : -pz
+ }, {
+ x : px,
+ y : py,
+ z : pz
+ } ];
+ return rotate(points, xy, xz, yz);
+ }
+
+ function translateLeft(xy, xz, yz) {
+ var px = width / 2;
+ var py = height / 2;
+ var pz = depth/2;
+ var points = [ {
+ x : px,
+ y : py,
+ z : pz
+ }, {
+ x : px,
+ y : py,
+ z : -pz
+ }, {
+ x : -px,
+ y : py,
+ z : -pz
+ }, {
+ x : -px,
+ y : py,
+ z : pz
+ } ];
+ return rotate(points, xy, xz, yz);
+ }
+
+ function translateRight(xy, xz, yz) {
+ var px = width / 2;
+ var py = -height / 2;
+ var pz = depth/2;
+ var points = [ {
+ x : px,
+ y : py,
+ z : pz
+ }, {
+ x : px,
+ y : py,
+ z : -pz
+ }, {
+ x : -px,
+ y : py,
+ z : -pz
+ }, {
+ x : -px,
+ y : py,
+ z : pz
+ } ];
+ return rotate(points, xy, xz, yz);
+ }
+
+
+ function renderUI() {
+ var canvas = document.getElementById("phoneposition");
+ var ctx = canvas.getContext("2d");
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+
+ var r = 62;
+
+ var xy = (180 - angleX) * Math.PI / 180;
+ var yz = (angleY - 180) * Math.PI / 180;
+ var xz = (180 - angleZ) * Math.PI / 180 + Math.PI / 2;
+
+ var back = translateBack(xy, xz, yz);
+ if ((back[0].z + back[2].z)/2 < 0) {
+ paint(canvas, ctx, back);
+ } else {
+ paint(canvas, ctx, translateFace(xy, xz, yz));
+ paintScreen(canvas, ctx, translateScreen(xy, xz, yz));
+ }
+
+ var dz = 0;
+ if (back[0].z > back[3].z) {
+ var bottom = translateBottom(xy, xz, yz);
+ paint(canvas, ctx, bottom);
+ dz = bottom[1].y - bottom[0].y;
+ } else if (back[0].z != back[3].z) {
+ var top = translateTop(xy, xz, yz);
+ paint(canvas, ctx, top);
+ dz = top[1].y - top[0].y;
+ }
+
+ if (back[1].z > back[0].z) {
+ paint(canvas, ctx, translateLeft(xy, xz, yz));
+ } else if (back[1].z != back[0].z) {
+ paint(canvas, ctx, translateRight(xy, xz, yz));
+ }
+ var accelX = (back[1].y - back[0].y) / width;
+ var accelY = (back[0].y - back[3].y) / height;
+ var accelZ = dz / depth;
+
+ notifyAcceleration(accelX, accelY, accelZ);
+ }
+
+ function rotate(points, xy, xz, yz) {
+ var res = new Array();
+ for ( var p in points) {
+ var px = points[p].x;
+ var py = points[p].y;
+ var pz = points[p].z;
+
+ var rx = Math.sqrt(px * px + py * py);
+ var angXY = Math.atan(px / py) + (px < 0 ? Math.PI : 0);
+
+ px = rx * Math.sin(angXY + xy);
+ py = rx * Math.cos(angXY + xy);
+
+ var rz = Math.sqrt(px * px + pz * pz);
+ var angXZ = (px == 0 ? 0 : Math.atan(pz / px))
+ + (px < 0 ? Math.PI : 0);
+
+ px = rz * Math.sin(angXZ + xz);
+ pz = rz * Math.cos(angXZ + xz);
+
+ var ry = Math.sqrt(py * py + pz * pz);
+ var angYZ = (pz == 0 ? 0 : Math.atan(py / pz))
+ + (pz < 0 ? Math.PI : 0);
+
+ py = ry * Math.sin(angYZ + yz);
+ pz = ry * Math.cos(angYZ + yz);
+
+ res.push( {
+ x : px,
+ y : py,
+ z : pz
+ });
+ }
+ return res;
+ }
+
+ function updateAngleX(event, ui) {
+ angleX = ui.value;
+ renderUI();
+ }
+
+ function updateAngleY(event, ui) {
+ angleY = ui.value;
+ renderUI();
+ }
+
+ function updateAngleZ(event, ui) {
+ angleZ = ui.value;
+ renderUI();
+ }
+
+ function paint(canvas, ctx, points) {
+ var xcoord = canvas.width / 2;
+ var ycoord = canvas.height / 2;
+
+ ctx.fillStyle = "yellow";
+ ctx.strokeStyle = "black";
+ ctx.beginPath();
+ ctx.moveTo(xcoord + points[3].x, ycoord + points[3].y);
+ for (point in points) {
+ ctx.lineTo(xcoord + points[point].x, ycoord + points[point].y);
+ }
+ ctx.fill();
+ ctx.beginPath();
+ ctx.moveTo(xcoord + points[3].x, ycoord + points[3].y);
+ for (point in points) {
+ ctx.lineTo(xcoord + points[point].x, ycoord + points[point].y);
+ }
+ ctx.stroke();
+ }
+
+ function paintScreen(canvas, ctx, screen) {
+ var xcoord = canvas.width / 2;
+ var ycoord = canvas.height / 2;
+
+ ctx.fillStyle = "grey";
+ ctx.beginPath();
+ ctx.moveTo(xcoord + screen[3].x, ycoord + screen[3].y);
+ for (point in screen) {
+ ctx.lineTo(xcoord + screen[point].x, ycoord + screen[point].y);
+ }
+ ctx.fill();
+ }
+
+ function notifyAcceleration(x, y, z) {
+ accelerationCallback(x, y, z);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/preview/script/emulator.js Tue Jun 29 13:44:16 2010 -0700
@@ -0,0 +1,260 @@
+/**
+ * Copyright (c) 2009-2010 Symbian Foundation and/or its subsidiary(-ies). All
+ * rights reserved. This component and the accompanying materials are made
+ * available under the terms of the License "Eclipse Public License v1.0" which
+ * accompanies this distribution, and is available at the URL
+ * "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors: Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+function Emulator() {
+ this.child = false;
+ this.accelerationCallback = false;
+ this.iconFile = 'preview/images/default-Icon.png';
+ this.loaded = false;
+ this.FORCE = 62;
+ this.state = new EmulatorState(0, this.FORCE, 0, true);
+ this.orientation = "DisplayUp";
+
+ this.plist = {
+ DisplayName : '',
+ Identifier : '',
+ MainHTML : '',
+ AllowNetworkAccess : "false",
+ Version : '',
+ MiniViewEnabled : "false",
+ is_browserReady : false
+ };
+};
+
+Emulator.prototype.setAccelerationCallback = function(acceleration) {
+ this.accelerationCallback = acceleration;
+ this.accelerationCallback(this.state.XAxis, this.state.YAxis, this.state.ZAxis, this.orientation);
+};
+
+function orientationFromAcceleration(x, y, z) {
+ var orientation = NOKIA.emulator.orientation;
+
+ var xangle = Math.asin(x) * 180 / Math.PI;
+ if (xangle > 55) {
+ orientation = "DisplayRightUp";
+ } else if (xangle < -55) {
+ orientation = "DisplayLeftUp";
+ }
+
+ var yangle = Math.asin(y) * 180 / Math.PI;
+ if (yangle > 55) {
+ orientation = "DisplayUp";
+ } else if (yangle < -55) {
+ orientation = "DisplayDown";
+ }
+
+ var zangle = Math.asin(z) * 180 / Math.PI;
+ if (zangle > 75) {
+ orientation = "DisplayUpwards";
+ } else if (zangle < -75) {
+ orientation = "DisplayDownwards";
+ }
+
+ return orientation;
+}
+
+
+Emulator.prototype.accelerationChanged = function(x, y, z) {
+ this.state.XAxis = x * this.FORCE;
+ this.state.YAxis = y * this.FORCE;
+ this.state.ZAxis = z * this.FORCE;
+
+ var orientation = orientationFromAcceleration(x, y, z);
+
+ if (orientation != this.orientation) {
+ this.orientation = orientation;
+ NOKIA.layout.render();
+ }
+
+ if (this.accelerationCallback) {
+ this.accelerationCallback(this.state.XAxis, this.state.YAxis, this.state.ZAxis, this.orientation);
+ }
+};
+
+Emulator.prototype.load = function() {
+ if (this.loaded)
+ return false;
+ NOKIA.layout._console_minimized = (NOKIA.helper
+ .getPreference('__SYM_NOKIA_CONSOLE_OPEN') != "true");
+ // load the saved device Info
+ var device = NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_DEVICE');
+ NOKIA.currentDevice = device || NOKIA.currentDevice;
+
+ // load the saved device mode
+ var mode = NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE');
+ if (mode != null)
+ NOKIA.mode = mode;
+
+ var orientation = Number(NOKIA.helper
+ .getPreference('__SYM_NOKIA_EMULATOR_ORIENTATION'));
+ if (typeof orientation == "number" && orientation >= -90
+ && orientation <= 180)
+ NOKIA.orientation = orientation;
+
+ // SAVE the device DATA
+ NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE',
+ NOKIA.currentDevice);
+ NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode);
+ NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_ORIENTATION',
+ NOKIA.orientation);
+
+ this.loaded = true;
+
+};
+
+Emulator.prototype.render = function() {
+ this.load();
+ // Selecting Resoltion
+ var resOptions = $("#resOptions")[0];
+ for ( var i = 0; i < NOKIA.resolution.length; i++) {
+ if (NOKIA.resolution[i] == NOKIA.currentDevice) {
+ resOptions.options[i].selected = true;
+ break;
+ }
+ }
+
+ if (!NOKIA.emulator.orientationSupports())
+ NOKIA.mode = NOKIA.deviceList[NOKIA.currentDevice]['default'];
+
+ if (typeof NOKIA.deviceList == 'undefined'
+ || typeof NOKIA.deviceList[NOKIA.currentDevice] == 'undefined'
+ || typeof NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode] == 'undefined') {
+ alert('Deive resolution: ' + NOKIA.currentDevice + ' or the mode: '
+ + NOKIA.mode + ' not found');
+ return false;
+ }
+
+ this.setStyle();
+ var or = (NOKIA.mode == 'portrait') ? NOKIA.orientation
+ : (NOKIA.orientation + 90);
+ var val = "rotate(" + or + "deg)";
+ $("#DeviceDisplayLayout").css("-moz-transform", val);
+ $("#DeviceDisplayLayout").css("-webkit-transform", val);
+};
+
+Emulator.prototype.setMode = function(mode) {
+ NOKIA.mode = mode;
+
+ // SAVE the device DATA
+ NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode);
+
+ NOKIA.emulator.render();
+};
+
+Emulator.prototype.toggle = function(o) {
+ NOKIA.orientation = o;
+ NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_ORIENTATION',
+ NOKIA.orientation);
+ NOKIA.emulator.child.device.implementation.setOrientation(o, 0);
+ if (NOKIA.emulator.orientationSupports() && (o == 0 || o == -90)) {
+ NOKIA.emulator.setMode(o == 0 ? 'portrait' : 'landscape');
+ } else {
+ NOKIA.emulator.render();
+ }
+};
+
+Emulator.prototype.orientationSupports = function() {
+ return NOKIA.deviceList[NOKIA.currentDevice]['orientation'];
+};
+
+Emulator.prototype.setStyle = function() {
+ if (!NOKIA.helper.checkDependencies()) {
+ setTimeout(NOKIA.emulator.setStyle, 1000);
+ }
+
+ var deviceProperties = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode];
+ var style = deviceProperties['style'];
+
+ // Apply Style and propertis to Device layers
+ $("#DeviceDisplayLayout").css(style['layout']);
+ $('#DisplayArea').css(style['display']);
+
+ NOKIA.emulator.setWidgetStyle();
+
+ $('#SoftKeysArea').css( {
+ 'width' : style['menu']['width'] + 'px',
+ 'height' : style['menu']['height'] + 'px',
+ 'float' : style['menu']['float']
+ });
+
+ $('#SoftKeysArea > ul > li').css('width',
+ parseInt(style['menu']['width'] / 2) - 10);
+
+ NOKIA.emulator.setMenuItemsStyle();
+
+ $('#SoftKeys').css(style['softkeys']);
+ // $('#SoftKeys > a > img').css(style['softkeysImg']);
+
+ NOKIA.menu.createSFKArea();
+
+ $("#DeviceDisplayLayout").show();
+ $("#InspectorTab").show();
+
+ if (/chrome/.test(navigator.userAgent.toLowerCase())) {
+ $("#InspectorBtn").show();
+ }
+ if (/mac/.test(navigator.userAgent.toLowerCase())) {
+ $("#MacShortcut").show();
+ } else {
+ $("#UniversalShortcut").show();
+ }
+},
+
+Emulator.prototype.setWidgetStyle = function() {
+ var style = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
+ var height;
+ if (NOKIA.menu.softkeys_visibility || NOKIA.menu.is_softkeys_visible)
+ height = parseInt(style['widget']['height'] - style['menu']['height']);
+ else
+ height = style['widget']['height'];
+
+ $('#WidgetArea').css( {
+ 'width' : style['widget']['width'] + 'px',
+ 'height' : height + 'px',
+ 'float' : style['widget']['float']
+ });
+};
+
+Emulator.prototype.setMenuItemsStyle = function() {
+ var style = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
+ var count = 1;
+ try {
+ if (NOKIA.emulator.child.menu) {
+ count = parseInt(NOKIA.helper
+ .getElementsLengthInObject(NOKIA.emulator.child.menu.items)) + 1;
+ }
+ } catch (e) {
+ count = 1;
+ }
+ var height = parseInt(count * style['menu']['optionKeysheight']) + 10;
+ var top = parseInt(style['widget']['height'] - height);
+
+ $('#MenuItemsArea').css(
+ {
+ 'width' : style['widget']['width'] + 'px',
+ 'height' : height + 'px',
+ 'marginTop' : '-2px',
+ 'top' : (style['widget']['height'] - height
+ - style['menu']['height'] + 2)
+ + 'px',
+ 'position' : 'relative'
+ });
+};
+
+function EmulatorState(x, y, z, orientation) {
+ this.XAxis = x;
+ this.YAxis = y;
+ this.ZAxis = z;
+ this.portrait = orientation;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/preview/script/helper.js Tue Jun 29 13:44:16 2010 -0700
@@ -0,0 +1,632 @@
+function EmulatorHelper() {
+ this.path = document.location.pathname;
+ this.errorDailog = null;
+ this.prefDailog = null;
+ this.inspectorDailog = null;
+ this.intervalId = null;
+ this.infoPlistCounter = false;
+ this.IconFileCounter = false;
+}
+
+EmulatorHelper.prototype.loadScript = function(path) {
+ var head = document.getElementsByTagName("head")[0]
+ || document.documentElement;
+ var script = document.createElement("script");
+
+ script.type = "text/javascript";
+ script.src = src;
+ head.appendChild(script);
+};
+
+EmulatorHelper.prototype.loadPreferences = function() {
+ if (/dreamweaver/i.test(navigator.userAgent)) {
+ $("#dwDeviceHelp")[0].className = '';
+ // $("#resSupportLink")[0].className = 'hide';
+ }
+ // Selecting Resoltion
+ var resOptions = $("#resOptions")[0];
+ for ( var i = 0; i < NOKIA.resolution.length; i++) {
+ if (NOKIA.resolution[i] == NOKIA.currentDevice) {
+ resOptions.options[i].selected = true;
+ break;
+ }
+ }
+
+ // Selecting Version
+ if (NOKIA.version == 'WRT 1.0')
+ $('#wrt_version_1_0')[0].checked = true;
+ else
+ $('#wrt_version_1_1')[0].checked = true;
+
+ // HomeScreen Support
+ if (NOKIA.deviceList[NOKIA.currentDevice].homeScreenSupport) {
+ if (typeof NOKIA.emulator.plist.MiniViewEnabled != 'undefined') {
+ if (NOKIA.emulator.plist.MiniViewEnabled == 'false')
+ $('#HS_Control_Info')
+ .html(
+ "<span id='wrt-help' onclick='javascipt:NOKIA.helper.showMiniviewHelp();'></span><strong>Not Enabled</strong><br/><small>Click on help to read more about enabling Mini view support</small>");
+ else
+ $('#HS_Control_Info').html("Supported");
+ } else
+ $('#HS_Control_Info').html(
+ "<span id='wrt-help'></span>Not Supported");
+
+ $('#HS_Control_Info').show();
+
+ } else {
+ $('#HS_Control_Info').html(
+ "Not Supported for the selected Device resolution");
+ $('#HS_Control_Info').show();
+ }
+};
+
+EmulatorHelper.prototype.getInfo = function(url, callback) {
+ try {
+ var xhr = this.ajax();
+
+ if ((/AppleWebKit/i.test(navigator.userAgent)))
+ xhr.open("GET", url, false);
+ else
+ xhr.open("GET", url, true);
+
+ xhr.onreadystatechange = function() {
+ // readyState = 4 ; "complete"
+ if (xhr.readyState == 4) {
+ // status = 200 ; "ok"
+ if ((xhr.status == 200) || (!xhr.status)) {
+ callback(true, xhr);
+ } else {
+ callback(false, xhr);
+ }
+ }
+
+ };
+ xhr.send(null);
+ } catch (e) {
+ if (e.name == 'NS_ERROR_FILE_NOT_FOUND') {
+ callback(false, xhr);
+ }
+ }
+};
+
+EmulatorHelper.prototype.getInfoCallback = function(flag, xhr) {
+ // If Info.plis NOT FOUND / FAILED LOAD
+ // an ERROR!, unable to proceed further
+ // STOP there
+ if (!flag) {
+ if (!NOKIA.helper.infoPlistCounter) {
+ NOKIA.helper.infoPlistCounter = true;
+ NOKIA.helper.getInfo('info.plist', NOKIA.helper.getInfoCallback);
+ return false;
+ }
+
+ NOKIA.helper
+ .error('WRT Previewer: Initialization failed. Could not open Info.plist file.<br/>Please ensure <strong style="color:#efe352;">Info.plist</strong> file exists in the project root folder and that it is named properly.');
+ return false;
+ } else {
+
+ var xmlString = xhr.responseText;
+
+ // do some cheating here
+ xmlString = xmlString.replace(/<!--(.|[\n\r])*?-->/gm, "");
+ xmlString = xmlString.replace(/<\s*true\s*\/>/gi,
+ "<string>true</string>");
+ xmlString = xmlString.replace(/<\s*false\s*\/>/gi,
+ "<string>false</string>");
+ xmlString = xmlString.replace(/[\n\r]/gi, "");
+ // return the JSON Object
+ NOKIA.helper.validate(xmlString);
+ }
+};
+
+EmulatorHelper.prototype.getIconCallback = function(flag, xhr) {
+
+ if (!flag) {
+ if (!NOKIA.helper.IconFileCounter) {
+ NOKIA.helper.IconFileCounter = true;
+ NOKIA.helper.getInfo('icon.png', NOKIA.helper.getIconCallback);
+ return false;
+ }
+ } else
+ NOKIA.emulator.iconFile = (NOKIA.helper.IconFileCounter) ? "icon.png"
+ : "Icon.png";
+};
+
+EmulatorHelper.prototype.validate = function(xmlObject) {
+ var values = xmlObject
+ .match(/.*<plist.*?(<dict.*?>\s*(<key[^>]*?>[^<]*?<\/key>\s*<string[^>]*?>[^<]*?<\/string>)*\s*<\/dict>)\s*<\/plist>/)[1];
+ if (values == null || values == undefined) {
+ NOKIA.helper.error('Corrupted Info.plist file');
+ return false;
+ }
+ values = values.replace(/<dict.*?(<key.*?>\s*.*\s*<\/string>)\s*<\/dict>/,
+ "{ $1 }");
+ values = values
+ .replace(
+ /\s*<key.*?>\s*(.*?)\s*<\/key>\s*<string.*?>\s*(.*?)\s*<\/string>\s*/g,
+ "\"$1\" : \"$2\", ");
+ values = values.replace(/"\s*?,\s*?}/g, "\" }");
+ try {
+ NOKIA.emulator.plist = JSON.parse(values);
+ } catch (exception) {
+ NOKIA.helper.error('Corrupted Info.plist file');
+ return false;
+ }
+
+ try {
+ if (typeof NOKIA.emulator.plist.DisplayName != 'undefined') {
+ document.title = NOKIA.emulator.plist.DisplayName + ' - '
+ + document.title;
+ }
+ } catch (e) {
+ }
+
+ // Add UI-Event listeners
+ NOKIA.helper.addListeners();
+ NOKIA.layout.init();
+ NOKIA.emulator.render();
+};
+
+EmulatorHelper.prototype.ajax = function() {
+ // xmlHttpRequest object
+ var request = null;
+
+ // branch for native XMLHttpRequest object
+ if (window.XMLHttpRequest && !(window.ActiveXObject)) {
+ try {
+ request = new XMLHttpRequest();
+ try {
+ // attach the Bypass code, if the browser is firefox
+ if (netscape.security.PrivilegeManager.enablePrivilege) {
+ // duplicate the function
+ request._open = request.open;
+
+ // redefine the function definition
+ request.open = function(method, url, flag) {
+ try {
+ // Enable Universal Browser Read
+ netscape.security.PrivilegeManager
+ .enablePrivilege("UniversalBrowserRead");
+
+ // call the native XmlHttpRequest.open method
+ this._open(method, url, flag);
+ } catch (e) {
+ // call the native XmlHttpRequest.open method
+ this._open(method, url, flag);
+ }
+ };
+ }
+ } catch (e) {
+ // eatup all exceptions
+ }
+ } catch (e) {
+ request = null;
+ }
+ // branch for IE/Windows ActiveX version
+ } else if (window.ActiveXObject) {
+ try {
+ request = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+ try {
+ request = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e) {
+ alert('Failed to create XmlHttprequest');
+ return null;
+ }
+ }
+ }
+
+ return (request);
+};
+
+EmulatorHelper.prototype.error = function(msg) {
+ if (NOKIA.menu.enable_log)
+ NOKIA.layout.log("log", msg);
+
+ $("#Dialog").html(msg);
+ $("#Dialog").dialog('open');
+};
+
+EmulatorHelper.prototype.setPreference = function(name, value) {
+ if (NOKIA.emulator.prefs[name] != value) {
+ NOKIA.emulator.prefs[name] = value;
+ $.post("preview/preferences.js", JSON.stringify( {
+ "key" : name,
+ "value" : value
+ }), undefined, "json");
+ }
+};
+
+EmulatorHelper.prototype.getPreference = function(name) {
+ return NOKIA.emulator.prefs[name];
+};
+
+EmulatorHelper.prototype.rotateCW = function() {
+ var newOrient = NOKIA.orientation + 90;
+ NOKIA.emulator.toggle(newOrient - (newOrient > 180 ? 360 : 0));
+};
+
+EmulatorHelper.prototype.rotateCCW = function() {
+ var newOrient = NOKIA.orientation - 90;
+ NOKIA.emulator.toggle(newOrient + (newOrient <= -180 ? 360 : 0));
+};
+
+EmulatorHelper.prototype.version = function(ele) {
+ if (confirm('Would you like to reload the widget to apply the changes on the Version settings?')) {
+ NOKIA.helper.setPreference('__SYM_WRT_VERSION', ele.value);
+ $("#loaderDiv").html("Applying the " + ele.value + ", please wait...");
+ $("#loaderDiv").show();
+ $("#loaderDiv")[0].className = 'green';
+
+ window.setTimeout(function() {
+ document.location = document.location;
+ }, 3000);
+ } else {
+ ele.checked = false;
+ if (ele.value != 'WRT 1.0')
+ $("#wrt_version_1_0")[0].checked = true;
+ else
+ $("#wrt_version_1_1")[0].checked = true;
+ }
+};
+
+EmulatorHelper.prototype.addListeners = function() {
+ NOKIA.helper.loadPreferences();
+ /*
+ * Render Emulator for Interaction
+ */
+ NOKIA.helper.inspectorDailog = $("#InspectorTab").dialog( {
+ width : 370,
+ minWidth : 300,
+ minHeight : 200,
+ height : 250,
+ autoOpen : false,
+ position : top,
+ title : ' ',
+ buttons : {
+ "Close" : function() {
+ $("#InspectorTab").dialog('close');
+ },
+ "Disconnect Debugger" : function() {
+ $.ajax( {
+ url : "__sym_command/terminateDebug"
+ });
+ }
+ }
+ });
+
+ $('#InspectorBtn').click(function() {
+ $('#InspectorTab').dialog('open');
+ // Hack for Mac firefox
+ if (/Mac/i.test(navigator.userAgent)) {
+ $("#WidgetArea iframe").css( {
+ overflow : 'hidden'
+ });
+ }
+ });
+
+ $('#rotateCW').click(function() {
+ NOKIA.helper.rotateCW();
+ });
+ $('#rotateCCW').click(function() {
+ NOKIA.helper.rotateCCW();
+ });
+ $('#resOptions').change(
+ function(ele) {
+ ele = ele.target || this;
+
+ NOKIA.currentDevice = ele.options[ele.selectedIndex].text;
+
+ // SAVE the device DATA
+ NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE',
+ NOKIA.currentDevice);
+
+ NOKIA.emulator.render();
+ NOKIA.helper.loadPreferences();
+ });
+
+ // Hack for Mac firefox
+ if (/Mac/i.test(navigator.userAgent)) {
+ if (!(/AppleWebKit/i.test(navigator.userAgent))) {
+ $("#resOptions")[0].size = '4';
+ }
+ }
+
+ // WRT Version controls
+ $('#wrt_version_1_0').change(function() {
+ NOKIA.helper.version(this);
+ });
+
+ $('#wrt_version_1_1').change(function() {
+ NOKIA.helper.version(this);
+ });
+
+ $("#orientationIcon").click(function() {
+ var mode = (NOKIA.mode == 'portrait') ? 'landscape' : 'portrait';
+ NOKIA.emulator.setMode(mode);
+ $("#WidgetArea")[0].className = 'hs_' + NOKIA.mode;
+ });
+
+ $("#iframeMask").click(function() {
+ $("#orientationIcon").hide();
+ $("#iframeMask").hide();
+ $("#loaderDiv").hide();
+
+ NOKIA.menu.is_dimmed = false;
+
+ $("#WidgetArea")[0].className = '';
+
+ NOKIA.menu.softkeys_visibility = true;
+ NOKIA.menu.showSoftKeys();
+
+ });
+
+ // MenuItems DIV events
+ $("#MenuItemsArea").mouseover(function() {
+ if (NOKIA.helper.intervalId)
+ clearInterval(NOKIA.helper.intervalId);
+
+ $("#MenuItemsArea").show();
+ });
+
+ $("#MenuItemsArea").mouseout(function() {
+ if (NOKIA.helper.intervalId)
+ clearInterval(NOKIA.helper.intervalId);
+
+ NOKIA.helper.intervalId = setTimeout(function() {
+ NOKIA.menu.cancel();
+ }, 500);
+ });
+
+ // Tabs
+ $('#tabs').tabs( {
+ // select : function(event, ui){
+ // switch (ui.index) {
+ // case 1:
+ // $("event-battery-info").show();
+ // break;
+ // case 2:
+ // $("event-messaging-info").show();
+ // break;
+ // case 3:
+ // $("event-memory-info").show();
+ // break;
+ // case 4:
+ // $("settings-view").show();
+ // break;
+ //
+ // }}
+ });
+ $(".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *").removeClass(
+ "ui-corner-all ui-corner-top").addClass("ui-corner-bottom");
+
+ /*
+ * Event triggering
+ */
+
+ // for battery
+ $("#event-battery").click(function(event) {
+ if (event.target.className == 'active') {
+ $("#event-icons").hide();
+ $("#event-battery-info").show();
+
+ /*
+ * $('#slider').slider('option', 'value',
+ * NOKIA.emulator.child._BRIDGE_REF.helper.getBatteryStrength());
+ * NOKIA.emulator.child._BRIDGE_REF.helper.getBatteryStrength()
+ * $('#slider').slider('option', 'value', 10);
+ * $('#slider').slider();
+ */
+ }
+ });
+
+ $("#event-battery-back").click(function(event) {
+ $("#event-icons").show();
+ $("#event-battery-info").hide();
+ });
+
+ // for messaging
+ $("#event-messaging").click(function(event) {
+ if (event.target.className == 'active') {
+ $("#event-icons").hide();
+ $("#event-messaging-info").show();
+ }
+ });
+
+ $("#event-messaging-back").click(function(event) {
+ $("#event-icons").show();
+ $("#event-messaging-info").hide();
+ });
+
+ // for memory
+ $("#event-memory").click(function(event) {
+ if (event.target.className == 'active') {
+ $("#event-icons").hide();
+ $("#event-memory-info").show();
+ }
+ });
+
+ $("#event-memory-back").click(function(event) {
+ $("#event-icons").show();
+ $("#event-memory-info").hide();
+ });
+
+ // for minView more info
+ $("#mini-view-back").click(function(event) {
+ $("#settings-view").show();
+ $("#mini-view-info").hide();
+ });
+
+ // Slider
+ $('#slider').slider(
+ {
+ min : 0,
+ max : 100,
+ step : 1,
+ value : 10,
+ animate : true,
+ slide : function(event, ui) {
+ $("#slider-value-panel > span").html(
+ ui.value.toString() + "%");
+ },
+ change : function(event, ui) {
+ var chargeValue = ui.value;
+ NOKIA.helper.trigger("power", "chargelevel", chargeValue);
+ if (NOKIA.version == 'WRT 1.1')
+ NOKIA.helper.triggerSapi("Service.SysInfo",
+ "Battery.BatteryStrength", {
+ Status : chargeValue
+ });
+ }
+ });
+ $("#slider-value-panel > span").html("10%");
+
+ var cc = $("#close-camera");
+ cc.click(NOKIA.helper.hideCamera);
+ // Bind Buttons to trigger values to WRT 1.0 / 1.1 bindings
+
+ $("#connect-charger").click(NOKIA.helper.triggerEvents);
+ $("#disconnect-charger").click(NOKIA.helper.triggerEvents);
+
+ $("#send-sms").click(NOKIA.helper.triggerEvents);
+ $("#send-mms").click(NOKIA.helper.triggerEvents);
+
+ $("#connect-memory-card").click(NOKIA.helper.triggerEvents);
+ $("#disconnect-memory-card").click(NOKIA.helper.triggerEvents);
+
+};
+
+EmulatorHelper.prototype.setHomeScreen = function() {
+ // HomeScreen Support
+ if (NOKIA.deviceList[NOKIA.currentDevice].homeScreenSupport) {
+
+ if (typeof NOKIA.emulator.plist.MiniViewEnabled != 'undefined') {
+ if (NOKIA.emulator.plist.MiniViewEnabled != 'false') {
+ $("#WidgetArea")[0].className = 'hs_' + NOKIA.mode;
+
+ // menu handlining
+ NOKIA.menu.softkeys_visibility = false;
+ NOKIA.menu.cancel();
+ NOKIA.menu.is_dimmed = true;
+
+ $("#loaderDiv").html("Click on widget for Return to Full view");
+ $("#loaderDiv")[0].className = 'green';
+ $("#loaderDiv").show();
+
+ $("#iframeMask").show();
+ $("#orientationIcon").show();
+
+ return true;
+ }
+ }
+ }
+ return false;
+};
+
+EmulatorHelper.prototype.getElementsLengthInObject = function(items) {
+ var count = 0;
+ for ( var i in items) {
+ if (!items[i].isDimmed)
+ count++;
+ }
+
+ return count;
+};
+
+EmulatorHelper.prototype.showCamera = function() {
+ $("#camera").show();
+ $("#WidgetArea").hide();
+};
+
+EmulatorHelper.prototype.hideCamera = function() {
+ $("#camera").hide();
+ $("#WidgetArea").show();
+};
+
+EmulatorHelper.prototype.triggerEvents = function(event) {
+ if (typeof event.target.id == 'undefined')
+ return false;
+
+ switch (event.target.id) {
+ // for battery
+ case 'connect-charger':
+ NOKIA.helper.trigger("power", "chargerconnected", 1);
+ if (NOKIA.version == 'WRT 1.1')
+ NOKIA.helper.triggerSapi("Service.SysInfo",
+ "Battery.ChargingStatus", {
+ Status : 1
+ });
+ break;
+
+ case 'disconnect-charger':
+ NOKIA.helper.trigger("power", "chargerconnected", 0);
+ if (NOKIA.version == 'WRT 1.1')
+ NOKIA.helper.triggerSapi("Service.SysInfo",
+ "Battery.ChargingStatus", {
+ Status : 0
+ });
+ break;
+
+ // for messaging
+ case 'send-sms':
+ if (NOKIA.version == 'WRT 1.1')
+ NOKIA.helper.triggerSapi("Service.Messaging", "NewMessage", {
+ MessageType : 'SMS'
+ });
+ break;
+ case 'send-mms':
+ if (NOKIA.version == 'WRT 1.1')
+ NOKIA.helper.triggerSapi("Service.Messaging", "NewMessage", {
+ MessageType : 'MMS'
+ });
+ break;
+
+ // for memory
+ case 'connect-memory-card':
+ if (NOKIA.version == 'WRT 1.1')
+ NOKIA.helper.triggerSapi("Service.SysInfo", "Memory.MemoryCard", {
+ Status : 1
+ });
+ break;
+ case 'disconnect-memory-card':
+ if (NOKIA.version == 'WRT 1.1')
+ NOKIA.helper.triggerSapi("Service.SysInfo", "Memory.MemoryCard", {
+ Status : 0
+ });
+ break;
+ }
+};
+
+EmulatorHelper.prototype.triggerSapi = function(provider, eventType, data) {
+ NOKIA.emulator.child.device.implementation.triggerListener(provider,
+ eventType, data);
+};
+
+EmulatorHelper.prototype.trigger = function(provider, eventType, data) {
+ NOKIA.emulator.child.widget.triggerListener(provider, eventType, data);
+};
+
+EmulatorHelper.prototype.showMiniviewHelp = function() {
+ $("#settings-view").hide();
+ $("#mini-view-info").show();
+};
+
+EmulatorHelper.prototype.checkDependencies = function() {
+
+ for ( var key in NOKIA.scriptsLoaded) {
+ if (!NOKIA.scriptsLoaded[key])
+ return false;
+ }
+
+ // for LSK
+ NOKIA.menu.setLsk(NOKIA.emulator.child.menu.show);
+
+ // for RSK
+ NOKIA.menu.setRsk(NOKIA.menu.exit);
+
+ return true;
+};
+
+function accelerationCallback(x, y, z) {
+ NOKIA.emulator.accelerationChanged(x, y, z);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/preview/script/layout.js Tue Jun 29 13:44:16 2010 -0700
@@ -0,0 +1,136 @@
+/**
+ * Copyright (c) 2009-2010 Symbian Foundation and/or its subsidiary(-ies). All
+ * rights reserved. This component and the accompanying materials are made
+ * available under the terms of the License "Eclipse Public License v1.0" which
+ * accompanies this distribution, and is available at the URL
+ * "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors: Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+function EmulatorLayout() {
+ this._console_minimized = true;
+ this._console_enabled = false;
+ this._consoleWindowHeight = 290;
+ this._consoleHeaderHeight = 31;
+ this._tabHeight = 27;
+}
+
+EmulatorLayout.prototype.init = function() {
+ // Toggle console window
+ $('#preview-ui-bottom-header')
+ .click(
+ function() {
+ NOKIA.layout._console_minimized = (NOKIA.layout._console_minimized) ? false
+ : true;
+ NOKIA.layout.render();
+ NOKIA.helper.setPreference("__SYM_NOKIA_CONSOLE_OPEN",
+ !NOKIA.layout._console_minimized);
+ });
+
+ // clear Log
+ $("#Console-Clear-Button").click(function() {
+ $("#preview-ui-bottom-body")[0].innerHTML = '';
+ });
+
+ $('#preview-ui-bottom').show();
+ NOKIA.layout.render();
+};
+
+EmulatorLayout.prototype.log = function(type, msg) {
+ var p = document.createElement('p');
+ p.className = type;
+ p.innerHTML = msg;
+ var divBody = $('#preview-ui-bottom-body');
+ divBody.append(p);
+ divBody[0].scrollTop = divBody[0].scrollHeight;
+};
+
+EmulatorLayout.prototype.render = function() {
+ var _width = parseInt(window.innerWidth);
+ var _height = parseInt(window.innerHeight);
+
+ if (!NOKIA.layout._console_enabled) {
+ $('#preview-ui-bottom').css( {
+ display : 'none'
+ });
+
+ $('#preview-ui-top').css( {
+ height : _height + 'px'
+ });
+
+ return false;
+ }
+
+ if (!NOKIA.layout._console_minimized) {
+ $('#Console-Toggle-Button')[0].className = 'open';
+
+ // set STYLE details for TOP window
+ $('#preview-ui-top').css(
+ {
+ height : parseInt(_height
+ - NOKIA.layout._consoleWindowHeight)
+ + 'px'
+ });
+
+ // set STYLE details for Bottom window
+ $('#preview-ui-bottom').css( {
+ height : NOKIA.layout._consoleWindowHeight + 'px',
+ display : 'block'
+ });
+
+ $('#preview-ui-bottom-header').css( {
+ height : NOKIA.layout._consoleHeaderHeight + 'px'
+ });
+
+ $('#tabs').css(
+ {
+ height : parseInt(NOKIA.layout._consoleWindowHeight
+ - NOKIA.layout._consoleHeaderHeight)
+ + 'px',
+ display : 'block'
+ });
+ $('#console').css(
+ {
+ height : parseInt(NOKIA.layout._consoleWindowHeight
+ - NOKIA.layout._consoleHeaderHeight
+ - NOKIA.layout._tabHeight * 2)
+ + 'px',
+ display : 'block'
+ });
+
+ // Auto scroll when console window opened from MINIMIZED =>
+ // MAXIMIZED state
+ window
+ .setTimeout(
+ function() {
+ $('#preview-ui-bottom-body')[0].scrollTop = $('#preview-ui-bottom-body')[0].scrollHeight;
+ }, 100);
+
+ } else {
+ $('#Console-Toggle-Button')[0].className = 'close';
+
+ // set STYLE details for TOP window
+ $('#preview-ui-top').css(
+ {
+ height : parseInt(_height
+ - NOKIA.layout._consoleHeaderHeight)
+ + 'px'
+ });
+
+ // set STYLE details for Bottom window
+ $('#preview-ui-bottom').css( {
+ height : NOKIA.layout._consoleHeaderHeight + 'px',
+ display : 'block'
+ });
+
+ $('#preview-ui-bottom-header').css( {
+ height : NOKIA.layout._consoleHeaderHeight + 'px',
+ display : 'block'
+ });
+ }
+};
\ No newline at end of file
--- a/org.symbian.tools.wrttools.previewer/preview/script/lib/sapi/Landmarks.js Mon Jun 28 10:47:32 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/script/lib/sapi/Landmarks.js Tue Jun 29 13:44:16 2010 -0700
@@ -41,7 +41,7 @@
this.Export = __Export;
this.Organise = __Organise;
this.Cancel = __Cancel;
- }
+ };
device.implementation.extend(provider, Interface, new LandmarkService() );
--- a/org.symbian.tools.wrttools.previewer/preview/script/lib/sapi/Sensor.js Mon Jun 28 10:47:32 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/script/lib/sapi/Sensor.js Tue Jun 29 13:44:16 2010 -0700
@@ -36,8 +36,8 @@
var AccelerometerDoubleTapping = new Array();
var Orientation = new Array();
var Rotation = new Array();
- var xyOrientation = 0;
- var zOrientation = 0;
+ var orientation;
+ var xaxis = 0, yaxis = 0, zaxis = 0;
var provider = 'Service.Sensor',
Interface = 'ISensor';
@@ -64,31 +64,50 @@
result = false,
DBase = null;
- device.implementation.setOrientation = function(xy, z) {
- xyOrientation = xy;
- zOrientation = z;
-
- for (var i = 0; i < Orientation.length; i++) {
- notifyOrientationChangeListener(Orientation[i]);
- }
- };
+ function notifyAcceleration(x, y, z, o) {
+ xaxis = Math.round(x);
+ yaxis = Math.round(y);
+ zaxis = Math.round(z);
+
+ var res = createAccelerationResult();
- function notifyOrientationChangeListener(callback) {
- var orientation;
- if (xyOrientation > -45 && xyOrientation <= 45) {
- orientation = "DisplayUp";
- } else if (xyOrientation > 45 && xyOrientation <= 135) {
- orientation = "DisplayLeftUp";
- } else if (xyOrientation > 135 || xyOrientation <= -135) {
- orientation = "DisplayDown";
- } else if (xyOrientation > -135 && xyOrientation <= -45) {
- orientation = "DisplayRightUp";
+ window.setTimeout(function() {
+ for ( var i = 0; i < AccelerometerAxis.length; i++) {
+ var callback = AccelerometerAxis[i];
+ callback(getTransactionId(callback), 9, res);
+ }
+ }, 5);
+
+ if (orientation != o) {
+ orientation = o;
+ var orRes = createOrientationResult();
+ window.setTimeout(function() {
+ for ( var i = 0; i < Orientation.length; i++) {
+ var callback = Orientation[i];
+ callback(getTransactionId(callback), 9, orRes);
+ }
+ }, 5);
}
- callback(getTransactionId(callback), 9, context.Result( {
+ }
+
+ function createAccelerationResult() {
+ return context.Result( {
+ DataType : "AxisData",
+ TimeStamp : new Date().getTime(),
+ XAxisData : xaxis,
+ YAxisData : yaxis,
+ ZAxisData : zaxis
+ });
+ }
+
+ function createOrientationResult() {
+ return context.Result( {
+ DataType : "AxisData",
+ TimeStamp : new Date().getTime(),
DeviceOrientation : orientation
- }));
+ });
}
-
+
function getTransactionId(callback) {
for ( var tId in transactionToCallback) {
if (transactionToCallback[tId] == callback) {
@@ -137,7 +156,6 @@
function __RegisterForNotification(criteria, callback, flag){
flag = flag || false;
method = 'RegisterForNotification';
- context.notify(_t('%s:: RegisterForNotification not implemented in preview').arg(provider));
if(arguments.length >2 && (typeof flag != "undefined" && typeof flag != "boolean"))
return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgCriteriaMissing);
@@ -167,17 +185,18 @@
if (typeof callback == 'function') {
var channels = criteria.ChannelInfoMap;
// for ( var channel in channels) {
- var notify = null;
+ var result = false;
switch (channels.ChannelId) {
case CHANNEL_ACCEL:
AccelerometerAxis.push(callback);
+ result = createAccelerationResult();
break;
case CHANNEL_ACCELDT:
AccelerometerDoubleTapping.push(callback);
break;
case CHANNEL_ORIENTATION:
Orientation.push(callback);
- notify = notifyOrientationChangeListener;
+ result = createOrientationResult();
break;
case CHANNEL_ROTATION:
Rotation.push(callback);
@@ -186,7 +205,9 @@
// }
var tID = nextTransactionId++;
transactionToCallback[tID] = callback;
- setTimeout(notify, 20, callback);
+ if (result) {
+ setTimeout(function() {callback(tID, 9, result);}, 20, callback);
+ }
// var result = context.callAsync(this, arguments.callee, criteria, callback);
return context.AsyncResult(tID);
}
@@ -337,5 +358,6 @@
msgChannelNotSupported : '%s:%s:Channel property not supported',
msgChannelInfoMapInvalid : '%s:%s:ChannelInfoMap Type Invalid'
};
-
+
+ _BRIDGE_REF.nokia.emulator.setAccelerationCallback(notifyAcceleration);
}) ();
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/preview/script/menu.js Tue Jun 29 13:44:16 2010 -0700
@@ -0,0 +1,332 @@
+function EmulatorMenu() {
+ this.is_menu_visible = false; // true/false
+ this.is_softkeys_visible = false; // true : only when MenuItem's are
+ // displayed
+ this.softkeys_visibility = true; // true/false : for hide/show SFK's
+ this.is_dimmed = false;
+ this.is_rsk_overridden = false;
+ this.log_counter = 1;
+ this.enable_log = false;
+ this.rsk_label = '';
+ this.rsk_event = false;
+ this.highlighted_item = null;
+}
+
+EmulatorMenu.prototype.hide = function() {
+ $("#MenuItemsArea").fadeIn("slow");
+
+ // Hide the SFK's If user hidden them from his code
+ if (NOKIA.menu.softkeys_visibility)
+ $("#SoftKeysArea").fadeIn("slow");
+
+ NOKIA.menu.is_softkeys_visible = false;
+};
+
+EmulatorMenu.prototype.log = function(str) {
+ if (!this.enable_log)
+ return false;
+ NOKIA.layout.log("log", NOKIA.menu.log_counter + ' ' + str);
+ NOKIA.layout.log("log", 'is_rsk_overridden: '
+ + NOKIA.menu.is_rsk_overridden);
+ NOKIA.layout.log("log", 'rsk_label: ' + NOKIA.menu.rsk_label);
+ NOKIA.layout.log("log", 'rsk_event: ' + NOKIA.menu.rsk_event);
+
+ NOKIA.menu.log_counter++;
+};
+
+EmulatorMenu.prototype.show = function() {
+ if (NOKIA.menu.is_dimmed)
+ return false;
+
+ NOKIA.menu.showSoftKeys();
+
+ NOKIA.menu.is_menu_visible = true;
+ $("#MenuItemsArea").show();
+
+ NOKIA.menu.highlighted_item = $("#MenuItemsArea > ul > li")[0];
+ NOKIA.menu.highlighted_item.className = 'active';
+
+ $("#MenuItemsArea > ul > li").mouseover(function() {
+ if (NOKIA.menu.highlighted_item != null) {
+ NOKIA.menu.highlighted_item.className = '';
+ NOKIA.menu.highlighted_item = null;
+ }
+
+ NOKIA.menu.highlighted_item = this;
+ NOKIA.menu.highlighted_item.className = 'active';
+ });
+
+ $("#SoftKeysArea").mouseout(function() {
+ if (!NOKIA.menu.is_menu_visible) {
+ return false;
+ }
+
+ if (NOKIA.helper.intervalId) {
+ clearInterval(NOKIA.helper.intervalId);
+ }
+ NOKIA.helper.intervalId = setTimeout(function() {
+ NOKIA.menu.cancel();
+ }, 500);
+ });
+
+ // Change the label "Options" to "Select" to LSK
+ $("#LskLabel > a")[0].innerHTML = "Select";
+ NOKIA.menu.setLsk(NOKIA.menu.selectMenu);
+
+ // Change the label "Exit" to "Cancel" to RSK
+ $("#RskLabel > a")[0].innerHTML = 'Cancel';
+ NOKIA.menu.setRsk(NOKIA.menu.cancel);
+
+ NOKIA.emulator.setMenuItemsStyle();
+
+};
+
+EmulatorMenu.prototype.selectMenu = function() {
+ try {
+ if (typeof NOKIA.menu.highlighted_item.onclick != 'undefined') {
+ eval(NOKIA.menu.highlighted_item.onclick)();
+ }
+ } catch (e) {
+
+ }
+ // NOKIA.menu.cancel();
+};
+
+EmulatorMenu.prototype.cancel = function() {
+ if (NOKIA.menu.is_dimmed)
+ return false;
+
+ NOKIA.menu.hideSoftKeys();
+
+ NOKIA.menu.is_menu_visible = false;
+ $("#MenuItemsArea").hide();
+
+ // Reset the "OPTION" label to LSK
+ $("#LskLabel > a")[0].innerHTML = 'Options';
+ NOKIA.menu.setLsk(NOKIA.emulator.child.menu.show);
+
+ // Change the label "CANCEL" to "EXIT" to RSK
+ if (!NOKIA.menu.is_rsk_overridden) {
+ $("#RskLabel > a")[0].innerHTML = 'Exit';
+ NOKIA.menu.setRsk(NOKIA.menu.exit);
+ } else {
+ $("#RskLabel > a")[0].innerHTML = NOKIA.menu.rsk_label;
+ NOKIA.menu.setRsk(NOKIA.menu.rsk_event);
+ }
+
+};
+
+EmulatorMenu.prototype.exit = function() {
+ if (NOKIA.menu.is_dimmed)
+ return false;
+
+ if (NOKIA.helper.setHomeScreen())
+ return false;
+
+ // clear the Menu Settings
+ NOKIA.menu.cancel();
+ NOKIA.emulator.child.menu.setRightSoftkeyLabel('', null);
+ NOKIA.emulator.child.menu.items = [];
+ NOKIA.menu.softkeys_visibility = false;
+
+ // Hide Widget DIV
+ NOKIA.menu.hideSoftKeys();
+ NOKIA.menu.setLsk(function() {
+ });
+ NOKIA.menu.setRsk(function() {
+ });
+
+ $("#WidgetArea").hide();
+
+ // Show Icon
+ var style = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
+ $('#IconArea').css( {
+ 'width' : '100%',
+ 'height' : style['widget']['height'] + 'px',
+ 'float' : style['widget']['float']
+ });
+
+ $('#IconArea')[0].className = NOKIA.mode + NOKIA.currentDevice;
+
+ var img = document.createElement('img');
+ img.src = NOKIA.emulator.iconFile;
+ img.border = 0;
+
+ var div = document.createElement('div');
+ var p = document.createElement('p');
+
+ if (NOKIA.emulator.plist.DisplayName.length <= 12)
+ p.innerHTML = NOKIA.emulator.plist.DisplayName;
+ else
+ p.innerHTML = NOKIA.emulator.plist.DisplayName.substr(0, 11) + '...';
+
+ div.className = 'IconFile';
+ div.style.marginTop = parseInt(parseInt(style['widget']['height'] / 2) - 80)
+ + 'px';
+ div.appendChild(img);
+ img.onclick = function() {
+
+ // close the console DIV
+ NOKIA.layout._console_enabled = false;
+ NOKIA.layout.render();
+
+ $("#loaderDiv").html("Widget is loading. Please wait...");
+ $("#loaderDiv")[0].className = 'green';
+ $("#loaderDiv").show();
+ window.setTimeout(function() {
+ document.location = document.location;
+ }, 3000);
+
+ };
+
+ div.appendChild(p);
+
+ $("#loaderDiv").html("Click on Icon to Launch Widget");
+ $("#loaderDiv").show();
+ $("#loaderDiv")[0].className = 'yellow';
+
+ $('#IconArea').append(div);
+ $('#IconArea').show();
+
+ NOKIA.menu.is_dimmed = true;
+
+};
+
+EmulatorMenu.prototype.setLsk = function(func) {
+ // for RSK
+ $('#LskArea')[0].onclick = function() {
+ if (!NOKIA.menu.is_dimmed)
+ func();
+ };
+
+ $('#LskLabel > a')[0].onclick = function() {
+ if (!NOKIA.menu.is_dimmed)
+ func();
+ };
+
+ return true;
+};
+
+EmulatorMenu.prototype.setRsk = function(func) {
+ // for RSK
+ $('#RskArea')[0].onclick = function() {
+ if (!NOKIA.menu.is_dimmed)
+ func();
+ };
+
+ $('#RskLabel > a')[0].onclick = function() {
+ if (!NOKIA.menu.is_dimmed)
+ func();
+ };
+
+ return true;
+};
+
+EmulatorMenu.prototype.triggerLsk = function(event) {
+ var callback;
+ if (NOKIA.mode == 'portrait')
+ callback = NOKIA.menu.lsk_event;
+ else if ((NOKIA.mode == 'landscape') && (event.id == 'LskLabel'))
+ callback = NOKIA.menu.lsk_event;
+ else
+ callback = NOKIA.menu.rsk_event;
+
+ if (typeof callback == 'function' && !NOKIA.menu.is_dimmed) {
+ callback();
+ }
+};
+
+EmulatorMenu.prototype.triggerRsk = function(event) {
+ var callback;
+ if (NOKIA.mode == 'portrait')
+ callback = NOKIA.menu.rsk_event;
+ else if ((NOKIA.mode == 'landscape') && (event.id == 'RskLabel'))
+ callback = NOKIA.menu.rsk_event;
+ else
+ callback = NOKIA.menu.lsk_event;
+
+ if (typeof callback == 'function') {
+ if (!NOKIA.menu.is_dimmed) {
+ callback();
+ NOKIA.menu.cancel();
+ }
+ }
+};
+
+EmulatorMenu.prototype.render = function() {
+ if (!NOKIA.menu.softkeys_visibility)
+ NOKIA.menu.hideSoftKeys();
+ else
+ NOKIA.menu.showSoftKeys();
+
+ NOKIA.emulator.setWidgetStyle();
+};
+
+EmulatorMenu.prototype.init = function() {
+ NOKIA.menu.render();
+};
+
+EmulatorMenu.prototype.createSFKArea = function() {
+ var a = $('#SoftKeys > a');
+ a.html('');
+
+ var preferences = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode];
+
+ var lsk = document.createElement('img');
+ lsk.border = "0";
+ lsk.id = "LskArea";
+ lsk.name = "LskArea";
+ lsk.src = "preview/images/TransperantImage.png";
+ lsk.style.width = preferences.style.softkeysImg.width;
+ lsk.style.height = preferences.style.softkeysImg.height;
+
+ var rsk = document.createElement('img');
+ rsk.border = 0;
+ rsk.id = "RskArea";
+ rsk.name = "RskArea";
+ rsk.src = "preview/images/TransperantImage.png";
+ rsk.style.width = preferences.style.softkeysImg.width;
+ rsk.style.height = preferences.style.softkeysImg.height;
+
+ if (NOKIA.mode == 'portrait') {
+ lsk.onclick = function() {
+ $("#LskLabel > a").trigger('click');
+ };
+ a[0].appendChild(lsk);
+
+ rsk.onclick = function() {
+ $("#RskLabel > a").trigger('click');
+ };
+ a[1].appendChild(rsk);
+
+ } else {
+
+ rsk.onclick = function() {
+ $("#RskLabel > a").trigger('click');
+ };
+ a[0].appendChild(rsk);
+
+ lsk.onclick = function() {
+ $("#LskLabel > a").trigger('click');
+ };
+ a[1].appendChild(lsk);
+ }
+
+};
+
+EmulatorMenu.prototype.showSoftKeys = function() {
+ NOKIA.menu.is_softkeys_visible = true;
+
+ NOKIA.emulator.setWidgetStyle();
+ $("#SoftKeysArea").show();
+};
+
+EmulatorMenu.prototype.hideSoftKeys = function() {
+ // Hide the SFK's If user hidden them from his code
+ if (!NOKIA.menu.softkeys_visibility)
+ $("#SoftKeysArea").hide();
+
+ NOKIA.menu.is_softkeys_visible = false;
+
+ NOKIA.emulator.setWidgetStyle();
+};
--- a/org.symbian.tools.wrttools.previewer/preview/script/nokia.js Mon Jun 28 10:47:32 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/script/nokia.js Tue Jun 29 13:44:16 2010 -0700
@@ -127,7 +127,9 @@
this.helper.getInfo('Info.plist', NOKIA.helper.getInfoCallback);
// For getting Icon.png
- this.helper.getInfo('Icon.png', NOKIA.helper.getIconCallback);
+ this.helper.getInfo('Icon.png', NOKIA.helper.getIconCallback);
+
+ new RotationSupport(accelerationCallback);
};
/*
@@ -139,1325 +141,30 @@
NOKIA.deviceList = data;
};
-
-
/*
* NOKIA.emulator
*/
NOKIA.namespace('menu');
- NOKIA.menu = {
- is_menu_visible : false, // true/false
- is_softkeys_visible : false, // true : only when MenuItem's are displayed
- softkeys_visibility : true, // true/false : for hide/show SFK's
- is_dimmed : false,
- is_rsk_overridden : false,
- log_counter : 1,
- enable_log : false,
- rsk_label : '',
- rsk_event : false,
- highlighted_item : null,
-
- hide : function()
- {
- $("#MenuItemsArea").fadeIn("slow");
-
- // Hide the SFK's If user hidden them from his code
- if(NOKIA.menu.softkeys_visibility)
- $("#SoftKeysArea").fadeIn("slow");
-
- NOKIA.menu.is_softkeys_visible = false;
- },
-
- log : function(str)
- {
- if(!this.enable_log)
- return false;
- NOKIA.layout.log("log", NOKIA.menu.log_counter + ' ' +str);
- NOKIA.layout.log("log", 'is_rsk_overridden: '+NOKIA.menu.is_rsk_overridden);
- NOKIA.layout.log("log", 'rsk_label: '+NOKIA.menu.rsk_label);
- NOKIA.layout.log("log", 'rsk_event: '+NOKIA.menu.rsk_event);
-
- NOKIA.menu.log_counter++;
- },
-
- show : function()
- {
- if(NOKIA.menu.is_dimmed)
- return false;
-
- NOKIA.menu.showSoftKeys();
-
- NOKIA.menu.is_menu_visible = true;
- $("#MenuItemsArea").show();
-
- NOKIA.menu.highlighted_item = $("#MenuItemsArea > ul > li")[0];
- NOKIA.menu.highlighted_item.className = 'active';
-
-
- $("#MenuItemsArea > ul > li").mouseover(function(){
- if(NOKIA.menu.highlighted_item != null)
- {
- NOKIA.menu.highlighted_item.className = '';
- NOKIA.menu.highlighted_item = null;
- }
-
- NOKIA.menu.highlighted_item = this;
- NOKIA.menu.highlighted_item.className = 'active';
- });
-
- $("#SoftKeysArea").mouseout(function(){
- if (!NOKIA.menu.is_menu_visible) {
- return false;
- }
-
- if (NOKIA.helper.intervalId) {
- clearInterval(NOKIA.helper.intervalId);
- }
- NOKIA.helper.intervalId = setTimeout(function(){
- NOKIA.menu.cancel();
- }, 500);
- });
-
-
- // Change the label "Options" to "Select" to LSK
- $("#LskLabel > a")[0].innerHTML = "Select";
- NOKIA.menu.setLsk(NOKIA.menu.selectMenu);
-
- // Change the label "Exit" to "Cancel" to RSK
- $("#RskLabel > a")[0].innerHTML = 'Cancel';
- NOKIA.menu.setRsk(NOKIA.menu.cancel);
-
-
- NOKIA.emulator.setMenuItemsStyle();
-
- },
-
- selectMenu : function(){
- try {
- if(typeof NOKIA.menu.highlighted_item.onclick != 'undefined'){
- eval(NOKIA.menu.highlighted_item.onclick)();
- }
- } catch (e) {
-
- }
-// NOKIA.menu.cancel();
- },
-
-
- cancel : function()
- {
- if(NOKIA.menu.is_dimmed)
- return false;
-
- NOKIA.menu.hideSoftKeys();
-
- NOKIA.menu.is_menu_visible = false;
- $("#MenuItemsArea").hide();
-
- // Reset the "OPTION" label to LSK
- $("#LskLabel > a")[0].innerHTML = 'Options';
- NOKIA.menu.setLsk(NOKIA.emulator.child.menu.show);
-
- // Change the label "CANCEL" to "EXIT" to RSK
- if(!NOKIA.menu.is_rsk_overridden)
- {
- $("#RskLabel > a")[0].innerHTML = 'Exit';
- NOKIA.menu.setRsk(NOKIA.menu.exit);
- }
- else
- {
- $("#RskLabel > a")[0].innerHTML = NOKIA.menu.rsk_label;
- NOKIA.menu.setRsk(NOKIA.menu.rsk_event);
- }
-
- },
-
- exit : function()
- {
- if(NOKIA.menu.is_dimmed)
- return false;
-
- if(NOKIA.helper.setHomeScreen())
- return false;
-
- // clear the Menu Settings
- NOKIA.menu.cancel();
- NOKIA.emulator.child.menu.setRightSoftkeyLabel('', null);
- NOKIA.emulator.child.menu.items = [];
- NOKIA.menu.softkeys_visibility = false;
-
- // Hide Widget DIV
- NOKIA.menu.hideSoftKeys();
- NOKIA.menu.setLsk(function(){});
- NOKIA.menu.setRsk(function(){});
-
- $("#WidgetArea").hide();
-
- // Show Icon
- var style = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
- $('#IconArea').css({
- 'width' : '100%',
- 'height' : style['widget']['height']+'px',
- 'float' : style['widget']['float']
- });
-
- $('#IconArea')[0].className = NOKIA.mode+NOKIA.currentDevice;
-
- var img = document.createElement('img');
- img.src = NOKIA.emulator.iconFile;
- img.border = 0;
-
- var div = document.createElement('div');
- var p = document.createElement('p');
-
- if(NOKIA.emulator.plist.DisplayName.length <= 12)
- p.innerHTML = NOKIA.emulator.plist.DisplayName;
- else
- p.innerHTML = NOKIA.emulator.plist.DisplayName.substr(0, 11) + '...';
-
- div.className = 'IconFile';
- div.style.marginTop = parseInt(parseInt(style['widget']['height']/2)-80) + 'px';
- div.appendChild(img);
- img.onclick = function(){
-
- // close the console DIV
- NOKIA.layout._console_enabled = false;
- NOKIA.layout.render();
-
- $("#loaderDiv").html("Widget is loading. Please wait...");
- $("#loaderDiv")[0].className = 'green';
- $("#loaderDiv").show();
- window.setTimeout(function(){
- document.location = document.location;
- }, 3000);
-
- };
-
- div.appendChild(p);
-
- $("#loaderDiv").html("Click on Icon to Launch Widget");
- $("#loaderDiv").show();
- $("#loaderDiv")[0].className = 'yellow';
-
- $('#IconArea').append(div);
- $('#IconArea').show();
-
- NOKIA.menu.is_dimmed = true;
-
- },
-
- setLsk : function(func)
- {
- // for RSK
- $('#LskArea')[0].onclick = function(){
- if(!NOKIA.menu.is_dimmed)
- func();
- };
-
- $('#LskLabel > a')[0].onclick = function(){
- if(!NOKIA.menu.is_dimmed)
- func();
- };
-
- return true;
- },
-
- setRsk : function(func)
- {
- // for RSK
- $('#RskArea')[0].onclick = function(){
- if(!NOKIA.menu.is_dimmed)
- func();
- };
-
- $('#RskLabel > a')[0].onclick = function(){
- if(!NOKIA.menu.is_dimmed)
- func();
- };
-
- return true;
- },
-
-
- triggerLsk : function(event)
- {
- var callback;
- if(NOKIA.mode == 'portrait')
- callback = NOKIA.menu.lsk_event;
- else if( (NOKIA.mode == 'landscape') && (event.id =='LskLabel') )
- callback = NOKIA.menu.lsk_event;
- else
- callback = NOKIA.menu.rsk_event;
-
- if(typeof callback == 'function' && !NOKIA.menu.is_dimmed)
- {
- callback();
- }
- },
-
- triggerRsk : function(event)
- {
- var callback;
- if(NOKIA.mode == 'portrait')
- callback = NOKIA.menu.rsk_event;
- else if( (NOKIA.mode == 'landscape') && (event.id =='RskLabel') )
- callback = NOKIA.menu.rsk_event;
- else
- callback = NOKIA.menu.lsk_event;
-
- if(typeof callback == 'function')
- {
- if(!NOKIA.menu.is_dimmed)
- {
- callback();
- NOKIA.menu.cancel();
- }
- }
- },
-
- render : function()
- {
- if(!NOKIA.menu.softkeys_visibility)
- NOKIA.menu.hideSoftKeys();
- else
- NOKIA.menu.showSoftKeys();
-
- NOKIA.emulator.setWidgetStyle();
- },
-
-
- init : function()
- {
- NOKIA.menu.render();
- },
-
- createSFKArea : function()
- {
- var a = $('#SoftKeys > a');
- a.html('');
-
- var preferences = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode];
-
- var lsk = document.createElement('img');
- lsk.border="0";
- lsk.id = "LskArea";
- lsk.name ="LskArea";
- lsk.src = "preview/images/TransperantImage.png";
- lsk.style.width = preferences.style.softkeysImg.width;
- lsk.style.height = preferences.style.softkeysImg.height;
-
- var rsk = document.createElement('img');
- rsk.border = 0;
- rsk.id = "RskArea";
- rsk.name = "RskArea";
- rsk.src = "preview/images/TransperantImage.png";
- rsk.style.width = preferences.style.softkeysImg.width;
- rsk.style.height = preferences.style.softkeysImg.height;
-
- if(NOKIA.mode == 'portrait')
- {
- lsk.onclick = function(){
- $("#LskLabel > a").trigger('click');
- };
- a[0].appendChild(lsk);
-
- rsk.onclick = function(){
- $("#RskLabel > a").trigger('click');
- };
- a[1].appendChild(rsk);
-
- }else{
-
- rsk.onclick = function(){
- $("#RskLabel > a").trigger('click');
- };
- a[0].appendChild(rsk);
-
- lsk.onclick = function(){
- $("#LskLabel > a").trigger('click');
- };
- a[1].appendChild(lsk);
- }
-
-
- },
-
- showSoftKeys : function()
- {
- NOKIA.menu.is_softkeys_visible = true;
-
- NOKIA.emulator.setWidgetStyle();
- $("#SoftKeysArea").show();
- },
-
- hideSoftKeys : function()
- {
- // Hide the SFK's If user hidden them from his code
- if(!NOKIA.menu.softkeys_visibility)
- $("#SoftKeysArea").hide();
-
- NOKIA.menu.is_softkeys_visible = false;
-
- NOKIA.emulator.setWidgetStyle();
- }
- };
-
-
+ NOKIA.menu = new EmulatorMenu();
/*
* NOKIA.emulator
*/
NOKIA.namespace('emulator');
- NOKIA.emulator = {
- child : false,
- iconFile : 'preview/images/default-Icon.png',
- loaded : false,
- plist : {
- DisplayName : '',
- Identifier : '',
- MainHTML : '',
- AllowNetworkAccess : "false",
- Version : '',
- MiniViewEnabled : "false",
- is_browserReady : false
- },
-
- load : function()
- {
- if(this.loaded)
- return false;
- NOKIA.layout._console_minimized = (NOKIA.helper.getPreference('__SYM_NOKIA_CONSOLE_OPEN') != "true");
- // load the saved device Info
- var device = NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_DEVICE');
- NOKIA.currentDevice = device || NOKIA.currentDevice;
-
- // load the saved device mode
- var mode = NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE');
- if(mode != null)
- NOKIA.mode = mode;
-
- var orientation = Number(NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_ORIENTATION'));
- if (typeof orientation == "number" && orientation >= -90 && orientation <= 180)
- NOKIA.orientation = orientation;
-
- // SAVE the device DATA
- NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE', NOKIA.currentDevice);
- NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode);
- NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_ORIENTATION', NOKIA.orientation);
-
- this.loaded = true;
-
- },
-
- render : function()
- {
- this.load();
- // Selecting Resoltion
- var resOptions = $("#resOptions")[0];
- for(var i=0; i<NOKIA.resolution.length; i++)
- {
- if(NOKIA.resolution[i] == NOKIA.currentDevice)
- {
- resOptions.options[i].selected = true;
- break;
- }
- }
-
- if(!NOKIA.emulator.orientationSupports())
- NOKIA.mode = NOKIA.deviceList[NOKIA.currentDevice]['default'];
-
- if(typeof NOKIA.deviceList == 'undefined' || typeof NOKIA.deviceList[NOKIA.currentDevice] == 'undefined' || typeof NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode] == 'undefined')
- {
- alert('Deive resolution: '+NOKIA.currentDevice+' or the mode: '+NOKIA.mode+' not found');
- return false;
- }
-
- this.setStyle();
- var or = (NOKIA.mode == 'portrait') ? NOKIA.orientation : (NOKIA.orientation + 90);
- var val = "rotate(" + or + "deg)";
- $("#DeviceDisplayLayout").css("-moz-transform", val);
- $("#DeviceDisplayLayout").css("-webkit-transform", val);
- },
-
- setMode : function(mode)
- {
- NOKIA.mode = mode;
-
- // SAVE the device DATA
- NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode);
-
- NOKIA.emulator.render();
- },
-
- toggle : function(o)
- {
- NOKIA.orientation = o;
- NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_ORIENTATION', NOKIA.orientation);
- NOKIA.emulator.child.device.implementation.setOrientation(o, 0);
- if (NOKIA.emulator.orientationSupports() && (o == 0 || o == -90)) {
- NOKIA.emulator.setMode(o == 0 ? 'portrait' : 'landscape');
- } else {
- NOKIA.emulator.render();
- }
- },
-
- orientationSupports : function()
- {
- return NOKIA.deviceList[NOKIA.currentDevice]['orientation'];
- },
-
- setStyle:function()
- {
- if(!NOKIA.helper.checkDependencies())
- {
- setTimeout(NOKIA.emulator.setStyle, 1000);
- }
-
- var deviceProperties = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode];
- var style = deviceProperties['style'];
-
- // Apply Style and propertis to Device layers
- $("#DeviceDisplayLayout").css(style['layout']);
- $('#DisplayArea').css(style['display']);
-
- NOKIA.emulator.setWidgetStyle();
-
- $('#SoftKeysArea').css({
- 'width' : style['menu']['width']+'px',
- 'height' : style['menu']['height']+'px',
- 'float' : style['menu']['float']
- });
-
- $('#SoftKeysArea > ul > li').css('width', parseInt(style['menu']['width']/2)-10);
-
-
- NOKIA.emulator.setMenuItemsStyle();
-
- $('#SoftKeys').css(style['softkeys']);
-// $('#SoftKeys > a > img').css(style['softkeysImg']);
-
- NOKIA.menu.createSFKArea();
-
- $("#DeviceDisplayLayout").show();
- $("#InspectorTab").show();
-
- if (/chrome/.test( navigator.userAgent.toLowerCase())) {
- $("#InspectorBtn").show();
- }
- if (/mac/.test( navigator.userAgent.toLowerCase())) {
- $("#MacShortcut").show();
- } else {
- $("#UniversalShortcut").show();
- }
- },
-
- setWidgetStyle : function()
- {
- var style = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
- var height;
- if(NOKIA.menu.softkeys_visibility || NOKIA.menu.is_softkeys_visible)
- height = parseInt(style['widget']['height'] - style['menu']['height']);
- else
- height = style['widget']['height'];
-
- $('#WidgetArea').css({
- 'width' : style['widget']['width']+'px',
- 'height' : height+'px',
- 'float' : style['widget']['float']
- });
- },
-
- setMenuItemsStyle : function()
- {
- var style = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
- var count = 1;
- try {
- if (NOKIA.emulator.child.menu) {
- count = parseInt(NOKIA.helper.getElementsLengthInObject(NOKIA.emulator.child.menu.items)) + 1;
- }
- } catch (e) {
- count = 1;
- }
- var height = parseInt(count*style['menu']['optionKeysheight']) + 10;
- var top = parseInt(style['widget']['height'] - height);
-
- $('#MenuItemsArea').css({
- 'width' : style['widget']['width']+'px',
- 'height' : height+'px',
- 'marginTop' : '-2px',
- 'top' : (style['widget']['height']-height-style['menu']['height']+2)+'px',
- 'position' : 'relative'
- });
- }
- };
+ NOKIA.emulator = new Emulator();
/*
* NOKIA.helper functions
*/
NOKIA.namespace('helper.loadScript');
- NOKIA.helper = {
- path : document.location.pathname,
- errorDailog : null,
- prefDailog : null,
- inspectorDailog : null,
- intervalId : null,
- infoPlistCounter : false,
- IconFileCounter : false,
- loadScript : function(path)
- {
- var head = document.getElementsByTagName("head")[0] || document.documentElement;
- var script = document.createElement("script");
-
- script.type = "text/javascript";
- script.src = src;
- head.appendChild( script );
- },
-
- loadPreferences : function()
- {
- if(/dreamweaver/i.test(navigator.userAgent))
- {
- $("#dwDeviceHelp")[0].className = '';
-// $("#resSupportLink")[0].className = 'hide';
- }
- // Selecting Resoltion
- var resOptions = $("#resOptions")[0];
- for(var i=0; i<NOKIA.resolution.length; i++)
- {
- if(NOKIA.resolution[i] == NOKIA.currentDevice)
- {
- resOptions.options[i].selected = true;
- break;
- }
- }
-
- // Selecting Version
- if(NOKIA.version == 'WRT 1.0')
- $('#wrt_version_1_0')[0].checked = true;
- else
- $('#wrt_version_1_1')[0].checked = true;
-
- // HomeScreen Support
- if(NOKIA.deviceList[NOKIA.currentDevice].homeScreenSupport)
- {
- if (typeof NOKIA.emulator.plist.MiniViewEnabled != 'undefined') {
- if (NOKIA.emulator.plist.MiniViewEnabled == 'false')
- $('#HS_Control_Info').html("<span id='wrt-help' onclick='javascipt:NOKIA.helper.showMiniviewHelp();'></span><strong>Not Enabled</strong><br/><small>Click on help to read more about enabling Mini view support</small>");
- else
- $('#HS_Control_Info').html("Supported");
- }
- else
- $('#HS_Control_Info').html("<span id='wrt-help'></span>Not Supported");
-
- $('#HS_Control_Info').show();
-
- }
- else
- {
- $('#HS_Control_Info').html("Not Supported for the selected Device resolution");
- $('#HS_Control_Info').show();
- }
- },
-
- getInfo : function(url, callback)
- {
- try {
- var xhr = this.ajax();
-
- if ((/AppleWebKit/i.test(navigator.userAgent)))
- xhr.open("GET", url, false);
- else
- xhr.open("GET", url, true);
-
-
- xhr.onreadystatechange = function()
- {
- // readyState = 4 ; "complete"
- if (xhr.readyState==4)
- {
- // status = 200 ; "ok"
- if( (xhr.status == 200) || (!xhr.status) )
- {
- callback(true, xhr);
- }
- else
- {
- callback(false, xhr);
- }
- }
-
- };
- xhr.send(null);
- } catch (e) {
- if (e.name == 'NS_ERROR_FILE_NOT_FOUND') {
- callback(false, xhr);
- }
- }
- },
-
- getInfoCallback : function(flag, xhr)
- {
- // If Info.plis NOT FOUND / FAILED LOAD
- // an ERROR!, unable to proceed further
- // STOP there
- if(!flag)
- {
- if(!NOKIA.helper.infoPlistCounter)
- {
- NOKIA.helper.infoPlistCounter = true;
- NOKIA.helper.getInfo('info.plist', NOKIA.helper.getInfoCallback);
- return false;
- }
-
- NOKIA.helper.error('WRT Previewer: Initialization failed. Could not open Info.plist file.<br/>Please ensure <strong style="color:#efe352;">Info.plist</strong> file exists in the project root folder and that it is named properly.');
- return false;
- }
- else{
-
- var xmlString = xhr.responseText;
-
- // do some cheating here
- xmlString = xmlString.replace(/<!--(.|[\n\r])*?-->/gm, "");
- xmlString = xmlString.replace(/<\s*true\s*\/>/gi, "<string>true</string>");
- xmlString = xmlString.replace(/<\s*false\s*\/>/gi, "<string>false</string>");
- xmlString = xmlString.replace(/[\n\r]/gi, "");
- // return the JSON Object
- NOKIA.helper.validate(xmlString);
- }
-
- },
-
- getIconCallback : function(flag, xhr)
- {
-
- if(!flag)
- {
- if(!NOKIA.helper.IconFileCounter)
- {
- NOKIA.helper.IconFileCounter = true;
- NOKIA.helper.getInfo('icon.png', NOKIA.helper.getIconCallback);
- return false;
- }
- }
- else
- NOKIA.emulator.iconFile = (NOKIA.helper.IconFileCounter) ? "icon.png" : "Icon.png";
- },
-
-
- validate : function(xmlObject)
- {
- var values = xmlObject.match(/.*<plist.*?(<dict.*?>\s*(<key[^>]*?>[^<]*?<\/key>\s*<string[^>]*?>[^<]*?<\/string>)*\s*<\/dict>)\s*<\/plist>/)[1];
- if(values == null || values == undefined)
- {
- NOKIA.helper.error('Corrupted Info.plist file');
- return false;
- }
- values = values.replace(/<dict.*?(<key.*?>\s*.*\s*<\/string>)\s*<\/dict>/, "{ $1 }");
- values = values.replace(/\s*<key.*?>\s*(.*?)\s*<\/key>\s*<string.*?>\s*(.*?)\s*<\/string>\s*/g, "\"$1\" : \"$2\", ");
- values = values.replace(/"\s*?,\s*?}/g, "\" }");
- try {
- NOKIA.emulator.plist = JSON.parse(values);
- } catch (exception) {
- NOKIA.helper.error('Corrupted Info.plist file');
- return false;
- }
-
- try {
- if(typeof NOKIA.emulator.plist.DisplayName != 'undefined'){
- document.title = NOKIA.emulator.plist.DisplayName + ' - ' + document.title;
- }
- } catch (e) {}
-
- // Add UI-Event listeners
- NOKIA.helper.addListeners();
- NOKIA.layout.init();
- NOKIA.emulator.render();
- },
-
-
- ajax : function()
- {
- // xmlHttpRequest object
- var request = null;
-
- // branch for native XMLHttpRequest object
- if(window.XMLHttpRequest && !(window.ActiveXObject)) {
- try
- {
- request = new XMLHttpRequest();
- try
- {
- // attach the Bypass code, if the browser is firefox
- if(netscape.security.PrivilegeManager.enablePrivilege)
- {
- // duplicate the function
- request._open = request.open;
-
- // redefine the function definition
- request.open = function(method, url, flag)
- {
- try
- {
- // Enable Universal Browser Read
- netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
-
- // call the native XmlHttpRequest.open method
- this._open(method, url, flag);
- }catch(e)
- {
- // call the native XmlHttpRequest.open method
- this._open(method, url, flag);
- }
- };
- }
- }
- catch(e)
- {
- // eatup all exceptions
- }
- }
- catch(e) {
- request = null;
- }
- // branch for IE/Windows ActiveX version
- } else if(window.ActiveXObject) {
- try {
- request = new ActiveXObject("Msxml2.XMLHTTP");
- } catch(e) {
- try {
- request = new ActiveXObject("Microsoft.XMLHTTP");
- } catch(e) {
- alert('Failed to create XmlHttprequest');
- return null;
- }
- }
- }
-
- return (request);
- },
-
- error : function(msg)
- {
- if(NOKIA.menu.enable_log)
- NOKIA.layout.log("log", msg);
-
- $("#Dialog").html(msg);
- $("#Dialog").dialog('open');
- },
-
- setPreference : function(name,value)
- {
- if (NOKIA.emulator.prefs[name] != value) {
- NOKIA.emulator.prefs[name] = value;
- $.post("preview/preferences.js", JSON.stringify({ "key" : name, "value" : value }), undefined, "json");
- }
- },
-
- getPreference : function(name)
- {
- return NOKIA.emulator.prefs[name];
- },
-
- rotateCW : function() {
- var newOrient = NOKIA.orientation + 90;
- NOKIA.emulator.toggle(newOrient - (newOrient > 180 ? 360 : 0));
- },
- rotateCCW : function() {
- var newOrient = NOKIA.orientation - 90;
- NOKIA.emulator.toggle(newOrient + (newOrient <= -180 ? 360 : 0));
- },
-
- version : function(ele)
- {
- if (confirm('Would you like to reload the widget to apply the changes on the Version settings?'))
- {
- NOKIA.helper.setPreference('__SYM_WRT_VERSION', ele.value);
- $("#loaderDiv").html("Applying the " + ele.value + ", please wait...");
- $("#loaderDiv").show();
- $("#loaderDiv")[0].className = 'green';
-
- window.setTimeout(function(){
- document.location = document.location;
- }, 3000);
- }
- else
- {
- ele.checked = false;
- if(ele.value != 'WRT 1.0')
- $("#wrt_version_1_0")[0].checked = true;
- else
- $("#wrt_version_1_1")[0].checked = true;
- }
- },
-
- addListeners : function()
- {
- NOKIA.helper.loadPreferences();
- /*
- * Render Emulator for Interaction
- */
- NOKIA.helper.inspectorDailog = $("#InspectorTab").dialog({
- width: 370, minWidth: 300, minHeight: 200, height: 250, autoOpen: false, position : top, title : ' ',
- buttons : {
- "Close" : function(){
- $("#InspectorTab").dialog('close');
- },
- "Disconnect Debugger" : function(){
- $.ajax({url : "__sym_command/terminateDebug"});
- }}
- });
-
- $('#InspectorBtn').click(function(){
- $('#InspectorTab').dialog('open');
- // Hack for Mac firefox
- if(/Mac/i.test(navigator.userAgent))
- {
- $("#WidgetArea iframe").css({overflow:'hidden'});
- }
- });
-
- $('#rotateCW').click(function(){
- NOKIA.helper.rotateCW();
- });
- $('#rotateCCW').click(function(){
- NOKIA.helper.rotateCCW();
- });
- $('#resOptions').change(function(ele){
- ele = ele.target || this;
-
- NOKIA.currentDevice = ele.options[ele.selectedIndex].text;
-
- // SAVE the device DATA
- NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE', NOKIA.currentDevice);
-
- NOKIA.emulator.render();
- NOKIA.helper.loadPreferences();
- });
-
- // Hack for Mac firefox
- if (/Mac/i.test(navigator.userAgent)) {
- if (!(/AppleWebKit/i.test(navigator.userAgent))) {
- $("#resOptions")[0].size = '4';
- }
- }
-
-
- // WRT Version controls
- $('#wrt_version_1_0').change(function(){
- NOKIA.helper.version(this);
- });
-
- $('#wrt_version_1_1').change(function(){
- NOKIA.helper.version(this);
- });
-
-
- $("#orientationIcon").click(function(){
- var mode = (NOKIA.mode == 'portrait') ? 'landscape' : 'portrait';
- NOKIA.emulator.setMode(mode);
- $("#WidgetArea")[0].className = 'hs_'+NOKIA.mode;
- });
-
-
- $("#iframeMask").click(function(){
- $("#orientationIcon").hide();
- $("#iframeMask").hide();
- $("#loaderDiv").hide();
-
- NOKIA.menu.is_dimmed = false;
-
- $("#WidgetArea")[0].className = '';
-
- NOKIA.menu.softkeys_visibility = true;
- NOKIA.menu.showSoftKeys();
-
- });
-
-
- // MenuItems DIV events
- $("#MenuItemsArea").mouseover(function(){
- if(NOKIA.helper.intervalId)
- clearInterval(NOKIA.helper.intervalId);
-
- $("#MenuItemsArea").show();
- });
-
- $("#MenuItemsArea").mouseout(function(){
- if(NOKIA.helper.intervalId)
- clearInterval(NOKIA.helper.intervalId);
-
- NOKIA.helper.intervalId = setTimeout(function(){
- NOKIA.menu.cancel();
- }, 500);
- });
-
-
- // Tabs
- $('#tabs').tabs({
-// select : function(event, ui){
-// switch (ui.index) {
-// case 1:
-// $("event-battery-info").show();
-// break;
-// case 2:
-// $("event-messaging-info").show();
-// break;
-// case 3:
-// $("event-memory-info").show();
-// break;
-// case 4:
-// $("settings-view").show();
-// break;
-//
-// }}
- });
- $(".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *")
- .removeClass("ui-corner-all ui-corner-top")
- .addClass("ui-corner-bottom");
-
- /*
- * Event triggering
- */
-
- // for battery
- $("#event-battery").click(function(event){
- if(event.target.className == 'active')
- {
- $("#event-icons").hide();
- $("#event-battery-info").show();
-
-/*
- $('#slider').slider('option', 'value', NOKIA.emulator.child._BRIDGE_REF.helper.getBatteryStrength());
- NOKIA.emulator.child._BRIDGE_REF.helper.getBatteryStrength()
- $('#slider').slider('option', 'value', 10);
- $('#slider').slider();
-*/
- }
- });
-
- $("#event-battery-back").click(function(event){
- $("#event-icons").show();
- $("#event-battery-info").hide();
- });
-
-
- // for messaging
- $("#event-messaging").click(function(event){
- if(event.target.className == 'active')
- {
- $("#event-icons").hide();
- $("#event-messaging-info").show();
- }
- });
-
- $("#event-messaging-back").click(function(event){
- $("#event-icons").show();
- $("#event-messaging-info").hide();
- });
-
-
- // for memory
- $("#event-memory").click(function(event){
- if(event.target.className == 'active')
- {
- $("#event-icons").hide();
- $("#event-memory-info").show();
- }
- });
-
- $("#event-memory-back").click(function(event){
- $("#event-icons").show();
- $("#event-memory-info").hide();
- });
-
-
- // for minView more info
- $("#mini-view-back").click(function(event){
- $("#settings-view").show();
- $("#mini-view-info").hide();
- });
-
-
- // Slider
- $('#slider').slider({
- min : 0,
- max : 100,
- step : 1,
- value : 10,
- animate: true,
- slide: function(event, ui) {
- $("#slider-value-panel > span").html(ui.value.toString() + "%");
- },
- change: function(event, ui) {
- var chargeValue = ui.value;
- NOKIA.helper.trigger("power", "chargelevel", chargeValue);
- if(NOKIA.version == 'WRT 1.1')
- NOKIA.helper.triggerSapi("Service.SysInfo", "Battery.BatteryStrength", {Status: chargeValue});
- }
- });
- $("#slider-value-panel > span").html("10%");
-
- var cc = $("#close-camera");
- cc.click(NOKIA.helper.hideCamera);
- // Bind Buttons to trigger values to WRT 1.0 / 1.1 bindings
-
- $("#connect-charger").click(NOKIA.helper.triggerEvents);
- $("#disconnect-charger").click(NOKIA.helper.triggerEvents);
-
- $("#send-sms").click(NOKIA.helper.triggerEvents);
- $("#send-mms").click(NOKIA.helper.triggerEvents);
-
- $("#connect-memory-card").click(NOKIA.helper.triggerEvents);
- $("#disconnect-memory-card").click(NOKIA.helper.triggerEvents);
-
-
- },
-
- setHomeScreen : function()
- {
- // HomeScreen Support
- if (NOKIA.deviceList[NOKIA.currentDevice].homeScreenSupport) {
-
- if (typeof NOKIA.emulator.plist.MiniViewEnabled != 'undefined') {
- if (NOKIA.emulator.plist.MiniViewEnabled != 'false')
- {
- $("#WidgetArea")[0].className = 'hs_' + NOKIA.mode;
-
- // menu handlining
- NOKIA.menu.softkeys_visibility = false;
- NOKIA.menu.cancel();
- NOKIA.menu.is_dimmed = true;
-
-
- $("#loaderDiv").html("Click on widget for Return to Full view");
- $("#loaderDiv")[0].className = 'green';
- $("#loaderDiv").show();
-
- $("#iframeMask").show();
- $("#orientationIcon").show();
-
- return true;
- }
- }
- }
- return false;
- },
-
- getElementsLengthInObject : function(items){
- var count = 0;
- for (var i in items)
- {
- if(!items[i].isDimmed)
- count++;
- }
-
- return count;
- },
-
- showCamera : function() {
- $("#camera").show();
- $("#WidgetArea").hide();
- },
-
- hideCamera : function() {
- $("#camera").hide();
- $("#WidgetArea").show();
- },
-
- triggerEvents : function(event)
- {
- if(typeof event.target.id == 'undefined')
- return false;
-
- switch(event.target.id)
- {
- // for battery
- case 'connect-charger':
- NOKIA.helper.trigger("power", "chargerconnected", 1);
- if(NOKIA.version == 'WRT 1.1')
- NOKIA.helper.triggerSapi("Service.SysInfo", "Battery.ChargingStatus", {Status: 1});
- break;
-
- case 'disconnect-charger':
- NOKIA.helper.trigger("power", "chargerconnected", 0);
- if(NOKIA.version == 'WRT 1.1')
- NOKIA.helper.triggerSapi("Service.SysInfo", "Battery.ChargingStatus", {Status: 0});
- break;
-
- // for messaging
- case 'send-sms':
- if(NOKIA.version == 'WRT 1.1')
- NOKIA.helper.triggerSapi("Service.Messaging", "NewMessage", {MessageType: 'SMS'});
- break;
- case 'send-mms':
- if(NOKIA.version == 'WRT 1.1')
- NOKIA.helper.triggerSapi("Service.Messaging", "NewMessage", {MessageType: 'MMS'});
- break;
-
- // for memory
- case 'connect-memory-card':
- if(NOKIA.version == 'WRT 1.1')
- NOKIA.helper.triggerSapi("Service.SysInfo", "Memory.MemoryCard", {Status: 1});
- break;
- case 'disconnect-memory-card':
- if(NOKIA.version == 'WRT 1.1')
- NOKIA.helper.triggerSapi("Service.SysInfo", "Memory.MemoryCard", {Status: 0});
- break;
- }
- },
-
- triggerSapi : function(provider, eventType, data){
- NOKIA.emulator.child.device.implementation.triggerListener(provider, eventType, data);
- },
-
- trigger : function(provider, eventType, data){
- NOKIA.emulator.child.widget.triggerListener(provider, eventType, data);
- },
-
- showMiniviewHelp : function(){
- $("#settings-view").hide();
- $("#mini-view-info").show();
- },
-
- checkDependencies : function(){
-
- for(var key in NOKIA.scriptsLoaded)
- {
- if(!NOKIA.scriptsLoaded[key])
- return false;
- }
-
- // for LSK
- NOKIA.menu.setLsk(NOKIA.emulator.child.menu.show);
-
- // for RSK
- NOKIA.menu.setRsk(NOKIA.menu.exit);
-
- return true;
- }
- };
+ NOKIA.helper = new EmulatorHelper();
/*
* NOKIA.layout functions
*/
NOKIA.namespace('layout');
- NOKIA.layout = {
- _console_minimized : true,
- _console_enabled : false,
- _consoleWindowHeight : 290,
- _consoleHeaderHeight : 31,
- _tabHeight : 27,
-
- init : function(){
-
- // Toggle console window
- $('#preview-ui-bottom-header').click(function(){
- NOKIA.layout._console_minimized = (NOKIA.layout._console_minimized) ? false : true;
- NOKIA.layout.render();
- NOKIA.helper.setPreference("__SYM_NOKIA_CONSOLE_OPEN", !NOKIA.layout._console_minimized);
- });
-
- // clear Log
- $("#Console-Clear-Button").click(function(){
- $("#preview-ui-bottom-body")[0].innerHTML = '';
- });
-
-
- $('#preview-ui-bottom').show();
- NOKIA.layout.render();
- },
-
- log : function(type, msg){
- var p = document.createElement('p');
- p.className = type;
- p.innerHTML = msg;
- var divBody = $('#preview-ui-bottom-body');
- divBody.append(p);
- divBody[0].scrollTop = divBody[0].scrollHeight;
- },
-
-
- render : function(){
- var _width = parseInt(window.innerWidth);
- var _height = parseInt(window.innerHeight);
-
- if(!NOKIA.layout._console_enabled)
- {
- $('#preview-ui-bottom').css({
- display: 'none'
- });
-
- $('#preview-ui-top').css({
- height: _height+'px'
- });
-
- return false;
- }
-
-
- if(!NOKIA.layout._console_minimized)
- {
- $('#Console-Toggle-Button')[0].className = 'open';
-
- // set STYLE details for TOP window
- $('#preview-ui-top').css({
- height: parseInt(_height - NOKIA.layout._consoleWindowHeight) + 'px'
- });
-
- // set STYLE details for Bottom window
- $('#preview-ui-bottom').css({
- height: NOKIA.layout._consoleWindowHeight + 'px',
- display : 'block'
- });
-
- $('#preview-ui-bottom-header').css({
- height: NOKIA.layout._consoleHeaderHeight + 'px'
- });
-
- $('#tabs').css({
- height: parseInt(NOKIA.layout._consoleWindowHeight - NOKIA.layout._consoleHeaderHeight) + 'px',
- display : 'block'
- });
- $('#console').css({
- height : parseInt(NOKIA.layout._consoleWindowHeight
- - NOKIA.layout._consoleHeaderHeight
- - NOKIA.layout._tabHeight * 2)
- + 'px',
- display : 'block'
- });
-
- // Auto scroll when console window opened from MINIMIZED => MAXIMIZED state
- window.setTimeout(function(){
- $('#preview-ui-bottom-body')[0].scrollTop = $('#preview-ui-bottom-body')[0].scrollHeight;
- }, 100);
-
- }else{
- $('#Console-Toggle-Button')[0].className = 'close';
-
- // set STYLE details for TOP window
- $('#preview-ui-top').css({
- height: parseInt(_height - NOKIA.layout._consoleHeaderHeight) + 'px'
- });
-
- // set STYLE details for Bottom window
- $('#preview-ui-bottom').css({
- height: NOKIA.layout._consoleHeaderHeight + 'px',
- display : 'block'
- });
-
- $('#preview-ui-bottom-header').css({
- height: NOKIA.layout._consoleHeaderHeight + 'px',
- display : 'block'
- });
-// TODO
-// $('#preview-ui-bottom-body').css({
-// display : 'none'
-// });
- }
- }
-
- };
+ NOKIA.layout = new EmulatorLayout();
}
$(document).ready(function () {
--- a/org.symbian.tools.wrttools.previewer/preview/wrt_preview.html Mon Jun 28 10:47:32 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/wrt_preview.html Tue Jun 29 13:44:16 2010 -0700
@@ -18,13 +18,18 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TMW Debugger</title>
<!-- jQuery-ui Begins -->
- <link type="text/css" rel="stylesheet" href="preview/script/jquery-ui/css/ui-darkness/jquery-ui-1.8.2.custom.css"/>
- <script type="text/javascript" src="preview/script/jquery-ui/js/jquery-1.4.2.min.js"></script>
- <script type="text/javascript" src="preview/script/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"></script>
+ <link type="text/css" rel="stylesheet" href="preview/script/jquery-ui/css/ui-darkness/jquery-ui-1.8.2.custom.css"/>
+ <script type="text/javascript" src="preview/script/jquery-ui/js/jquery-1.4.2.min.js"></script>
+ <script type="text/javascript" src="preview/script/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"></script>
<!-- jQuery-ui Ends -->
+ <script type="text/javascript" language="JavaScript" src="preview/script/emulator.js"></script>
+ <script type="text/javascript" language="JavaScript" src="preview/script/helper.js"></script>
+ <script type="text/javascript" language="JavaScript" src="preview/script/layout.js"></script>
+ <script type="text/javascript" language="JavaScript" src="preview/script/menu.js"></script>
<script type="text/javascript" language="JavaScript" src="preview/script/nokia.js"></script>
<script type="text/javascript" language="JavaScript" src="preview/script/resolution.js"></script>
<script type="text/javascript" language="JavaScript" src="preview/preferences.js"></script>
+ <script type="text/javascript" language="JavaScript" src="preview/script/accelerometer.js"></script>
<link type="text/css" rel="stylesheet" href="preview/css/style.css"/>
<link rel="icon" type="image/gif" href="preview/favicon.gif" />
</head>
@@ -79,6 +84,7 @@
<div id="tabs" class="tabs-bottom">
<ul id="tabs-header">
<li><a href="#console">Console</a></li>
+ <li><a href="#event-acceleration">Acceleration</a></li>
<li><a href="#event-battery-info">Battery</a></li>
<li><a href="#event-messaging-info">Events</a></li>
<li><a href="#settings-view">Preferences</a></li>
@@ -88,6 +94,29 @@
<div style="clear:left;"></div>
<div id="preview-ui-bottom-body" style="height: 100%"></div>
</div>
+ <div id="event-acceleration" class="hide">
+ <div style="width: 100%">
+ <div style="margin-left: auto; margin-right: auto; width: 250px">
+ <canvas width="140px" height="120px" id="phoneposition" >No canvas available</canvas>
+ <div id="accel-data">
+ <div>X Axis: <span id="xaxis" class="readonly-field">0000</span></div>
+ <div>Y Axis: <span id="yaxis" class="readonly-field">0</span></div>
+ <div>Z Axis: <span id="zaxis" class="readonly-field">0</span></div>
+ </div>
+ </div>
+ <div id="accel-sliders">
+ <div style="height: 15px">
+ <div id="sliderY"></div>
+ </div>
+ <div style="height: 15px">
+ <div id="sliderZ"></div>
+ </div>
+ <div style="height: 15px">
+ <div id="sliderX"></div>
+ </div>
+ </div>
+ </div>
+ </div>
<div id="event-battery-info" class="hide">
<table cellpadding='0' cellspacing='0' width="100%">
<tr>
@@ -101,7 +130,7 @@
<th>Battery Strength</th>
<td>
<div id="slider"></div>
- <div id="slider-value-panel"><span>0</span></div>
+ <div id="slider-value-panel"><span class="readonly-field">0</span></div>
</td>
</tr>
</table>
--- a/work-in-progress-patches/phonegap.txt Mon Jun 28 10:47:32 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-diff -r eef7c6acd0f3 org.symbian.tools.wrttools/plugin.xml
---- a/org.symbian.tools.wrttools/plugin.xml Mon Apr 19 18:04:34 2010 -0700
-+++ b/org.symbian.tools.wrttools/plugin.xml Tue Apr 20 15:14:30 2010 -0700
-@@ -875,5 +875,13 @@
- installer="org.symbian.tools.wrttools.core.libraries.PhoneGapInstaller"
- name="PhoneGap">
- </library>
-+ </extension>
-+ <extension
-+ id="org.symbian.tools.wrttools.phonegap"
-+ name="PhoneGap Library Support"
-+ point="org.eclipse.wst.jsdt.core.inferrenceSupport">
-+ <inferenceProvider
-+ class="org.symbian.tools.wrttools.core.libraries.jsdt.PhoneGapInferrenceProvider">
-+ </inferenceProvider>
- </extension>
- </plugin>
-diff -r eef7c6acd0f3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/PlatformServicesTypeProvider.java
---- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/PlatformServicesTypeProvider.java Mon Apr 19 18:04:34 2010 -0700
-+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/PlatformServicesTypeProvider.java Tue Apr 20 15:14:30 2010 -0700
-@@ -41,7 +41,7 @@
- if (file.exists()) {
- IProject project = file.getProject();
- if (ProjectUtils.hasWrtNature(project)) {
-- return InferrenceProvider.ONLY_THIS;
-+ return InferrenceProvider.MAYBE_THIS;
- }
- }
- }
-diff -r eef7c6acd0f3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/jsdt/PhoneGapInferEngine.java
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/jsdt/PhoneGapInferEngine.java Tue Apr 20 15:14:30 2010 -0700
-@@ -0,0 +1,70 @@
-+/**
-+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
-+ * All rights reserved.
-+ * This component and the accompanying materials are made available
-+ * under the terms of the License "Eclipse Public License v1.0"
-+ * which accompanies this distribution, and is available
-+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
-+ *
-+ * Initial Contributors:
-+ * Symbian Foundation - initial contribution.
-+ * Contributors:
-+ * Description:
-+ * Overview:
-+ * Details:
-+ * Platforms/Drives/Compatibility:
-+ * Assumptions/Requirement/Pre-requisites:
-+ * Failures and causes:
-+ */
-+package org.symbian.tools.wrttools.core.libraries.jsdt;
-+
-+import java.util.Map;
-+import java.util.TreeMap;
-+
-+import org.eclipse.wst.jsdt.core.infer.InferEngine;
-+import org.eclipse.wst.jsdt.core.infer.InferredAttribute;
-+import org.eclipse.wst.jsdt.core.infer.InferredType;
-+import org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration;
-+
-+public class PhoneGapInferEngine extends InferEngine {
-+ private static final Map<String, String> TYPE_TO_PROPERTY = new TreeMap<String, String>();
-+ private CompilationUnitDeclaration compilationUnit;
-+ static {
-+ TYPE_TO_PROPERTY.put("Notification", "notification");
-+ TYPE_TO_PROPERTY.put("Accelerometer", "accelerometer");
-+ TYPE_TO_PROPERTY.put("Camera", "camera");
-+ TYPE_TO_PROPERTY.put("Contacts", "contacts");
-+ TYPE_TO_PROPERTY.put("Geolocation", "geolocation");
-+ TYPE_TO_PROPERTY.put("Media", "media");
-+ TYPE_TO_PROPERTY.put("Notification", "notification");
-+ TYPE_TO_PROPERTY.put("Orientation", "orientation");
-+ TYPE_TO_PROPERTY.put("Sms", "sms");
-+ TYPE_TO_PROPERTY.put("Storage", "storage");
-+ }
-+
-+ @SuppressWarnings("restriction")
-+ @Override
-+ public void setCompilationUnit(CompilationUnitDeclaration compilationUnit) {
-+ this.compilationUnit = compilationUnit;
-+ super.setCompilationUnit(compilationUnit);
-+ }
-+
-+ @SuppressWarnings("restriction")
-+ @Override
-+ protected InferredType addType(char[] className, boolean isDefinition) {
-+ InferredType type = super.addType(className, isDefinition);
-+ if (TYPE_TO_PROPERTY.containsKey(String.valueOf(type.getName()))) {
-+ InferredType inferredType = compilationUnit.findInferredType("Navigator".toCharArray());
-+ System.out.println(inferredType);
-+ if (inferredGlobal != null) {
-+ InferredAttribute[] attributes = inferredGlobal.attributes;
-+ for (InferredAttribute attr : attributes) {
-+ System.out.println(String.valueOf(attr.name));
-+ }
-+ }
-+ final InferredType definedType = findDefinedType("Navigator".toCharArray());
-+ System.out.println(definedType);
-+ }
-+ return type;
-+ }
-+}
-diff -r eef7c6acd0f3 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/jsdt/PhoneGapInferrenceProvider.java
---- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/jsdt/PhoneGapInferrenceProvider.java Tue Apr 20 15:14:30 2010 -0700
-@@ -0,0 +1,89 @@
-+/**
-+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
-+ * All rights reserved.
-+ * This component and the accompanying materials are made available
-+ * under the terms of the License "Eclipse Public License v1.0"
-+ * which accompanies this distribution, and is available
-+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
-+ *
-+ * Initial Contributors:
-+ * Symbian Foundation - initial contribution.
-+ * Contributors:
-+ * Description:
-+ * Overview:
-+ * Details:
-+ * Platforms/Drives/Compatibility:
-+ * Assumptions/Requirement/Pre-requisites:
-+ * Failures and causes:
-+ */
-+package org.symbian.tools.wrttools.core.libraries.jsdt;
-+
-+import java.util.Arrays;
-+import java.util.Collection;
-+import java.util.TreeSet;
-+
-+import org.eclipse.core.resources.IFile;
-+import org.eclipse.core.resources.ResourcesPlugin;
-+import org.eclipse.core.runtime.Path;
-+import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-+import org.eclipse.wst.jsdt.core.IType;
-+import org.eclipse.wst.jsdt.core.JavaScriptCore;
-+import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-+import org.eclipse.wst.jsdt.core.infer.IInferenceFile;
-+import org.eclipse.wst.jsdt.core.infer.InferEngine;
-+import org.eclipse.wst.jsdt.core.infer.InferrenceProvider;
-+import org.eclipse.wst.jsdt.core.infer.RefactoringSupport;
-+import org.eclipse.wst.jsdt.core.infer.ResolutionConfiguration;
-+import org.symbian.tools.wrttools.Activator;
-+
-+public class PhoneGapInferrenceProvider implements InferrenceProvider {
-+ public static final String ID = "org.symbian.tools.wrttools.phonegap";
-+ private static final Collection<String> PHONEGAP_TYPES = new TreeSet<String>(Arrays.asList("Acceleration",
-+ "AccelerationOptions", "Accelerometer", "Camera", "DeviceError", "Contacts", "Contact", "Geolocation",
-+ "PositionOptions", "Coordinates", "Media", "Notification", "Orientation", "Position", "PositionError",
-+ "Sms", "Storage"));
-+
-+ public int applysTo(IInferenceFile scriptFile) {
-+ String path = String.valueOf(scriptFile.getFileName());
-+
-+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
-+ if (file != null && file.isAccessible()) {
-+ IJavaScriptUnit unit = (IJavaScriptUnit) JavaScriptCore.create(file);
-+ try {
-+ IType[] types = unit.getAllTypes();
-+ int typeCount = 0;
-+ for (IType type : types) {
-+ if (PHONEGAP_TYPES.contains(type.getElementName())) {
-+ typeCount += 1;
-+ }
-+ }
-+ if (typeCount > 1) {
-+ return ONLY_THIS;
-+ }
-+ } catch (JavaScriptModelException e) {
-+ Activator.log(e);
-+ }
-+ }
-+ return NOT_THIS;
-+ }
-+
-+ public String getID() {
-+ return ID;
-+ }
-+
-+ public InferEngine getInferEngine() {
-+ final InferEngine engine = new PhoneGapInferEngine();
-+ engine.inferenceProvider = this;
-+ return engine;
-+ }
-+
-+ public RefactoringSupport getRefactoringSupport() {
-+ // TODO Auto-generated method stub
-+ return null;
-+ }
-+
-+ public ResolutionConfiguration getResolutionConfiguration() {
-+ return new ResolutionConfiguration();
-+ }
-+
-+}