Repository navigation
Expand file tree
/
Copy pathMFAController.js
More file actions
117 lines (110 loc) · 4.4 KB
/
Copy pathMFAController.js
File metadata and controls
117 lines (110 loc) · 4.4 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
function FBAview (formId, rxnId, geneId, cpdId, mfaComponentId) {
var MFAviewIds = new Array();'FBAview','4_tab_1','4_tab_4','4_tab_2',''
var MFAerrorIds = new Array();
$('#' + formId + ' input').each(function() {
if($(this).attr('checked')) {
if($(this).hasClass('noGrowth')) {
MFAerrorIds.push($(this).attr('value'));
} else {
MFAviewIds.push($(this).attr('value'));
}
}
});
var RunIds = new Array();
var Models = new Array();
// SplitMFAviewIds a MODEL,RUN_ID into [MODEL] and [RUN_ID]
for(var i=0; i < MFAviewIds.length; i++) {
var tmp = new Array();
var tmp = MFAviewIds[i].split('_');
if(tmp.length != 2) { console.log("Invalid runId passed: " + MFAviewIds[i]); }
Models.push(tmp[0]);
RunIds.push(MFAviewIds[i]);
}
// Compare current models to selected.
var CurrentModels = new Array();
CurrentModels = $('#model').val().split(',');
var needToReload = 0;
if(CurrentModels.length == Models.length ) {
for( var i=0; i < Models.length; i++) {
var noneFound = 1;
for( var j=0; j < CurrentModels.length; j++) {
if(CurrentModels[j] == Models[i]) {
noneFound = 0;
}
}
if ( noneFound ) {
needToReload = 1;
break;
}
}
} else { needToReload = 1; }
needToReload = 1;//Seems to be a bug with the code when the page does not reload, so we're always going to reload until this is fixed
if(needToReload) {
// If there is a difference reload whole page...
var cgi = 'fluxIds=' + RunIds.join(',') + '&model=' + Models.join(',') + '&tab=1';
execute_ajax("output","content", cgi, "Loading fluxes for selected models...",0,"post_hook");
} else {
// Otherwise just reload the tables...
var cgi = 'fluxIds=' + RunIds.join(',') + '&models=' + Models.join(',');
var rxnParts = rxnId.split('_');
var ajaxArray = ['output', rxnId, cgi, 'ReactionTable|rxnTbl'];
FBAchangeTabViewAjax (rxnParts[0], rxnParts[2], ajaxArray);
}
if(MFAerrorIds.length == 1) {
alert("You cannot view fluxes on simulations that did not grow. " + MFAerrorIds.length + " simulation will not be shown.");
}
if(MFAerrorIds.length > 1) {
alert("You cannot view fluxes on simulations that did not grow. " + MFAerrorIds.length + " simulations will not be shown.");
}
}
function FBAdelete ( formId ) {
var fluxIds = new Array();
$('#' + formId + ' input').each(function() {
if($(this).attr('checked')) {
fluxIds.push($(this).attr('value'));
}
});
var fluxCgi = 'fluxIds=' + fluxIds.join(',');
execute_ajax('delete_results', 'fbaResultsTable', fluxCgi, 'Loading...', 0, 'post_hook', 'MFBAController|mfba_controller');
}
function FBArun ( formId ) {
var form = document.getElementById(formId);
var media = form.media.value;
var model = modelIds.join(',');
FBAloadMissingTabs(0,4,'fbaResultsTable', 20, function() {
execute_ajax('FBArun', 'fbaResultsTable', "media="+ media + "&model=" + model,
'Loading...', 0, 'post_hook', 'MFBAController|mfba_controller');
});
}
function FBAloadMissingTabs (tabViewerId, tabId, tabContentId, maxWaitTime, postHook) {
tab_view_select(tabViewerId, tabId);
FBAwaitForMissingContent(tabContentId, maxWaitTime, postHook);
}
function FBAwaitForMissingContent (contentId, maxWaitTime, postHook) {
var waitTime = 0;
var done = 0;
var waitIntervalId = setInterval(function () {
if (document.getElementById(contentId)) {
done = 1;
postHook();
} else {
waitTime += 0.5;
}
if (waitTime > maxWaitTime || done) {
clearInterval(waitIntervalId);
}
}, 500);
}
function FBAchangeTabViewAjax (tabViewId, tabId, ajaxSetupArray) {
tab_view_select(tabViewId, tabId);
var div = $('#' + tabViewId + "_content_" + tabId);
var ajaxDiv = $('#' + tabViewId + "_tabajax_" + tabId);
if(div && ajaxDiv) {
var newTabAjax = [0];
newTabAjax = newTabAjax.concat(ajaxSetupArray);
ajaxDiv.attr('value', newTabAjax.join(';'));
}
if(div && div.hasClass('tab_view_content_selected')) {
tab_view_select(tabViewId, tabId);
}
}