/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
83.2.12 by elof.bigestans at gmail
* Merged trunk
1
$(document).ready(function() {
2
3
	/* 
4
	 * Binds password hint button in login form to display correct password hint 
5
	 */
6
	$("#login .hint").click(function(e) {
7
		e.preventDefault();
8
		e.stopPropagation();
9
10
		// If username field is empty, inform user and exit function
11
		var uname = $("#login #username").val();
12
		if(uname == "") {
13
			alert("You have to enter a username to receive a password hint");
14
			return;
15
		}
16
17
		// POST username to the function /ajax/pwdhint which returns a json object with password hint
18
		$.post(
19
			// Replace with final production URL!!!
20
			"http://webblabb.iki.his.se/imp/elof-bigestans/pvp/codeigniter/ajax/pwdhint",
21
22
			// Data sent through POST
23
			{ username: uname },
24
25
			// Callback function
26
			function(data) {
27
				var result = $.parseJSON(data)["hint"];
28
29
				// result["hint"] is either a boolean false or a string containing the hint
30
				if(result === false) {
31
					$("#hinttext").html('<p class="error">No password hint available</p>');
32
				} else {
33
					$("#hinttext").html('<p>Hint: ' + result + '</p>');
34
				}
35
36
				$("#login").toggleClass("expanded");
37
				$("#hinttext").toggle();
38
39
			}
40
		); // End $.post {}
41
42
	}); // End $.click {}
43
44
}); // End $.ready {}