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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
'use strict';
'require baseclass';
'require rpc';
let callDawnGetNetwork, callDawnGetHearingMap, callHostHints;
callDawnGetNetwork = rpc.declare({
object: 'dawn',
method: 'get_network',
expect: { }
});
callDawnGetHearingMap = rpc.declare({
object: 'dawn',
method: 'get_hearing_map',
expect: { }
});
callHostHints = rpc.declare({
object: 'luci-rpc',
method: 'getHostHints',
expect: { }
});
function getAvailableText(available) {
return ( available ? _('Available') : _('Not available') );
}
function getYesText(yes) {
return ( yes ? _('Yes') : _('No') );
}
function getChannelFromFrequency(freq) {
if (freq <= 2400) {
return 0;
}
else if (freq == 2484) {
return 14;
}
else if (freq < 2484) {
return (freq - 2407) / 5;
}
else if (freq >= 4910 && freq <= 4980) {
return (freq - 4000) / 5;
}
else if (freq <= 45000) {
return (freq - 5000) / 5;
}
else if (freq >= 58320 && freq <= 64800) {
return (freq - 56160) / 2160;
}
else {
return 0;
}
}
function getFormattedNumber(num, decimals, divider = 1) {
return (num/divider).toFixed(decimals);
}
function getHostnameFromMAC(hosthints, mac) {
return ( hosthints[mac] && hosthints[mac].name ? hosthints[mac].name + ' (' + mac + ')' : mac);
}
return L.Class.extend({
callDawnGetNetwork: callDawnGetNetwork,
callDawnGetHearingMap: callDawnGetHearingMap,
callHostHints: callHostHints,
getAvailableText: getAvailableText,
getYesText: getYesText,
getChannelFromFrequency: getChannelFromFrequency,
getFormattedNumber: getFormattedNumber,
getHostnameFromMAC: getHostnameFromMAC
});
|