source: extensions/net.sf.basedb.reggie/trunk/resources/partitionform.jsp @ 1628

Last change on this file since 1628 was 1628, checked in by Nicklas Nordborg, 10 years ago

Fixes #383: Remove BASE 3.0 CSS support

And also updated the index page.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 25.8 KB
Line 
1<%@ page
2  pageEncoding="UTF-8"
3  session="false"
4  import="net.sf.basedb.core.User"
5  import="net.sf.basedb.core.DbControl"
6  import="net.sf.basedb.core.SessionControl"
7  import="net.sf.basedb.core.Application"
8  import="net.sf.basedb.clients.web.Base" 
9  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
10%>
11<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
12<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
13<%
14final SessionControl sc = Base.getExistingSessionControl(request, true);
15final String ID = sc.getId();
16final float scale = Base.getScale(sc);
17final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie");
18DbControl dc = null;
19try
20{
21  dc = sc.newDbControl();
22  final User user = User.getById(dc, sc.getLoggedInUserId());
23%>
24<base:page type="default" >
25<base:head scripts="ajax.js" styles="path.css">
26  <link rel="stylesheet" type="text/css" href="css/reggie.css">
27  <script language="JavaScript" src="reggie.js" type="text/javascript" charset="UTF-8"></script>
28 
29 
30<script language="JavaScript">
31var debug = false;
32var currentStep = 1;
33
34var specimenTubes = null;
35var selectedTubes = null;
36
37var partitionDateIsValid = false;
38
39var spWeightsAreValid;
40var apWeightsAreValid;
41var hisWeightsAreValid;
42var oneOrMoreWeightsAreSet;
43var nofPiecesAreValid;
44var isRestoringFromLocalStorage = false; // A flag to keep track of what is happening
45
46function init()
47{
48  var frm = document.forms['reggie'];
49  var selectList = frm.tubesSelect;
50  getSpecimenTubes();
51 
52  var specimenTubeOptions = '';
53  if (specimenTubes != null && specimenTubes.length > 0)
54  {
55    for (var i=0;i<specimenTubes.length;i++)
56    {
57      var tube = specimenTubes[i];
58      var storeInfo = getStoredInfo(tube.id);
59      selectList.options[selectList.length] = new Option(tube.name + (storeInfo ? ' [*]' : ''), tube.name, storeInfo ? true : false);
60    }
61  }
62  else
63  {
64    selectList.disabled = true;
65    Main.hide('gonext');   
66    setInputStatus('tubes','No tubes available for partition', 'invalid')
67  } 
68}
69
70function goNextAuto()
71{
72  goNext(false);
73}
74
75function goNext(manual)
76{
77  setInnerHTML('gonext.message', '');
78  if (currentStep == 1)
79  {   
80    gotoStep2();
81  }
82  else if (currentStep == 2)
83  {
84    partitionDateOnBlur();
85    if (step2IsValid()) gotoStep3();
86  }
87}
88
89function step2IsValid()
90{
91  return partitionDateIsValid;
92}
93
94function step3IsValid()
95{
96  for (var i=0; i<spWeightsAreValid.length; i++)
97  {
98   
99    if (spWeightsAreValid[i] == false ||
100        apWeightsAreValid[i] == false ||
101        hisWeightsAreValid[i] == false ||
102        nofPiecesAreValid[i] == false)
103    {
104      return false;
105    }
106    if (oneOrMoreWeightsAreSet[i] == false)
107    {
108      return false;
109    }
110  } 
111  return true;
112}
113
114function sortTubesByPosition(t1, t2)
115{
116  var box1 = t1.box;
117  var box2 = t2.box;
118  if (box1 < box2) return -1;
119  else if (box1>box2) return 1;
120  else
121  {
122    var row1 = t1.row;
123    var row2 = t2.row;
124    if (row1 < row2) return -1;
125    else if (row1>row2) return 1;
126    else
127    {
128      var col1 = t1.column;
129      var col2 = t2.column;
130      return col1 - col2;
131    }
132  }
133}
134
135function gotoStep2()
136{
137  var frm = document.forms['reggie'];
138  var selectList = frm.tubesSelect;
139  selectedTubes = new Array();
140  for (var i=0;i<selectList.length; i++)
141  {
142    if (selectList.options[i].selected)
143      selectedTubes.push(specimenTubes[i]);
144  }   
145  selectedTubes.sort(sortTubesByPosition);
146  if (selectedTubes.length == 0)
147  {
148    setInputStatus('tubes', 'Missing', 'invalid');
149    return;
150  }
151 
152  setInputStatus('tubes', '', 'valid');
153  // Change section
154  frm.tubesSelect.disabled = true;
155 
156  Main.show('partitionSection');
157  Main.show('gocancel');
158  var currentTime = new Date();
159  var currentYear = currentTime.getFullYear().toString();
160  var currentMonth = (currentTime.getMonth()+1).toString();
161  currentMonth = currentMonth.length < 2 ? '0'+currentMonth : currentMonth;
162  var currentDate = currentTime.getDate().toString();
163  currentDate = currentDate.length < 2 ? '0'+currentDate : currentDate;
164 
165  var dateString = currentYear + currentMonth + currentDate;
166 
167  frm.partitionDate.value = dateString;
168  frm.partitionDate.setSelectionRange(0,frm.partitionDate.value.length);
169  frm.partitionDate.focus();
170  currentStep = 2;
171}
172
173function gotoStep3()
174{
175  var frm = document.forms['reggie'];
176  frm.partitionDate.disabled = true; 
177 
178  var inputWeightHtml; 
179  if (selectedTubes.length > 0)
180  {
181    spWeightsAreValid = Array();
182    apWeightsAreValid = Array();
183    hisWeightsAreValid = Array();
184    nofPiecesAreValid = Array();
185    oneOrMoreWeightsAreSet = Array();
186   
187    for (var i=0;i<selectedTubes.length;i++)
188    {
189      spWeightsAreValid[i] = true;
190      apWeightsAreValid[i] = true;
191      hisWeightsAreValid[i] = true;
192      nofPiecesAreValid[i] = false;
193      oneOrMoreWeightsAreSet[i] = false;     
194    }
195   
196    inputWeightHtml = '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
197    var spTitle = 'SpWeight<br>';
198    var apTitle = 'ApWeight<br>';
199    var hisTitle = 'HisWeight<br>';
200    var nofTitle = 'NofPieces<br>';
201    var appearanceTitle = 'Appearance<br>';
202    var necrosisTitle = 'Necrosis%<br>';
203    var fatTitle = 'Fat%<br>';
204    var colouredTitle = 'Coloured<br>';
205    var bloodyTitle = 'Bloody<br>';
206   
207    var appearanceOptions = '<option selected ></option>'; 
208    appearanceOptions += '<option value="HOMOGENEOUS">Homogeneous</option>';
209    appearanceOptions += '<option value="HETEROGENEOUS">Heterogeneous</option>';
210   
211    var necrosisOptions = '<option selected value="0">0</option>';
212    necrosisOptions += '<option value="5">5</option>';
213    necrosisOptions += '<option value="10">10</option>';
214    necrosisOptions += '<option value="15">15</option>';
215    necrosisOptions += '<option value="20">20</option>';
216    necrosisOptions += '<option value="30">30</option>';
217    necrosisOptions += '<option value="40">40</option>';
218    necrosisOptions += '<option value="60">60</option>';
219    necrosisOptions += '<option value="80">80</option>';
220    necrosisOptions += '<option value="100">100</option>';
221   
222    var fatOptions = '<option selected value=0>0</option>';
223    fatOptions += '<option value=20>20</option>';
224    fatOptions += '<option value=40>40</option>';
225    fatOptions += '<option value=60>60</option>';
226    fatOptions += '<option value=80>80</option>';
227    fatOptions += '<option value=100>100</option>';
228   
229    for (var i=0;i<selectedTubes.length; i++)
230    {
231      var tube = selectedTubes[i];
232      var nextStep = i<(selectedTubes.length-1) ? 'focusOnEnter(event, \'bloody'+(i+1)+'\')' : '';
233       
234      inputWeightHtml += '<tr>';
235      inputWeightHtml += '<td rowspan=2 class=prompt>'+tube.name;
236      // Only show box information if there is something show.     
237      if (tube.row != null && tube.column != null)
238      {
239        inputWeightHtml += ' ['+tube.box+'&nbsp;'+tube.row+tube.column+']';
240      }
241      inputWeightHtml += '</td>';
242     
243      inputWeightHtml += '<td style="width:400px;">';
244      inputWeightHtml += '<table style="width:100%"><tr>';     
245      inputWeightHtml += '<td>'+bloodyTitle+'<input type=checkbox onkeypress="checkOnNumber(event, this);focusOnEnter(event, \'appearance'+i+'\')" onchange="saveToLocalStorage('+i+')" onfocus="messageOnFocus(0,'+i+')" name=bloody'+i+' /></td>';
246      inputWeightHtml += '<td>'+appearanceTitle+'<select name=appearance'+i+' onfocus="messageOnFocus(1,'+i+')" onchange="saveToLocalStorage('+i+')" onkeypress="focusOnEnter(event, \'necrosis'+i+'\')">'+appearanceOptions+'</select></td>';
247      inputWeightHtml += '<td>'+necrosisTitle+'<select name=necrosis'+i+' onfocus="messageOnFocus(2,'+i+')" onchange="saveToLocalStorage('+i+')" onkeypress="focusOnEnter(event, \'fat'+i+'\')">'+necrosisOptions+'</select></td>';
248      inputWeightHtml += '<td>'+fatTitle+'<select name=fat'+i+' onfocus="messageOnFocus(3,'+i+')" onchange="saveToLocalStorage('+i+')" onkeypress="focusOnEnter(event, \'coloured'+i+'\')">'+fatOptions+'</select></td>';
249      inputWeightHtml += '<td>'+colouredTitle+'<input type=checkbox name=coloured'+i+' onfocus="messageOnFocus(4,'+i+')" onchange="saveToLocalStorage('+i+')" onkeypress="checkOnNumber(event, this);focusOnEnter(event, \'nofPieces'+i+'\')" /></td>'
250      inputWeightHtml += '<td>'+nofTitle+'<input name="nofPieces'+i+'" onfocus="messageOnFocus(5,'+i+')" onblur="nofPiecesOnChange('+i+')" onkeypress="focusOnEnter(event, \'spWeight'+i+'\');return isNumberKey(event)" size=2 /></td>';
251      inputWeightHtml += '<td>'+spTitle+'<input name="spWeight'+i+'" onfocus="messageOnFocus(6,'+i+')" onblur="spWeightOnChange('+i+')" onkeypress="focusOnEnter(event, \'hisWeight'+i+'\');return isNumberKey(event)" size=4 /></td>';
252      inputWeightHtml += '<td>'+hisTitle+'<input name="hisWeight'+i+'" onfocus="messageOnFocus(7,'+i+')" onblur="hisWeightOnChange('+i+')" onkeypress="focusOnEnter(event, \'apWeight'+i+'\');return isNumberKey(event)" size=4 /></td>';
253      inputWeightHtml += '<td>'+apTitle+'<input name="apWeight'+i+'" onfocus="messageOnFocus(8,'+i+')" onblur="apWeightOnChange('+i+')" onkeypress="'+nextStep+';return isNumberKey(event)" size=4 /></td>';     
254      inputWeightHtml += '</tr>';
255      inputWeightHtml += '</table>';
256      inputWeightHtml += '</td>';
257      inputWeightHtml += '<td rowspan=2 class="status" id="'+i+'.status"></td>';
258      inputWeightHtml += '</tr>';
259     
260      inputWeightHtml += '<tr>';
261      inputWeightHtml += '<td style="width:400px;" class="help"><span class="message" id="'+i+'.message"></span><span id="'+i+'.help"></span></td>';     
262      inputWeightHtml += '</tr>';     
263      inputWeightHtml += '<tr><td>&nbsp;</td></tr>';
264    }
265    inputWeightHtml += '</table>';
266    setInnerHTML('weightInputs', inputWeightHtml);
267   
268    // Restore saved information
269    isRestoringFromLocalStorage = true;
270    for (var i=0;i<selectedTubes.length; i++)
271    {
272      var tube = selectedTubes[i];
273      var storeInfo = getStoredInfo(tube.id);
274      if (storeInfo)
275      {
276        frm['bloody'+i].checked = storeInfo.bloody;
277        setSelectedValue(frm['appearance'+i], storeInfo.appearance);
278        setSelectedValue(frm['necrosis'+i], storeInfo.necrosis);
279        setSelectedValue(frm['fat'+i], storeInfo.fat);
280        frm['coloured'+i].checked = storeInfo.coloured;
281        frm['nofPieces'+i].value = storeInfo.nofPieces;
282        frm['spWeight'+i].value = storeInfo.spWeight;
283        frm['hisWeight'+i].value = storeInfo.hisWeight;
284        frm['apWeight'+i].value = storeInfo.apWeight;
285        nofPiecesOnChange(i);
286        spWeightOnChange(i);
287        hisWeightOnChange(i);
288        apWeightOnChange(i);
289      }
290    }
291    isRestoringFromLocalStorage = false;
292  }
293 
294 
295 
296  Main.show('weightSection');
297  Main.hide('gonext');
298  Main.show('gocreate');
299  frm.bloody0.focus();
300}
301
302function checkOnNumber(event, element)
303{
304  if (event.charCode == 48)
305  {
306    element.checked = false;
307  }
308  else if (event.charCode == 49)
309  {
310    element.checked = true;
311  }
312  return true;
313}
314
315function isNumberKey(evt)
316{
317  evt = (evt) ? evt : ((window.event) ? event : null);
318    if (evt) {
319       var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
320       if (elem) {
321           var charCode = (evt.charCode) ? evt.charCode : 
322               ((evt.which) ? evt.which : evt.keyCode);
323           if ((charCode < 32 ) || 
324               (charCode > 45 && charCode < 47) || 
325               (charCode > 47 && charCode < 58)) {
326               return true;
327           } else {
328               return false;
329           }
330       }
331    }
332}
333
334function messageOnFocus(order, tubeIndex)
335{ 
336  var helpMessage;
337  switch(order)
338  {
339    case 0:
340      helpMessage = 'Check this if the partition is bloody. Unchecked is default.';
341      break;
342    case 1:
343      helpMessage = 'Select appearance. Empty is default';
344      break;
345    case 2:
346      helpMessage = 'Select percentage of necrosis. \'0\' is default.';
347      break;
348    case 3:
349      helpMessage = 'Select percentage of fat. \'0\' is default.';
350      break;
351    case 4:
352      helpMessage = 'Check this if the partition is coloured. Unchecked is default.';
353      break;
354    case 5:
355      helpMessage = 'Number of pieces in this partition.';
356      break;
357    case 6:
358      helpMessage = 'Sp weight in [mg].';
359      break;
360    case 7:
361      helpMessage = 'His weight in [mg].';
362      break;
363    case 8:
364      helpMessage = 'Ap weight in [mg].';
365      break;
366    default:
367      helpMessage='&nbsp;';
368  }
369  for (var i=0;i<selectedTubes.length;i++)
370  {
371    if (i!=tubeIndex) setInnerHTML(i+'.help', '&nbsp;')
372  }
373  setInnerHTML(tubeIndex+'.help', helpMessage); 
374}
375
376
377
378/**
379  Save as much information as possible about the partitioned
380  specimen tube. The information is stored in the localStorage()
381  under the key 'reggie.specimen.<id>.partitionInfo' where
382  <id> is the ID of the specimen tube.
383*/
384function saveToLocalStorage(tubeIndex)
385{
386  if (window.localStorage && !isRestoringFromLocalStorage)
387  {
388    var tube = selectedTubes[tubeIndex];
389    var frm = document.forms['reggie'];
390    var storeInfo = new Object();
391    storeInfo.tubeId = tube.id;
392    storeInfo.bloody = frm['bloody'+tubeIndex].checked;
393    storeInfo.appearance = getSelectedValue(frm['appearance'+tubeIndex]);
394    storeInfo.necrosis = getSelectedValue(frm['necrosis'+tubeIndex]);
395    storeInfo.fat = getSelectedValue(frm['fat'+tubeIndex]);
396    storeInfo.coloured = frm['coloured'+tubeIndex].checked;
397    storeInfo.nofPieces = frm['nofPieces'+tubeIndex].value;
398    storeInfo.spWeight = frm['spWeight'+tubeIndex].value;
399    storeInfo.hisWeight = frm['hisWeight'+tubeIndex].value;
400    storeInfo.apWeight = frm['apWeight'+tubeIndex].value;
401    window.localStorage.setItem('reggie.specimen.' + tube.id + '.partitionInfo', JSON.stringify(storeInfo));
402    if (debug)
403    {
404      Main.debug(tubeIndex + ': ' + window.localStorage.getItem('reggie.specimen.' + tube.id + '.partitionInfo'));
405    }
406  }
407}
408
409function removeFromLocalStorage(tubeId)
410{
411  if (!window.localStorage) return;
412  if (debug) Main.debug('removeFromLocalStorage:' + tubeId);
413  window.localStorage.removeItem('reggie.specimen.' + tubeId + '.partitionInfo');
414}
415 
416function getStoredInfo(tubeId)
417{
418  if (!window.localStorage) return null;
419  try
420  {
421    var stored = window.localStorage.getItem('reggie.specimen.' + tubeId + '.partitionInfo');
422    if (debug) Main.debug(stored);
423    return stored ? JSON.parse(stored) : null;
424  }
425  catch (e)
426  {
427    Main.debug('Could not load stored information for tube ' + tubeId + ': ' + e);
428  }
429}
430
431function updateInputStatus(tubeIndex)
432{
433  saveToLocalStorage(tubeIndex);
434  var frm = document.forms['reggie'];
435  if(nofPiecesAreValid[tubeIndex] == false)
436  {
437    setInputStatus(tubeIndex, 'NofPieces is invalid.', 'invalid');
438    frm.elements['nofPieces'+tubeIndex].focus();
439    return ;
440  }
441  if (spWeightsAreValid[tubeIndex] == false)
442  {
443    setInputStatus(tubeIndex, 'SpWeight is invalid.','invalid');
444    return;
445  }
446  if(hisWeightsAreValid[tubeIndex] == false)
447  {
448    setInputStatus(tubeIndex, 'HisWeight is invalid.', 'invalid');
449    return;
450  }
451  if(apWeightsAreValid[tubeIndex] == false)
452  {
453    setInputStatus(tubeIndex, 'APWeight is invalid.', 'invalid');
454    return;
455  }
456 
457  var spWeightValue = frm.elements['spWeight'+tubeIndex].value;
458  var apWeightValue = frm.elements['apWeight'+tubeIndex].value;
459  var hisWeightValue = frm.elements['hisWeight'+tubeIndex].value;
460  if (spWeightValue == '' && apWeightValue == '' && hisWeightValue == '')
461  {
462    oneOrMoreWeightsAreSet[tubeIndex] = false;
463    setInputStatus(tubeIndex, 'No weight is defined.', 'invalid');
464    return;
465  }
466  oneOrMoreWeightsAreSet[tubeIndex] = true;
467  setInputStatus(tubeIndex, '', 'valid');
468}
469
470function spWeightOnChange(tubeIndex)
471{
472  var inputName = 'spWeight'+tubeIndex;
473  var frm = document.forms['reggie'];
474  var weightInput = frm.elements[inputName].value;
475  if (weightInput != '')
476  {
477    if (weightInput < 0)
478    {
479      spWeightsAreValid[tubeIndex] = false;
480      updateInputStatus(tubeIndex);
481      return;
482    }
483    if (weightInput == '0')
484    {
485      frm.elements[inputName].value = '';
486    }
487  } 
488  spWeightsAreValid[tubeIndex] = true;
489  updateInputStatus(tubeIndex);
490}
491
492function apWeightOnChange(tubeIndex)
493{
494  var inputName = 'apWeight'+tubeIndex;
495  var frm = document.forms['reggie'];
496  var weightInput = frm.elements[inputName].value;
497  if (weightInput != '')
498  {
499    if (weightInput < 0)
500    {
501      apWeightsAreValid[tubeIndex] = false;
502      updateInputStatus(tubeIndex);
503      return;
504    } 
505    if (weightInput == '0')
506    {
507      frm.elements[inputName].value = '';
508    } 
509  }
510  apWeightsAreValid[tubeIndex] = true;
511  updateInputStatus(tubeIndex);
512}
513
514function hisWeightOnChange(tubeIndex)
515{
516  var inputName = 'hisWeight'+tubeIndex;
517  var frm = document.forms['reggie'];
518  var weightInput = frm.elements[inputName].value;
519  if (weightInput != '')
520  {
521    if (weightInput < 0)
522    {
523      hisWeightsAreValid[tubeIndex] = false;
524      updateInputStatus(tubeIndex);
525      return;
526    }
527    if (weightInput == '0')
528    {
529      frm.elements[inputName].value = '';
530    }   
531  } 
532  hisWeightsAreValid[tubeIndex] = true;
533  updateInputStatus(tubeIndex);
534}
535
536function nofPiecesOnChange(tubeIndex)
537{
538  var inputName = 'nofPieces'+tubeIndex;
539  var frm = document.forms['reggie'];
540  var fieldInput = frm.elements[inputName].value;
541  if (fieldInput != '')
542  {
543    if (fieldInput < 0)
544    {
545      nofPiecesAreValid[tubeIndex] = false;
546      updateInputStatus(tubeIndex);
547      return;
548    } 
549    if (fieldInput == '0')
550    {
551      fieldInput = '';     
552      frm.elements[inputName].value = fieldInput;
553    }
554  } 
555  if (fieldInput == '')
556  {
557    nofPiecesAreValid[tubeIndex] = false;
558    updateInputStatus(tubeIndex);
559    return;
560  }
561  nofPiecesAreValid[tubeIndex] = true;
562  updateInputStatus(tubeIndex);
563}
564
565function partitionDateOnBlur()
566{
567  var frm = document.forms['reggie'];
568  var partitionDate = frm.partitionDate.value;
569  var todaysDate = new Date();
570  partitionDateIsValid = false;
571 
572  setInputStatus('partitionDate', '', '');
573 
574  if (partitionDate != '')
575  {
576    partitionDate = autoFillDate(partitionDate);
577    frm.partitionDate.value = partitionDate;
578   
579    if (!Dates.isDate(partitionDate, 'yyyyMMdd'))
580    {
581      setInputStatus('partitionDate', 'Not a valid date', 'invalid');
582      return;
583    }   
584    if (todaysDate < new Date(partitionDate.substring(0,4), new Number(partitionDate.substring(4,6)-1), partitionDate.substring(6)))
585    {
586      setInputStatus('partitionDate', 'Future dates are not valid','invalid');
587      return;
588    }
589    setInputStatus('partitionDate','','valid');   
590  }
591  else
592  {
593    setInputStatus('partitionDate', 'Missing', 'invalid');
594    return;
595  }
596  partitionDateIsValid = true;
597}
598
599function getSpecimenTubes()
600{
601  var frm = document.forms['reggie']; 
602 
603  var request = Ajax.getXmlHttpRequest();
604  var url = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=GetSpecimenTubes';   
605  request.open("GET", url, false); 
606  request.send(null);
607
608  if (debug) Main.debug(request.responseText); 
609  var response = JSON.parse(request.responseText); 
610  if (response.status != 'ok')
611  {
612    setFatalError(response.message);
613    return false;
614  } 
615  specimenTubes = response.tubeInfo.specimenTubes;
616}
617
618function goCreate()
619{
620  if (!step3IsValid()) return;
621 
622  Main.hide('gocancel');
623  Main.hide('gocreate');
624 
625  var frm = document.forms['reggie'];
626  var tubeInfo = new Object();
627 
628  var specimens = selectedTubes;
629  var nofTubes = specimens.length;
630  var partitionDateValue = frm.elements['partitionDate'].value;
631  tubeInfo.partitionDate = partitionDateValue;
632  for (var i=0; i<nofTubes; i++)
633  {
634    frm.elements['spWeight'+i].disabled = true;
635    frm.elements['apWeight'+i].disabled = true;
636    frm.elements['hisWeight'+i].disabled = true;
637    frm.elements['nofPieces'+i].disabled = true;
638    frm.elements['bloody'+i].disabled = true;
639    frm.elements['appearance'+i].disabled = true;
640    frm.elements['necrosis'+i].disabled = true;
641    frm.elements['fat'+i].disabled = true;
642    frm.elements['coloured'+i].disabled = true;
643       
644    var specimenTube = specimens[i];
645   
646    var spWeightValue = frm.elements['spWeight'+i].value; 
647    if (spWeightValue != '') specimenTube.spWeight = spWeightValue;
648    var apWeightValue = frm.elements['apWeight'+i].value;
649    if (apWeightValue != '') specimenTube.apWeight = apWeightValue;
650    var hisWeightValue = frm.elements['hisWeight'+i].value;
651    if (hisWeightValue != '') specimenTube.hisWeight = hisWeightValue;
652    var nofPiecesValue = frm.elements['nofPieces'+i].value;
653    if (nofPiecesValue != '') specimenTube.nofPieces = nofPiecesValue;
654   
655    var partitionComment = ''; 
656    var appearanceElement = frm.elements['appearance'+i];
657    var necrosisElement = frm.elements['necrosis'+i];
658    var fatElement = frm.elements['fat'+i];
659    var appearanceValue = appearanceElement.options[appearanceElement.selectedIndex].value;   
660    var necrosisValue = necrosisElement.options[necrosisElement.selectedIndex].value;
661    var fatValue = fatElement.options[fatElement.selectedIndex].value;
662   
663    // Generate partition comment string
664    if (frm.elements['bloody'+i].checked == true) partitionComment += 'BLOODY';
665    if (appearanceValue != '') partitionComment += (partitionComment.length>0 ? ';' : '') + appearanceValue;
666    if (necrosisValue != '0') partitionComment += (partitionComment.length>0 ? ';' : '') + 'NECROSIS'+necrosisValue+'%';
667    if (fatValue != '0') partitionComment += (partitionComment.length>0 ? ';' : '') + 'FAT'+fatValue+'%';
668    if (frm.elements['coloured'+i].checked == true) partitionComment += partitionComment.length>0 ? ';COLOURED' : 'COLOURED';
669   
670    specimenTube.operatorPartitionComment = partitionComment.length > 0 ? partitionComment : null;
671   
672    specimens[i] = specimenTube;   
673  }
674  tubeInfo.specimens = specimens;
675  var submitInfo = new Object();
676  submitInfo.tubeInfo = tubeInfo;
677 
678  if (debug) Main.debug(JSON.stringify(submitInfo));     
679  var request = Ajax.getXmlHttpRequest();
680  var url = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=CreatePartitions';
681  request.open("POST", url, false);
682  request.setRequestHeader("Content-Type", "application/json");
683  request.send(JSON.stringify(submitInfo));
684
685  if (debug) Main.debug(request.responseText);
686
687  var response = JSON.parse(request.responseText);
688  if (response.status != 'ok')
689  {
690    setFatalError(response.message);
691    return false;
692  }
693
694  var msg = '<ul>';
695  for (var i = 0; i < response.messages.length; i++)
696  {
697    msg += '<li>' + response.messages[i];
698  }
699  msg += '</ul>';
700  setInnerHTML('done', msg);
701 
702  for (var i = 0; i < response.partitioned.length; i++)
703  {
704    removeFromLocalStorage(response.partitioned[i]);
705  }
706 
707  Main.show('done');
708  Main.show('gorestart');
709}
710
711function downloadLabelFile()
712{ 
713  var downloadFileInput = 'PartitionRegistration.servlet?ID=<%=ID%>&cmd=GetLabelFile';
714  downloadFileInput += '&tubes=';
715  var separator = '';
716  for (i in selectedTubes)
717  {
718    downloadFileInput += separator + selectedTubes[i].name;
719    separator = ',';
720  } 
721  window.location = downloadFileInput;
722}
723</script>
724
725
726</base:head>
727<base:body onload="init()">
728
729  <p:path><p:pathelement 
730    title="Reggie" href="<%="index.jsp?ID="+ID%>" 
731    /><p:pathelement title="Partition registration" 
732    /></p:path>
733
734  <div class="content">
735  <%
736  if (sc.getActiveProjectId() == 0)
737  {
738    %>
739    <div class="messagecontainer note" style="width: 800px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;">
740      No project has been selected. You may proceed with the registration but
741      created items will not be shared.
742    </div>
743    <%
744  }
745  %>
746
747  <form name="reggie" onsubmit="return false;">
748 
749  <!-- 1. Case name-->
750  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
751  <tr>
752    <td rowspan="3" class="stepno">1</td>
753    <td class="steptitle">Select specimen tubes</td>
754  </tr>
755  <tr>
756    <td class="stepfields">
757      <table border="0" cellspacing="0" cellpadding="0" width="100%">
758      <tr valign="top">
759        <td class="prompt">Specimen tubes</td>
760        <td class="input"><select style="width:50%" name="tubeSelect" id="tubesSelect" multiple="multiple" size="12" onkeypress='doOnTab(event, goNextAuto)'></select></td>
761        <td class="status" id="tubes.status"></td>
762        <td class="help"><span id="tubes.message" class="message" style="display: none;"></span>Select specimen tubes to include in the partition.<br>
763        * = There is unsaved partitioning information for this tube
764        </td>
765      </tr>
766      </table>
767    </td>
768  </tr>
769  </table>
770 
771  <!-- 2. General partition information -->
772  <div id="partitionSection" style="display: none;">
773    <p></p>
774    <table border="0" cellspacing="0" cellpadding="0" class="stepform">
775    <tr>
776      <td rowspan="2" class="stepno">2</td>
777      <td class="steptitle">General partition information</td>
778    </tr>
779    <tr>
780      <td class="stepfields">
781        <table border="0" cellspacing="0" cellpadding="0" width="100%">
782        <tr valign="top">
783          <td class="prompt">Partition date</td>
784          <td class="input"><input type="text" name="partitionDate" 
785             onkeypress="focusOnEnter(event, 'download')" size="12" maxlength="10" onBlur="partitionDateOnBlur()"></td>
786          <td class="status" id="partitionDate.status"></td>
787          <td class="help"><span id="partitionDate.message" class="message" style="display: none;"></span>The date when the partition was done.</td>
788        </tr>
789        <tr>
790          <td class="prompt">Download label file</td>
791          <td class="input" name="downloadfile.input" id="downloadfile.input">
792            <base:button id="downloadlabels" title="Download..." onclick="downloadLabelFile()" image="<%=home + "/images/download.png"%>" style="width:115px"/>
793          </td>
794          <td class="status" id="downloadfile.status"></td>
795          <td class="help"><span id="downloadfile.message" class="message" style="display:none;"></span>Download label file for the selected tubes.</td>
796        </tr>       
797        </table>
798      </td>
799    </tr>   
800    </table>
801  </div>
802 
803  <div id="weightSection" style="display:none;">
804    <p></p>
805    <table border="0" cellspacing="0" cellpadding="0" class="stepform">
806    <tr>
807      <td rowspan="2" class="stepno">3</td>
808      <td class="steptitle">Enter weight information</td>   
809    </tr>
810    <tr>
811      <td class="stepfields" id="weightInputs">
812       
813      </td>
814    </tr>
815    </table>
816  </div>
817   
818  <div class="messagecontainer error" id="errorMessage" style="display: none; width: 800px; margin-left: 20px; margin-bottom: 0px;"></div>
819 
820  <div id="done" class="success" style="display: none; width: 800px; margin-left: 20px; margin-top: 20px;"></div>
821 
822  <table style="margin-left: 20px; margin-top: 10px;" class="navigation">
823    <tr>
824      <td><base:button id="gocancel" title="Cancel" onclick="goRestart(false)" style="display: none;"/></td>
825      <td><base:button id="gonext" title="Next" image="<%=home+"/images/gonext.png"%>" onclick="goNext(true)"/></td>
826      <td><base:button id="gocreate" title="Create" image="<%=home+"/images/gonext.png"%>" onclick="goCreate()" style="display: none;"/></td>
827      <td><base:button id="goupdate" title="Update" image="<%=home+"/images/gonext.png"%>" onclick="goCreate()" style="display: none;"/></td>
828      <td><base:button id="gorestart" title="Restart" image="<%=home+"/images/goback.png"%>" onclick="goRestart(true)" style="display: none;"/></td>
829      <td id="gonext.message" class="message"></td>
830    </tr>
831  </table>
832  </form>
833  </div>
834 
835</base:body>
836</base:page>
837<%
838}
839finally
840{
841  if (dc != null) dc.close();
842}
843%>
Note: See TracBrowser for help on using the repository browser.