forked from abhijitWakchaure/akatsuki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
46 lines (41 loc) · 1.23 KB
/
utils.js
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
38
39
40
41
42
43
44
45
46
function setDriverName(value) {
if (typeof (Storage) !== "undefined") {
sessionStorage.driverName = value;
} else {
console.error(`Sorry, your browser does not support web storage`);
}
}
function getDriverName() {
if (typeof (Storage) !== "undefined") {
if (sessionStorage.driverName) {
return sessionStorage.driverName;
} else {
sessionStorage.driverName = 'anonymous';
return 'anonymous';
}
} else {
console.error(`Sorry, your browser does not support web storage`);
}
}
function getX(x, width) {
return x + (width * 0.5);
}
function isPlatformPresent(i) {
for (var j = 0; j < world.bodies.length; j++) {
if (world.bodies[j].label == ('platform#' + i)) {
return world.bodies[j];
}
}
return;
}
function getRandomDestination() {
var index = random(destinationsAvailable.length);
return destinationsAvailable.splice(index, 1)[0];
}
function titleCase(name) {
var splitStr = name.toString().toLowerCase().split(' ');
for (var i = 0; i < splitStr.length; i++) {
splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);
}
return splitStr.join(' ');
}