10 distributed under the License is distributed on an "AS IS" BASIS, |
10 distributed under the License is distributed on an "AS IS" BASIS, |
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 See the License for the specific language governing permissions and |
12 See the License for the specific language governing permissions and |
13 limitations under the License. |
13 limitations under the License. |
14 {% endcomment %} |
14 {% endcomment %} |
15 {% block scripts %} |
|
16 <script type="text/javascript" src="/jquery/jquery-progressbar.js"></script> |
|
17 <script type="text/javascript"> |
|
18 $(document).ready(function() { |
|
19 $("#applications_progress_bar").progressBar({showText: false}); |
|
20 }); |
|
21 |
15 |
22 function acceptOrgInit() { |
|
23 $("#acceptance_text").fadeOut("slow", |
|
24 function() { |
|
25 $("#applications_progress_bar").fadeIn("slow"); |
|
26 } |
|
27 ); |
|
28 $.getJSON("{{ bulk_accept_link|safe }}", |
|
29 function(data){ |
|
30 setTimeout(function(){acceptOrg(data)}, 0); |
|
31 } |
|
32 ); |
|
33 } |
|
34 |
|
35 function acceptOrg(accepted_applications) { |
|
36 var application_index = 0, max_applications=accepted_applications.applications.length; |
|
37 for (application_index; application_index<max_applications; application_index++) { |
|
38 // regular expression to find a valid scope path inside matching parenthesis |
|
39 var re = /\((\w*)\)/; |
|
40 var scope_path = accepted_applications.link.match(re)[1]; |
|
41 // the URL is obtained by using the scope path found in the matching parenthesis |
|
42 var url_to_call = accepted_applications.link.replace(re,eval("accepted_applications.applications[application_index]."+scope_path)); |
|
43 // now we can call the URL found |
|
44 $.ajax({ |
|
45 async: false, |
|
46 url: url_to_call, |
|
47 timeout: 10000, |
|
48 complete: function(data) { |
|
49 if (data) { |
|
50 // update progress bar percentage and description |
|
51 var percentage = Math.floor(100 * (application_index+1) / (accepted_applications.nr_applications)); |
|
52 $("#description_progressbar").html(" Processed application "+accepted_applications.applications[application_index].name+" ("+(application_index+1)+"/"+accepted_applications.nr_applications+")"); |
|
53 $("#applications_progress_bar").progressBar(percentage); |
|
54 } |
|
55 } |
|
56 }); |
|
57 } |
|
58 // tell the user we are done |
|
59 $("#description_done").html(" <strong>Done!</strong>"); |
|
60 |
|
61 } |
|
62 </script> |
|
63 {% endblock %} |
|
64 {% block body %} |
16 {% block body %} |
65 <span id="acceptance_text">If you want to accept all pre-accepted organizations please <button id="button_accept" onclick="javascript:acceptOrgInit();">click here</button></span><span class="progressBar" style="display:none;" id="applications_progress_bar"></span><span id="description_progressbar"></span><span id="description_done"></span> |
17 <span id="acceptance_text">If you want to accept all pre-accepted organizations please <button id="button_accept" onclick="javascript:acceptOrgInit();">click here</button></span><span class="progressBar" style="display:none;" id="applications_progress_bar"></span><span id="description_progressbar"></span><span id="description_done"></span> |
66 {{ block.super}} |
18 {{ block.super}} |
|
19 |
67 {% endblock %} |
20 {% endblock %} |