Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

DeviceProxy.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. function getPlatform () {
  23. return 'browser';
  24. }
  25. function getModel () {
  26. return getBrowserInfo(true);
  27. }
  28. function getVersion () {
  29. return getBrowserInfo(false);
  30. }
  31. function getBrowserInfo (getModel) {
  32. var userAgent = navigator.userAgent;
  33. var returnVal = '';
  34. var offset;
  35. if ((offset = userAgent.indexOf('Edge')) !== -1) {
  36. returnVal = (getModel) ? 'Edge' : userAgent.substring(offset + 5);
  37. } else if ((offset = userAgent.indexOf('Chrome')) !== -1) {
  38. returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7);
  39. } else if ((offset = userAgent.indexOf('Safari')) !== -1) {
  40. if (getModel) {
  41. returnVal = 'Safari';
  42. } else {
  43. returnVal = userAgent.substring(offset + 7);
  44. if ((offset = userAgent.indexOf('Version')) !== -1) {
  45. returnVal = userAgent.substring(offset + 8);
  46. }
  47. }
  48. } else if ((offset = userAgent.indexOf('Firefox')) !== -1) {
  49. returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8);
  50. } else if ((offset = userAgent.indexOf('MSIE')) !== -1) {
  51. returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5);
  52. } else if ((offset = userAgent.indexOf('Trident')) !== -1) {
  53. returnVal = (getModel) ? 'MSIE' : '11';
  54. }
  55. if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) {
  56. returnVal = returnVal.substring(0, offset);
  57. }
  58. return returnVal;
  59. }
  60. module.exports = {
  61. getDeviceInfo: function (success, error) {
  62. setTimeout(function () {
  63. success({
  64. cordova: browser.cordovaVersion,
  65. platform: getPlatform(),
  66. model: getModel(),
  67. version: getVersion(),
  68. uuid: null,
  69. isVirtual: false
  70. });
  71. }, 0);
  72. }
  73. };
  74. require('cordova/exec/proxy').add('Device', module.exports);