dynamic.js
1.47 KB
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
45
46
47
48
49
50
51
function dynamic($) {
$.get(endpoint('project_state'), {}, select_project_partial);
}
function endpoint(action){
var profile = jQuery('#project-content').attr('data-profile');
var project = jQuery('#project-content').attr('data-content');
return '/profile/' + profile + '/plugins/mezuro/' + action + '/' + project;
}
function select_project_partial(state){
var action, callback = show_project_content;
if (state == 'ERROR')
action = 'project_error';
else if (state == 'READY')
action = 'project_result';
else {
// wait(10);
action = 'project_state';
callback = select_project_partial;
}
jQuery.get(endpoint(action), {}, callback);
}
//function wait(seconds){
// var remaining = seconds;
// while(remaining > 0){
// setTimeout(function() {
// jQuery('#project-content').html("Processing. Trying again in " + remaining + " seconds");
// }, 1000);
// remaining--;
// }
// jQuery('#project-content').html("Trying now...");
//}
function show_project_content(content){
jQuery('#project-content').html(content);
jQuery('.module-result-link').click(show_module_result);
return false;
}
function show_module_result(){
var module_name = jQuery(this).attr('data-module-name');
jQuery('#module-result').html("Loading results for " + module_name + "...");
jQuery.get(endpoint('module_result'), { module_name: module_name }, show_result_table);
return false;
}
function show_result_table(content){
jQuery('#module-result').html(content);
}