6
6
/* Makes the bannermenu scrollable horizontally but not vertically */
7
7
$('#bannerBody').scrollToFixed();
9
$("#dropdownUserMenu").click(function(e) {
9
13
/* Sets the click-function for the usermenubutton */
10
14
$('#bannerUserMenuButton').click(function(e){
12
16
$.get('ajax/isLoggedIn', function(response) {
13
17
if(response == 'yes') {
14
18
// If the user is logged in and the usermenu-div is hidden it's shown.
15
if($('#dropdownUserMenu').is(':hidden')) {
16
19
// TODO: Secure that the courseblock-div is hidden when the usermenu-div is oppened.
18
21
if($('#dropdownMenuCourseBlock').is(':visible')) {
21
24
$('#dropdownUserMenu').load('bannermenu.php #dropdownUserMenu');
23
$('#dropdownUserMenu').show();
26
//$("#dropdownMenuCourseBlock").hide();
25
27
// If the user is logged in and the usermenu-div is shown it's hidden.
27
$('#dropdownUserMenu').hide();
28
$('#dropdownMenuCourseBlock').hide();
29
$('#dropdownUserMenu').toggle();
31
33
// If the user is not logged in and the popup-div is hidden it's filled and shown.
32
34
if($('#popup').is(':hidden')) {
33
35
$('#popup').load('ajax/popup/login', function(){
36
$('#popup').show().click(function(e){e.stopPropagation();});
35
37
$("#popup .hint").click(loginHint);
38
$("#popup #username").focus().keydown(function() {
39
$("#popup .hint").addClass("available");
41
$("#popup form").submit(loginSubmit);
38
44
// If the user is not logged in and the popup-div shows it's hidden.
b'\\ No newline at end of file'
68
$("#dropdownMenuLogout").click(function(e) {
70
window.location.href = "./start/logout";
73
$("html").click(function(e) {
75
$("#dropdownUserMenu").hide();
80
function loginSubmit(e) {
84
var un = $(this).find("#username").val();
85
var pw = $(this).find("#password").val();
89
{ username: un, password: pw},
92
window.location.href ="./cms";
94
if($("#popup .popup").hasClass("error")) {
95
$("#popup .popup form .errorContainer").html('Error! '+data+' Please try again.');
97
$("#popup .popup").addClass("error");
98
$("#popup .popup form").prepend('<div class="errorContainer">Error! '+data+' Please try again. </div>');
105
function loginHint(e) {
109
// If username field is empty, inform user and exit function
110
var uname = $("#login #username").val();
115
// POST username to the function /ajax/pwdhint which returns a json object with password hint
117
// Replace with final production URL!!!
120
// Data sent through POST
125
var result = $.parseJSON(data)["hint"];
127
// result["hint"] is either a boolean false or a string containing the hint
128
if(result === false) {
129
$("#hinttext").html('<p class="error">No password hint available</p>');
131
$("#hinttext").html('<p>Hint: ' + result + '</p>');
134
$("#login").toggleClass("expanded");
135
$("#hinttext").toggle();
b'\\ No newline at end of file'