-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoordinateRandomizerDynamicValue.js
More file actions
37 lines (29 loc) · 1.05 KB
/
CoordinateRandomizerDynamicValue.js
File metadata and controls
37 lines (29 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class CoordinateRandomizerDynamicValue {
text(context) { }
sign() {
return (Math.random() > 0.5) ? 1 : -1;
}
randomLatitude() {
return this.sign() * Math.random() * 90.0;
}
randomLongitude() {
return this.sign() * Math.random() * 180.0;
}
title(context) {
return "Coordinate Randomizer " + (this.coordinate == "lat" ? "Latitude" : "Longitude");
}
evaluate(context) {
if (this.coordinate == "lat") {
return this.randomLatitude();
} else if (this.coordinate == "lng") {
return this.randomLongitude();
}
return "0";
}
}
CoordinateRandomizerDynamicValue.identifier = "com.sergiobuj.PawExtensions.CoordinateRandomizerDynamicValue";
CoordinateRandomizerDynamicValue.title = "Coordinate Randomizer";
CoordinateRandomizerDynamicValue.inputs = [
InputField("coordinate", "Coordinate", "Radio", { "choices": { "lat": "Latitude", "lng": "Longitude" }, defaultValue: "lat" }),
]
registerDynamicValueClass(CoordinateRandomizerDynamicValue);