1
|
/*
|
2
|
* '$RCSfile$'
|
3
|
* Purpose: Default style sheet for KNP project web pages
|
4
|
* Using this stylesheet rather than placing styles directly in
|
5
|
* the KNP web documents allows us to globally change the
|
6
|
* formatting styles of the entire site in one easy place.
|
7
|
* Copyright: 2009 Regents of the University of California and the
|
8
|
* National Center for Ecological Analysis and Synthesis
|
9
|
* Authors: Matt Jones
|
10
|
*
|
11
|
* '$Author: daigle $'
|
12
|
* '$Date: 2008-07-06 21:25:34 -0700 (Sun, 06 Jul 2008) $'
|
13
|
* '$Revision: 4080 $'
|
14
|
*
|
15
|
* This program is free software; you can redistribute it and/or modify
|
16
|
* it under the terms of the GNU General Public License as published by
|
17
|
* the Free Software Foundation; either version 2 of the License, or
|
18
|
* (at your option) any later version.
|
19
|
*
|
20
|
* This program is distributed in the hope that it will be useful,
|
21
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23
|
* GNU General Public License for more details.
|
24
|
*
|
25
|
* You should have received a copy of the GNU General Public License
|
26
|
* along with this program; if not, write to the Free Software
|
27
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
28
|
*/
|
29
|
|
30
|
var lastInputIndex = 0;
|
31
|
|
32
|
function getSearchModeList(searchModeString) {
|
33
|
var abbrevArray = searchModeString.split('|');
|
34
|
var smArray = new Array();
|
35
|
|
36
|
for (i = 0; i < abbrevArray.length; i++) {
|
37
|
if (abbrevArray[i] == 'co') {
|
38
|
smArray.push(new Array('contains', 'contains','Contains'));
|
39
|
} else if (abbrevArray[i] == 'sw') {
|
40
|
smArray.push(new Array('starts-with', 'starts with', 'Starts With'));
|
41
|
} else if (abbrevArray[i] == 'ew') {
|
42
|
smArray.push(new Array('ends-with', 'ends with', 'Ends With'));
|
43
|
} else if (abbrevArray[i] == 'eq') {
|
44
|
smArray.push(new Array('equals', 'equals', 'Equals'));
|
45
|
} else if (abbrevArray[i] == 'ne') {
|
46
|
smArray.push(new Array('isnot-equal', 'is not equal', 'Is Not Equal'));
|
47
|
} else if (abbrevArray[i] == 'gt') {
|
48
|
smArray.push(new Array('greater-than', 'is greater than', 'Is Greater Than'));
|
49
|
} else if (abbrevArray[i] == 'lt') {
|
50
|
smArray.push(new Array('less-than', 'is less than', 'Is Less Than'));
|
51
|
} else if (abbrevArray[i] == 'ge') {
|
52
|
smArray.push(new Array('greater-than-equals', 'is greater than or equal to', 'Is Greater Than Or Equal To'));
|
53
|
} else if (abbrevArray[i] == 'le') {
|
54
|
smArray.push(new Array('less-than-equals', 'is less than or equal to', 'Is Less Than Or Equal To'));
|
55
|
} else if (abbrevArray[i] == 'af') {
|
56
|
smArray.push(new Array('greater-than', 'is after', 'Is After'));
|
57
|
} else if (abbrevArray[i] == 'be') {
|
58
|
smArray.push(new Array('less-than', 'is before', 'Is Before'));
|
59
|
} else if (abbrevArray[i] == 'is') {
|
60
|
smArray.push(new Array('equals', 'is', 'Is'));
|
61
|
} else if (abbrevArray[i] == 'in') {
|
62
|
smArray.push(new Array('isnot-equal', 'is not', 'Is Not'));
|
63
|
}
|
64
|
}
|
65
|
|
66
|
return smArray;
|
67
|
}
|
68
|
|
69
|
function addSearchDropdown(formName, inputLabel, inputIdBase, inputName, searchModes) {
|
70
|
|
71
|
var formObj = document.getElementById(formName);
|
72
|
var newdiv = document.createElement('div');
|
73
|
var searchModeArray = getSearchModeList(searchModes);
|
74
|
|
75
|
var innerHtml = "";
|
76
|
innerHtml += ' <div class="field-label dropdown-field-label">' + inputLabel + '</div>';
|
77
|
innerHtml += ' <select class="dropdown-input" name="dd-' + inputIdBase + lastInputIndex + '">';
|
78
|
for (i = 0; i < searchModeArray.length; i++ ) {
|
79
|
innerHtml += ' <option value="' + searchModeArray[i][0] + '">' + searchModeArray[i][1] + '</option>';
|
80
|
}
|
81
|
innerHtml += ' </select>';
|
82
|
innerHtml += ' <input class="text-input" id="tx-' + inputIdBase + lastInputIndex + '" name="' + inputName + '" type="text"/>';
|
83
|
innerHtml += ' </div>'
|
84
|
|
85
|
newdiv.setAttribute('class','content-subsection');
|
86
|
newdiv.innerHTML = innerHtml;
|
87
|
formObj.appendChild(newdiv);
|
88
|
|
89
|
lastInputIndex++;
|
90
|
}
|
91
|
|
92
|
function addSearchDropdownBefore(selectObj) {
|
93
|
//alert(selectObj.value);
|
94
|
if (selectObj.value == "name") {
|
95
|
addSearchSelectionBefore('tpcSearch','Name','name','co|eq|sw|ew','form-base-row');
|
96
|
} else if (selectObj.value == "keyword") {
|
97
|
addSearchSelectionBefore('tpcSearch','Keyword','keyword','co|eq|sw|ew','form-base-row');
|
98
|
} else if (selectObj.value == "creator") {
|
99
|
addSearchSelectionBefore('tpcSearch','Creator','creator','co|eq|sw|ew','form-base-row');
|
100
|
} else if (selectObj.value == "description") {
|
101
|
addSearchSelectionBefore('tpcSearch','Description','description','co|eq|sw|ew','form-base-row');
|
102
|
} else if (selectObj.value == "date-executed") {
|
103
|
addSearchSelectionBefore('tpcSearch','Date Executed','date-executed','be|af','form-base-row');
|
104
|
} else if (selectObj.value == "workflow-run-lsid") {
|
105
|
addSearchSelectionBefore('tpcSearch','Workflow-run-lsid','workflow-run-lsid','co|eq|sw|ew','form-base-row');
|
106
|
} else if (selectObj.value == "workflow-lsid") {
|
107
|
addSearchSelectionBefore('tpcSearch','Workflow-lsid','workflow-lsid','co|eq|sw|ew','form-base-row');
|
108
|
} else if (selectObj.value == "status") {
|
109
|
addSearchSelectionBefore('tpcSearch','Status','Status','is|in','form-base-row');
|
110
|
} else if (selectObj.value == "date-created") {
|
111
|
addSearchSelectionBefore('tpcSearch','Date Created','date-created','be|af','form-base-row');
|
112
|
} /*else if (selectObj.value == "workflow-id") {
|
113
|
addSearchSelectionBefore('tpcSearch','Workflow-id','workflow-id','co|eq|sw|ew','form-base-row');
|
114
|
}*/
|
115
|
}
|
116
|
|
117
|
function addSearchSelectionBefore(formId, inputLabel, inputName, searchModes, beforeElementId) {
|
118
|
//alert('in addDropdownInputBefore - formId: ' + formId + ' inputLabel: ' + inputLabel + ' inputName: ' + inputName + ' searchModes: ' + searchModes + ' beforeElementId: ' + beforeElementId);
|
119
|
var formObj = document.getElementById(formId);
|
120
|
var beforeObj = document.getElementById(beforeElementId);
|
121
|
var newDiv = document.createElement('div');
|
122
|
var searchModeArray = getSearchModeList(searchModes);
|
123
|
|
124
|
var innerHtml = '';
|
125
|
innerHtml += ' <div class="field-label dropdown-field-label">' + inputLabel + '</div>';
|
126
|
innerHtml += ' <select class="dropdown-input" id="sm-' + inputName + lastInputIndex + '">';
|
127
|
for (i = 0; i < searchModeArray.length; i++ ) {
|
128
|
innerHtml += ' <option value="' + searchModeArray[i][0] + '">' + searchModeArray[i][1] + '</option>';
|
129
|
}
|
130
|
innerHtml += ' </select>';
|
131
|
innerHtml += ' <input class="text-input" id="sf-' + inputName + lastInputIndex + '" name="' + inputName + '" type="text"/>';
|
132
|
innerHtml += ' <input class="field-remove-button" type="button" value="-" onclick="removeInput(\''+ formId + '\',\'cs-' + inputName + lastInputIndex + '\')"/>';
|
133
|
innerHtml += '</div>';
|
134
|
//alert('innerHtml: ' + innerHtml);
|
135
|
|
136
|
// alert('formObj:' + formObj);
|
137
|
newDiv.setAttribute('id', 'cs-' + inputName + lastInputIndex);
|
138
|
newDiv.setAttribute('class', 'form-input-row');
|
139
|
newDiv.innerHTML = innerHtml;
|
140
|
// alert('newDiv:' + newDiv);
|
141
|
formObj.insertBefore(newDiv, beforeObj);
|
142
|
|
143
|
lastInputIndex++;
|
144
|
}
|
145
|
|
146
|
function removeInput(formId, inputId) {
|
147
|
//alert('in remove input - formname: ' + formId + ' inputid: ' + inputId);
|
148
|
var formObj = document.getElementById(formId);
|
149
|
var inputObj = document.getElementById(inputId);
|
150
|
|
151
|
if ((formObj != null) && (inputObj != null)) {
|
152
|
// alert('removing child: ' + inputObj.toString());
|
153
|
formObj.removeChild(inputObj);
|
154
|
}
|
155
|
}
|
156
|
|