-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysbioLoadSim.html
138 lines (123 loc) · 4.11 KB
/
sysbioLoadSim.html
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<html>
<!-- Code grabs the model from ../models/ and sends it and sim info to the simulator. -->
<head>
</head>
<body>
<script type="text/javascript">
if (typeof window !== 'undefined') {
// Perform sessionStorage action
const item = sessionStorage.getItem('key')
}
var iframeSize = '';
</script>
<script type="text/javascript">
// This is the default data that needs to be populated.
var newModel = ""; // SBML model in XML format. Some ways of populating string listed below.
var newRT = ''; // Length of run
var newSS = ''; // integrator step size, thus 1000 points (10/0.010)
var staticRun = 'true'; // Display after all calculations are done.
var parSliders = ''; // param sliders, exact id match
var spPlot = ''; // Species to plot, exact id match
var yLabel = 'conc (uM)';
var xLabel = 'sec';
</script>
<script type="text/javascript">
async function loadInfo(newEventData) {
// can message back using event.source.postMessage(...)
var newURL = '';
var iframeID = '';
//var modelCode = '';
try {
//console.log("**** loadInfo(): ", newEventData);
JSONdata = JSON.parse(newEventData);
newRT = JSONdata.m_RT;
newSS = JSONdata.m_SS;
staticRun = JSONdata.m_static;
parSliders = JSONdata.m_pars;
spPlot = JSONdata.m_species;
newURL = JSONdata.m_URL;
iframeID = JSONdata.m_iframeID;
yLabel = JSONdata.m_yLabel;
xLabel = JSONdata.m_xLabel;
//modelCode = JSONdata.m_code;
console.log('loadInfo(): Model code: ', newURL);
//runModel2(newURL, iframeID, modelCode);
runModel2(newURL, iframeID);
}
catch(err) {
console.log('loadInfo: message error: ', err);
//window.alert('Model information not received!');
}
return;
}
</script>
<script type="text/javascript">
window.addEventListener('message',function (event) {
if (event.origin != 'https://bioblahblah.org') {
// something not from bioblahblah domain, ignore it
console.log("*****Unknown data :", event.data);
return;
}
try {
loadInfo(event.data);
}
catch(err) {
console.log('eventListener: message error: ', err);
}
} );
</script>
<script type="text/javascript">
// Store sim info in window.sessionStorage and launch simulator.
function getInfo2(model,rt, ss,staticBool,pars,sp, frameid) {
// frameid: not needed for now
sessionStorage.setItem("MODEL", model);
sessionStorage.setItem('RUNTIME', rt);
sessionStorage.setItem('STEPSIZE', ss);
sessionStorage.setItem('STATIC', staticBool);
sessionStorage.setItem('SLIDERS', pars.trim());// check for only whitespace
sessionStorage.setItem('PLOT_SPECIES', sp.trim());
sessionStorage.setItem('X_LABEL', xLabel);
sessionStorage.setItem('Y_LABEL', yLabel);
window.location.href = ('https://sys-bio.github.io/InteractiveModels/simulator/index.html?'); // Location of miniSidewinder
//document.getElementById(frameid).src = "../Debug/index.html?"; // Location of miniSidewinder
}
</script>
<script type="text/javascript">
//function runModel2(modelURL, newFrameID, newCode) {
function runModel2(modelURL, newFrameID) {
// modelURL: URL of SBML model (XML format)
// newFrameID: optional
fetch(modelURL)
.then(response => response.text())
.then((data) => {
//console.log('Loading from github: ', data);
getInfo2(data,newRT,newSS,staticRun,parSliders,spPlot, newFrameID);
})
}
</script>
<script type="text/javascript">
function loadSearchInfo(newStrSearch) {
newRT = newStrSearch.get('m_RT');
newSS = newStrSearch.get('m_SS');
staticRun = newStrSearch.get('m_static');
parSliders = newStrSearch.get('m_pars');
spPlot = newStrSearch.get('m_species');
newURL = newStrSearch.get('m_URL');
console.log('loadSearchInfo: Model url: ', newURL);
iframeID = newStrSearch.get('m_iframeID');
yLabel = newStrSearch.get('m_yLabel');
xLabel = newStrSearch.get('m_xLabel');
runModel2(newURL, iframeID);
}
</script>
<script type="text/javascript">
// console.log(" * sysbioLoadSim.html file loaded......");
const para = new URLSearchParams(window.location.search);
const new_url = para.get('m_URL');
if (new_url) {
//console.log('Model url: ', new_url);
loadSearchInfo(para);
}
</script>
</body>
</html>