5344 |
02 Apr 19 |
nicklas |
var PauseSettings = function() |
5344 |
02 Apr 19 |
nicklas |
2 |
{ |
5344 |
02 Apr 19 |
nicklas |
var pause = {}; |
5344 |
02 Apr 19 |
nicklas |
var debug = 0; |
5344 |
02 Apr 19 |
nicklas |
var sites; |
5344 |
02 Apr 19 |
nicklas |
6 |
|
5344 |
02 Apr 19 |
nicklas |
// Page initialization |
5344 |
02 Apr 19 |
nicklas |
pause.initPage = function() |
5344 |
02 Apr 19 |
nicklas |
9 |
{ |
5344 |
02 Apr 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
5344 |
02 Apr 19 |
nicklas |
Buttons.addClickHandler('btnSave', pause.saveSettings); |
5344 |
02 Apr 19 |
nicklas |
12 |
|
5344 |
02 Apr 19 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
5344 |
02 Apr 19 |
nicklas |
url += '&cmd=GetPauseSettings'; |
5344 |
02 Apr 19 |
nicklas |
Wizard.showLoadingAnimation('Loading pause settings...'); |
5344 |
02 Apr 19 |
nicklas |
Wizard.asyncJsonRequest(url, pause.onSettingsLoaded); |
5344 |
02 Apr 19 |
nicklas |
17 |
} |
5344 |
02 Apr 19 |
nicklas |
18 |
|
5344 |
02 Apr 19 |
nicklas |
pause.onSettingsLoaded = function(response) |
5344 |
02 Apr 19 |
nicklas |
20 |
{ |
5344 |
02 Apr 19 |
nicklas |
sites = response.sites; |
5344 |
02 Apr 19 |
nicklas |
var html = ''; |
5344 |
02 Apr 19 |
nicklas |
for (var siteNo = 0; siteNo < sites.length; siteNo++) |
5344 |
02 Apr 19 |
nicklas |
24 |
{ |
5344 |
02 Apr 19 |
nicklas |
var site = sites[siteNo]; |
5344 |
02 Apr 19 |
nicklas |
var id = 'site.'+site.prefix; |
5344 |
02 Apr 19 |
nicklas |
html += '<div class="site">' |
5344 |
02 Apr 19 |
nicklas |
html += '<input type="checkbox" id="'+id+'" name="'+id+'" ' + (site.paused?'checked':'')+'>'; |
5344 |
02 Apr 19 |
nicklas |
html += '<label for="'+id+'">'+Strings.encodeTags(site.name)+'</label>'; |
5344 |
02 Apr 19 |
nicklas |
html += '</div>'; |
5344 |
02 Apr 19 |
nicklas |
31 |
} |
5344 |
02 Apr 19 |
nicklas |
Doc.element('siteList').innerHTML = html; |
5344 |
02 Apr 19 |
nicklas |
33 |
} |
5344 |
02 Apr 19 |
nicklas |
34 |
|
5344 |
02 Apr 19 |
nicklas |
pause.saveSettings = function() |
5344 |
02 Apr 19 |
nicklas |
36 |
{ |
5344 |
02 Apr 19 |
nicklas |
var paused = []; |
5344 |
02 Apr 19 |
nicklas |
var frm = document.forms['reggie']; |
5344 |
02 Apr 19 |
nicklas |
for (var siteNo = 0; siteNo < sites.length; siteNo++) |
5344 |
02 Apr 19 |
nicklas |
40 |
{ |
5344 |
02 Apr 19 |
nicklas |
var site = sites[siteNo]; |
5344 |
02 Apr 19 |
nicklas |
if (frm['site.'+site.prefix].checked) paused[paused.length] = site.prefix; |
5344 |
02 Apr 19 |
nicklas |
43 |
} |
5344 |
02 Apr 19 |
nicklas |
44 |
|
5344 |
02 Apr 19 |
nicklas |
var submitInfo = {}; |
5344 |
02 Apr 19 |
nicklas |
submitInfo.pausedSites = paused; |
5344 |
02 Apr 19 |
nicklas |
47 |
|
5344 |
02 Apr 19 |
nicklas |
var url = '../SpecimenTubeRegistration.servlet?ID='+App.getSessionId(); |
5344 |
02 Apr 19 |
nicklas |
url += '&cmd=SavePauseSettings'; |
5344 |
02 Apr 19 |
nicklas |
Wizard.showLoadingAnimation('Saving settings...'); |
5344 |
02 Apr 19 |
nicklas |
Wizard.asyncJsonRequest(url, pause.submissionResults, 'POST', JSON.stringify(submitInfo)); |
5344 |
02 Apr 19 |
nicklas |
52 |
} |
5344 |
02 Apr 19 |
nicklas |
53 |
|
5344 |
02 Apr 19 |
nicklas |
pause.submissionResults = function(response) |
5344 |
02 Apr 19 |
nicklas |
55 |
{ |
5344 |
02 Apr 19 |
nicklas |
var url = App.getRoot() + 'common/close_popup.jsp?ID='+App.getSessionId(); |
5344 |
02 Apr 19 |
nicklas |
url += '&refresh_opener=1' |
5344 |
02 Apr 19 |
nicklas |
if (response.messages.length > 0) |
5344 |
02 Apr 19 |
nicklas |
59 |
{ |
5344 |
02 Apr 19 |
nicklas |
url += '&message='+encodeURIComponent(response.messages[0]); |
5344 |
02 Apr 19 |
nicklas |
61 |
} |
5344 |
02 Apr 19 |
nicklas |
location.href = url; |
5344 |
02 Apr 19 |
nicklas |
63 |
|
5344 |
02 Apr 19 |
nicklas |
64 |
} |
5344 |
02 Apr 19 |
nicklas |
65 |
|
5344 |
02 Apr 19 |
nicklas |
return pause; |
5344 |
02 Apr 19 |
nicklas |
67 |
}(); |
5344 |
02 Apr 19 |
nicklas |
68 |
|
5344 |
02 Apr 19 |
nicklas |
Doc.onLoad(PauseSettings.initPage); |
5344 |
02 Apr 19 |
nicklas |
70 |
|