mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 08:26:16 -04:00
socket.io: Factor out client connection logic
This commit is contained in:
parent
7eb0f996c3
commit
303964c51e
8 changed files with 44 additions and 38 deletions
|
@ -1,16 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
$(document).ready(() => {
|
||||
const loc = document.location;
|
||||
const port = loc.port === '' ? (loc.protocol === 'https:' ? 443 : 80) : loc.port;
|
||||
const url = `${loc.protocol}//${loc.hostname}:${port}/`;
|
||||
const pathComponents = location.pathname.split('/');
|
||||
// Strip admin/plugins
|
||||
const baseURL = `${pathComponents.slice(0, pathComponents.length - 2).join('/')}/`;
|
||||
/* global socketio */
|
||||
|
||||
// connect
|
||||
const room = `${url}settings`;
|
||||
const socket = io.connect(room, {path: `${baseURL}socket.io`});
|
||||
$(document).ready(() => {
|
||||
const socket = socketio.connect('..', '/settings');
|
||||
|
||||
socket.on('settings', (settings) => {
|
||||
/* Check whether the settings.json is authorized to be viewed */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue