eb94f8ef49af8fc44b19e8917cd88a6ae06bb4ad
1const COOKIENAME = "settings";
2const COOKIEEXP = 365;
3
4function setCookie(cname, cvalue, exdays) {
5 var d = new Date();
6 d.setTime(d.getTime() + (exdays*24*60*60*1000));
7 var expires = "expires="+ d.toUTCString();
8 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
9}
10
11function getCookie(cname) {
12 var name = cname + "=";
13 var decodedCookie = decodeURIComponent(document.cookie);
14 var ca = decodedCookie.split(';');
15 for(var i = 0; i <ca.length; i++) {
16 var c = ca[i];
17 while (c.charAt(0) == ' ') {
18 c = c.substring(1);
19 }
20 if (c.indexOf(name) == 0) {
21 return c.substring(name.length, c.length);
22 }
23 }
24 return 0;
25}
26
27function saveSettings() {
28 settingsString = JSON.stringify({showcurrent: show_current.checked, shownext: show_next.checked, enable_shortcuts: shortcuts.checked});
29 setCookie(COOKIENAME, settingsString, COOKIEEXP);
30}
31
32function initSettings() {
33 if (getCookie(COOKIENAME) == 0) {
34 if (window.obssstudio) {
35 shortcuts.checked = False;
36 show_current.checked = False;
37 }
38 saveSettings()
39 } else {
40 cookie = JSON.parse(getCookie(COOKIENAME));
41 show_current.checked = cookie.showcurrent;
42 show_next.checked = cookie.shownext;
43 shortcuts.checked = cookie.enable_shortcuts;
44 sync_current();
45 sync_next();
46 }
47
48}
49