/*!
- Ripple Mobile Environment Emulator v0.9.8 :: Built On Thu Jan 16 2014 10:33:05 GMT+0800 (CST)
+ Ripple Mobile Environment Emulator v0.9.8 :: Built On Mon Jan 20 2014 11:00:22 GMT+0800 (CST)
Apache License
Version 2.0, January 2004
return require('ripple/platform/' + _current.name + "/" + _current.version + "/spec");
}
+function _getCurrentPlatform() {
+ var uriParams, platform = {};
+
+ uriParams = utils.getURIParams(document.documentURI);
+ if (uriParams && uriParams.platform) {
+ var platformName = uriParams.platform.split("-")[0], platformVersion;
+
+ if (platformName === "mobile" || platformName === "tizen") {
+ platformName = "tizen";
+ platformVersion = "2.0";
+ }
+ else {
+ platformName = "ivi";
+ platformVersion = "3.0";
+ }
+ platform.name = platformName;
+ platform.version = platformVersion;
+
+ return platform;
+ }
+
+ return undefined;
+}
+
_self = {
initialize: function () {
var firstAvailablePlatform = utils.map(this.getList(), function (platform) {
})[0];
})[0];
- _current = _getRequestedPlatform() || db.retrieveObject("api-key") || firstAvailablePlatform;
+ _current = _getRequestedPlatform() || _getCurrentPlatform() ||
+ db.retrieveObject("api-key") || firstAvailablePlatform;
_current = _validatePlatform(_current, firstAvailablePlatform);
+
db.saveObject("api-key", _current);
_console.prefix = _current.name;
jQuery("#item_container :nth-child(2)").hide();
jQuery("#item_container :nth-child(3)").hide();
+
+ jQuery("#hwkeys-panel").hide();
}
else {
jQuery("#configuration-window-save-btn").show();
jQuery("#item_container :nth-child(2)").show();
jQuery("#item_container :nth-child(3)").show();
+
+ jQuery("#hwkeys-panel").show();
}
}
var emulatorBridge = require('ripple/emulatorBridge'),
platform = require('ripple/platform'),
db = require('ripple/db'),
+ utils = require('ripple/utils'),
devices = require('ripple/devices'),
constants = require('ripple/constants'),
_event = require('ripple/event'),
_persistRoot(url);
});
-function _getUrlParams(url) {
- var params = {};
-
- url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str, key, value) {
- params[key] = value;
- });
-
- return params;
-}
-
module.exports = {
initialize: function () {
var omnibar = _omnibar(), loc, tmp,
$(".omni-bar").show();
- uriParams = _getUrlParams(document.documentURI);
- if (uriParams.platform !== undefined) {
- platformName = uriParams.platform.split("-")[0];
-
- if (platformName === "mobile" || platformName === "tizen") {
- platformName = "tizen";
- platformVersion = "2.0";
- }
- else {
- platformName = "ivi";
- platformVersion = "3.0";
- }
-
- if (platform.current().id !== platformName) {
- deviceId = devices.getCurrentDevice().id;
- if (deviceId == "CUSTOM") {
- deviceId = "custom";
- }
-
- platform.changeEnvironment({
- "name": platformName,
- "version": platformVersion
- }, deviceId, function () {
- window.tinyHipposReload = true;
- newUrl = location.href.replace(/&platform=(.+?)-(.+?)$/, "&platform=" + platformName + "-" + platformVersion);
- location.href = newUrl;
- //location.reload();
- });
- }
- }
-
+ uriParams = utils.getURIParams(document.documentURI);
if (uriParams.url !== undefined) {
url = uriParams.url;
if (url.match(/^\.[\.]?/) !== null) {
jQuery("#item_container :nth-child(2)").hide();
jQuery("#item_container :nth-child(3)").hide();
+
+ jQuery("#hwkeys-panel").hide();
}
else {
jQuery("#configuration-window-save-btn").show();
jQuery("#item_container :nth-child(2)").show();
jQuery("#item_container :nth-child(3)").show();
+
+ jQuery("#hwkeys-panel").show();
}
}
},
navHelper: function () {
- return {\r
- getHeading: function (lat1, lon1, lat2, lon2) {\r
+ return {
+ getHeading: function (lat1, lon1, lat2, lon2) {
var dLon = this.rad(lon2 - lon1),
llat1 = this.rad(lat1),
llat2 = this.rad(lat2),
y = Math.sin(dLon) * Math.cos(llat2),
x = Math.cos(llat1) * Math.sin(llat2) - Math.sin(llat1) * Math.cos(llat2) * Math.cos(dLon);
- return (this.deg(Math.atan2(y, x)) + 360) % 360;\r
+ return (this.deg(Math.atan2(y, x)) + 360) % 360;
},
- getDistance: function (lat1, lon1, lat2, lon2) {\r
+ getDistance: function (lat1, lon1, lat2, lon2) {
var dLat = this.rad(lat2 - lat1),
dLon = this.rad(lon2 - lon1),
a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(this.rad(lat1)) * Math.cos(this.rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2),
c = 2 * Math.asin(Math.sqrt(a)),
d = 6378100 * c;
- return d;\r
+ return d;
},
- simulateTravel: function (lat, lon, hdg, dist) {\r
+ simulateTravel: function (lat, lon, hdg, dist) {
var lat1 = this.rad(lat),
lon1 = this.rad(lon),
brng = this.rad(hdg),
lon2 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(angularDistance) * Math.cos(lat1), Math.cos(angularDistance) - Math.sin(lat1) * Math.sin(lat2));
lon2 = (lon2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI; // Normalise to -180..+180
- return {\r
- latitude: this.deg(lat2),\r
- longitude: this.deg(lon2)\r
- };\r
+ return {
+ latitude: this.deg(lat2),
+ longitude: this.deg(lon2)
+ };
},
- deg: function (num) {\r
- return num * 180 / Math.PI;\r
+ deg: function (num) {
+ return num * 180 / Math.PI;
},
- rad: function (num) {\r
- return num * Math.PI / 180;\r
- }\r
+ rad: function (num) {
+ return num * Math.PI / 180;
+ }
};
+ },
+
+ getURIParams: function (uriString) {
+ var params = {};
+
+ uriString.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str, key, value) {
+ params[key] = value;
+ });
+
+ return params;
}
};