2989 |
02 Dec 14 |
olle |
var LabEnvDbEvPopup = function() |
2989 |
02 Dec 14 |
olle |
2 |
{ |
2989 |
02 Dec 14 |
olle |
var labenvdbevpopup = {}; |
2989 |
02 Dec 14 |
olle |
var debug = 0; |
2989 |
02 Dec 14 |
olle |
var storageIntervalInSeconds = null; |
2989 |
02 Dec 14 |
olle |
var intervalIsValid = true; |
2989 |
02 Dec 14 |
olle |
7 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.getStorageIntervalInSeconds = function() |
2989 |
02 Dec 14 |
olle |
9 |
{ |
2989 |
02 Dec 14 |
olle |
return storageIntervalInSeconds; |
2989 |
02 Dec 14 |
olle |
11 |
} |
2989 |
02 Dec 14 |
olle |
12 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.setStorageIntervalInSeconds = function(storageIntervalInSecondsInput) |
2989 |
02 Dec 14 |
olle |
14 |
{ |
2989 |
02 Dec 14 |
olle |
storageIntervalInSeconds = storageIntervalInSecondsInput; |
2989 |
02 Dec 14 |
olle |
16 |
} |
2989 |
02 Dec 14 |
olle |
17 |
|
2989 |
02 Dec 14 |
olle |
// Page initialization |
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.initPage = function() |
2989 |
02 Dec 14 |
olle |
20 |
{ |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
22 |
|
2989 |
02 Dec 14 |
olle |
// Step 1 |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('goprint', 'click', labenvdbevpopup.printVersion); |
2989 |
02 Dec 14 |
olle |
25 |
|
2989 |
02 Dec 14 |
olle |
// Navigation |
2989 |
02 Dec 14 |
olle |
Buttons.addClickHandler('goprint', labenvdbevpopup.printVersion); |
2989 |
02 Dec 14 |
olle |
Buttons.addClickHandler('gocancel', labenvdbevpopup.cancelPrint); |
2989 |
02 Dec 14 |
olle |
29 |
|
2989 |
02 Dec 14 |
olle |
// Fetch and store storage interval in seconds |
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.fetchStorageIntervalInSeconds(); |
2989 |
02 Dec 14 |
olle |
32 |
|
2989 |
02 Dec 14 |
olle |
// Create pop-up window from request parameter data |
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.goCreate(); |
2989 |
02 Dec 14 |
olle |
35 |
}; |
2989 |
02 Dec 14 |
olle |
36 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.fetchStorageIntervalInSeconds = function() |
2989 |
02 Dec 14 |
olle |
38 |
{ |
2989 |
02 Dec 14 |
olle |
// Get lab environment database configuration JSON object with AJAX |
2989 |
02 Dec 14 |
olle |
var request = Ajax.getXmlHttpRequest(); |
2989 |
02 Dec 14 |
olle |
var url = '../LabEnvironment.servlet?ID='+App.getSessionId(); |
2989 |
02 Dec 14 |
olle |
url += '&cmd=GetLabEnvDatabaseConfig'; |
2989 |
02 Dec 14 |
olle |
43 |
|
2989 |
02 Dec 14 |
olle |
Wizard.asyncJsonRequest(url, labenvdbevpopup.fetchStorageIntervalInSeconds2); |
2989 |
02 Dec 14 |
olle |
45 |
} |
2989 |
02 Dec 14 |
olle |
46 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.fetchStorageIntervalInSeconds2 = function(response) |
2989 |
02 Dec 14 |
olle |
48 |
{ |
2989 |
02 Dec 14 |
olle |
if (response.status != 'ok') |
2989 |
02 Dec 14 |
olle |
50 |
{ |
2989 |
02 Dec 14 |
olle |
setFatalError(response.message); |
2989 |
02 Dec 14 |
olle |
return false; |
2989 |
02 Dec 14 |
olle |
53 |
} |
2989 |
02 Dec 14 |
olle |
// Get lab environment database configuration information from the AJAX response |
2989 |
02 Dec 14 |
olle |
var labEnvDatabaseConfig = response.labEnvDatabaseConfig; |
2989 |
02 Dec 14 |
olle |
if (labEnvDatabaseConfig != null) |
2989 |
02 Dec 14 |
olle |
57 |
{ |
2989 |
02 Dec 14 |
olle |
var storageIntervalInSecondsCurrent = labEnvDatabaseConfig.storageIntervalInSeconds; |
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.setStorageIntervalInSeconds(storageIntervalInSecondsCurrent); |
2989 |
02 Dec 14 |
olle |
60 |
} |
2989 |
02 Dec 14 |
olle |
61 |
} |
2989 |
02 Dec 14 |
olle |
62 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.getQueryParameter = function(parameterName) |
2989 |
02 Dec 14 |
olle |
64 |
{ |
2989 |
02 Dec 14 |
olle |
var queryString = window.top.location.search.substring(1); |
2989 |
02 Dec 14 |
olle |
var parameterName = parameterName + "="; |
2989 |
02 Dec 14 |
olle |
if ( queryString.length > 0 ) |
2989 |
02 Dec 14 |
olle |
68 |
{ |
2989 |
02 Dec 14 |
olle |
begin = queryString.indexOf(parameterName); |
2989 |
02 Dec 14 |
olle |
if (begin != -1) |
2989 |
02 Dec 14 |
olle |
71 |
{ |
2989 |
02 Dec 14 |
olle |
begin += parameterName.length; |
2989 |
02 Dec 14 |
olle |
end = queryString.indexOf("&" , begin); |
2989 |
02 Dec 14 |
olle |
if (end == -1) |
2989 |
02 Dec 14 |
olle |
75 |
{ |
2989 |
02 Dec 14 |
olle |
end = queryString.length; |
2989 |
02 Dec 14 |
olle |
77 |
} |
2989 |
02 Dec 14 |
olle |
return unescape(queryString.substring(begin, end)); |
2989 |
02 Dec 14 |
olle |
79 |
} |
2989 |
02 Dec 14 |
olle |
80 |
} |
4525 |
15 Jun 17 |
nicklas |
return null; |
2989 |
02 Dec 14 |
olle |
82 |
} |
2989 |
02 Dec 14 |
olle |
83 |
|
2989 |
02 Dec 14 |
olle |
function getStorageIntervalInSeconds() |
2989 |
02 Dec 14 |
olle |
85 |
{ |
2989 |
02 Dec 14 |
olle |
var storageIntervalInSeconds = 0; |
2989 |
02 Dec 14 |
olle |
var labEnvDatabaseConfig = getLabEnvDatabaseConfig(); |
2989 |
02 Dec 14 |
olle |
if (labEnvDatabaseConfig != null) |
2989 |
02 Dec 14 |
olle |
89 |
{ |
2989 |
02 Dec 14 |
olle |
storageIntervalInSeconds = labEnvDatabaseConfig.storageIntervalInSeconds; |
2989 |
02 Dec 14 |
olle |
91 |
} |
2989 |
02 Dec 14 |
olle |
return storageIntervalInSeconds; |
2989 |
02 Dec 14 |
olle |
93 |
} |
2989 |
02 Dec 14 |
olle |
94 |
|
2989 |
02 Dec 14 |
olle |
function getLabEnvDatabaseConfig() |
2989 |
02 Dec 14 |
olle |
96 |
{ |
2989 |
02 Dec 14 |
olle |
// Get lab environment database configuration JSON object with AJAX |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
var request = Ajax.getXmlHttpRequest(); |
4525 |
15 Jun 17 |
nicklas |
var url = '../../labenv.jar/LabEnvironment.servlet?ID='+App.getSessionId()+'&cmd=GetLabEnvDatabaseConfig'; |
2989 |
02 Dec 14 |
olle |
request.open("GET", url, false); |
2989 |
02 Dec 14 |
olle |
request.send(null); |
2989 |
02 Dec 14 |
olle |
103 |
|
2989 |
02 Dec 14 |
olle |
var response = JSON.parse(request.responseText); |
2989 |
02 Dec 14 |
olle |
if (response.status != 'ok') |
2989 |
02 Dec 14 |
olle |
106 |
{ |
2989 |
02 Dec 14 |
olle |
setFatalError(response.message); |
2989 |
02 Dec 14 |
olle |
return false; |
2989 |
02 Dec 14 |
olle |
109 |
} |
2989 |
02 Dec 14 |
olle |
110 |
|
2989 |
02 Dec 14 |
olle |
// Get lab environment database configuration information from the AJAX response |
2989 |
02 Dec 14 |
olle |
var labEnvDatabaseConfig = response.labEnvDatabaseConfig; |
2989 |
02 Dec 14 |
olle |
113 |
|
2989 |
02 Dec 14 |
olle |
return labEnvDatabaseConfig; |
2989 |
02 Dec 14 |
olle |
115 |
} |
2989 |
02 Dec 14 |
olle |
116 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.addEventHandlers = function(elements, eventName, handler) |
2989 |
02 Dec 14 |
olle |
118 |
{ |
2989 |
02 Dec 14 |
olle |
for (var i = 0; i < elements.length; i++) |
2989 |
02 Dec 14 |
olle |
120 |
{ |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler(elements[i], eventName, handler); |
2989 |
02 Dec 14 |
olle |
122 |
} |
2989 |
02 Dec 14 |
olle |
123 |
} |
2989 |
02 Dec 14 |
olle |
124 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.fetchSimpleDate = function(dateStr) |
2989 |
02 Dec 14 |
olle |
126 |
{ |
2989 |
02 Dec 14 |
olle |
var simpleDateStr = dateStr; |
2989 |
02 Dec 14 |
olle |
if (simpleDateStr != null) |
2989 |
02 Dec 14 |
olle |
129 |
{ |
2989 |
02 Dec 14 |
olle |
var blankIndex = simpleDateStr.indexOf(" "); |
2989 |
02 Dec 14 |
olle |
if (blankIndex >= 0) |
2989 |
02 Dec 14 |
olle |
132 |
{ |
2989 |
02 Dec 14 |
olle |
// YYYYMMDD HHmm or YYYY-MM-DD HH:mm |
2989 |
02 Dec 14 |
olle |
// Cut off date string before first space |
2989 |
02 Dec 14 |
olle |
simpleDateStr = simpleDateStr.substr(0,blankIndex); |
2989 |
02 Dec 14 |
olle |
136 |
} |
2989 |
02 Dec 14 |
olle |
//alert("simpleDateStr = \"" + simpleDateStr + "\" after removing daytime"); |
2989 |
02 Dec 14 |
olle |
// YYYYMMDD or YYYY-MM-DD |
2989 |
02 Dec 14 |
olle |
var hyphenIndex = simpleDateStr.indexOf("-"); |
2989 |
02 Dec 14 |
olle |
//alert("simpleDateStr = \"" + simpleDateStr + "\" after removing daytime, hyphenIndex = " + hyphenIndex); |
2989 |
02 Dec 14 |
olle |
if (hyphenIndex >= 0) |
2989 |
02 Dec 14 |
olle |
142 |
{ |
2989 |
02 Dec 14 |
olle |
// YYYY-MM-DD |
2989 |
02 Dec 14 |
olle |
// Cut off date string before first space |
2989 |
02 Dec 14 |
olle |
var yearStr = simpleDateStr.substr(0,4); |
2989 |
02 Dec 14 |
olle |
var monthStr = simpleDateStr.substr(5,2); |
2989 |
02 Dec 14 |
olle |
var dayStr = simpleDateStr.substr(8,2); |
2989 |
02 Dec 14 |
olle |
simpleDateStr = yearStr + monthStr + dayStr; |
2989 |
02 Dec 14 |
olle |
//alert("simpleDateStr = \"" + simpleDateStr + "\" after removing hyphens, yearStr = \"" + yearStr + "\" monthStr = \"" + monthStr + "\" dayStr = \"" + dayStr + "\""); |
2989 |
02 Dec 14 |
olle |
150 |
} |
2989 |
02 Dec 14 |
olle |
151 |
} |
2989 |
02 Dec 14 |
olle |
// Date in YYYYMMDD format |
2989 |
02 Dec 14 |
olle |
return simpleDateStr; |
2989 |
02 Dec 14 |
olle |
154 |
} |
2989 |
02 Dec 14 |
olle |
155 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.goCreate = function() |
2989 |
02 Dec 14 |
olle |
157 |
{ |
2989 |
02 Dec 14 |
olle |
if (!intervalIsValid) return; |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
4526 |
19 Jun 17 |
nicklas |
var reportType = labenvdbevpopup.getQueryParameter('reportType') || 'labenvironmentdailydisplay'; |
4525 |
15 Jun 17 |
nicklas |
var url = '../LabEnvironmentDisplay.servlet?ID='+App.getSessionId()+'&cmd='+reportType; |
2989 |
02 Dec 14 |
olle |
var fromDate = null; |
2989 |
02 Dec 14 |
olle |
var chartVariant = null; |
2989 |
02 Dec 14 |
olle |
if (chartVariant == null) |
2989 |
02 Dec 14 |
olle |
165 |
{ |
2989 |
02 Dec 14 |
olle |
chartVariant = 'http://givare1.onk.lu.se/'; |
2989 |
02 Dec 14 |
olle |
167 |
} |
2989 |
02 Dec 14 |
olle |
var pageTitle = labenvdbevpopup.getQueryParameter('pageTitle'); |
2989 |
02 Dec 14 |
olle |
var labSensorUrl = labenvdbevpopup.getQueryParameter('labSensorUrl'); |
2989 |
02 Dec 14 |
olle |
var originDate = labenvdbevpopup.getQueryParameter('originDate'); |
2989 |
02 Dec 14 |
olle |
originDate = labenvdbevpopup.fetchSimpleDate(originDate); |
2989 |
02 Dec 14 |
olle |
if (originDate != null) |
2989 |
02 Dec 14 |
olle |
173 |
{ |
2989 |
02 Dec 14 |
olle |
fromDate = originDate; |
2989 |
02 Dec 14 |
olle |
175 |
} |
2989 |
02 Dec 14 |
olle |
if (labSensorUrl != null) |
2989 |
02 Dec 14 |
olle |
177 |
{ |
2989 |
02 Dec 14 |
olle |
chartVariant = labSensorUrl; |
2989 |
02 Dec 14 |
olle |
179 |
} |
2989 |
02 Dec 14 |
olle |
if (pageTitle != null) url += '&pagetitle='+pageTitle; |
2989 |
02 Dec 14 |
olle |
if (fromDate != null) url += '&fdate='+fromDate; |
2989 |
02 Dec 14 |
olle |
if (chartVariant != null) url += '&cvariant='+chartVariant; |
2989 |
02 Dec 14 |
olle |
183 |
|
2989 |
02 Dec 14 |
olle |
Wizard.showLoadingAnimation('Generating plots...'); |
2989 |
02 Dec 14 |
olle |
Wizard.asyncJsonRequest(url, labenvdbevpopup.onPlotGenerated); |
2989 |
02 Dec 14 |
olle |
186 |
} |
2989 |
02 Dec 14 |
olle |
187 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.onPlotGenerated = function(response) |
2989 |
02 Dec 14 |
olle |
189 |
{ |
3364 |
02 Jun 15 |
olle |
Doc.show('reportSection'); |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
var reportType = 'labenvironmentdailydisplay'; |
2989 |
02 Dec 14 |
olle |
if (response.status != 'ok') |
2989 |
02 Dec 14 |
olle |
194 |
{ |
2989 |
02 Dec 14 |
olle |
setFatalError(response.message); |
2989 |
02 Dec 14 |
olle |
return false; |
2989 |
02 Dec 14 |
olle |
197 |
} |
2989 |
02 Dec 14 |
olle |
var report = response.report; |
2989 |
02 Dec 14 |
olle |
var permissionDeniedForPatientName = report.permissionDeniedForPatientName; |
2989 |
02 Dec 14 |
olle |
var pageTitle = report.pageTitle; |
2989 |
02 Dec 14 |
olle |
if (pageTitle == null || pageTitle == '') |
2989 |
02 Dec 14 |
olle |
202 |
{ |
2989 |
02 Dec 14 |
olle |
pageTitle = 'LabEnv'; |
2989 |
02 Dec 14 |
olle |
204 |
} |
2989 |
02 Dec 14 |
olle |
// Print optional page title |
2989 |
02 Dec 14 |
olle |
var pageTitleElement = document.getElementById('pageTitleId'); |
2989 |
02 Dec 14 |
olle |
pageTitleElement.innerHTML = pageTitle; |
2989 |
02 Dec 14 |
olle |
var reportTable; |
2989 |
02 Dec 14 |
olle |
var cellElement = document.getElementById('reportdiv'); |
2989 |
02 Dec 14 |
olle |
if (report != null) |
2989 |
02 Dec 14 |
olle |
211 |
{ |
2989 |
02 Dec 14 |
olle |
var storageIntervalInSeconds = labenvdbevpopup.getStorageIntervalInSeconds(); |
4525 |
15 Jun 17 |
nicklas |
var draw_area_wdt = parseInt(labenvdbevpopup.getQueryParameter('plotWidth')) || 700; |
4525 |
15 Jun 17 |
nicklas |
var draw_area_hgt = parseInt(labenvdbevpopup.getQueryParameter('plotHeight')) || 550; |
2989 |
02 Dec 14 |
olle |
var draw_scale_factor = 2; |
2989 |
02 Dec 14 |
olle |
var jsonStatisticsPlotArray = report.plotStatistics; |
2989 |
02 Dec 14 |
olle |
// Draw plots |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportdiv").innerHTML=""; |
2989 |
02 Dec 14 |
olle |
// Write optional page header |
2989 |
02 Dec 14 |
olle |
if (pageTitle != null && pageTitle != '') |
2989 |
02 Dec 14 |
olle |
221 |
{ |
2989 |
02 Dec 14 |
olle |
// Print optional page headline |
2989 |
02 Dec 14 |
olle |
var headlineText = document.createElement('text'); |
2989 |
02 Dec 14 |
olle |
headlineText.innerHTML = "<h2>" + pageTitle + "</h2><BR>"; |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(headlineText); |
2989 |
02 Dec 14 |
olle |
226 |
} |
4525 |
15 Jun 17 |
nicklas |
var originDate = labenvdbevpopup.getQueryParameter('originDate') || Dates.formatDate(new Date()); |
2989 |
02 Dec 14 |
olle |
for (var plotIndex in jsonStatisticsPlotArray) |
2989 |
02 Dec 14 |
olle |
229 |
{ |
2989 |
02 Dec 14 |
olle |
230 |
// |
2989 |
02 Dec 14 |
olle |
// Get plot JSON data container with extra info and plot data |
2989 |
02 Dec 14 |
olle |
var plotJsonDataContainer = jsonStatisticsPlotArray[plotIndex]; |
2989 |
02 Dec 14 |
olle |
// Get plot JSON extra info and plot data |
2989 |
02 Dec 14 |
olle |
var plotChartVariant = plotJsonDataContainer['chartVariant']; |
2989 |
02 Dec 14 |
olle |
var plotViewType = plotJsonDataContainer['viewType']; |
2989 |
02 Dec 14 |
olle |
var plotOptionalHeadline = plotJsonDataContainer['optionalHeadline']; |
2989 |
02 Dec 14 |
olle |
var boxPlotJsonData = plotJsonDataContainer['plotData']; |
2989 |
02 Dec 14 |
olle |
// Create plot from plot JSON data |
2989 |
02 Dec 14 |
olle |
if (plotOptionalHeadline != null && plotOptionalHeadline != '') |
2989 |
02 Dec 14 |
olle |
240 |
{ |
2989 |
02 Dec 14 |
olle |
// Print optional headline |
2989 |
02 Dec 14 |
olle |
var headlineText = document.createElement('text'); |
2989 |
02 Dec 14 |
olle |
headlineText.innerHTML = "<BR>" + plotOptionalHeadline + "<BR>"; |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(headlineText); |
2989 |
02 Dec 14 |
olle |
245 |
} |
2989 |
02 Dec 14 |
olle |
var plotKey = plotChartVariant + '_' + plotViewType; |
2989 |
02 Dec 14 |
olle |
// Add plot |
2989 |
02 Dec 14 |
olle |
var canvasInTable = document.createElement('canvas'); |
2989 |
02 Dec 14 |
olle |
canvasInTable.setAttribute('id', plotKey); |
2989 |
02 Dec 14 |
olle |
canvasInTable.setAttribute('width', draw_area_wdt * draw_scale_factor); |
2989 |
02 Dec 14 |
olle |
canvasInTable.setAttribute('height', draw_area_hgt * draw_scale_factor); |
4525 |
15 Jun 17 |
nicklas |
canvasInTable.style.width = (draw_area_wdt)+'px'; |
4525 |
15 Jun 17 |
nicklas |
canvasInTable.style.height = (draw_area_hgt)+'px'; |
4525 |
15 Jun 17 |
nicklas |
boxPlotJsonData.titleTop = originDate; |
2989 |
02 Dec 14 |
olle |
createGraphPlot(boxPlotJsonData, canvasInTable, draw_area_wdt, draw_area_hgt, draw_scale_factor, plotViewType, storageIntervalInSeconds); |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(canvasInTable); |
2989 |
02 Dec 14 |
olle |
canvasInTable.addEventListener('mousemove', labenvdbevpopup.drawCanvasGuidelines, false); |
2989 |
02 Dec 14 |
olle |
canvasInTable.addEventListener('mouseleave', labenvdbevpopup.hideCanvasGuidelines, false); |
2989 |
02 Dec 14 |
olle |
259 |
} |
2989 |
02 Dec 14 |
olle |
// Print optional appended info |
2989 |
02 Dec 14 |
olle |
var appendedInfo = report.appendedInfo; |
2989 |
02 Dec 14 |
olle |
if (appendedInfo != null && appendedInfo != '') |
2989 |
02 Dec 14 |
olle |
263 |
{ |
2989 |
02 Dec 14 |
olle |
// Print optional headline |
2989 |
02 Dec 14 |
olle |
var infoText = document.createElement('text'); |
2989 |
02 Dec 14 |
olle |
infoText.innerHTML = "<BR>" + appendedInfo + "<BR>"; |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(infoText); |
2989 |
02 Dec 14 |
olle |
268 |
} |
2989 |
02 Dec 14 |
olle |
269 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
271 |
{ |
2989 |
02 Dec 14 |
olle |
var messageCell = getTableCellElement(document, 'No values could be found during given period', 'reportheader'); |
2989 |
02 Dec 14 |
olle |
var messageRow = document.createElement('tr'); |
2989 |
02 Dec 14 |
olle |
messageRow.appendChild(messageCell); |
2989 |
02 Dec 14 |
olle |
var messageTable = getReportTable(); |
2989 |
02 Dec 14 |
olle |
messageTable.appendChild(messageRow); |
2989 |
02 Dec 14 |
olle |
reportTable = messageTable; |
2989 |
02 Dec 14 |
olle |
278 |
} |
2989 |
02 Dec 14 |
olle |
Doc.show('goprint'); |
2989 |
02 Dec 14 |
olle |
Doc.show('gorestart'); |
2989 |
02 Dec 14 |
olle |
281 |
} |
2989 |
02 Dec 14 |
olle |
282 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.getReportTable = function() |
2989 |
02 Dec 14 |
olle |
284 |
{ |
2989 |
02 Dec 14 |
olle |
var reportTable = document.createElement('table'); |
2989 |
02 Dec 14 |
olle |
reportTable.setAttribute('class','reporttable'); |
2989 |
02 Dec 14 |
olle |
reportTable.setAttribute('border','1'); |
2989 |
02 Dec 14 |
olle |
return reportTable; |
2989 |
02 Dec 14 |
olle |
289 |
} |
2989 |
02 Dec 14 |
olle |
290 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.getTableCellElement = function(topDocument, text, clazz, colspan, rowspan) |
2989 |
02 Dec 14 |
olle |
292 |
{ |
2989 |
02 Dec 14 |
olle |
if (topDocument != null) |
2989 |
02 Dec 14 |
olle |
294 |
{ |
2989 |
02 Dec 14 |
olle |
cellElement = topDocument.createElement('td'); |
2989 |
02 Dec 14 |
olle |
296 |
} |
2989 |
02 Dec 14 |
olle |
var cellElement = topDocument.createElement('td'); |
2989 |
02 Dec 14 |
olle |
text = new String(text); |
2989 |
02 Dec 14 |
olle |
var textArray = text.split("\n"); |
2989 |
02 Dec 14 |
olle |
if (textArray.length > 1) |
2989 |
02 Dec 14 |
olle |
301 |
{ |
2989 |
02 Dec 14 |
olle |
for (var i=0;i<textArray.length;i++) |
2989 |
02 Dec 14 |
olle |
303 |
{ |
2989 |
02 Dec 14 |
olle |
if (i>0)cellElement.appendChild(topDocument.createElement('br')); |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(topDocument.createTextNode(textArray[i])); |
2989 |
02 Dec 14 |
olle |
306 |
} |
2989 |
02 Dec 14 |
olle |
307 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
309 |
{ |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(topDocument.createTextNode(text)); |
2989 |
02 Dec 14 |
olle |
311 |
} |
2989 |
02 Dec 14 |
olle |
cellElement.setAttribute('class', clazz); |
2989 |
02 Dec 14 |
olle |
if (colspan != null) cellElement.setAttribute('colspan', colspan); |
2989 |
02 Dec 14 |
olle |
if (rowspan != null) cellElement.setAttribute('rowspan', rowspan); |
2989 |
02 Dec 14 |
olle |
315 |
|
2989 |
02 Dec 14 |
olle |
return cellElement; |
2989 |
02 Dec 14 |
olle |
317 |
} |
2989 |
02 Dec 14 |
olle |
318 |
|
2989 |
02 Dec 14 |
olle |
var xGuide; |
2989 |
02 Dec 14 |
olle |
var yGuide; |
2989 |
02 Dec 14 |
olle |
321 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.drawCanvasGuidelines = function(event) |
2989 |
02 Dec 14 |
olle |
323 |
{ |
2989 |
02 Dec 14 |
olle |
if (!xGuide) |
2989 |
02 Dec 14 |
olle |
325 |
{ |
2989 |
02 Dec 14 |
olle |
xGuide = document.getElementById('x-guide'); |
2989 |
02 Dec 14 |
olle |
yGuide = document.getElementById('y-guide'); |
2989 |
02 Dec 14 |
olle |
328 |
} |
2989 |
02 Dec 14 |
olle |
var canvas = event.target; |
2989 |
02 Dec 14 |
olle |
var centerX = event.clientX; |
2989 |
02 Dec 14 |
olle |
var centerY = event.clientY; |
3364 |
02 Jun 15 |
olle |
var canvasPos = Doc.getElementPosition(canvas); |
4526 |
19 Jun 17 |
nicklas |
var startX = canvasPos.left+60; |
4526 |
19 Jun 17 |
nicklas |
var widthX = canvasPos.width-120; |
4526 |
19 Jun 17 |
nicklas |
var startY = canvasPos.top+65; |
4526 |
19 Jun 17 |
nicklas |
var heightY = canvasPos.height-120; |
2989 |
02 Dec 14 |
olle |
if (centerY < startY || centerY > startY+heightY) |
2989 |
02 Dec 14 |
olle |
338 |
{ |
2989 |
02 Dec 14 |
olle |
// Hide when mouse is in the text area below or over the plot |
2989 |
02 Dec 14 |
olle |
yGuide.style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
341 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
343 |
{ |
2989 |
02 Dec 14 |
olle |
yGuide.style.top = (centerY-2) + 'px'; |
2989 |
02 Dec 14 |
olle |
yGuide.style.left = startX + 'px'; |
2989 |
02 Dec 14 |
olle |
yGuide.style.width = widthX + 'px'; |
2989 |
02 Dec 14 |
olle |
yGuide.style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
348 |
} |
2989 |
02 Dec 14 |
olle |
if (centerX < startX || centerX > startX + widthX) |
2989 |
02 Dec 14 |
olle |
350 |
{ |
2989 |
02 Dec 14 |
olle |
// Hide when mouse is in the text area to the left or right of the plot |
2989 |
02 Dec 14 |
olle |
xGuide.style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
353 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
355 |
{ |
3364 |
02 Jun 15 |
olle |
// Avoid drawing outside the avilable height (causes an extra pair of scroll bars) |
3364 |
02 Jun 15 |
olle |
var yLimit = App.getWindowPosition().height; |
2989 |
02 Dec 14 |
olle |
if (startY+heightY > yLimit) |
2989 |
02 Dec 14 |
olle |
359 |
{ |
2989 |
02 Dec 14 |
olle |
heightY = yLimit-startY; |
2989 |
02 Dec 14 |
olle |
361 |
} |
2989 |
02 Dec 14 |
olle |
xGuide.style.top = startY + 'px'; |
2989 |
02 Dec 14 |
olle |
xGuide.style.left = (centerX-2) + 'px'; |
2989 |
02 Dec 14 |
olle |
xGuide.style.height = heightY + 'px'; |
2989 |
02 Dec 14 |
olle |
xGuide.style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
366 |
} |
2989 |
02 Dec 14 |
olle |
367 |
|
2989 |
02 Dec 14 |
olle |
368 |
} |
2989 |
02 Dec 14 |
olle |
369 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.hideCanvasGuidelines = function(event) |
2989 |
02 Dec 14 |
olle |
371 |
{ |
2989 |
02 Dec 14 |
olle |
xGuide.style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
yGuide.style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
374 |
} |
2989 |
02 Dec 14 |
olle |
375 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.printVersion = function() |
2989 |
02 Dec 14 |
olle |
377 |
{ |
2989 |
02 Dec 14 |
olle |
var printNote = '<b>Note!</b> For better printing set page orientation to <i>portrait</i>.'; |
2989 |
02 Dec 14 |
olle |
printNote += ' Scale down to <i>90%</i> to fit 2 plots per page.'; |
3735 |
10 Feb 16 |
olle |
LabEnv.openPrintWindow('reportcell', 'Lab environment ', 'portrait', printNote, '../', 'report.css'); |
2989 |
02 Dec 14 |
olle |
381 |
} |
2989 |
02 Dec 14 |
olle |
382 |
|
2989 |
02 Dec 14 |
olle |
labenvdbevpopup.cancelPrint = function() |
2989 |
02 Dec 14 |
olle |
384 |
{ |
2989 |
02 Dec 14 |
olle |
window.close(); |
2989 |
02 Dec 14 |
olle |
386 |
} |
2989 |
02 Dec 14 |
olle |
387 |
|
2989 |
02 Dec 14 |
olle |
return labenvdbevpopup; |
2989 |
02 Dec 14 |
olle |
389 |
}(); |
2989 |
02 Dec 14 |
olle |
390 |
|
2989 |
02 Dec 14 |
olle |
Doc.onLoad(LabEnvDbEvPopup.initPage); |
2989 |
02 Dec 14 |
olle |
392 |
|