project_content.js
2.68 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var processingTree = false;
jQuery(function (){
jQuery('.source-tree-link').live("click", reloadModule);
jQuery('[data-show]').live("click", toggle_mezuro);
showLoadingProcess(true);
showProjectContent();
});
function showProjectContent() {
callAction('project_state', {}, showProjectContentFor);
}
function toggle_mezuro(){
var element = jQuery(this).attr('data-show');
jQuery(element).toggle();
return false;
}
function reloadModule(){
var module_name = jQuery(this).attr('data-module-name');
showLoadingProcess(false);
processingTree = true;
callAction('project_tree', {module_name: module_name }, showProjectTree);
callAction('module_result', {module_name: module_name}, showModuleResult);
return false;
}
function reloadProject(date){
callAction('project_result', {date: date}, showProjectResult);
callAction('project_tree', {date: date}, showProjectTree);
callAction('module_result', {date: date}, showModuleResult);
}
function showProjectContentFor(state){
if (state == 'ERROR')
callAction('project_error', {}, showProjectResult);
else if (state == 'READY') {
callAction('project_result', {}, showProjectResult);
callAction('project_tree', {}, showProjectTree);
var project_name = jQuery("#project-result").attr('data-project-name');
callAction('module_result', {module_name: project_name}, showModuleResult);
}
else if (state.endsWith("ING"))
showProjectContentAfter(20);
}
function showProjectContentAfter(seconds){
if (seconds > 0){
setTimeout(function() { showProjectContentAfter(seconds - 10);}, 10000);
} else {
showProjectContent();
}
}
function showProjectResult(content) {
jQuery('#project-result').html(content);
}
function showProjectTree(content){
processingTree = false;
jQuery('#project-tree').html(content);
return false;
}
function showModuleResult(content){
if (processingTree != true){
jQuery('#module-result').html(content);
}
return false;
}
function callAction(action, params, callback){
var profile = projectContentData('profile');
var content = projectContentData('content');
var endpoint = '/profile/' + profile + '/plugins/mezuro/' + action + '/' + content;
jQuery.get(endpoint, params, callback);
}
function projectContentData(data){
return jQuery('#project-result').attr('data-' + data);
}
function showLoadingProcess(firstLoad){
if(firstLoad)
showProjectResult("<img src='/images/loading-small.gif'/>");
showProjectTree("<img src='/images/loading-small.gif'/>");
showModuleResult("<img src='/images/loading-small.gif'/>");
}
function sourceNodeToggle(id){
var suffixes = ['_hidden', '_plus', '_minus'];
for (var i in suffixes)
jQuery('#' + id + suffixes[i]).toggle();
}