| 15747 |
anikendra |
1 |
/*
|
|
|
2 |
*
|
|
|
3 |
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
4 |
* or more contributor license agreements. See the NOTICE file
|
|
|
5 |
* distributed with this work for additional information
|
|
|
6 |
* regarding copyright ownership. The ASF licenses this file
|
|
|
7 |
* to you under the Apache License, Version 2.0 (the
|
|
|
8 |
* "License"); you may not use this file except in compliance
|
|
|
9 |
* with the License. You may obtain a copy of the License at
|
|
|
10 |
*
|
|
|
11 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
12 |
*
|
|
|
13 |
* Unless required by applicable law or agreed to in writing,
|
|
|
14 |
* software distributed under the License is distributed on an
|
|
|
15 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
16 |
* KIND, either express or implied. See the License for the
|
|
|
17 |
* specific language governing permissions and limitations
|
|
|
18 |
* under the License.
|
|
|
19 |
*
|
|
|
20 |
*/
|
|
|
21 |
var browser = require('cordova/platform');
|
|
|
22 |
var cordova = require('cordova');
|
|
|
23 |
|
|
|
24 |
function getPlatform() {
|
|
|
25 |
return "browser";
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
function getModel() {
|
|
|
29 |
return getBrowserInfo(true);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
function getVersion() {
|
|
|
33 |
return getBrowserInfo(false);
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
function getBrowserInfo(getModel) {
|
|
|
37 |
var userAgent = navigator.userAgent;
|
|
|
38 |
var returnVal = '';
|
|
|
39 |
|
|
|
40 |
if ((offset = userAgent.indexOf('Chrome')) !== -1) {
|
|
|
41 |
returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7);
|
|
|
42 |
} else if ((offset = userAgent.indexOf('Safari')) !== -1) {
|
|
|
43 |
if (getModel) {
|
|
|
44 |
returnVal = 'Safari';
|
|
|
45 |
} else {
|
|
|
46 |
returnVal = userAgent.substring(offset + 7);
|
|
|
47 |
|
|
|
48 |
if ((offset = userAgent.indexOf('Version')) !== -1) {
|
|
|
49 |
returnVal = userAgent.substring(offset + 8);
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
} else if ((offset = userAgent.indexOf('Firefox')) !== -1) {
|
|
|
53 |
returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8);
|
|
|
54 |
} else if ((offset = userAgent.indexOf('MSIE')) !== -1) {
|
|
|
55 |
returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5);
|
|
|
56 |
} else if ((offset = userAgent.indexOf('Trident')) !== -1) {
|
|
|
57 |
returnVal = (getModel) ? 'MSIE' : '11';
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) {
|
|
|
61 |
returnVal = returnVal.substring(0, offset);
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
return returnVal;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
module.exports = {
|
|
|
69 |
getDeviceInfo: function (success, error) {
|
|
|
70 |
setTimeout(function () {
|
|
|
71 |
success({
|
|
|
72 |
cordova: browser.cordovaVersion,
|
|
|
73 |
platform: getPlatform(),
|
|
|
74 |
model: getModel(),
|
|
|
75 |
version: getVersion(),
|
|
|
76 |
uuid: null
|
|
|
77 |
});
|
|
|
78 |
}, 0);
|
|
|
79 |
}
|
|
|
80 |
};
|
|
|
81 |
|
|
|
82 |
require("cordova/exec/proxy").add("Device", module.exports);
|