forked from binary-com/binary-static
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatforms.js
More file actions
58 lines (54 loc) · 1.89 KB
/
platforms.js
File metadata and controls
58 lines (54 loc) · 1.89 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const BinarySocket = require('../../app/base/socket');
const isIndonesia = require('../../app/common/country_base').isIndonesia;
const getElementById = require('../../_common/common_functions').getElementById;
const TabSelector = require('../../_common/tab_selector');
const isBinaryApp = require('../../config').isBinaryApp;
const os_list = [
{
name : 'mac',
url_test: /\.dmg$/,
},
{
name : 'windows',
url_test: /\.exe$/,
},
// {
// name : 'linux',
// url_test: /x86_64\.AppImage$/,
// }
];
const Platforms = (() => {
const onLoad = () => {
const staticFull = getElementById('static_full');
const loadingImage = getElementById('loading_image');
BinarySocket.wait('authorize').then(() => {
staticFull.setVisibility(1);
loadingImage.setVisibility(0);
});
BinarySocket.wait('website_status').then(() => {
$('.desktop-app').setVisibility(isIndonesia() && !isBinaryApp());
});
TabSelector.onLoad();
$.getJSON('https://api.github.com/repos/binary-com/binary-desktop-installers/releases/latest', (data = { assets: [] }) => {
data.assets.some((asset) => {
if (os_list.every(os => os.download_url)) {
return true;
}
os_list.forEach(os => {
if (!os.download_url && os.url_test.test(asset.browser_download_url)) {
os.download_url = asset.browser_download_url;
}
});
return false;
});
os_list.forEach(os => {
const el_button = getElementById(`app_${os.name}`);
el_button.setAttribute('href', os.download_url);
});
});
};
return {
onLoad,
};
})();
module.exports = Platforms;