2785 |
10 Oct 14 |
nicklas |
var Protocol = function() |
2785 |
10 Oct 14 |
nicklas |
2 |
{ |
2785 |
10 Oct 14 |
nicklas |
var protocol = {}; |
2785 |
10 Oct 14 |
nicklas |
var debug = 0; |
2785 |
10 Oct 14 |
nicklas |
5 |
|
2785 |
10 Oct 14 |
nicklas |
var lysatesIsValid = false; |
2785 |
10 Oct 14 |
nicklas |
7 |
|
2785 |
10 Oct 14 |
nicklas |
// Page initialization |
2785 |
10 Oct 14 |
nicklas |
protocol.initPage = function() |
2785 |
10 Oct 14 |
nicklas |
10 |
{ |
2785 |
10 Oct 14 |
nicklas |
var pageId = Doc.getPageId(); |
2785 |
10 Oct 14 |
nicklas |
if (pageId == 'protocol') |
2785 |
10 Oct 14 |
nicklas |
13 |
{ |
2785 |
10 Oct 14 |
nicklas |
Buttons.addClickHandler('print-button', Wizard.goPrint); |
5309 |
15 Feb 19 |
nicklas |
Buttons.addClickHandler('downloadLabelsCsv', protocol.downloadLabels); |
5309 |
15 Feb 19 |
nicklas |
Buttons.addClickHandler('downloadLabelsXlsx', protocol.downloadLabels); |
2785 |
10 Oct 14 |
nicklas |
Doc.show('all-protocol'); |
2785 |
10 Oct 14 |
nicklas |
18 |
} |
2785 |
10 Oct 14 |
nicklas |
else |
2785 |
10 Oct 14 |
nicklas |
20 |
{ |
2785 |
10 Oct 14 |
nicklas |
Buttons.addClickHandler('btnCreateWorkList', protocol.createWorkList); |
2785 |
10 Oct 14 |
nicklas |
Buttons.addClickHandler('gocreate', protocol.viewProtocol); |
2785 |
10 Oct 14 |
nicklas |
23 |
|
2785 |
10 Oct 14 |
nicklas |
var url = '../Histology.servlet?ID='+App.getSessionId(); |
2785 |
10 Oct 14 |
nicklas |
url += '&cmd=GetHistologyWorkLists'; |
2785 |
10 Oct 14 |
nicklas |
Wizard.showLoadingAnimation('Loading histology work lists...'); |
2785 |
10 Oct 14 |
nicklas |
Wizard.asyncJsonRequest(url, protocol.initializeStep1); |
2785 |
10 Oct 14 |
nicklas |
28 |
} |
2785 |
10 Oct 14 |
nicklas |
29 |
} |
2785 |
10 Oct 14 |
nicklas |
30 |
|
2785 |
10 Oct 14 |
nicklas |
protocol.initializeStep1 = function(response) |
2785 |
10 Oct 14 |
nicklas |
32 |
{ |
2785 |
10 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2785 |
10 Oct 14 |
nicklas |
var workLists = response.workLists; |
2785 |
10 Oct 14 |
nicklas |
35 |
|
2785 |
10 Oct 14 |
nicklas |
var workList = frm.workList; |
2785 |
10 Oct 14 |
nicklas |
if (workLists.length > 0) |
2785 |
10 Oct 14 |
nicklas |
38 |
{ |
2785 |
10 Oct 14 |
nicklas |
for (var i=0; i < workLists.length; i++) |
2785 |
10 Oct 14 |
nicklas |
40 |
{ |
2785 |
10 Oct 14 |
nicklas |
var list = workLists[i]; |
2785 |
10 Oct 14 |
nicklas |
var name = list.name + ' (' + list.size + ')'; |
2785 |
10 Oct 14 |
nicklas |
var option = new Option(name, list.id); |
2785 |
10 Oct 14 |
nicklas |
workList.options[workList.length] = option; |
2785 |
10 Oct 14 |
nicklas |
45 |
} |
2785 |
10 Oct 14 |
nicklas |
46 |
|
2785 |
10 Oct 14 |
nicklas |
47 |
} |
2785 |
10 Oct 14 |
nicklas |
else |
2785 |
10 Oct 14 |
nicklas |
49 |
{ |
2785 |
10 Oct 14 |
nicklas |
Wizard.setInputStatus('workList', 'invalid', 'No Histology works lists available for processing.'); |
2785 |
10 Oct 14 |
nicklas |
51 |
} |
2785 |
10 Oct 14 |
nicklas |
52 |
|
2785 |
10 Oct 14 |
nicklas |
Doc.show('step-1'); |
2785 |
10 Oct 14 |
nicklas |
Doc.show('gocreate'); |
2785 |
10 Oct 14 |
nicklas |
55 |
} |
2785 |
10 Oct 14 |
nicklas |
56 |
|
2785 |
10 Oct 14 |
nicklas |
57 |
|
2785 |
10 Oct 14 |
nicklas |
protocol.createWorkList = function() |
2785 |
10 Oct 14 |
nicklas |
59 |
{ |
2785 |
10 Oct 14 |
nicklas |
var url = 'histology_work_list.jsp?ID='+App.getSessionId(); |
2785 |
10 Oct 14 |
nicklas |
location.href = url; |
2785 |
10 Oct 14 |
nicklas |
62 |
} |
2785 |
10 Oct 14 |
nicklas |
63 |
|
2785 |
10 Oct 14 |
nicklas |
protocol.viewProtocol = function() |
2785 |
10 Oct 14 |
nicklas |
65 |
{ |
2785 |
10 Oct 14 |
nicklas |
var frm = document.forms['reggie']; |
2785 |
10 Oct 14 |
nicklas |
if (frm.workList.selectedIndex == -1) |
2785 |
10 Oct 14 |
nicklas |
68 |
{ |
2785 |
10 Oct 14 |
nicklas |
Wizard.notifyError(); |
2785 |
10 Oct 14 |
nicklas |
return; |
2785 |
10 Oct 14 |
nicklas |
71 |
} |
2785 |
10 Oct 14 |
nicklas |
frm.submit(); |
2785 |
10 Oct 14 |
nicklas |
73 |
} |
2785 |
10 Oct 14 |
nicklas |
74 |
|
2785 |
10 Oct 14 |
nicklas |
protocol.downloadLabels = function(event) |
2785 |
10 Oct 14 |
nicklas |
76 |
{ |
5309 |
15 Feb 19 |
nicklas |
var format = Data.get(event.currentTarget, 'format'); |
2785 |
10 Oct 14 |
nicklas |
var numLabelsPerBlock = prompt('Number of labels per block?', 3); |
2785 |
10 Oct 14 |
nicklas |
if (numLabelsPerBlock == null) return; |
2785 |
10 Oct 14 |
nicklas |
80 |
|
2785 |
10 Oct 14 |
nicklas |
if (!parseInt(numLabelsPerBlock, 10)) |
2785 |
10 Oct 14 |
nicklas |
82 |
{ |
2785 |
10 Oct 14 |
nicklas |
alert('"' + numLabelsPerBlock + '" is not a valid number'); |
2785 |
10 Oct 14 |
nicklas |
return; |
2785 |
10 Oct 14 |
nicklas |
85 |
} |
2785 |
10 Oct 14 |
nicklas |
86 |
|
2785 |
10 Oct 14 |
nicklas |
var url = '../Histology.servlet?ID='+App.getSessionId(); |
2785 |
10 Oct 14 |
nicklas |
url += '&cmd=DownloadHEGlassLabels'; |
2785 |
10 Oct 14 |
nicklas |
url += '&workListId='+Data.int(event.currentTarget, 'list-id'); |
2785 |
10 Oct 14 |
nicklas |
url += '&numSlides=' + parseInt(numLabelsPerBlock, 10); |
5309 |
15 Feb 19 |
nicklas |
url += '&format='+encodeURIComponent(format); |
2785 |
10 Oct 14 |
nicklas |
92 |
|
2785 |
10 Oct 14 |
nicklas |
location.href = url; |
2785 |
10 Oct 14 |
nicklas |
94 |
} |
2785 |
10 Oct 14 |
nicklas |
95 |
|
2785 |
10 Oct 14 |
nicklas |
96 |
|
2785 |
10 Oct 14 |
nicklas |
return protocol; |
2785 |
10 Oct 14 |
nicklas |
98 |
}(); |
2785 |
10 Oct 14 |
nicklas |
99 |
|
2785 |
10 Oct 14 |
nicklas |
Doc.onLoad(Protocol.initPage); |
2785 |
10 Oct 14 |
nicklas |
101 |
|