mirror of https://github.com/PiyushXCoder/lupt.git
cookies
This commit is contained in:
parent
9333f398eb
commit
6587d92e5f
|
|
@ -273,6 +273,8 @@ function vayaktiList() {
|
|||
|
||||
function changeColor() {
|
||||
$('body').toggleClass('dark')
|
||||
if($('body').hasClass('dark')) setCookie('theme', 'dark', 30);
|
||||
else setCookie('theme', 'light', 30);
|
||||
$('#action_clip').addClass('is-hidden');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches || getCookie('theme') == 'dark') {
|
||||
$('body').toggleClass('dark');
|
||||
}
|
||||
|
||||
|
|
@ -47,3 +47,25 @@ $(document).ready(function() {
|
|||
|
||||
Images.setupImages();
|
||||
});
|
||||
|
||||
function setCookie(cname, cvalue, exdays) {
|
||||
var d = new Date();
|
||||
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
||||
var expires = "expires="+d.toUTCString();
|
||||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||||
}
|
||||
|
||||
function getCookie(cname) {
|
||||
var name = cname + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) == ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
if (c.indexOf(name) == 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
Loading…
Reference in New Issue