-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (36 loc) · 1.02 KB
/
index.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
var settings = require('ep_etherpad-lite/node/utils/Settings');
// Get settings
exports.clientVars = function (hook, context, callback) {
var areParamsOk = settings.ep_solar ? true : false,
lat,
lon;
if (areParamsOk) {
lat = settings.ep_solar.lat;
lon = settings.ep_solar.lon;
areParamsOk =
typeof lat === 'number' &&
lat >= -90 &&
lat <= 90 &&
typeof lon === 'number' &&
lon >= -180 &&
lon <= 180
? true
: false;
if (areParamsOk === false) {
console.error(
'ep_solar.lat and ep_solar.lon must be in decimal degrees, latitude must be between -90 and 90 and longitude between -180 and 180.'
);
return callback({
ep_solar_settings: false,
});
} else {
// return the setting to the clientVars, sending the value
return callback({
lat: settings.ep_solar.lat,
lon: settings.ep_solar.lon,
});
}
} else {
console.error('You need to configure ep_solar in your settings.json!');
}
};