You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by za...@apache.org on 2014/06/04 10:53:14 UTC
[2/4] git commit: added firefoxos version
added firefoxos version
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/commit/357848b2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/357848b2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/357848b2
Branch: refs/heads/master
Commit: 357848b242f9649553ce1bf78d891ca242fddc25
Parents: 72bfd9c
Author: Jason Weathersby <jw...@mozilla.com>
Authored: Wed Apr 23 14:19:06 2014 -0700
Committer: Rodrigo Silveira <ro...@outlook.com>
Committed: Tue Jun 3 21:23:41 2014 -0700
----------------------------------------------------------------------
src/firefoxos/DeviceProxy.js | 35 +++++++++++++++++++++++++++++------
1 file changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/357848b2/src/firefoxos/DeviceProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/DeviceProxy.js b/src/firefoxos/DeviceProxy.js
index f37e761..47bcdb0 100644
--- a/src/firefoxos/DeviceProxy.js
+++ b/src/firefoxos/DeviceProxy.js
@@ -1,4 +1,4 @@
-/*
+cordova.define("org.apache.cordova.device.DeviceProxy", function(require, exports, module) { /*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -17,19 +17,41 @@
* specific language governing permissions and limitations
* under the License.
*
-*/
-
+ */
+//example UA String for Firefox OS
+//Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0
var firefoxos = require('cordova/platform');
var cordova = require('cordova');
+//UA parsing not recommended but currently this is the only way to get the Firefox OS version
+//https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference
+
+function getVersion() {
+ if (navigator.userAgent.match(/(mobile|tablet)/i)) {
+ var ffVersionArray = (navigator.userAgent.match(/Firefox\/([\d]+\.[\w]?\.?[\w]+)/));
+ if (ffVersionArray.length === 2) {
+ return (ffVersionArray[1]);
+ }
+ }
+ return (null);
+}
+function getModel() {
+ var uaArray = navigator.userAgent.split(/\s*[;)(]\s*/);
+ if (navigator.userAgent.match(/(mobile|tablet)/i)) {
+ if (uaArray.length === 5) {
+ return (uaArray[2]);
+ }
+ }
+ return (null);
+}
module.exports = {
- getDeviceInfo: function(success, error) {
+ getDeviceInfo: function (success, error) {
setTimeout(function () {
success({
cordova: firefoxos.cordovaVersion,
platform: 'firefoxos',
- model: null,
- version: null,
+ model: getModel(),
+ version: getVersion(),
uuid: null
});
}, 0);
@@ -37,3 +59,4 @@ module.exports = {
};
require("cordova/firefoxos/commandProxy").add("Device", module.exports);
+});