Bläddra i källkod

add browser information in geo file

Victor Luiz Domingues 5 år sedan
förälder
incheckning
4c16fc28ec

+ 2 - 0
src/app/components/intersection-component/models/intersection-model.js

@@ -9,6 +9,8 @@ export class IntersectionModel extends PointModel {
     super.setClass(ELEMENTS_CLASS.INTERSECTION_POINT);
     this.visible = visible;
     this.index = index;
+    this.color = -65536;
+    this.definitions = [];
     this.definitions.push(this.r);
     this.definitions.push(this.s);
   }

+ 0 - 1
src/app/components/point-component/models/point-model.js

@@ -5,7 +5,6 @@ export class PointModel extends GeometricObject {
     super(id);
     this.posX = posX;
     this.posY = posY;
-    console.info(posX, posY);
     this.setLabel(label);
     super.setClass(ELEMENTS_CLASS.POINT);
     this.definitions = [{ id: this.posX + 5 }, { id: -this.posY - 5 }];

+ 76 - 0
src/app/core/application/browser.js

@@ -0,0 +1,76 @@
+class Browser {
+  constructor() {
+    let nVer = navigator.appVersion;
+    let nAgt = navigator.userAgent;
+    let browserName = navigator.appName;
+    let fullVersion = "" + parseFloat(navigator.appVersion);
+    let majorVersion = parseInt(navigator.appVersion, 10);
+    let nameOffset;
+    let verOffset;
+    let ix;
+
+    // In Opera, the true version is after "Opera" or after "Version"
+    if ((verOffset = nAgt.indexOf("Opera")) != -1) {
+      browserName = "Opera";
+      fullVersion = nAgt.substring(verOffset + 6);
+      if ((verOffset = nAgt.indexOf("Version")) != -1)
+        fullVersion = nAgt.substring(verOffset + 8);
+    }
+    // In MSIE, the true version is after "MSIE" in userAgent
+    else if ((verOffset = nAgt.indexOf("MSIE")) != -1) {
+      browserName = "Microsoft Internet Explorer";
+      fullVersion = nAgt.substring(verOffset + 5);
+    }
+    // In Chrome, the true version is after "Chrome"
+    else if ((verOffset = nAgt.indexOf("Chrome")) != -1) {
+      browserName = "Chrome";
+      fullVersion = nAgt.substring(verOffset + 7);
+    }
+    // In Safari, the true version is after "Safari" or after "Version"
+    else if ((verOffset = nAgt.indexOf("Safari")) != -1) {
+      browserName = "Safari";
+      fullVersion = nAgt.substring(verOffset + 7);
+      if ((verOffset = nAgt.indexOf("Version")) != -1)
+        fullVersion = nAgt.substring(verOffset + 8);
+    }
+    // In Firefox, the true version is after "Firefox"
+    else if ((verOffset = nAgt.indexOf("Firefox")) != -1) {
+      browserName = "Firefox";
+      fullVersion = nAgt.substring(verOffset + 8);
+    }
+    // In most other browsers, "name/version" is at the end of userAgent
+    else if (
+      (nameOffset = nAgt.lastIndexOf(" ") + 1) <
+      (verOffset = nAgt.lastIndexOf("/"))
+    ) {
+      browserName = nAgt.substring(nameOffset, verOffset);
+      fullVersion = nAgt.substring(verOffset + 1);
+      if (browserName.toLowerCase() == browserName.toUpperCase()) {
+        browserName = navigator.appName;
+      }
+    }
+    // trim the fullVersion string at semicolon/space if present
+    if ((ix = fullVersion.indexOf(";")) != -1)
+      fullVersion = fullVersion.substring(0, ix);
+    if ((ix = fullVersion.indexOf(" ")) != -1)
+      fullVersion = fullVersion.substring(0, ix);
+
+    majorVersion = parseInt("" + fullVersion, 10);
+    if (isNaN(majorVersion)) {
+      fullVersion = "" + parseFloat(navigator.appVersion);
+      majorVersion = parseInt(navigator.appVersion, 10);
+    }
+    let OSName = "Unknown OS";
+    if (navigator.appVersion.indexOf("Win") != -1) OSName = "Windows";
+    if (navigator.appVersion.indexOf("Mac") != -1) OSName = "MacOS";
+    if (navigator.appVersion.indexOf("X11") != -1) OSName = "UNIX";
+    if (navigator.appVersion.indexOf("Linux") != -1) OSName = "Linux";
+    this.browserName = browserName;
+    this.fullVersion = fullVersion;
+    this.majorVersion = majorVersion;
+    this.appName = navigator.appName;
+    this.userAgent = navigator.userAgent;
+    this.osName = OSName;
+  }
+}
+export const browser = new Browser();

+ 6 - 5
src/app/core/models/application/actions/action-manager.js

@@ -1,3 +1,5 @@
+import { browser } from "../../../application/browser";
+
 export class ActionManager {
   constructor() {
     this.actions = [];
@@ -15,16 +17,15 @@ export class ActionManager {
     const LINES = [
       `# igeom: http://www.matematica.br!
 [ .: iGeom : Geometria Interativa na Internet :. ]!
-[ versao: 5.9.22 ]!
-[ PC = 3; DD = 0 ]!
-[[Nov 24, 2019 8:35:20 PM; Victor]]!
-[0:1.1, 1:3,  - iGeom versao 5.9.22]!\n`
+[ versao: 1.0.0 ]!
+[ PC = ${browser.appName}; DD = 0 ]!
+[[${new Date()}; ${browser.osName}]]!
+[0:1.1, 1:3,  - iGeom versao 1.0.0]!\n`
     ];
     this.actions.forEach(action => {
       action.rehydrate();
       LINES.push(action.toString());
     });
-    console.info(this.actions);
     var file = new Blob([...LINES], {
       type: "text/plain;charset=utf-8"
     });