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 Configure = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var configure = {}; |
7604 |
25 Feb 19 |
nicklas |
var parameters; |
7604 |
25 Feb 19 |
nicklas |
var parametersByName = []; |
7604 |
25 Feb 19 |
nicklas |
var selectedParameter = null; |
7604 |
25 Feb 19 |
nicklas |
var selectedValueIndex; |
7604 |
25 Feb 19 |
nicklas |
33 |
|
7604 |
25 Feb 19 |
nicklas |
34 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
36 |
*/ |
7604 |
25 Feb 19 |
nicklas |
configure.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
38 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Dialog buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', configure.cancelWizard); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnTestWithFile', configure.testWithFile); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNext', configure.saveSettings); |
7604 |
25 Feb 19 |
nicklas |
43 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnShowErrorList', configure.showErrorList); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnHideErrorList', configure.hideErrorList); |
7604 |
25 Feb 19 |
nicklas |
46 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAddValue', configure.addValueOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRemoveValue', configure.removeValueOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('values', 'click', configure.valuesOnClick); |
7604 |
25 Feb 19 |
nicklas |
50 |
|
7604 |
25 Feb 19 |
nicklas |
// Parameters |
7604 |
25 Feb 19 |
nicklas |
parameters = Data.json('page-data', 'plugin-parameters'); |
7604 |
25 Feb 19 |
nicklas |
var parameterList = Doc.element('parameter-list'); |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < parameters.length; i++) |
7604 |
25 Feb 19 |
nicklas |
55 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pp = parameters[i]; |
7604 |
25 Feb 19 |
nicklas |
parametersByName[pp.name] = pp; |
7604 |
25 Feb 19 |
nicklas |
58 |
|
7604 |
25 Feb 19 |
nicklas |
App.debug(JSON.stringify(pp)); |
7604 |
25 Feb 19 |
nicklas |
60 |
|
7604 |
25 Feb 19 |
nicklas |
// Create entry in parameter selection list |
7604 |
25 Feb 19 |
nicklas |
if (!pp.hidden) |
7604 |
25 Feb 19 |
nicklas |
63 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pDiv = document.createElement('div'); |
7604 |
25 Feb 19 |
nicklas |
pDiv.id = 'parameter-'+pp.name+':prompt'; |
7604 |
25 Feb 19 |
nicklas |
Data.set(pDiv, 'parameter-name', pp.name); |
7604 |
25 Feb 19 |
nicklas |
67 |
|
7604 |
25 Feb 19 |
nicklas |
if (!pp.valueClass) |
7604 |
25 Feb 19 |
nicklas |
69 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Section header entry |
7604 |
25 Feb 19 |
nicklas |
pDiv.className = 'section interactable'; |
7604 |
25 Feb 19 |
nicklas |
pDiv.innerHTML = Strings.encodeTags(pp.label); |
7604 |
25 Feb 19 |
nicklas |
73 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
75 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Parameter entry |
7604 |
25 Feb 19 |
nicklas |
pDiv.className = 'param interactable'; |
7604 |
25 Feb 19 |
nicklas |
var icon = ''; |
7604 |
25 Feb 19 |
nicklas |
if (pp.values.length > 0) |
7604 |
25 Feb 19 |
nicklas |
80 |
{ |
7604 |
25 Feb 19 |
nicklas |
icon = pp.nullable ? 'notrequired_values.png' : 'required_values.png'; |
7604 |
25 Feb 19 |
nicklas |
82 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
84 |
{ |
7604 |
25 Feb 19 |
nicklas |
icon = pp.nullable ? 'notrequired_novalues.png' : 'required_novalues.png'; |
7604 |
25 Feb 19 |
nicklas |
86 |
} |
7604 |
25 Feb 19 |
nicklas |
87 |
|
7604 |
25 Feb 19 |
nicklas |
var html = '<span class="icon">'; |
7604 |
25 Feb 19 |
nicklas |
html += '<img id="parameter-'+pp.name+':icon" src="../../images/'+icon+'" alt="">'; |
7604 |
25 Feb 19 |
nicklas |
html += '</span>'; |
7604 |
25 Feb 19 |
nicklas |
html += '<span class="label">'+Strings.encodeTags(pp.label)+'</span>'; |
7604 |
25 Feb 19 |
nicklas |
pDiv.innerHTML = html; |
7604 |
25 Feb 19 |
nicklas |
93 |
} |
7604 |
25 Feb 19 |
nicklas |
parameterList.appendChild(pDiv); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(pDiv, 'click', configure.parameterOnClick); |
7604 |
25 Feb 19 |
nicklas |
96 |
} |
7604 |
25 Feb 19 |
nicklas |
97 |
|
7604 |
25 Feb 19 |
nicklas |
// Attach event handlers to input fields |
7604 |
25 Feb 19 |
nicklas |
var valueClass = pp.valueClass; |
7604 |
25 Feb 19 |
nicklas |
var fieldName = 'parameter-'+pp.name; |
7604 |
25 Feb 19 |
nicklas |
// Detect changes |
7604 |
25 Feb 19 |
nicklas |
if (valueClass != 'BooleanParameterType') |
7604 |
25 Feb 19 |
nicklas |
103 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(fieldName, 'change', configure.parameterValueOnChanage); |
7604 |
25 Feb 19 |
nicklas |
105 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
107 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(fieldName+':null', 'change', configure.parameterValueOnChanage); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(fieldName+':true', 'change', configure.parameterValueOnChanage); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(fieldName+':false', 'change', configure.parameterValueOnChanage); |
7604 |
25 Feb 19 |
nicklas |
111 |
} |
7604 |
25 Feb 19 |
nicklas |
if (valueClass == 'IntegerParameterType' || valueClass == 'LongParameterType') |
7604 |
25 Feb 19 |
nicklas |
113 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Block non-numeric keys from INT and LONG fields |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(fieldName, 'keypress', Events.integerOnly); |
7604 |
25 Feb 19 |
nicklas |
116 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (valueClass == 'FloatParameterType' || valueClass == 'DoubleParameterType') |
7604 |
25 Feb 19 |
nicklas |
118 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Block non-numeric keys from FLOAT and DOUBLE fields |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(fieldName, 'keypress', Events.numberOnly); |
7604 |
25 Feb 19 |
nicklas |
121 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (valueClass == 'FileParameterType') |
7604 |
25 Feb 19 |
nicklas |
123 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Browse button |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(fieldName+':browse', configure.selectFileOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(fieldName, 'base-selected', configure.onFileSelected); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(fieldName+':recent', 'change', configure.recentFileSelected); |
7604 |
25 Feb 19 |
nicklas |
128 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (valueClass = 'PathParameterType') |
7604 |
25 Feb 19 |
nicklas |
130 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Browse button |
7604 |
25 Feb 19 |
nicklas |
if (pp.pathType == 'FILE') |
7604 |
25 Feb 19 |
nicklas |
133 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(fieldName+':browse', configure.saveAsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(fieldName, 'base-selected', configure.onSaveAsSelected); |
7604 |
25 Feb 19 |
nicklas |
136 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
138 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(fieldName+':browse', configure.selectDirectoryOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(fieldName, 'base-selected', configure.onFileSelected); |
7604 |
25 Feb 19 |
nicklas |
141 |
} |
7604 |
25 Feb 19 |
nicklas |
142 |
} |
7604 |
25 Feb 19 |
nicklas |
143 |
} |
7604 |
25 Feb 19 |
nicklas |
144 |
|
7604 |
25 Feb 19 |
nicklas |
145 |
} |
7604 |
25 Feb 19 |
nicklas |
146 |
|
7604 |
25 Feb 19 |
nicklas |
configure.initElements = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
148 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'toggle-stacktrace') |
7604 |
25 Feb 19 |
nicklas |
150 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, configure.toggleStacktrace); |
7604 |
25 Feb 19 |
nicklas |
152 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'select-all') |
7604 |
25 Feb 19 |
nicklas |
154 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, configure.selectAll); |
7604 |
25 Feb 19 |
nicklas |
156 |
} |
7604 |
25 Feb 19 |
nicklas |
157 |
} |
7604 |
25 Feb 19 |
nicklas |
158 |
|
7604 |
25 Feb 19 |
nicklas |
159 |
/** |
7604 |
25 Feb 19 |
nicklas |
When clicking on a parameter in the selection list, the input fields |
7604 |
25 Feb 19 |
nicklas |
for that section should be displayed. |
7604 |
25 Feb 19 |
nicklas |
162 |
*/ |
7604 |
25 Feb 19 |
nicklas |
configure.parameterOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
164 |
{ |
7604 |
25 Feb 19 |
nicklas |
var name = Data.get(event.currentTarget, 'parameter-name'); |
7604 |
25 Feb 19 |
nicklas |
var parameter = parametersByName[name]; |
7604 |
25 Feb 19 |
nicklas |
if (parameter) configure.selectParameter(parameter); |
7604 |
25 Feb 19 |
nicklas |
168 |
} |
7604 |
25 Feb 19 |
nicklas |
169 |
|
7604 |
25 Feb 19 |
nicklas |
configure.selectParameter = function(parameter) |
7604 |
25 Feb 19 |
nicklas |
171 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (selectedParameter) |
7604 |
25 Feb 19 |
nicklas |
173 |
{ |
7604 |
25 Feb 19 |
nicklas |
// De-select current parameter |
7604 |
25 Feb 19 |
nicklas |
Doc.removeClass('parameter-'+selectedParameter.name+':prompt', 'selected'); |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('parameter-'+selectedParameter.name+':section'); |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('valuecontainer'); |
7604 |
25 Feb 19 |
nicklas |
178 |
} |
7604 |
25 Feb 19 |
nicklas |
179 |
|
7604 |
25 Feb 19 |
nicklas |
selectedParameter = parameter; |
7604 |
25 Feb 19 |
nicklas |
181 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.addClass('parameter-'+parameter.name+':prompt', 'selected'); |
7604 |
25 Feb 19 |
nicklas |
Doc.show('parameter-'+parameter.name+':section'); |
7604 |
25 Feb 19 |
nicklas |
184 |
|
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['configure']; |
7604 |
25 Feb 19 |
nicklas |
var field = frm['parameter-'+parameter.name]; |
7604 |
25 Feb 19 |
nicklas |
if (field.focus && !field.disabled) field.focus(); |
7604 |
25 Feb 19 |
nicklas |
188 |
|
7604 |
25 Feb 19 |
nicklas |
if (parameter.enumeration) |
7604 |
25 Feb 19 |
nicklas |
190 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Enumerated parameters are in a <select> element |
7604 |
25 Feb 19 |
nicklas |
var numSelected = Forms.selectListOptions(field, parameter.values, true); |
7604 |
25 Feb 19 |
nicklas |
if (numSelected == 0) |
7604 |
25 Feb 19 |
nicklas |
194 |
{ |
7604 |
25 Feb 19 |
nicklas |
parameter.values.length = 0; |
7604 |
25 Feb 19 |
nicklas |
configure.updateStyle(parameter); |
7604 |
25 Feb 19 |
nicklas |
197 |
} |
7604 |
25 Feb 19 |
nicklas |
198 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (parameter.multiplicity == 1) |
7604 |
25 Feb 19 |
nicklas |
200 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Single-values parameters are 'text' or 'radio' elements |
7604 |
25 Feb 19 |
nicklas |
var currentValue = parameter.values.length > 0 ? parameter.values[0] : ''; |
7604 |
25 Feb 19 |
nicklas |
if (field.length) // radio buttons for boolean parameter |
7604 |
25 Feb 19 |
nicklas |
204 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.checkRadio(field, currentValue); |
7604 |
25 Feb 19 |
nicklas |
206 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (!field.disabled) |
7604 |
25 Feb 19 |
nicklas |
208 |
{ |
7604 |
25 Feb 19 |
nicklas |
field.value = currentValue; |
7604 |
25 Feb 19 |
nicklas |
210 |
} |
7604 |
25 Feb 19 |
nicklas |
211 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
213 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Multi-values parameters must be copied to a <select> element |
7604 |
25 Feb 19 |
nicklas |
var values = frm.values; |
7604 |
25 Feb 19 |
nicklas |
// Clear existing values from the <select> element |
7604 |
25 Feb 19 |
nicklas |
values.length = 0; |
7604 |
25 Feb 19 |
nicklas |
// Copy values |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < parameter.values.length; i++) |
7604 |
25 Feb 19 |
nicklas |
220 |
{ |
7604 |
25 Feb 19 |
nicklas |
var value = Strings.cut(parameter.values[i].replace(/\n/g, ' '), 40); |
7604 |
25 Feb 19 |
nicklas |
values[values.length] = new Option(value); |
7604 |
25 Feb 19 |
nicklas |
223 |
} |
7604 |
25 Feb 19 |
nicklas |
var mult = Doc.element('multiplicity'); |
7604 |
25 Feb 19 |
nicklas |
mult.innerHTML = parameter.multiplicity == 0 ? '' : '(Max '+parameter.multiplicity+' values)'; |
7604 |
25 Feb 19 |
nicklas |
Doc.show('valuecontainer'); |
7604 |
25 Feb 19 |
nicklas |
227 |
} |
7604 |
25 Feb 19 |
nicklas |
228 |
|
7604 |
25 Feb 19 |
nicklas |
229 |
} |
7604 |
25 Feb 19 |
nicklas |
230 |
|
7604 |
25 Feb 19 |
nicklas |
231 |
|
7604 |
25 Feb 19 |
nicklas |
configure.parameterValueOnChanage = function(event) |
7604 |
25 Feb 19 |
nicklas |
233 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['configure']; |
7604 |
25 Feb 19 |
nicklas |
if (!selectedParameter) return; |
7604 |
25 Feb 19 |
nicklas |
236 |
|
7604 |
25 Feb 19 |
nicklas |
if (selectedParameter.multiplicity == 1) |
7604 |
25 Feb 19 |
nicklas |
238 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Single-valued parameters are copied as a new array |
7604 |
25 Feb 19 |
nicklas |
var value = event.target.value; |
7604 |
25 Feb 19 |
nicklas |
if (value == null || value == '') |
7604 |
25 Feb 19 |
nicklas |
242 |
{ |
7604 |
25 Feb 19 |
nicklas |
selectedParameter.values = []; |
7604 |
25 Feb 19 |
nicklas |
244 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
246 |
{ |
7604 |
25 Feb 19 |
nicklas |
selectedParameter.values = [value]; |
7604 |
25 Feb 19 |
nicklas |
248 |
} |
7604 |
25 Feb 19 |
nicklas |
249 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (selectedParameter.enumeration) |
7604 |
25 Feb 19 |
nicklas |
251 |
{ |
7604 |
25 Feb 19 |
nicklas |
// All values are in a <select multiple> element |
7604 |
25 Feb 19 |
nicklas |
var values = []; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < event.target.length; i++) |
7604 |
25 Feb 19 |
nicklas |
255 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (event.target[i].checked || event.target[i].selected) |
7604 |
25 Feb 19 |
nicklas |
257 |
{ |
7604 |
25 Feb 19 |
nicklas |
values[values.length] = event.target[i].value; |
7604 |
25 Feb 19 |
nicklas |
259 |
} |
7604 |
25 Feb 19 |
nicklas |
260 |
} |
7604 |
25 Feb 19 |
nicklas |
selectedParameter.values = values; |
7604 |
25 Feb 19 |
nicklas |
262 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
264 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Multi-valued parameters are updated for the current index |
7604 |
25 Feb 19 |
nicklas |
if (selectedValueIndex >= 0) |
7604 |
25 Feb 19 |
nicklas |
267 |
{ |
7604 |
25 Feb 19 |
nicklas |
var value = event.target.value; |
7604 |
25 Feb 19 |
nicklas |
if (value == null || value == '') |
7604 |
25 Feb 19 |
nicklas |
270 |
{ |
7604 |
25 Feb 19 |
nicklas |
selectedParameter.values.splice(selectedValueIndex, 1); |
7604 |
25 Feb 19 |
nicklas |
frm.values[selectedValueIndex] = null; |
7604 |
25 Feb 19 |
nicklas |
273 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
275 |
{ |
7604 |
25 Feb 19 |
nicklas |
selectedParameter.values[selectedValueIndex] = value; |
7604 |
25 Feb 19 |
nicklas |
frm.values[selectedValueIndex].text = value; |
7604 |
25 Feb 19 |
nicklas |
278 |
} |
7604 |
25 Feb 19 |
nicklas |
279 |
} |
7604 |
25 Feb 19 |
nicklas |
280 |
} |
7604 |
25 Feb 19 |
nicklas |
281 |
|
7604 |
25 Feb 19 |
nicklas |
configure.updateStyle(selectedParameter); |
7604 |
25 Feb 19 |
nicklas |
283 |
} |
7604 |
25 Feb 19 |
nicklas |
284 |
|
7604 |
25 Feb 19 |
nicklas |
configure.updateStyle = function(parameter) |
7604 |
25 Feb 19 |
nicklas |
286 |
{ |
7604 |
25 Feb 19 |
nicklas |
var icon = Doc.element('parameter-'+parameter.name+':icon'); |
7604 |
25 Feb 19 |
nicklas |
var img = App.getRoot()+'images/'; |
7604 |
25 Feb 19 |
nicklas |
if (parameter.values.length == 0) |
7604 |
25 Feb 19 |
nicklas |
290 |
{ |
7604 |
25 Feb 19 |
nicklas |
img += parameter.nullable ? 'notrequired_novalues.png' : 'required_novalues.png'; |
7604 |
25 Feb 19 |
nicklas |
292 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
294 |
{ |
7604 |
25 Feb 19 |
nicklas |
img += parameter.nullable ? 'notrequired_values.png' : 'required_values.png'; |
7604 |
25 Feb 19 |
nicklas |
296 |
} |
7604 |
25 Feb 19 |
nicklas |
icon.src = img; |
7604 |
25 Feb 19 |
nicklas |
298 |
} |
7604 |
25 Feb 19 |
nicklas |
299 |
|
7604 |
25 Feb 19 |
nicklas |
300 |
|
7604 |
25 Feb 19 |
nicklas |
configure.selectFileOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
302 |
{ |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('FILE', Data.get(event.currentTarget, 'field')); |
7604 |
25 Feb 19 |
nicklas |
304 |
} |
7604 |
25 Feb 19 |
nicklas |
305 |
|
7604 |
25 Feb 19 |
nicklas |
configure.onFileSelected = function(event) |
7604 |
25 Feb 19 |
nicklas |
307 |
{ |
7604 |
25 Feb 19 |
nicklas |
event.currentTarget.value = event.detail.name; |
7604 |
25 Feb 19 |
nicklas |
Events.sendChangeEvent(event.target); |
7604 |
25 Feb 19 |
nicklas |
if (parametersByName['charset']) |
7604 |
25 Feb 19 |
nicklas |
311 |
{ |
7604 |
25 Feb 19 |
nicklas |
configure.getCharsetOfFile(event.detail.id); |
7604 |
25 Feb 19 |
nicklas |
313 |
} |
7604 |
25 Feb 19 |
nicklas |
314 |
} |
7604 |
25 Feb 19 |
nicklas |
315 |
|
7604 |
25 Feb 19 |
nicklas |
configure.recentFileSelected = function(event) |
7604 |
25 Feb 19 |
nicklas |
317 |
{ |
7604 |
25 Feb 19 |
nicklas |
var fileList = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
var field = Data.get(fileList, 'field'); |
7604 |
25 Feb 19 |
nicklas |
var detail = {'id': fileList.value, 'name': fileList[fileList.selectedIndex].text}; |
7604 |
25 Feb 19 |
nicklas |
Events.sendCustomEvent(field, 'base-selected', detail); |
7604 |
25 Feb 19 |
nicklas |
fileList.selectedIndex = 0; |
7604 |
25 Feb 19 |
nicklas |
323 |
} |
7604 |
25 Feb 19 |
nicklas |
324 |
|
7604 |
25 Feb 19 |
nicklas |
configure.saveAsOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
326 |
{ |
7604 |
25 Feb 19 |
nicklas |
var field = Data.get(event.currentTarget, 'field'); |
7604 |
25 Feb 19 |
nicklas |
var url = App.getRoot() +'filemanager/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=SaveAs&callback='+field; |
7604 |
25 Feb 19 |
nicklas |
330 |
|
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['configure']; |
7604 |
25 Feb 19 |
nicklas |
var i = frm[field].value.lastIndexOf('/'); |
7604 |
25 Feb 19 |
nicklas |
if (i >= 0) |
7604 |
25 Feb 19 |
nicklas |
334 |
{ |
7604 |
25 Feb 19 |
nicklas |
url += '&fileName=' + encodeURIComponent(frm[field].value.substring(i+1)); |
7604 |
25 Feb 19 |
nicklas |
336 |
} |
7604 |
25 Feb 19 |
nicklas |
337 |
|
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'SaveAs', 1050, 700); |
7604 |
25 Feb 19 |
nicklas |
339 |
} |
7604 |
25 Feb 19 |
nicklas |
340 |
|
7604 |
25 Feb 19 |
nicklas |
configure.onSaveAsSelected = function(event) |
7604 |
25 Feb 19 |
nicklas |
342 |
{ |
7604 |
25 Feb 19 |
nicklas |
event.target.value = event.detail.path; |
7604 |
25 Feb 19 |
nicklas |
Events.sendChangeEvent(event.target); |
7604 |
25 Feb 19 |
nicklas |
345 |
} |
7604 |
25 Feb 19 |
nicklas |
346 |
|
7604 |
25 Feb 19 |
nicklas |
configure.selectDirectoryOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
348 |
{ |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('DIRECTORY', Data.get(event.currentTarget, 'field')); |
7604 |
25 Feb 19 |
nicklas |
350 |
} |
7604 |
25 Feb 19 |
nicklas |
351 |
|
7604 |
25 Feb 19 |
nicklas |
configure.getCharsetOfFile = function(fileId) |
7604 |
25 Feb 19 |
nicklas |
353 |
{ |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
var url = '../../filemanager/files/ajax.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=GetFileInfo&item_id=' + fileId; |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, true); |
7604 |
25 Feb 19 |
nicklas |
Ajax.setReadyStateHandler(request, configure.updateCharsetCallback); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
360 |
} |
7604 |
25 Feb 19 |
nicklas |
361 |
|
7604 |
25 Feb 19 |
nicklas |
configure.updateCharsetCallback = function(request) |
7604 |
25 Feb 19 |
nicklas |
363 |
{ |
7604 |
25 Feb 19 |
nicklas |
var response = JSON.parse(request.responseText); |
7604 |
25 Feb 19 |
nicklas |
var charset = response.characterSet; |
7604 |
25 Feb 19 |
nicklas |
if (!charset) return; |
7604 |
25 Feb 19 |
nicklas |
367 |
|
7604 |
25 Feb 19 |
nicklas |
var parameter = parametersByName['charset']; |
7604 |
25 Feb 19 |
nicklas |
if (!parameter) return; |
7604 |
25 Feb 19 |
nicklas |
370 |
|
7604 |
25 Feb 19 |
nicklas |
parameter.values = [ charset ]; |
7604 |
25 Feb 19 |
nicklas |
configure.updateStyle(parameter); |
7604 |
25 Feb 19 |
nicklas |
373 |
} |
7604 |
25 Feb 19 |
nicklas |
374 |
|
7604 |
25 Feb 19 |
nicklas |
configure.selectAll = function(event) |
7604 |
25 Feb 19 |
nicklas |
376 |
{ |
7604 |
25 Feb 19 |
nicklas |
var field = Data.get(event.currentTarget, 'field'); |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['configure']; |
7604 |
25 Feb 19 |
nicklas |
var list = Doc.element(field); |
7604 |
25 Feb 19 |
nicklas |
380 |
|
7604 |
25 Feb 19 |
nicklas |
if (!list || list.length == 0) return; |
7604 |
25 Feb 19 |
nicklas |
var select = !list[0].selected;; |
7604 |
25 Feb 19 |
nicklas |
383 |
|
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < list.length; i++) |
7604 |
25 Feb 19 |
nicklas |
385 |
{ |
7604 |
25 Feb 19 |
nicklas |
list[i].selected = select; |
7604 |
25 Feb 19 |
nicklas |
387 |
} |
7604 |
25 Feb 19 |
nicklas |
Events.sendChangeEvent(list); |
7604 |
25 Feb 19 |
nicklas |
389 |
} |
7604 |
25 Feb 19 |
nicklas |
390 |
|
7604 |
25 Feb 19 |
nicklas |
configure.cancelWizard = function() |
7604 |
25 Feb 19 |
nicklas |
392 |
{ |
7604 |
25 Feb 19 |
nicklas |
location.href = 'index.jsp?ID='+App.getSessionId()+'&cmd=CancelWizard'; |
7604 |
25 Feb 19 |
nicklas |
394 |
} |
7604 |
25 Feb 19 |
nicklas |
395 |
|
7604 |
25 Feb 19 |
nicklas |
configure.testWithFile = function() |
7604 |
25 Feb 19 |
nicklas |
397 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = 'test_with_file.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'TestWithFile', 1050, 700); |
7604 |
25 Feb 19 |
nicklas |
400 |
} |
7604 |
25 Feb 19 |
nicklas |
401 |
|
7604 |
25 Feb 19 |
nicklas |
configure.valuesOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
403 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['configure']; |
7604 |
25 Feb 19 |
nicklas |
if (!selectedParameter) return; |
7604 |
25 Feb 19 |
nicklas |
406 |
|
7604 |
25 Feb 19 |
nicklas |
selectedValueIndex = frm.values.selectedIndex; |
7604 |
25 Feb 19 |
nicklas |
if (selectedValueIndex >= 0) |
7604 |
25 Feb 19 |
nicklas |
409 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm['parameter-'+selectedParameter.name].value = selectedParameter.values[selectedValueIndex]; |
7604 |
25 Feb 19 |
nicklas |
411 |
} |
7604 |
25 Feb 19 |
nicklas |
412 |
} |
7604 |
25 Feb 19 |
nicklas |
413 |
|
7604 |
25 Feb 19 |
nicklas |
configure.addValueOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
415 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!selectedParameter) return; |
7604 |
25 Feb 19 |
nicklas |
417 |
|
7604 |
25 Feb 19 |
nicklas |
// Check multiplicity |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['configure']; |
7604 |
25 Feb 19 |
nicklas |
var field = frm['parameter-'+selectedParameter.name]; |
7604 |
25 Feb 19 |
nicklas |
if (selectedParameter.multiplicity > 0 && selectedParameter.values.length >= selectedParameter.multiplicity) |
7604 |
25 Feb 19 |
nicklas |
422 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification('btnAddValue', 'Max '+selectedParameter.multiplicity+' values allowed'); |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
425 |
} |
7604 |
25 Feb 19 |
nicklas |
426 |
|
7604 |
25 Feb 19 |
nicklas |
if (frm.values.selectedIndex < 0 && field.value != '') |
7604 |
25 Feb 19 |
nicklas |
428 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Insert a new option with the value from the field |
7604 |
25 Feb 19 |
nicklas |
frm.values[frm.values.length] = new Option(field.value, ''); |
7604 |
25 Feb 19 |
nicklas |
selectedParameter.values[selectedParameter.values.length] = field.value; |
7604 |
25 Feb 19 |
nicklas |
field.value = ''; |
7604 |
25 Feb 19 |
nicklas |
selectedValueIndex = -1; |
7604 |
25 Feb 19 |
nicklas |
434 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
436 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Clear current selection |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < frm.values.length; i++) |
7604 |
25 Feb 19 |
nicklas |
439 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.values[i].selected = false; |
7604 |
25 Feb 19 |
nicklas |
441 |
} |
7604 |
25 Feb 19 |
nicklas |
// Insert an empty option |
7604 |
25 Feb 19 |
nicklas |
selectedValueIndex = frm.values.length; |
7604 |
25 Feb 19 |
nicklas |
frm.values[selectedValueIndex] = new Option('<new>', '', false, true); |
7604 |
25 Feb 19 |
nicklas |
selectedParameter.values[selectedValueIndex] = ''; |
7604 |
25 Feb 19 |
nicklas |
field.value = ''; |
7604 |
25 Feb 19 |
nicklas |
447 |
} |
7604 |
25 Feb 19 |
nicklas |
field.focus(); |
7604 |
25 Feb 19 |
nicklas |
configure.updateStyle(selectedParameter); |
7604 |
25 Feb 19 |
nicklas |
450 |
} |
7604 |
25 Feb 19 |
nicklas |
451 |
|
7604 |
25 Feb 19 |
nicklas |
configure.removeValueOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
453 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!selectedParameter) return; |
7604 |
25 Feb 19 |
nicklas |
455 |
|
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['configure']; |
7604 |
25 Feb 19 |
nicklas |
var values = frm.values; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < values.length; i++) |
7604 |
25 Feb 19 |
nicklas |
459 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (values[i].selected) |
7604 |
25 Feb 19 |
nicklas |
461 |
{ |
7604 |
25 Feb 19 |
nicklas |
selectedParameter.values.splice(i, 1); |
7604 |
25 Feb 19 |
nicklas |
values[i] = null; |
7604 |
25 Feb 19 |
nicklas |
i--; |
7604 |
25 Feb 19 |
nicklas |
465 |
} |
7604 |
25 Feb 19 |
nicklas |
466 |
} |
7604 |
25 Feb 19 |
nicklas |
selectedValueIndex = -1; |
7604 |
25 Feb 19 |
nicklas |
frm.values.selectedIndex = -1; |
7604 |
25 Feb 19 |
nicklas |
frm['parameter-'+selectedParameter.name].value = ''; |
7604 |
25 Feb 19 |
nicklas |
configure.updateStyle(selectedParameter); |
7604 |
25 Feb 19 |
nicklas |
471 |
} |
7604 |
25 Feb 19 |
nicklas |
472 |
|
7604 |
25 Feb 19 |
nicklas |
473 |
|
7604 |
25 Feb 19 |
nicklas |
configure.saveSettings = function() |
7604 |
25 Feb 19 |
nicklas |
475 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['configure']; |
7604 |
25 Feb 19 |
nicklas |
477 |
|
7604 |
25 Feb 19 |
nicklas |
// Check that all required parameters have values |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < parameters.length; i++) |
7604 |
25 Feb 19 |
nicklas |
480 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pp = parameters[i]; |
7604 |
25 Feb 19 |
nicklas |
if (pp.valueClass) |
7604 |
25 Feb 19 |
nicklas |
483 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!pp.nullable && pp.values.length == 0) |
7604 |
25 Feb 19 |
nicklas |
485 |
{ |
7604 |
25 Feb 19 |
nicklas |
configure.selectParameter(pp); |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm['parameter-'+pp.name], 'No value entered for parameter '+pp.label); |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
489 |
} |
7604 |
25 Feb 19 |
nicklas |
490 |
} |
7604 |
25 Feb 19 |
nicklas |
491 |
} |
7604 |
25 Feb 19 |
nicklas |
492 |
|
7604 |
25 Feb 19 |
nicklas |
// Save parameters to form and submit |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < parameters.length; i++) |
7604 |
25 Feb 19 |
nicklas |
495 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pp = parameters[i]; |
7604 |
25 Feb 19 |
nicklas |
if (pp.valueClass) |
7604 |
25 Feb 19 |
nicklas |
498 |
{ |
7604 |
25 Feb 19 |
nicklas |
for (var j = 0; j < pp.values.length; j++) |
7604 |
25 Feb 19 |
nicklas |
500 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.addHidden(frm, 'parameter:'+pp.name, pp.values[j]); |
7604 |
25 Feb 19 |
nicklas |
502 |
} |
7604 |
25 Feb 19 |
nicklas |
503 |
} |
7604 |
25 Feb 19 |
nicklas |
504 |
} |
7604 |
25 Feb 19 |
nicklas |
505 |
|
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
507 |
} |
7604 |
25 Feb 19 |
nicklas |
508 |
|
7604 |
25 Feb 19 |
nicklas |
configure.hideErrorList = function() |
7604 |
25 Feb 19 |
nicklas |
510 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('errorlist'); |
7604 |
25 Feb 19 |
nicklas |
Doc.show('showerrorlist'); |
7604 |
25 Feb 19 |
nicklas |
513 |
} |
7604 |
25 Feb 19 |
nicklas |
configure.showErrorList = function() |
7604 |
25 Feb 19 |
nicklas |
515 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.show('errorlist'); |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('showerrorlist'); |
7604 |
25 Feb 19 |
nicklas |
518 |
} |
7604 |
25 Feb 19 |
nicklas |
519 |
|
7604 |
25 Feb 19 |
nicklas |
configure.toggleStacktrace = function(event) |
7604 |
25 Feb 19 |
nicklas |
521 |
{ |
7604 |
25 Feb 19 |
nicklas |
var index = Data.get(event.currentTarget, 'stracktrace-index'); |
7604 |
25 Feb 19 |
nicklas |
Doc.showHide('stacktrace.' + index); |
7604 |
25 Feb 19 |
nicklas |
var img = event.currentTarget.firstChild; |
7604 |
25 Feb 19 |
nicklas |
if (img.src.indexOf('gonext') > 0) |
7604 |
25 Feb 19 |
nicklas |
526 |
{ |
7604 |
25 Feb 19 |
nicklas |
img.src = App.getRoot() + '/images/move_down.png'; |
7604 |
25 Feb 19 |
nicklas |
528 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
530 |
{ |
7604 |
25 Feb 19 |
nicklas |
img.src = App.getRoot() + '/images/gonext.png'; |
7604 |
25 Feb 19 |
nicklas |
532 |
} |
7604 |
25 Feb 19 |
nicklas |
533 |
} |
7604 |
25 Feb 19 |
nicklas |
534 |
|
7656 |
19 Mar 19 |
nicklas |
configure.getParameterDef = function(name) |
7656 |
19 Mar 19 |
nicklas |
536 |
{ |
7656 |
19 Mar 19 |
nicklas |
return parametersByName[name]; |
7656 |
19 Mar 19 |
nicklas |
538 |
} |
7604 |
25 Feb 19 |
nicklas |
539 |
|
7604 |
25 Feb 19 |
nicklas |
configure.getParameterValue = function(name) |
7604 |
25 Feb 19 |
nicklas |
541 |
{ |
7604 |
25 Feb 19 |
nicklas |
var parameter = parametersByName[name]; |
7604 |
25 Feb 19 |
nicklas |
if (parameter && parameter.values.length > 0) |
7604 |
25 Feb 19 |
nicklas |
544 |
{ |
7604 |
25 Feb 19 |
nicklas |
return parameter.values[0]; |
7604 |
25 Feb 19 |
nicklas |
546 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
548 |
{ |
7604 |
25 Feb 19 |
nicklas |
return ''; |
7604 |
25 Feb 19 |
nicklas |
550 |
} |
7604 |
25 Feb 19 |
nicklas |
551 |
} |
7604 |
25 Feb 19 |
nicklas |
552 |
|
7604 |
25 Feb 19 |
nicklas |
configure.getAllParameters = function() |
7604 |
25 Feb 19 |
nicklas |
554 |
{ |
7604 |
25 Feb 19 |
nicklas |
return parameters; |
7604 |
25 Feb 19 |
nicklas |
556 |
} |
7604 |
25 Feb 19 |
nicklas |
557 |
|
7604 |
25 Feb 19 |
nicklas |
configure.setParameterValue = function(name, value) |
7604 |
25 Feb 19 |
nicklas |
559 |
{ |
7604 |
25 Feb 19 |
nicklas |
var parameter = parametersByName[name]; |
7604 |
25 Feb 19 |
nicklas |
if (!parameter) return; |
7604 |
25 Feb 19 |
nicklas |
if (value == null || value == '') |
7604 |
25 Feb 19 |
nicklas |
563 |
{ |
7604 |
25 Feb 19 |
nicklas |
parameter.values = []; |
7604 |
25 Feb 19 |
nicklas |
565 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
567 |
{ |
7604 |
25 Feb 19 |
nicklas |
parameter.values = [value]; |
7604 |
25 Feb 19 |
nicklas |
569 |
} |
7604 |
25 Feb 19 |
nicklas |
configure.updateStyle(parameter); |
7604 |
25 Feb 19 |
nicklas |
if (selectedParameter && selectedParameter.name == name) |
7604 |
25 Feb 19 |
nicklas |
572 |
{ |
7604 |
25 Feb 19 |
nicklas |
configure.selectParameter(parameter); |
7604 |
25 Feb 19 |
nicklas |
574 |
} |
7604 |
25 Feb 19 |
nicklas |
575 |
} |
7604 |
25 Feb 19 |
nicklas |
576 |
|
7604 |
25 Feb 19 |
nicklas |
return configure; |
7604 |
25 Feb 19 |
nicklas |
578 |
}(); |
7604 |
25 Feb 19 |
nicklas |
579 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(Configure.initPage); |
6391 |
21 Jan 14 |
nicklas |
Doc.addElementInitializer(Configure.initElements); |