forked from anders-biostat/lamp_plate_analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplateBrowser.html
299 lines (283 loc) · 7.95 KB
/
plateBrowser.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<head>
<title>Plate Browser</title>
<style type="text/css">
body {
font-family: Helvetica, Arial, sans-serif;
}
a {
text-decoration: none;
color: #c21210;
}
a:hover {
color: #5c0807;
}
h3 {
font-weight: normal;
text-align: center;
}
#info #highlighted {
font-size: 14pt;
border: 1px solid black;
padding: 10px 20px 10px 20px;
width: 340px;
}
#highlighted .linked-charts {
line-height: 1.4;
}
.failed {
background: #f1a3a3;
}
.assign span.status {
display: inline-block;
width: 30px;
text-align: center;
height: 30px;
font-weight: bold;
font-size: 150%;
color: #666;
}
.assign span.status:hover {
opacity: 0.7;
}
.smokeScreen {
position: fixed;
padding: 0;
margin: 0;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #111;
opacity: 0.75;
z-index: 10;
}
.hidden {
display: none;
}
.message {
text-align: center;
color: #4a1f02;
letter-spacing: 1px;
}
.modal {
background: #ddd;
position: fixed;
top: 50%;
left: 50%;
width: 600px;
height: 300px;
margin-left: -300px;
margin-top: -150px;
z-index: 15;
}
#login, #report {
padding: 20px;
padding-top: 0px;
margin-left: 50px;
}
#errorLog {
width: 100%
padding: 10px;
margin-bottom: 10px;
height: 100px;
overflow-y: scroll;
border: solid 1px black;
}
</style>
<script type="text/javascript">
function addPlates(opts, plates) {
d3.select("#rackIds").selectAll("option")
.data(d3.range(opts.length).map(i => ({
text: opts[i],
plate: plates[i]
})))
.enter()
.append("option")
.attr("value", d => d.plate)
.text(d => d.text);
d3.select("#plateName").text(plates[0]);
};
function hideMessage() {
d3.select("#report")
.classed("hidden", true);
d3.select("#login")
.classed("hidden", false);
d3.select(".modal")
.classed("hidden", true);
d3.select(".smokeScreen")
.classed("hidden", true);
};
function askForCredentials() {
d3.select(".smokeScreen")
.classed("hidden", false);
d3.select(".modal")
.classed("hidden", false);
};
function wrongPassword() {
d3.select('#loginMessage').text('Incorrect user name or password.');
};
function reportSuccess(successNum, totalNum, log) {
d3.select('#loginMessage').text('Ready');
d3.select("#login")
.classed("hidden", true);
d3.select('#loginMessage').text('');
d3.select("#successNum")
.text(successNum);
d3.select("#totalNum")
.text(totalNum);
d3.select("#report")
.classed("hidden", false);
var errEntrs = d3.select("#errorLog").select("table")
.selectAll(".entry").data(log);
errEntrs.exit().remove();
errEntrs.enter()
.append("tr")
.attr("class", "entry")
.merge(errEntrs)
.html(d => '<td>' + d.barcode + '</td><td>' + d.status + '</td><td>' + d.message + '</td>')
};
function submitPassword() {
jrc.callFunction('post', [
document.getElementById('username').value,
document.getElementById('psw').value
])
d3.select('#loginMessage').text('Please, wait...');
};
function alertContentProblem(type) {
if(!Array.isArray(spurious))
spurious = [spurious];
var message = "";
if(type == "duplicates"){
message = "Duplicated wells detected\n" +
spurious.map(el => "rack: " + el.rack + ", well: " + el.well96)
.join("; ");
} else if(type == "mixed_content") {
message = "Pooled wells with mixed content detected\n" +
spurious.map(el => "plate: " + el.plate + ", well: " + el.well96)
.join("; ");
} else {
message = "Unknown content problem: " + type;
}
alert(message);
window.close();
};
function setCheckboxes(racks) {
var checkbox = d3.select("#rack_checkboxes")
.selectAll(".checkbox")
.data(racks, d => d);
checkbox.exit()
.remove();
var spans = checkbox.enter()
.append("span")
.attr("class", "checkbox");
spans
.append("input")
.attr("type", "checkbox")
.property("checked", true)
.attr("id", d => d);
spans
.append("label")
.attr("for", d => d)
.text(d => d);
};
function updateSamples(prop, to) {
var racks = d3.selectAll("span.checkbox")
.selectAll("input")
.filter(function() {return this.checked})
.nodes()
.map(el => el.id);
if(racks.length == 0){
alert("Please, select at least one rack.")
} else {
jrc.callFunction(prop, [to, racks]);
}
};
</script>
</head>
<body>
<div style="position: absolute;">
Select a plate to display:
<select id="rackIds" onchange="jrc.callFunction('switchPlate', this.value); d3.select('#plateName').text(this.value);" style="width: 300px;"></select>
</div>
<h2 style="text-align: center;">LAMP results viewer</h2>
<h3>Opened file:</h3>
<div style="display: grid;">
<div id="lines" style="grid-column: 1; grid-row: 1">
<table>
<tr>
<td id="A1"></td>
<td id="A2"></td>
</tr>
<tr>
<td id="B1"></td>
<td id="B2"></td>
</tr>
</table>
</div>
<div id="plates" style="grid-column: 2; grid-row: 1;"></div>
<div id="info" style="grid-column: 1; grid-row: 2; padding-left: 150px">
<table>
<tr>
<td id="legend_sample"></td>
<td id="highlighted"></td>
<td id="legend_res"></td>
</tr>
</table>
<div style="padding-top: 20px; font-size: 80%; font-style: italic;">
Made with <a href="anders-biostat.github.io/linked-charts">R/Linked-Charts</a> by S.Ovchinnikova and S.Anders, ZMBH
</div>
</div>
<div class="assign" style="grid-column: 2; grid-row: 2">
<p id="rack_checkboxes">
<span>apply changes to racks:</span><br>
</p>
<p>mark selected as:
<span class="status" style="background: #ff0000;" onclick="updateSamples('assign', '3 positives');" title="3 positives">p3</span>
<span class="status" style="background: #ff6666;" onclick="updateSamples('assign', '2 positives');" title="2 positives">p2</span>
<span class="status" style="background: #ff99aa;" onclick="updateSamples('assign', '1 positive');" title="1 positive">p1</span>
<span class="status" style="background: #f58e09;" onclick="updateSamples('assign', 'inconclusive');" title="inconclusive">i</span>
<span class="status" style="background: #48b225;" onclick="updateSamples('assign', 'negative');" title="negative">n</span>
<span class="status" style="background: #194689;" onclick="updateSamples('assign', 'repeat');" title="repeat">r</span>
<span class="status" style="background: #270404;" onclick="updateSamples('assign', 'failed');" title="failed">f</span>
<button onclick="jrc.callFunction('reset')">Reset plate</button>
</p>
<p>
add comment: <input type="text" name="comment" id="comment">
<button onclick="updateSamples('comment', document.getElementById('comment').value);">Add</button>
</p>
<button onclick="jrc.callFunction('export')">Export all plates to file</button>
<button onclick="askForCredentials();">Post this plate to the server</button>
<p class="message" id="plateMessage"></p>
</div>
</div>
<div class="smokeScreen hidden" onclick="hideMessage();"></div>
<div class="modal hidden">
<h3>Post plate <span id="plateName"></span></h3>
<div id="login">
<p>Username: <input type="text" id="username"></p>
<p>Password: <input type="password" id="psw"></p>
<p>
<button onclick="hideMessage();">Close</button>
<button onclick="submitPassword();">Submit</button>
</p>
<p id="loginMessage" class="message"></p>
</div>
<div id="report" class="hidden">
<p>
New statuses for <span id="successNum" style="color: #247b0f; font-weight: bold;"></span>
out of <span id="totalNum" style="font-weight: bold;"></span> samples uploaded.
</p>
<p>Error log (stored automatically):</p>
<div id="errorLog">
<table>
<tr>
<th>Barcode</th>
<th>Status</th>
<th>Server response</th>
</tr>
</table>
</div>
<button onclick="hideMessage()">Close</button>
</div>
</div>
</body>