OLD | NEW |
---|---|
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 {string} error | 9 * @param {string} error |
10 */ | 10 */ |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 return null; | 67 return null; |
68 | 68 |
69 var isLatitudeValid = WebInspector.Geolocation.latitudeValidator(latitudeStr ing); | 69 var isLatitudeValid = WebInspector.Geolocation.latitudeValidator(latitudeStr ing); |
70 var isLongitudeValid = WebInspector.Geolocation.longitudeValidator(longitude String); | 70 var isLongitudeValid = WebInspector.Geolocation.longitudeValidator(longitude String); |
71 | 71 |
72 if (!isLatitudeValid && !isLongitudeValid) | 72 if (!isLatitudeValid && !isLongitudeValid) |
73 return null; | 73 return null; |
74 | 74 |
75 var latitude = isLatitudeValid ? parseFloat(latitudeString) : -1; | 75 var latitude = isLatitudeValid ? parseFloat(latitudeString) : -1; |
76 var longitude = isLongitudeValid ? parseFloat(longitudeString) : -1; | 76 var longitude = isLongitudeValid ? parseFloat(longitudeString) : -1; |
77 | 77 var error = errorStatus ? WebInspector.Geolocation.Error.PositionUnavailable : WebInspector.Geolocation.Error.None; |
78 return new WebInspector.Geolocation(latitude, longitude, errorStatus ? "Posi tionUnavailable" : ""); | 78 return new WebInspector.Geolocation(latitude, longitude, error); |
79 } | 79 } |
80 | 80 |
81 /** | 81 /** |
82 * @param {string} value | 82 * @param {string} value |
83 * @return {boolean} | 83 * @return {boolean} |
84 */ | 84 */ |
85 WebInspector.Geolocation.latitudeValidator = function(value) | 85 WebInspector.Geolocation.latitudeValidator = function(value) |
86 { | 86 { |
87 return !value || (/^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && value > = -90 && value <= 90); | 87 return !value || (/^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && value > = -90 && value <= 90); |
88 } | 88 } |
89 | 89 |
90 /** | 90 /** |
91 * @param {string} value | 91 * @param {string} value |
92 * @return {boolean} | 92 * @return {boolean} |
93 */ | 93 */ |
94 WebInspector.Geolocation.longitudeValidator = function(value) | 94 WebInspector.Geolocation.longitudeValidator = function(value) |
95 { | 95 { |
96 return !value || (/^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && value > = -180 && value <= 180); | 96 return !value || (/^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && value > = -180 && value <= 180); |
97 } | 97 } |
98 | |
99 WebInspector.Geolocation.Error = { | |
lushnikov
2016/04/23 00:19:46
/** @enum {string} */
luoe
2016/04/25 19:26:41
Done.
| |
100 None: "", | |
lushnikov
2016/04/23 00:19:46
None: "None",
luoe
2016/04/25 19:26:41
Okay. I've also updated another line from:
if (th
| |
101 PositionUnavailable: "PositionUnavailable" | |
102 } | |
OLD | NEW |