Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/Geolocation.js

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @param {number} latitude 7 * @param {number} latitude
8 * @param {number} longitude 8 * @param {number} longitude
9 * @param {boolean} error 9 * @param {boolean} error
10 */ 10 */
11 WebInspector.Geolocation = function(latitude, longitude, error) 11 WebInspector.Geolocation = function(latitude, longitude, error)
12 { 12 {
13 this.latitude = latitude; 13 this.latitude = latitude;
14 this.longitude = longitude; 14 this.longitude = longitude;
15 this.error = error; 15 this.error = error;
16 } 16 };
17 17
18 WebInspector.Geolocation.prototype = { 18 WebInspector.Geolocation.prototype = {
19 /** 19 /**
20 * @return {string} 20 * @return {string}
21 */ 21 */
22 toSetting: function() 22 toSetting: function()
23 { 23 {
24 return (typeof this.latitude === "number" && typeof this.longitude === " number" && typeof this.error === "string") ? this.latitude + "@" + this.longitud e + ":" + this.error : ""; 24 return (typeof this.latitude === "number" && typeof this.longitude === " number" && typeof this.error === "string") ? this.latitude + "@" + this.longitud e + ":" + this.error : "";
25 }, 25 },
26 26
27 apply: function() 27 apply: function()
28 { 28 {
29 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Capability.Browser)) { 29 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Capability.Browser)) {
30 if (this.error) 30 if (this.error)
31 target.emulationAgent().setGeolocationOverride(); 31 target.emulationAgent().setGeolocationOverride();
32 else 32 else
33 target.emulationAgent().setGeolocationOverride(this.latitude, th is.longitude, WebInspector.Geolocation.DefaultMockAccuracy); 33 target.emulationAgent().setGeolocationOverride(this.latitude, th is.longitude, WebInspector.Geolocation.DefaultMockAccuracy);
34 } 34 }
35 }, 35 },
36 36
37 clear: function() 37 clear: function()
38 { 38 {
39 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Capability.Browser)) 39 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Capability.Browser))
40 target.emulationAgent().clearGeolocationOverride(); 40 target.emulationAgent().clearGeolocationOverride();
41 } 41 }
42 } 42 };
43 43
44 /** 44 /**
45 * @return {!WebInspector.Geolocation} 45 * @return {!WebInspector.Geolocation}
46 */ 46 */
47 WebInspector.Geolocation.parseSetting = function(value) 47 WebInspector.Geolocation.parseSetting = function(value)
48 { 48 {
49 if (value) { 49 if (value) {
50 var splitError = value.split(":"); 50 var splitError = value.split(":");
51 if (splitError.length === 2) { 51 if (splitError.length === 2) {
52 var splitPosition = splitError[0].split("@"); 52 var splitPosition = splitError[0].split("@");
53 if (splitPosition.length === 2) 53 if (splitPosition.length === 2)
54 return new WebInspector.Geolocation(parseFloat(splitPosition[0]) , parseFloat(splitPosition[1]), splitError[1]); 54 return new WebInspector.Geolocation(parseFloat(splitPosition[0]) , parseFloat(splitPosition[1]), splitError[1]);
55 } 55 }
56 } 56 }
57 return new WebInspector.Geolocation(0, 0, false); 57 return new WebInspector.Geolocation(0, 0, false);
58 } 58 };
59 59
60 /** 60 /**
61 * @param {string} latitudeString 61 * @param {string} latitudeString
62 * @param {string} longitudeString 62 * @param {string} longitudeString
63 * @param {string} errorStatus 63 * @param {string} errorStatus
64 * @return {?WebInspector.Geolocation} 64 * @return {?WebInspector.Geolocation}
65 */ 65 */
66 WebInspector.Geolocation.parseUserInput = function(latitudeString, longitudeStri ng, errorStatus) 66 WebInspector.Geolocation.parseUserInput = function(latitudeString, longitudeStri ng, errorStatus)
67 { 67 {
68 if (!latitudeString && !longitudeString) 68 if (!latitudeString && !longitudeString)
69 return null; 69 return null;
70 70
71 var isLatitudeValid = WebInspector.Geolocation.latitudeValidator(latitudeStr ing); 71 var isLatitudeValid = WebInspector.Geolocation.latitudeValidator(latitudeStr ing);
72 var isLongitudeValid = WebInspector.Geolocation.longitudeValidator(longitude String); 72 var isLongitudeValid = WebInspector.Geolocation.longitudeValidator(longitude String);
73 73
74 if (!isLatitudeValid && !isLongitudeValid) 74 if (!isLatitudeValid && !isLongitudeValid)
75 return null; 75 return null;
76 76
77 var latitude = isLatitudeValid ? parseFloat(latitudeString) : -1; 77 var latitude = isLatitudeValid ? parseFloat(latitudeString) : -1;
78 var longitude = isLongitudeValid ? parseFloat(longitudeString) : -1; 78 var longitude = isLongitudeValid ? parseFloat(longitudeString) : -1;
79 return new WebInspector.Geolocation(latitude, longitude, !!errorStatus); 79 return new WebInspector.Geolocation(latitude, longitude, !!errorStatus);
80 } 80 };
81 81
82 /** 82 /**
83 * @param {string} value 83 * @param {string} value
84 * @return {boolean} 84 * @return {boolean}
85 */ 85 */
86 WebInspector.Geolocation.latitudeValidator = function(value) 86 WebInspector.Geolocation.latitudeValidator = function(value)
87 { 87 {
88 var numValue = parseFloat(value); 88 var numValue = parseFloat(value);
89 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -90 && numValue <= 90; 89 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -90 && numValue <= 90;
90 } 90 };
91 91
92 /** 92 /**
93 * @param {string} value 93 * @param {string} value
94 * @return {boolean} 94 * @return {boolean}
95 */ 95 */
96 WebInspector.Geolocation.longitudeValidator = function(value) 96 WebInspector.Geolocation.longitudeValidator = function(value)
97 { 97 {
98 var numValue = parseFloat(value); 98 var numValue = parseFloat(value);
99 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -180 & & numValue <= 180; 99 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -180 & & numValue <= 180;
100 } 100 };
101 101
102 WebInspector.Geolocation.DefaultMockAccuracy = 150; 102 WebInspector.Geolocation.DefaultMockAccuracy = 150;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698