cookies in separate file
This commit is contained in:
parent
eec1013c6c
commit
45902fd0f1
2 changed files with 11 additions and 12 deletions
10
public_html/js/cookies.js
Normal file
10
public_html/js/cookies.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
function getCookie(name) {//Code from OpenClassroom
|
||||||
|
nom = name + "=";
|
||||||
|
var liste = document.cookie.split (';');
|
||||||
|
for (var i = 0; i < liste.length; i++) {
|
||||||
|
var c = liste[i];
|
||||||
|
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
||||||
|
if (c.indexOf(nom) == 0) return c.substring(nom.length, c.length);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
|
@ -1,21 +1,10 @@
|
||||||
function CookiePseudo() {//Code from OpenClassroom
|
|
||||||
nom = "pseudo=";
|
|
||||||
var liste = document.cookie.split (';');
|
|
||||||
for (var i = 0; i < liste.length; i++) {
|
|
||||||
var c = liste[i];
|
|
||||||
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
||||||
if (c.indexOf(nom) == 0) return c.substring(nom.length, c.length);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let player = null;
|
let player = null;
|
||||||
let players = [];
|
let players = [];
|
||||||
let renderer = new Render("canvas");
|
let renderer = new Render("canvas");
|
||||||
let LB = new LeaderBoard("canvas");
|
let LB = new LeaderBoard("canvas");
|
||||||
let bulletSound = new Sound("./assets/sounds/shoot.mp3");
|
let bulletSound = new Sound("./assets/sounds/shoot.mp3");
|
||||||
let driftSound = new Sound("./assets/sounds/drift.mp3");
|
let driftSound = new Sound("./assets/sounds/drift.mp3");
|
||||||
let net = new Network("wss://ws.gta6.insat.fr:8080?name="+CookiePseudo());
|
let net = new Network("wss://ws.gta6.insat.fr:8080?name=" + getCookie("pseudo"));
|
||||||
let inp = new Input("canvas");
|
let inp = new Input("canvas");
|
||||||
let bullets = [];
|
let bullets = [];
|
||||||
let circles = [];
|
let circles = [];
|
||||||
|
|
Loading…
Reference in a new issue