Files: d14ff6e799b8cbfb78471c09928129a03c48ad78 / config.js
655 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 | location.reload() |
21 | } |
22 | |
23 | config.blobsUrl = host + '/blobs/get/' |
24 | config.emojiUrl = host + '/img/emoji/' |
25 | |
26 | if (config.ws.remote) |
27 | config.remote = config.ws.remote |
28 | else |
29 | config.remote = config.address |
30 | |
31 | return config |
32 | } |
33 |
Built with git-ssb-web