/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/js/header.js

  • Committer: b11johgu
  • Date: 2013-05-14 12:30:38 UTC
  • mto: This revision was merged to the branch mainline in revision 65.
  • Revision ID: b11johgu@student.his.se-20130514123038-rthxj3f34o32gpxy
ExamplesController:
- Added expand/collapse arrows for categories/subcategories.
- Added category positioning (incomplete).

more general changes made.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
        $('#popoutMenu').hide();
9
9
        $('#passwordChanger').hide();
10
10
 
11
 
 
12
11
        /* Check courses in expanded menu */
13
12
        $('li[class="expanded"]').click(function(){
14
13
                if($(this).hasClass('checkedCourse')){
105
104
        }
106
105
}
107
106
 
108
 
 
109
 
 
110
 
/* Password validation */
111
 
var acceptedNewPwd = false;
112
 
var acceptedRepeatedPwd = false;
113
 
 
114
 
function emptyField(inputId){
115
 
        var id = document.getElementById(inputId);
116
 
        if(id.value.match(/^\s*$/)){
117
 
                return true;
118
 
        }
119
 
        else return false;
120
 
}
121
 
 
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 _]*$/)){
126
 
                return true;
127
 
        }
128
 
        else return false;
129
 
}
130
 
 
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){
135
 
                return true;
136
 
        }
137
 
        else return false;
138
 
}
139
 
 
140
 
/* Checks if newPwd and repeatPwd are the same */
141
 
function pwdMatch(){
142
 
        var firstPwd = document.getElementById("newPwd").value;
143
 
        var secondPwd = document.getElementById("repeatPwd").value;
144
 
        if(firstPwd == secondPwd){
145
 
                return true;
146
 
        }
147
 
        else return false;
148
 
}
149
 
 
150
 
function validNewPwd(){
151
 
        var empty = emptyField("newPwd");
152
 
        var validchar = pwdValidCharacters("newPwd");
153
 
        var minimumchar = pwdMininumValue("newPwd");
154
 
 
155
 
        if (empty==false && validchar==true && minimumchar==true){
156
 
                document.getElementById("newPwd").className="Valid";
157
 
                $('.errorMessage[name="newPwd"]').animate({opacity:0}, 0);
158
 
                acceptedNewPwd=true;
159
 
        }
160
 
        else if(empty==true){
161
 
                acceptedNewPwd=false;
162
 
                document.getElementById("newPwd").className="";
163
 
                $('.errorMessage[name="newPwd"]').animate({opacity:0}, 0);
164
 
        }
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;
169
 
        }
170
 
}
171
 
 
172
 
function validRepeatedPwd(){
173
 
        var empty = emptyField("repeatPwd");
174
 
        var match = pwdMatch("repeatPwd");
175
 
        
176
 
        if(validNewPwd){
177
 
                if(empty==true){
178
 
                        document.getElementById("repeatPwd").className="";
179
 
                        $('.errorMessage[name="repeatPwd"]').animate({opacity:0}, 0);
180
 
                        acceptedRepeatedPwd=false;
181
 
                }
182
 
                else if(empty==false && match==false){
183
 
                        document.getElementById("repeatPwd").className="notValid";
184
 
                        $('.errorMessage[name="repeatPwd"]').animate({opacity:1}, 0);
185
 
                        acceptedRepeatedPwd=false;
186
 
                }
187
 
                else if(empty==false && match==true){
188
 
                        document.getElementById("repeatPwd").className="Valid";
189
 
                        $('.errorMessage[name="repeatPwd"]').animate({opacity:0}, 0);
190
 
                        acceptedRepeatedPwd=true;
191
 
                }
192
 
        }
193
 
        else{
194
 
                document.getElementById("repeatPwd").className="";
195
 
        }
196
 
}
197
 
 
198
 
/* baseURL skickas med som parameter */
199
 
function confirm(baseURL){
200
 
        if(acceptedNewPwd && acceptedRepeatedPwd){
201
 
                changePwd(baseURL);
202
 
        }
203
 
        else{
204
 
                alert("WRONG WRONG WRONG!! FILL OUT THE FORM AGAIN YOU FKIN PIECE OF SHIT!");
205
 
                return false;
206
 
        }
207
 
}
208
 
 
209
 
function changePwd(baseURL)
210
 
{
211
 
        var currentPwd = document.getElementById("currentPwd").value;
212
 
        var newPwd = document.getElementById("newPwd").value;
213
 
        var hintPwd = document.getElementById("hintPwd").value;
214
 
 
215
 
        $.ajax({
216
 
                type: 'POST',
217
 
                url: baseURL+'ajax/pwdchange',
218
 
                data: { 
219
 
                        currentPwd : currentPwd,
220
 
                        newPwd : newPwd,
221
 
                        hintPwd : hintPwd
222
 
                },
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({
230
 
                                opacity:1}, 400);
231
 
                                $('#changePassword')[0].reset();
232
 
                        }
233
 
                        else{
234
 
                                alert('Wrong password!');
235
 
                        }
236
 
                }
237
 
        });
238
 
}
 
 
b'\\ No newline at end of file'