/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
$(document).ready(function() {

	/* 
	 * Binds password hint button in login form to display correct password hint 
	 */
	$("#login .hint").click(function(e) {
		e.preventDefault();
		e.stopPropagation();

		// If username field is empty, inform user and exit function
		var uname = $("#login #username").val();
		if(uname == "") {
			alert("You have to enter a username to receive a password hint");
			return;
		}

		// POST username to the function /ajax/pwdhint which returns a json object with password hint
		$.post(
			// Replace with final production URL!!!
			"http://webblabb.iki.his.se/imp/elof-bigestans/pvp/codeigniter/ajax/pwdhint",

			// Data sent through POST
			{ username: uname },

			// Callback function
			function(data) {
				var result = $.parseJSON(data)["hint"];

				// result["hint"] is either a boolean false or a string containing the hint
				if(result === false) {
					$("#hinttext").html('<p class="error">No password hint available</p>');
				} else {
					$("#hinttext").html('<p>Hint: ' + result + '</p>');
				}

				$("#login").toggleClass("expanded");
				$("#hinttext").toggle();

			}
		); // End $.post {}

	}); // End $.click {}

}); // End $.ready {}