Save manu state with cookie

This commit is contained in:
Lars van Hijfte
2017-01-27 11:15:33 +01:00
parent f1bfc89e6a
commit cbff973b63
2 changed files with 21 additions and 1 deletions

View File

@@ -1,5 +1,4 @@
$(document).ready(function() {
// Toggle menu
$("#own-profile-picture, #open-notifications").click(function() {
if ($("#notification-center").css('right') == "-256px") {
@@ -8,12 +7,22 @@ $(document).ready(function() {
$(".modal").width("calc(100% - 512px)");
$(".content").css("margin-right", "256px");
$("#notification-center").css("right", "0px");
// Add cookie so the menu stays open on other pages
document.cookie = "menu=open; path=/";
} else {
// Make the menu invisible and move the content to the right.
$("#chat-history").width("calc(100% - 331px)");
$(".modal").width("calc(100% - 256px)");
$(".content").css("margin-right", "0px");
$("#notification-center").css("right", "-256px");
// Change menu cookie to close
document.cookie = "menu=closed; path=/";
}
});
if (getCookie("menu") == "open") {
$("#own-profile-picture").click();
}
});

View File

@@ -1,3 +1,14 @@
function getCookie(key) {
cookies = document.cookie.split("; ");
for (var i in cookies) {
cookie = cookies[i].split("=");
if (cookie[0] == key) {
return cookie[1];
}
}
return false;
}
function editFriendship(userID, value) {
$.post("API/editFriendship.php", { usr: userID, action: value })
.done(function() {