author | Sverre Rabbelier <srabbelier@gmail.com> |
Sun, 15 Feb 2009 20:25:35 +0000 | |
changeset 1356 | 32d8d83678cd |
child 1364 | b2709805fafe |
permissions | -rw-r--r-- |
1356
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
$(document).ready(function() { |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
$("#applications_progress_bar").progressBar({showText: false}); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
}); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
|
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
function acceptOrgInit() { |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
$("#acceptance_text").fadeOut("slow", |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
function() { |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
$("#applications_progress_bar").fadeIn("slow"); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
} |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
$.getJSON("{{ bulk_accept_link|safe }}", |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
function(data){ |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
setTimeout(function(){acceptOrg(data)}, 0); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
} |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
} |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
|
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
function acceptOrg(accepted_applications) { |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
var application_index = 0, max_applications=accepted_applications.applications.length; |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
for (application_index; application_index<max_applications; application_index++) { |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
// regular expression to find a valid scope path inside matching parenthesis |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
var re = /\((\w*)\)/; |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
var scope_path = accepted_applications.link.match(re)[1]; |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
// the URL is obtained by using the scope path found in the matching parenthesis |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
var url_to_call = accepted_applications.link.replace(re,eval("accepted_applications.applications[application_index]."+scope_path)); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
// now we can call the URL found |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
$.ajax({ |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
async: false, |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
url: url_to_call, |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
timeout: 10000, |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
complete: function(data) { |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
if (data) { |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
// update progress bar percentage and description |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
var percentage = Math.floor(100 * (application_index+1) / (accepted_applications.nr_applications)); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
$("#description_progressbar").html(" Processed application "+accepted_applications.applications[application_index].name+" ("+(application_index+1)+"/"+accepted_applications.nr_applications+")"); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
$("#applications_progress_bar").progressBar(percentage); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
} |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
} |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
39 |
}); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
} |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
// tell the user we are done |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
$("#description_done").html(" <strong>Done!</strong>"); |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
|
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
} |
32d8d83678cd
Make various JS methods into their own file
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |