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 BioAssaySets = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var bioassaysets = {}; |
7604 |
25 Feb 19 |
nicklas |
var plotQueue; |
7604 |
25 Feb 19 |
nicklas |
var plotIndex; |
7604 |
25 Feb 19 |
nicklas |
31 |
|
7604 |
25 Feb 19 |
nicklas |
32 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
34 |
*/ |
7604 |
25 Feb 19 |
nicklas |
bioassaysets.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
36 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pageId = Doc.getPageId(); |
7604 |
25 Feb 19 |
nicklas |
if (pageId == 'edit-page') |
7604 |
25 Feb 19 |
nicklas |
39 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Save + Close buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', bioassaysets.save); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
43 |
|
7604 |
25 Feb 19 |
nicklas |
// Tab validation |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('settings.annotations', Annotations.onSwitchToAnnotationsTab); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabValidator('settings.info', bioassaysets.validateBioAssaySet); |
7604 |
25 Feb 19 |
nicklas |
47 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'view-page') |
7604 |
25 Feb 19 |
nicklas |
49 |
{ |
7604 |
25 Feb 19 |
nicklas |
var itemId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var experimentId = Data.get('page-data', 'experiment-id'); |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'BIOASSAYSET', 'item-id': itemId, 'extra-url': '&experiment_id='+experimentId}; |
7604 |
25 Feb 19 |
nicklas |
53 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnFilter', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAnalyze', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnPlot', bioassaysets.openPlotTool); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnExperimentExplorer', bioassaysets.openExperimentExplorer); |
7604 |
25 Feb 19 |
nicklas |
65 |
|
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('view.annotations', AnnotationsList.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('view.bioassays', bioassaysets.viewBioAssays); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('view.spotdata', bioassaysets.viewSpotData); |
7604 |
25 Feb 19 |
nicklas |
if (Data.get('view', 'initial-tab') != 'overviewplots') |
7604 |
25 Feb 19 |
nicklas |
70 |
{ |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('view.overviewplots', bioassaysets.viewOverviewPlots); |
7604 |
25 Feb 19 |
nicklas |
72 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
74 |
{ |
7604 |
25 Feb 19 |
nicklas |
TabControl.setSwitchFunction('overviewplots', bioassaysets.loadOverviewPlots); |
7604 |
25 Feb 19 |
nicklas |
Doc.addFinalizer(bioassaysets.loadOverviewPlots); // Need delay since tab is not yet active |
7604 |
25 Feb 19 |
nicklas |
77 |
} |
7604 |
25 Feb 19 |
nicklas |
78 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'list-page') |
7604 |
25 Feb 19 |
nicklas |
80 |
{ |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'BIOASSAYSET'}; |
7604 |
25 Feb 19 |
nicklas |
var tableAttributes = {'table-id': 'bioAssaySets'}; |
7604 |
25 Feb 19 |
nicklas |
83 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnOk', Buttons.returnSelected, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
86 |
|
7604 |
25 Feb 19 |
nicklas |
TabControl.setSwitchFunction('main', bioassaysets.switchTab); |
7604 |
25 Feb 19 |
nicklas |
88 |
} |
7604 |
25 Feb 19 |
nicklas |
89 |
} |
7604 |
25 Feb 19 |
nicklas |
90 |
|
7604 |
25 Feb 19 |
nicklas |
bioassaysets.switchTab = function(event) |
7604 |
25 Feb 19 |
nicklas |
92 |
{ |
7604 |
25 Feb 19 |
nicklas |
var target = event.target; |
7604 |
25 Feb 19 |
nicklas |
var tabId = target.id.substring(5); |
7604 |
25 Feb 19 |
nicklas |
95 |
|
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioAssaySets']; |
7604 |
25 Feb 19 |
nicklas |
var experimentId = frm.experiment_id.value; |
7604 |
25 Feb 19 |
nicklas |
98 |
|
7604 |
25 Feb 19 |
nicklas |
var url; |
7604 |
25 Feb 19 |
nicklas |
if (tabId == 'clonedreporters') |
7604 |
25 Feb 19 |
nicklas |
101 |
{ |
7604 |
25 Feb 19 |
nicklas |
url = '../reporters/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&experiment_id='+experimentId; |
7604 |
25 Feb 19 |
nicklas |
104 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
106 |
{ |
7604 |
25 Feb 19 |
nicklas |
url = '../index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=ViewItem&item_id='+experimentId; |
7604 |
25 Feb 19 |
nicklas |
url += '&tab='+tabId; |
7604 |
25 Feb 19 |
nicklas |
110 |
} |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
112 |
} |
7604 |
25 Feb 19 |
nicklas |
113 |
|
7604 |
25 Feb 19 |
nicklas |
bioassaysets.validateBioAssaySet = function() |
7604 |
25 Feb 19 |
nicklas |
115 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioAssaySet']; |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.name.value) == '') |
7604 |
25 Feb 19 |
nicklas |
118 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.name, 'You must enter a name'); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
121 |
} |
7604 |
25 Feb 19 |
nicklas |
return true; |
7604 |
25 Feb 19 |
nicklas |
123 |
} |
7604 |
25 Feb 19 |
nicklas |
124 |
|
7604 |
25 Feb 19 |
nicklas |
bioassaysets.save = function() |
7604 |
25 Feb 19 |
nicklas |
126 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioAssaySet']; |
7604 |
25 Feb 19 |
nicklas |
if (TabControl.validateActiveTab('settings')) |
7604 |
25 Feb 19 |
nicklas |
129 |
{ |
7604 |
25 Feb 19 |
nicklas |
Annotations.saveModifiedAnnotationsToForm(frm); |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
132 |
} |
7604 |
25 Feb 19 |
nicklas |
133 |
} |
7604 |
25 Feb 19 |
nicklas |
134 |
|
7604 |
25 Feb 19 |
nicklas |
bioassaysets.viewBioAssays = function() |
7604 |
25 Feb 19 |
nicklas |
136 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../bioassays/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&experiment_id='+Data.get('page-data', 'experiment-id'); |
7604 |
25 Feb 19 |
nicklas |
url += '&bioassayset_id='+Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
141 |
} |
7604 |
25 Feb 19 |
nicklas |
142 |
|
7604 |
25 Feb 19 |
nicklas |
bioassaysets.viewSpotData = function() |
7604 |
25 Feb 19 |
nicklas |
144 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../spotdata/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&experiment_id='+Data.get('page-data', 'experiment-id'); |
7604 |
25 Feb 19 |
nicklas |
url += '&bioassayset_id='+Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
149 |
} |
7604 |
25 Feb 19 |
nicklas |
150 |
|
7604 |
25 Feb 19 |
nicklas |
bioassaysets.viewOverviewPlots = function() |
7604 |
25 Feb 19 |
nicklas |
152 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = 'index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=ViewItem&tab=overviewplots'; |
7604 |
25 Feb 19 |
nicklas |
url += '&experiment_id='+Data.get('page-data', 'experiment-id'); |
7604 |
25 Feb 19 |
nicklas |
url += '&bioassayset_id='+Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
158 |
} |
7604 |
25 Feb 19 |
nicklas |
159 |
|
7604 |
25 Feb 19 |
nicklas |
bioassaysets.openPlotTool = function() |
7604 |
25 Feb 19 |
nicklas |
161 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../plotter/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&bioassayset_id='+Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'Plotter', 1250, 700); |
7604 |
25 Feb 19 |
nicklas |
165 |
} |
7604 |
25 Feb 19 |
nicklas |
166 |
|
7604 |
25 Feb 19 |
nicklas |
bioassaysets.openExperimentExplorer = function(event) |
7604 |
25 Feb 19 |
nicklas |
168 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../explorer/view/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&bioassayset_id='+Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
location.href = url; |
7604 |
25 Feb 19 |
nicklas |
172 |
} |
7604 |
25 Feb 19 |
nicklas |
173 |
|
7604 |
25 Feb 19 |
nicklas |
174 |
/* |
7604 |
25 Feb 19 |
nicklas |
Initialize loading of overview plots for a single tab. |
7604 |
25 Feb 19 |
nicklas |
Eg. load 'plot' elements into the 'plotQueue' and reset |
7604 |
25 Feb 19 |
nicklas |
the plotIndex. |
7604 |
25 Feb 19 |
nicklas |
178 |
*/ |
7604 |
25 Feb 19 |
nicklas |
bioassaysets.loadOverviewPlots = function(event) |
7604 |
25 Feb 19 |
nicklas |
180 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (event) |
7604 |
25 Feb 19 |
nicklas |
182 |
{ |
7604 |
25 Feb 19 |
nicklas |
TabControl.setActiveTab(event.currentTarget); |
7604 |
25 Feb 19 |
nicklas |
184 |
} |
7604 |
25 Feb 19 |
nicklas |
var content = Doc.element(Doc.element('overviewplots').activeTab.id+'.content'); |
7604 |
25 Feb 19 |
nicklas |
186 |
|
7604 |
25 Feb 19 |
nicklas |
plotQueue = content.getElementsByClassName('plot'); |
7604 |
25 Feb 19 |
nicklas |
plotIndex = 0; |
7604 |
25 Feb 19 |
nicklas |
setTimeout(bioassaysets.loadNextPlot, 100); |
7604 |
25 Feb 19 |
nicklas |
190 |
} |
7604 |
25 Feb 19 |
nicklas |
191 |
|
7604 |
25 Feb 19 |
nicklas |
192 |
/* |
7604 |
25 Feb 19 |
nicklas |
Start loading the next plot from the plotQueue. plotIndex points |
7604 |
25 Feb 19 |
nicklas |
to the next plot to be loaded. |
7604 |
25 Feb 19 |
nicklas |
195 |
*/ |
7604 |
25 Feb 19 |
nicklas |
bioassaysets.loadNextPlot = function() |
7604 |
25 Feb 19 |
nicklas |
197 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!plotQueue) return; |
7604 |
25 Feb 19 |
nicklas |
199 |
|
7604 |
25 Feb 19 |
nicklas |
// Find next plot that is not yet loaded |
7604 |
25 Feb 19 |
nicklas |
while (plotIndex < plotQueue.length && Data.int(plotQueue[plotIndex], 'is-loaded')) |
7604 |
25 Feb 19 |
nicklas |
202 |
{ |
7604 |
25 Feb 19 |
nicklas |
plotIndex++; |
7604 |
25 Feb 19 |
nicklas |
204 |
} |
7604 |
25 Feb 19 |
nicklas |
if (plotIndex >= plotQueue.length) return; |
7604 |
25 Feb 19 |
nicklas |
206 |
|
7604 |
25 Feb 19 |
nicklas |
// Start loading the next plot in a temporary image |
7604 |
25 Feb 19 |
nicklas |
// while displaying a progress bar in the real image |
7604 |
25 Feb 19 |
nicklas |
// An event is used to catch the loading of the plot |
7604 |
25 Feb 19 |
nicklas |
var plot = plotQueue[plotIndex]; |
7604 |
25 Feb 19 |
nicklas |
plot.src = '../../../images/plot_generating_400x300.gif'; |
7604 |
25 Feb 19 |
nicklas |
var tmpPlot = new Image(); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(tmpPlot, 'load', bioassaysets.plotLoaded); |
7604 |
25 Feb 19 |
nicklas |
tmpPlot.src = Data.get(plot, 'plot-url'); |
7604 |
25 Feb 19 |
nicklas |
215 |
|
7604 |
25 Feb 19 |
nicklas |
216 |
} |
7604 |
25 Feb 19 |
nicklas |
217 |
|
7604 |
25 Feb 19 |
nicklas |
218 |
/* |
7604 |
25 Feb 19 |
nicklas |
Event handler that is called when a plot has been loaded. |
7604 |
25 Feb 19 |
nicklas |
Copy the plot to the real image and schedule loading of the |
7604 |
25 Feb 19 |
nicklas |
plot. |
7604 |
25 Feb 19 |
nicklas |
222 |
*/ |
7604 |
25 Feb 19 |
nicklas |
bioassaysets.plotLoaded = function(event) |
7604 |
25 Feb 19 |
nicklas |
224 |
{ |
7604 |
25 Feb 19 |
nicklas |
var tmpPlot = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
var plot = plotQueue[plotIndex]; |
7604 |
25 Feb 19 |
nicklas |
227 |
|
7604 |
25 Feb 19 |
nicklas |
plot.src = tmpPlot.src; |
7604 |
25 Feb 19 |
nicklas |
Data.set(plot, 'is-loaded', 1); |
7604 |
25 Feb 19 |
nicklas |
Doc.removeClass(plot, 'empty'); |
7604 |
25 Feb 19 |
nicklas |
231 |
|
7604 |
25 Feb 19 |
nicklas |
plotIndex++; |
7604 |
25 Feb 19 |
nicklas |
if (plotIndex < plotQueue.length) |
7604 |
25 Feb 19 |
nicklas |
234 |
{ |
7604 |
25 Feb 19 |
nicklas |
setTimeout(bioassaysets.loadNextPlot, 100); |
7604 |
25 Feb 19 |
nicklas |
236 |
} |
7604 |
25 Feb 19 |
nicklas |
237 |
} |
7604 |
25 Feb 19 |
nicklas |
238 |
|
7604 |
25 Feb 19 |
nicklas |
return bioassaysets; |
7604 |
25 Feb 19 |
nicklas |
240 |
}(); |
7604 |
25 Feb 19 |
nicklas |
241 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(BioAssaySets.initPage); |