6
$(document).ready(function(){
7
$('#expandedCourses').hide();
8
$('#popoutMenu').hide();
9
$('#passwordChanger').hide();
12
/* Check courses in expanded menu */
13
$('li[class="expanded"]').click(function(){
14
if($(this).hasClass('checkedCourse')){
15
$(this).removeClass('checkedCourse');
18
$(this).addClass("checkedCourse");
22
/* Blurs body and opens password changer */
23
$('li[name="changePwd"]').click(function(e){
25
$('#popoutMenu').stop(false, false).slideUp(300);
27
$('body *').not('#passwordChanger, #passwordChanger *').animate({
29
$('#passwordChanger').fadeIn(300);
30
$('#passwordChanger').css('z-index', 3000);
33
$('body').click(function(e){
34
$('#formContainer').fadeOut(300);
35
$('#passwordChanger').fadeOut(300);
38
$('#changePassword')[0].reset();
41
$('#passwordChanger').click(function(e){
45
$('#formContainer').click(function(e){
49
$('#popoutLink').click(function(e){
51
$('#popoutMenu').stop(false, true).slideDown(300);
54
// FIXA SÅ MENYN INTE KOMMER UPP IGEN
56
else if(popoutMenu==1){
57
$('#popoutMenu').stop(false, false).slideUp(300);
63
$('#loginLink').click(function(e){
64
var target = $('#formContainer');
65
if(target.is(":hidden")){
67
$('#username').focus();
77
window.onkeyup = function(event){
78
if(event.keyCode==27){
79
$('#formContainer').fadeOut(300);
80
$('#passwordChanger').fadeOut(300);
83
$('#changePassword')[0].reset();
87
/* Closing password changer and reactivates body */
88
function cancelPasswordChange(){
89
$('#passwordChanger').fadeOut(300);
92
$('#changePassword')[0].reset();
96
/* Expand/Collapse courses in popout menu */
97
function expandCourses(){
98
if(expandedCourses==0){
99
$('#expandedCourses').stop(false, true).slideDown(300);
102
else if(expandedCourses==1){
103
$('#expandedCourses').stop(false, false).slideUp(300);
110
/* Password validation */
111
var acceptedNewPwd = false;
112
var acceptedRepeatedPwd = false;
114
function emptyField(inputId){
115
var id = document.getElementById(inputId);
116
if(id.value.match(/^\s*$/)){
122
/* Checks input field for invalid characters */
123
function pwdValidCharacters(inputId){
124
var id = document.getElementById(inputId);
125
if(id.value.match(/^[A-Öa-ö0-9 _]*[A-Öa-ö0-9][A-Öa-ö0-9 _]*$/)){
131
/* Checks input field for minimum amount of characters(6) */
132
function pwdMininumValue(inputId){
133
var id = document.getElementById(inputId);
134
if(id.value.length > 5){
140
/* Checks if newPwd and repeatPwd are the same */
142
var firstPwd = document.getElementById("newPwd").value;
143
var secondPwd = document.getElementById("repeatPwd").value;
144
if(firstPwd == secondPwd){
150
function validNewPwd(){
151
var empty = emptyField("newPwd");
152
var validchar = pwdValidCharacters("newPwd");
153
var minimumchar = pwdMininumValue("newPwd");
155
if (empty==false && validchar==true && minimumchar==true){
156
document.getElementById("newPwd").className="Valid";
157
$('.errorMessage[name="newPwd"]').animate({opacity:0}, 0);
160
else if(empty==true){
161
acceptedNewPwd=false;
162
document.getElementById("newPwd").className="";
163
$('.errorMessage[name="newPwd"]').animate({opacity:0}, 0);
165
else if(empty==false && validchar==false || minimumchar==false){
166
document.getElementById("newPwd").className="notValid";
167
$('.errorMessage[name="newPwd"]').animate({opacity:1}, 0);
168
acceptedNewPwd=false;
172
function validRepeatedPwd(){
173
var empty = emptyField("repeatPwd");
174
var match = pwdMatch("repeatPwd");
178
document.getElementById("repeatPwd").className="";
179
$('.errorMessage[name="repeatPwd"]').animate({opacity:0}, 0);
180
acceptedRepeatedPwd=false;
182
else if(empty==false && match==false){
183
document.getElementById("repeatPwd").className="notValid";
184
$('.errorMessage[name="repeatPwd"]').animate({opacity:1}, 0);
185
acceptedRepeatedPwd=false;
187
else if(empty==false && match==true){
188
document.getElementById("repeatPwd").className="Valid";
189
$('.errorMessage[name="repeatPwd"]').animate({opacity:0}, 0);
190
acceptedRepeatedPwd=true;
194
document.getElementById("repeatPwd").className="";
198
/* baseURL skickas med som parameter */
199
function confirm(baseURL){
200
if(acceptedNewPwd && acceptedRepeatedPwd){
204
alert("WRONG WRONG WRONG!! FILL OUT THE FORM AGAIN YOU FKIN PIECE OF SHIT!");
209
function changePwd(baseURL)
211
var currentPwd = document.getElementById("currentPwd").value;
212
var newPwd = document.getElementById("newPwd").value;
213
var hintPwd = document.getElementById("hintPwd").value;
217
url: baseURL+'ajax/pwdchange',
219
currentPwd : currentPwd,
223
success: function(result){
224
var resultObject = JSON.parse(result);
225
if(resultObject.status==true){
226
alert('Password change is successful!');
227
$('#formContainer').fadeOut(300);
228
$('#passwordChanger').fadeOut(300);
229
$('body *').animate({
231
$('#changePassword')[0].reset();
234
alert('Wrong password!');
b'\\ No newline at end of file'