You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2014/09/05 19:55:01 UTC
[1/4] git commit: Added plugin support for the browser
Repository: cordova-plugin-device
Updated Branches:
refs/heads/master d5a8ac46e -> 03ccd33ed
Added plugin support for the browser
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/6ce0fdfe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/6ce0fdfe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/6ce0fdfe
Branch: refs/heads/master
Commit: 6ce0fdfe4d94871644a8e3d1862defac69d1062a
Parents: ae3f2ed
Author: Suraj Pindoria <su...@yahoo.com>
Authored: Thu Aug 21 13:48:27 2014 -0700
Committer: Suraj Pindoria <su...@yahoo.com>
Committed: Wed Aug 27 13:30:53 2014 -0700
----------------------------------------------------------------------
doc/index.md | 10 ++++++
plugin.xml | 13 +++++++
src/browser/DeviceProxy.js | 78 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/6ce0fdfe/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 9e5c677..3a6c6c2 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -49,6 +49,7 @@ Get the version of Cordova running on the device.
- Amazon Fire OS
- Android
- BlackBerry 10
+- Browser
- Firefox OS
- iOS
- Tizen
@@ -65,6 +66,7 @@ different across versions of the same product.
- Android
- BlackBerry 10
+- Browser
- iOS
- Tizen
- Windows Phone 7 and 8
@@ -75,6 +77,8 @@ different across versions of the same product.
// Android: Nexus One returns "Passion" (Nexus One code name)
// Motorola Droid returns "voles"
// BlackBerry: Torch 9800 returns "9800"
+ // Browser: Google Chrome returns "Chrome"
+ // Safari returns "Safari"
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
//
var model = device.model;
@@ -105,6 +109,7 @@ Get the device's operating system name.
- Android
- BlackBerry 10
+- Browser4
- Firefox OS
- iOS
- Tizen
@@ -116,6 +121,8 @@ Get the device's operating system name.
// Depending on the device, a few examples are:
// - "Android"
// - "BlackBerry 10"
+ // - Browser: returns "MacIntel" on Mac
+ // returns "Win32" on Windows
// - "iOS"
// - "WinCE"
// - "Tizen"
@@ -192,6 +199,7 @@ Get the operating system version.
- Android 2.1+
- BlackBerry 10
+- Browser
- iOS
- Tizen
- Windows Phone 7 and 8
@@ -205,6 +213,8 @@ Get the operating system version.
//
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
//
+ // Browser: Returns version number for the browser
+ //
// iPhone: iOS 3.2 returns "3.2"
//
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/6ce0fdfe/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index fd8bdc5..1e36d6c 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -152,4 +152,17 @@
</js-module>
</platform>
+ <!-- browser -->
+ <platform name="browser">
+ <config-file target="config.xml" parent="/*">
+ <feature name="Device">
+ <param name="browser-package" value="Device" />
+ </feature>
+ </config-file>
+
+ <js-module src="src/browser/DeviceProxy.js" name="DeviceProxy">
+ <runs />
+ </js-module>
+ </platform>
+
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/6ce0fdfe/src/browser/DeviceProxy.js
----------------------------------------------------------------------
diff --git a/src/browser/DeviceProxy.js b/src/browser/DeviceProxy.js
new file mode 100644
index 0000000..45e1d88
--- /dev/null
+++ b/src/browser/DeviceProxy.js
@@ -0,0 +1,78 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+var browser = require('cordova/platform');
+var cordova = require('cordova');
+
+function getPlatform() {
+ return navigator.platform;
+}
+
+function getModel() {
+ return getBrowserInfo(true);
+}
+
+function getVersion() {
+ return getBrowserInfo(false);
+}
+
+function getBrowserInfo(getModel) {
+ var userAgent = navigator.userAgent;
+ var returnVal;
+
+ if ((offset = userAgent.indexOf('Chrome')) !== -1) {
+ returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7);
+ } else if ((offset = userAgent.indexOf('Safari')) !== -1) {
+ if (getModel) {
+ returnVal = 'Safari';
+ } else {
+ returnVal = userAgent.substring(offset + 7);
+
+ if ((offset = userAgent.indexOf('Version')) !== -1) {
+ returnVal = userAgent.substring(offset + 8);
+ }
+ }
+ } else if ((offset = userAgent.indexOf('Firefox')) !== -1) {
+ returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8);
+ }
+
+ if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) {
+ returnVal = returnVal.substring(0, offset);
+ }
+
+ return returnVal;
+}
+
+
+module.exports = {
+ getDeviceInfo: function (success, error) {
+ setTimeout(function () {
+ success({
+ cordova: browser.cordovaVersion,
+ platform: getPlatform(),
+ model: getModel(),
+ version: getVersion(),
+ uuid: null
+ });
+ }, 0);
+ }
+};
+
+require("cordova/exec/proxy").add("Device", module.exports);
[3/4] git commit: [fxos] Fix cordova version
Posted by an...@apache.org.
[fxos] Fix cordova 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/77dcdf25
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/77dcdf25
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/77dcdf25
Branch: refs/heads/master
Commit: 77dcdf2591a76ed802acbbab35b55531f58b5b57
Parents: c64aac0
Author: Rodrigo Silveira <ro...@outlook.com>
Authored: Mon Aug 11 16:26:14 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Fri Sep 5 10:54:20 2014 -0700
----------------------------------------------------------------------
src/firefoxos/DeviceProxy.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/77dcdf25/src/firefoxos/DeviceProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/DeviceProxy.js b/src/firefoxos/DeviceProxy.js
index 5c7c81e..79f3a2b 100644
--- a/src/firefoxos/DeviceProxy.js
+++ b/src/firefoxos/DeviceProxy.js
@@ -67,7 +67,6 @@ module.exports = {
getDeviceInfo: function (success, error) {
setTimeout(function () {
success({
- cordova: firefoxos.cordovaVersion,
platform: 'firefoxos',
model: getModel(),
version: getVersion(),
@@ -77,4 +76,4 @@ module.exports = {
}
};
-require("cordova/exec/proxy").add("Device", module.exports);
\ No newline at end of file
+require("cordova/exec/proxy").add("Device", module.exports);
[4/4] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/cordova-plugin-device
Posted by an...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/cordova-plugin-device
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/03ccd33e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/03ccd33e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/03ccd33e
Branch: refs/heads/master
Commit: 03ccd33ed58a472da88bf62bc895225ad9757084
Parents: 77dcdf2 d5a8ac4
Author: Anis Kadri <an...@apache.org>
Authored: Fri Sep 5 10:54:47 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Fri Sep 5 10:54:47 2014 -0700
----------------------------------------------------------------------
----------------------------------------------------------------------
[2/4] git commit: added status box and documentation to manual tests
Posted by an...@apache.org.
added status box and documentation to manual tests
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/c64aac01
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/c64aac01
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/c64aac01
Branch: refs/heads/master
Commit: c64aac01458bdbd7ef26464e8fc3653185076080
Parents: 6ce0fdf
Author: Edna Morales <ed...@ednas-mbp-2.raleigh.ibm.com>
Authored: Thu Jul 24 15:09:29 2014 -0400
Committer: Anis Kadri <an...@apache.org>
Committed: Fri Sep 5 10:54:20 2014 -0700
----------------------------------------------------------------------
tests/tests.js | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/c64aac01/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index e22b7c1..f7c30ef 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -66,7 +66,29 @@ exports.defineAutoTests = function() {
};
exports.defineManualTests = function(contentEl, createActionButton) {
- createActionButton('Dump device', function() {
- console.log(JSON.stringify(window.device, null, '\t'));
- });
+ var logMessage = function (message, color) {
+ var log = document.getElementById('info');
+ var logLine = document.createElement('div');
+ if (color) {
+ logLine.style.color = color;
+ }
+ logLine.innerHTML = message;
+ log.appendChild(logLine);
+ }
+
+ var clearLog = function () {
+ var log = document.getElementById('info');
+ log.innerHTML = '';
+ }
+
+ var device_tests = '<h3>Press Dump Device button to get device information</h3>' +
+ '<div id="dump_device"></div>' +
+ 'Expected result: Status box will get updated with device info. (i.e. platform, version, uuid, model, etc)';
+
+ contentEl.innerHTML = '<div id="info"></div>' + device_tests;
+
+ createActionButton('Dump device', function() {
+ clearLog();
+ logMessage(JSON.stringify(window.device, null, '\t'));
+ }, "dump_device");
};