Modularize createUUID.

pull/25/head
Pontus Persson 2017-12-08 15:31:44 +01:00 committed by Pontus Alexander
parent 3231f4248a
commit ca640e39da
2 changed files with 10 additions and 10 deletions

9
client/random.js Normal file
View File

@ -0,0 +1,9 @@
// Taken from http://stackoverflow.com/a/105074/515584
// Strictly speaking, it's not a real UUID, but it gets the job done here
export function createUUID() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}

View File

@ -1,4 +1,5 @@
import { dataChannelConfig, peerConnectionConfig } from './config.js';
import { createUUID } from './random.js';
var localVideo;
var localStream;
@ -113,14 +114,4 @@ function errorHandler(error) {
console.log(error);
}
// Taken from http://stackoverflow.com/a/105074/515584
// Strictly speaking, it's not a real UUID, but it gets the job done here
function createUUID() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}
pageReady();