Files: d6b80ccf3b7cdf17831fe84ad7e1811bd6a6cbd5 / config.js
699 bytesRaw
1 | var http = require('http') |
2 | |
3 | module.exports = function () { |
4 | var host = window.location.origin |
5 | |
6 | function getConfig () { |
7 | http.get(host + '/get-config', function (res) { |
8 | res.on('data', function (data, remote) { |
9 | var config = data |
10 | localStorage[host] = config |
11 | }) |
12 | }) |
13 | } |
14 | |
15 | if (localStorage[host]) { |
16 | var config = JSON.parse(localStorage[host]) |
17 | getConfig() |
18 | } else { |
19 | getConfig() |
20 | setTimeout(function () { |
21 | location.reload() |
22 | }, 1000) |
23 | } |
24 | |
25 | config.blobsUrl = host + '/blobs/get/' |
26 | config.emojiUrl = host + '/img/emoji/' |
27 | |
28 | if (config.ws.remote) |
29 | config.remote = config.ws.remote |
30 | else |
31 | config.remote = config.address |
32 | |
33 | return config |
34 | } |
35 |
Built with git-ssb-web