287c0ea6cb404d1240246442aa43093fde31fd3f
1 // Source: https://www.quirksmode.org/js/cookies.html
2 function setCookie(name
, value
)
5 date
.setTime(date
.getTime()+(183*24*60*60*1000)); //6 months
6 var expires
= "; expires="+date
.toGMTString();
7 document
.cookie
= name
+"="+value
+expires
+"; path=/";
10 function getCookie(name
, defaut
) {
11 var nameEQ
= name
+ "=";
12 var ca
= document
.cookie
.split(';');
13 for (var i
=0;i
< ca
.length
;i
++)
16 while (c
.charAt(0)==' ')
17 c
= c
.substring(1,c
.length
);
18 if (c
.indexOf(nameEQ
) == 0)
19 return c
.substring(nameEQ
.length
,c
.length
);
21 return defaut
; //cookie not found
24 // Random (enough) string for socket and game IDs
25 function getRandString()
27 return (Date
.now().toString(36) + Math
.random().toString(36).substr(2, 7))
31 // Used both on index and variant page, to switch language
32 function setLanguage(e
)
34 setCookie("lang", e
.target
.value
);
35 location
.reload(); //to include the right .pug file
38 // Shortcut for an often used click (on a modal)
39 function doClick(elemId
)
41 document
.getElementById(elemId
).click(); //or ".checked = true"
44 function translate(msg
)
46 return translations
[msg
];