7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2013 Nicklas Nordborg |
7604 |
25 Feb 19 |
nicklas |
4 |
|
7604 |
25 Feb 19 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
7604 |
25 Feb 19 |
nicklas |
Available at http://base.thep.lu.se/ |
7604 |
25 Feb 19 |
nicklas |
7 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is free software; you can redistribute it and/or |
7604 |
25 Feb 19 |
nicklas |
modify it under the terms of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
as published by the Free Software Foundation; either version 3 |
7604 |
25 Feb 19 |
nicklas |
of the License, or (at your option) any later version. |
7604 |
25 Feb 19 |
nicklas |
12 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is distributed in the hope that it will be useful, |
7604 |
25 Feb 19 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7604 |
25 Feb 19 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7604 |
25 Feb 19 |
nicklas |
GNU General Public License for more details. |
7604 |
25 Feb 19 |
nicklas |
17 |
|
7604 |
25 Feb 19 |
nicklas |
You should have received a copy of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7604 |
25 Feb 19 |
nicklas |
20 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
21 |
|
7604 |
25 Feb 19 |
nicklas |
@author Nicklas |
7604 |
25 Feb 19 |
nicklas |
23 |
*/ |
7604 |
25 Feb 19 |
nicklas |
'use strict'; |
7604 |
25 Feb 19 |
nicklas |
25 |
|
7604 |
25 Feb 19 |
nicklas |
var View = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var view = {}; |
7604 |
25 Feb 19 |
nicklas |
29 |
|
7604 |
25 Feb 19 |
nicklas |
30 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
32 |
*/ |
7604 |
25 Feb 19 |
nicklas |
view.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
34 |
{ |
7604 |
25 Feb 19 |
nicklas |
35 |
|
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('explorer.search', view.viewSearch); |
7604 |
25 Feb 19 |
nicklas |
37 |
|
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['reporter']; |
7604 |
25 Feb 19 |
nicklas |
frm.cmd.value = 'SetReporterColumns'; |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnReporterColumns', Buttons.configureColumns, {'table-id': 'reporter', 'settings': 'reporter-columns'}); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSpotColumns', Buttons.configureColumns, {'table-id': 'spotdata'}); |
7604 |
25 Feb 19 |
nicklas |
42 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('newReporterIndex', 'keypress', Events.integerOnly); |
7604 |
25 Feb 19 |
nicklas |
Events.doOnEnter('newReporterIndex', view.gotoReporterIndex); |
7604 |
25 Feb 19 |
nicklas |
45 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('newSpotIndex', 'keypress', Events.integerOnly); |
7604 |
25 Feb 19 |
nicklas |
Events.doOnEnter('newSpotIndex', view.gotoSpotIndex); |
7604 |
25 Feb 19 |
nicklas |
48 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAssayPlot', view.assayPlot); |
7604 |
25 Feb 19 |
nicklas |
50 |
|
7604 |
25 Feb 19 |
nicklas |
view.initAnnotationSummary(); |
7604 |
25 Feb 19 |
nicklas |
52 |
} |
7604 |
25 Feb 19 |
nicklas |
53 |
|
7604 |
25 Feb 19 |
nicklas |
view.initElements = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
55 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'annotation-plot') |
7604 |
25 Feb 19 |
nicklas |
57 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, view.annotationPlot); |
7604 |
25 Feb 19 |
nicklas |
59 |
} |
7604 |
25 Feb 19 |
nicklas |
60 |
} |
7604 |
25 Feb 19 |
nicklas |
61 |
|
7604 |
25 Feb 19 |
nicklas |
view.gotoReporterIndex = function(event) |
7604 |
25 Feb 19 |
nicklas |
63 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['reporterIndex']; |
7604 |
25 Feb 19 |
nicklas |
var reporterIndex = parseInt(frm.newReporterIndex.value); |
7604 |
25 Feb 19 |
nicklas |
var maxIndex = Data.int(event.currentTarget, 'max-index'); |
7604 |
25 Feb 19 |
nicklas |
if (reporterIndex < 1 || reporterIndex > maxIndex) |
7604 |
25 Feb 19 |
nicklas |
68 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.newReporterIndex, 'The reporter index must be between 1 and ' + maxIndex); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
71 |
} |
7604 |
25 Feb 19 |
nicklas |
frm.cmd.value = 'SetReporterIndex'; |
7604 |
25 Feb 19 |
nicklas |
Forms.addHidden(frm, 'reporterIndex', reporterIndex-1); |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
75 |
} |
7604 |
25 Feb 19 |
nicklas |
76 |
|
7604 |
25 Feb 19 |
nicklas |
view.gotoSpotIndex = function(event) |
7604 |
25 Feb 19 |
nicklas |
78 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['spotIndex']; |
7604 |
25 Feb 19 |
nicklas |
var spotIndex = parseInt(frm.newSpotIndex.value); |
7604 |
25 Feb 19 |
nicklas |
var maxIndex = Data.int(event.currentTarget, 'max-index'); |
7604 |
25 Feb 19 |
nicklas |
if (spotIndex < 1 || spotIndex > maxIndex) |
7604 |
25 Feb 19 |
nicklas |
83 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.newSpotIndex, 'The spot index must be between 1 and ' + maxIndex); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
86 |
} |
7604 |
25 Feb 19 |
nicklas |
frm.cmd.value = 'SetSpotIndex'; |
7604 |
25 Feb 19 |
nicklas |
Forms.addHidden(frm, 'spotIndex', spotIndex-1); |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
90 |
} |
7604 |
25 Feb 19 |
nicklas |
91 |
|
7604 |
25 Feb 19 |
nicklas |
view.viewSearch = function() |
7604 |
25 Feb 19 |
nicklas |
93 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../search/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&bioassayset_id='+Data.get('page-data', 'bioassayset-id'); |
7604 |
25 Feb 19 |
nicklas |
location.href = url; |
7604 |
25 Feb 19 |
nicklas |
97 |
} |
7604 |
25 Feb 19 |
nicklas |
98 |
|
7604 |
25 Feb 19 |
nicklas |
view.assayPlot = function() |
7604 |
25 Feb 19 |
nicklas |
100 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['spotdata']; |
7604 |
25 Feb 19 |
nicklas |
102 |
|
7604 |
25 Feb 19 |
nicklas |
var url = 'plotter.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&type=assay'; |
7604 |
25 Feb 19 |
nicklas |
url += '&bioAssaySetId='+Data.get('page-data', 'bioassayset-id'); |
7604 |
25 Feb 19 |
nicklas |
url += '&reporterIndex='+frm.reporter_index.value; |
7604 |
25 Feb 19 |
nicklas |
url += '&positionIndex='+frm.position_index.value; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'AssayPlot', 1250, 700); |
7604 |
25 Feb 19 |
nicklas |
109 |
} |
7604 |
25 Feb 19 |
nicklas |
110 |
|
7604 |
25 Feb 19 |
nicklas |
view.annotationPlot = function(event) |
7604 |
25 Feb 19 |
nicklas |
112 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['spotdata']; |
7604 |
25 Feb 19 |
nicklas |
var url = 'plotter.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&type=annotation'; |
7604 |
25 Feb 19 |
nicklas |
url += '&bioAssaySetId='+Data.get('page-data', 'bioassayset-id'); |
7604 |
25 Feb 19 |
nicklas |
url += '&reporterIndex='+frm.reporter_index.value; |
7604 |
25 Feb 19 |
nicklas |
url += '&positionIndex='+frm.position_index.value; |
7604 |
25 Feb 19 |
nicklas |
url += '&annotationTypeId=' + Data.get(event.currentTarget, 'annotation-type'); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'AnnotationPlot', 1250, 700); |
7604 |
25 Feb 19 |
nicklas |
121 |
} |
7604 |
25 Feb 19 |
nicklas |
122 |
|
7604 |
25 Feb 19 |
nicklas |
view.initAnnotationSummary = function() |
7604 |
25 Feb 19 |
nicklas |
124 |
{ |
7604 |
25 Feb 19 |
nicklas |
var summary = Data.json('annotation-summary', 'summary'); |
7604 |
25 Feb 19 |
nicklas |
var channels = Data.int('annotation-summary', 'channels'); |
7604 |
25 Feb 19 |
nicklas |
127 |
|
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < summary.length; i++) |
7604 |
25 Feb 19 |
nicklas |
129 |
{ |
7604 |
25 Feb 19 |
nicklas |
var at = summary[i]; |
7604 |
25 Feb 19 |
nicklas |
131 |
|
7604 |
25 Feb 19 |
nicklas |
var groups = at.groups; |
7604 |
25 Feb 19 |
nicklas |
for (var g = 0; g < groups.length; g++) |
7604 |
25 Feb 19 |
nicklas |
134 |
{ |
7604 |
25 Feb 19 |
nicklas |
var group = groups[g]; |
7604 |
25 Feb 19 |
nicklas |
var elementId = at.id+'.'+group.id; |
7604 |
25 Feb 19 |
nicklas |
Doc.element('count.'+elementId).innerHTML = group.count; |
7604 |
25 Feb 19 |
nicklas |
138 |
|
7604 |
25 Feb 19 |
nicklas |
for (var ch = 1; ch <= channels; ch++) |
7604 |
25 Feb 19 |
nicklas |
140 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.element('mean.'+elementId+'.ch'+ch).innerHTML = group.mean[ch-1]; |
7604 |
25 Feb 19 |
nicklas |
142 |
} |
7604 |
25 Feb 19 |
nicklas |
143 |
|
7604 |
25 Feb 19 |
nicklas |
if (group.gmean) |
7604 |
25 Feb 19 |
nicklas |
145 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.element('gmean.'+elementId).innerHTML = group.gmean; |
7604 |
25 Feb 19 |
nicklas |
Doc.element('sd.'+elementId).innerHTML = group.sd; |
7604 |
25 Feb 19 |
nicklas |
148 |
} |
7604 |
25 Feb 19 |
nicklas |
149 |
} |
7604 |
25 Feb 19 |
nicklas |
150 |
} |
7604 |
25 Feb 19 |
nicklas |
151 |
} |
7604 |
25 Feb 19 |
nicklas |
152 |
|
7604 |
25 Feb 19 |
nicklas |
return view; |
7604 |
25 Feb 19 |
nicklas |
154 |
}(); |
7604 |
25 Feb 19 |
nicklas |
155 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(View.initPage); |
7604 |
25 Feb 19 |
nicklas |
Doc.addElementInitializer(View.initElements); |