7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2012 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 SelectPlugin = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var select = {}; |
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 |
select.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
34 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNext', select.next); |
7604 |
25 Feb 19 |
nicklas |
38 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('plugins', 'change', select.pluginOnChange); |
7604 |
25 Feb 19 |
nicklas |
select.initPluginList(); |
7604 |
25 Feb 19 |
nicklas |
select.pluginOnChange(); |
7604 |
25 Feb 19 |
nicklas |
42 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('pluginMessages', select.togglePluginMessages); |
7604 |
25 Feb 19 |
nicklas |
44 |
} |
7604 |
25 Feb 19 |
nicklas |
45 |
|
7604 |
25 Feb 19 |
nicklas |
46 |
|
7604 |
25 Feb 19 |
nicklas |
select.initPluginList = function() |
7604 |
25 Feb 19 |
nicklas |
48 |
{ |
7604 |
25 Feb 19 |
nicklas |
var list = Doc.element('plugins'); |
7604 |
25 Feb 19 |
nicklas |
var plugins = Data.json('page-data', 'plugins'); |
7604 |
25 Feb 19 |
nicklas |
// Add 'auto-detect' option |
7604 |
25 Feb 19 |
nicklas |
// (will be removed again if no plug-in supports auto-detection) |
7604 |
25 Feb 19 |
nicklas |
var option = new Option('- auto detect (all) -', '-1'); |
7604 |
25 Feb 19 |
nicklas |
list[list.length] = option; |
7604 |
25 Feb 19 |
nicklas |
option.className = 'selectoptionautodetect'; |
7604 |
25 Feb 19 |
nicklas |
56 |
|
7604 |
25 Feb 19 |
nicklas |
var numAutodetecting = 0; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < plugins.length; i++) |
7604 |
25 Feb 19 |
nicklas |
59 |
{ |
7604 |
25 Feb 19 |
nicklas |
var plugin = plugins[i]; |
7604 |
25 Feb 19 |
nicklas |
var option = new Option(plugin.name, plugin.id); |
7604 |
25 Feb 19 |
nicklas |
if (plugin.autoDetect) |
7604 |
25 Feb 19 |
nicklas |
63 |
{ |
7604 |
25 Feb 19 |
nicklas |
option.text += ' ×'; |
7604 |
25 Feb 19 |
nicklas |
numAutodetecting++; |
7604 |
25 Feb 19 |
nicklas |
66 |
} |
7604 |
25 Feb 19 |
nicklas |
option.plugin = plugin; |
7604 |
25 Feb 19 |
nicklas |
option.className = 'selectoptionheader'; |
7604 |
25 Feb 19 |
nicklas |
option.disabled = plugin.requiresConfig; |
7604 |
25 Feb 19 |
nicklas |
list[list.length] = option; |
7604 |
25 Feb 19 |
nicklas |
71 |
|
7604 |
25 Feb 19 |
nicklas |
if (plugin.supportsConfig && plugin.configurations.length > 0) |
7604 |
25 Feb 19 |
nicklas |
73 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (plugin.autoDetect) |
7604 |
25 Feb 19 |
nicklas |
75 |
{ |
7604 |
25 Feb 19 |
nicklas |
var option = new Option(' ├ auto detect (' + plugin.name + ') -', '-1'); |
7604 |
25 Feb 19 |
nicklas |
option.className = 'selectoptionautodetect'; |
7604 |
25 Feb 19 |
nicklas |
option.plugin = plugin; |
7604 |
25 Feb 19 |
nicklas |
list[list.length] = option; |
7604 |
25 Feb 19 |
nicklas |
80 |
} |
7604 |
25 Feb 19 |
nicklas |
for (var j = 0; j < plugin.configurations.length; j++) |
7604 |
25 Feb 19 |
nicklas |
82 |
{ |
7604 |
25 Feb 19 |
nicklas |
var conf = plugin.configurations[j]; |
7604 |
25 Feb 19 |
nicklas |
var prefix = j == plugin.configurations.length-1 ? ' └ ' : ' ├ ' |
7604 |
25 Feb 19 |
nicklas |
var option = new Option(prefix+conf.name, conf.id); |
7604 |
25 Feb 19 |
nicklas |
option.plugin = plugin; |
7604 |
25 Feb 19 |
nicklas |
option.configuration = conf; |
7604 |
25 Feb 19 |
nicklas |
list[list.length] = option; |
7604 |
25 Feb 19 |
nicklas |
89 |
} |
7604 |
25 Feb 19 |
nicklas |
90 |
} |
7604 |
25 Feb 19 |
nicklas |
91 |
} |
7604 |
25 Feb 19 |
nicklas |
if (numAutodetecting == 0) |
7604 |
25 Feb 19 |
nicklas |
93 |
{ |
7604 |
25 Feb 19 |
nicklas |
list[0] = null; |
7604 |
25 Feb 19 |
nicklas |
95 |
} |
7604 |
25 Feb 19 |
nicklas |
96 |
} |
7604 |
25 Feb 19 |
nicklas |
97 |
|
7604 |
25 Feb 19 |
nicklas |
select.pluginOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
99 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
var selected = frm.plugins[frm.plugins.selectedIndex]; |
7604 |
25 Feb 19 |
nicklas |
var plugin = selected.plugin; |
7604 |
25 Feb 19 |
nicklas |
var config = selected.configuration; |
7604 |
25 Feb 19 |
nicklas |
var selectedValue = selected.value; |
7604 |
25 Feb 19 |
nicklas |
105 |
|
7604 |
25 Feb 19 |
nicklas |
var descriptions = Doc.element('descriptions'); |
7604 |
25 Feb 19 |
nicklas |
descriptions.innerHTML = '<i>select plug-in above</i>'; |
7604 |
25 Feb 19 |
nicklas |
if (plugin) |
7604 |
25 Feb 19 |
nicklas |
109 |
{ |
7604 |
25 Feb 19 |
nicklas |
descriptions.innerHTML = plugin.description; |
7604 |
25 Feb 19 |
nicklas |
frm.plugindefinition_id.value = plugin.id; |
7604 |
25 Feb 19 |
nicklas |
frm.pluginconfiguration_id.value = selectedValue == -1 ? -1 : 0; |
7604 |
25 Feb 19 |
nicklas |
113 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
115 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.plugindefinition_id.value = selectedValue; |
7604 |
25 Feb 19 |
nicklas |
117 |
} |
7604 |
25 Feb 19 |
nicklas |
if (config) |
7604 |
25 Feb 19 |
nicklas |
119 |
{ |
7604 |
25 Feb 19 |
nicklas |
descriptions.innerHTML += '<p>'+config.description; |
7604 |
25 Feb 19 |
nicklas |
frm.pluginconfiguration_id.value = config.id; |
7604 |
25 Feb 19 |
nicklas |
122 |
} |
7604 |
25 Feb 19 |
nicklas |
123 |
} |
7604 |
25 Feb 19 |
nicklas |
124 |
|
7604 |
25 Feb 19 |
nicklas |
select.togglePluginMessages = function() |
7604 |
25 Feb 19 |
nicklas |
126 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.showHide('pluginMessages.content'); |
7604 |
25 Feb 19 |
nicklas |
128 |
} |
7604 |
25 Feb 19 |
nicklas |
129 |
|
7604 |
25 Feb 19 |
nicklas |
select.next = function() |
7604 |
25 Feb 19 |
nicklas |
131 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['plugin']; |
7604 |
25 Feb 19 |
nicklas |
var anotherWizardIsOpen = Data.int('page-data', 'another-wizard'); |
7604 |
25 Feb 19 |
nicklas |
if (anotherWizardIsOpen) |
7604 |
25 Feb 19 |
nicklas |
135 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!confirm('Are you sure? Unsaved settings in the other wizard will be lost.')) |
7604 |
25 Feb 19 |
nicklas |
137 |
{ |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
139 |
} |
7604 |
25 Feb 19 |
nicklas |
frm.warnIfOpen.value = '0'; |
7604 |
25 Feb 19 |
nicklas |
141 |
} |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
143 |
} |
7604 |
25 Feb 19 |
nicklas |
144 |
|
7604 |
25 Feb 19 |
nicklas |
return select; |
7604 |
25 Feb 19 |
nicklas |
146 |
}(); |
7604 |
25 Feb 19 |
nicklas |
147 |
|
6200 |
05 Nov 12 |
nicklas |
Doc.onLoad(SelectPlugin.initPage); |