var LoginPage = { onPageShow: function () { Dashboard.showLoadingMsg(); ApiClient.getAllUsers().done(LoginPage.loadUserList); }, getLastSeenText: function (lastActivityDate) { if (!lastActivityDate) { return ""; } return "Last seen " + humane_date(lastActivityDate); }, getImagePath: function (user) { if (!user.PrimaryImageTag) { return "css/images/logindefault.png"; } return ApiClient.getUserImageUrl(user.Id, { width: 240, tag: user.PrimaryImageTag, type: "Primary" }); }, authenticateUserLink: function (link) { LoginPage.authenticateUser(link.getAttribute('data-username'), link.getAttribute('data-userid')); }, authenticateUser: function (username, userId, password) { Dashboard.showLoadingMsg(); ApiClient.authenticateUser(userId, password).done(function () { Dashboard.setCurrentUser(userId); window.location = "index.html?u=" + userId; }).fail(function () { Dashboard.hideLoadingMsg(); setTimeout(function () { Dashboard.showError("Invalid user or password."); }, 300); }); }, loadUserList: function (users) { var html = ""; for (var i = 0, length = users.length; i < length; i++) { var user = users[i]; var linkId = "lnkUser" + i; var background = Dashboard.getRandomMetroColor(); html += '