BUG FIX: Menu now saves the cookie again #174

Merged
11291680 merged 1 commits from lars into master 2017-02-01 13:10:30 +01:00
6 changed files with 57 additions and 38 deletions

View File

@@ -17,12 +17,10 @@ $(window).on("load", function () {
because serialize doesn't take submit values. */ because serialize doesn't take submit values. */
$('#admin-batchform > button').click(function () { $('#admin-batchform > button').click(function () {
$('#batchinput').prop('value', $(this).prop('value')); $('#batchinput').prop('value', $(this).prop('value'));
console.log($('#batchinput').prop('value'));
}); });
$('#admin-groupbatchform > button').click(function () { $('#admin-groupbatchform > button').click(function () {
$('#groupbatchinput').prop('value', $(this).prop('value')); $('#groupbatchinput').prop('value', $(this).prop('value'));
console.log($('#batchinput').prop('value'));
}); });
}); });
@@ -67,7 +65,6 @@ function searchFromOne() {
} }
function adminSearch() { function adminSearch() {
console.log($("#admin-searchform").serialize());
$.post( $.post(
"API/adminSearchUsers.php", "API/adminSearchUsers.php",
$("#admin-searchform").serialize() $("#admin-searchform").serialize()

View File

@@ -49,7 +49,6 @@ function addMessages(messages) {
// Initialize message variables // Initialize message variables
var thisDate = new Date(messages[i].creationdate.replace(/ /,"T")); var thisDate = new Date(messages[i].creationdate.replace(/ /,"T"));
var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes(); var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes();
console.log(thisDate);
var type; var type;
thisDate.setHours(0,0,0,0); thisDate.setHours(0,0,0,0);

View File

@@ -25,6 +25,7 @@ function placeGroupButtons() {
.done(function() { .done(function() {
$buttonContainer.children().remove(); $buttonContainer.children().remove();
placeGroupButtons(); placeGroupButtons();
updateMenus();
}).fail(function() { }).fail(function() {
}); });
}); });

View File

@@ -30,11 +30,23 @@ $(document).ready(function() {
// Change menu cookie to close // Change menu cookie to close
document.cookie = "menu=closed; path=/"; document.cookie = "menu=closed; path=/";
} }
}); });
if (getCookie("menu") == "open") { if (getCookie("menu") == "open") {
$("#own-profile-picture").click(); // Make the menu visible and move the content to the left.
$(".modal").width("calc(100% - 512px)");
$(".content").css("margin-right", "256px");
$("#notification-center").css("right", "0px");
$("#notification-center").css("display", "block");
$("#contact-menu").css("display", "block");
// Add cookie so the menu stays open on other pages
if (window.innerWidth > 1080) {
$("#chat-history").width("calc(100% - 587px)");
document.cookie = "menu=open; path=/";
} else {
document.cookie = "menu=closed; path=/";
}
} }
}); });

View File

@@ -53,6 +53,7 @@ function editFriendship(userID, value) {
$.post("API/editFriendship.php", { usr: userID, action: value }) $.post("API/editFriendship.php", { usr: userID, action: value })
.done(function() { .done(function() {
placeFriendButtons(); placeFriendButtons();
updateMenus();
}); });
} }

View File

@@ -2,24 +2,29 @@ var menuFriendsData;
var menuGroupsData; var menuGroupsData;
var notificationMessagesData; var notificationMessagesData;
var notificationRequestsData; var notificationRequestsData;
var updatingMenus = 0;
// On document load, load menus and loops loading menus every 10 seconds.
$(document).ready(function() { $(document).ready(function() {
updatingMenus = 4;
loadMenuFriends(5); loadMenuFriends(5);
loadNotificationFriends(); loadNotificationFriends();
loadUnreadMessages(); loadUnreadMessages();
loadMenuGroups(); loadMenuGroups();
setInterval(updateMenus, 3000); setInterval(updateMenus, 10000);
}); });
// Update the menu and notification items. // Update the menu and notification items.
function updateMenus() { function updateMenus() {
if (updatingMenus <= 0) {
updatingMenus = 4;
loadMenuFriends(5); loadMenuFriends(5);
loadNotificationFriends(); loadNotificationFriends();
loadUnreadMessages(); loadUnreadMessages();
loadMenuGroups(); loadMenuGroups();
} }
}
// Get, every 3 seconds, the friends and insert them in the menu. // Get, every 3 seconds, the friends and insert them in the menu.
@@ -38,6 +43,7 @@ function loadMenuFriends(limit) {
$("#friends-menu-section").hide(); $("#friends-menu-section").hide();
} }
} }
updatingMenus --;
}); });
} }
@@ -57,6 +63,7 @@ function loadMenuGroups() {
$("#groups-menu-section").hide(); $("#groups-menu-section").hide();
} }
} }
updatingMenus --;
}); });
} }
@@ -73,6 +80,7 @@ function loadNotificationFriends() {
$("#friend-request-section").hide(); $("#friend-request-section").hide();
} }
} }
updatingMenus --;
}); });
} }
@@ -89,5 +97,6 @@ function loadUnreadMessages() {
$("#unread-messages-section").hide(); $("#unread-messages-section").hide();
} }
} }
updatingMenus --;
}); });
} }