Files
yacos/YACOSWeb/WebContent/WEB-INF/jsp/addConference4.jsp
2008-02-05 08:05:24 +00:00

152 lines
3.8 KiB
Plaintext

<%@ include file="/WEB-INF/decorators/include.jsp"%>
<html>
<head>
<script type='text/javascript' src='./dwr/engine.js'></script>
<script type='text/javascript' src='./dwr/util.js'></script>
<script type='text/javascript' src='./dwr/interface/AddCriteriaJS.js'></script>
<script type='text/javascript' src='./javascripts/prototype.js'></script>
<script type='text/javascript'>
function init() {
fillTable();
}
var peopleCache = { };
var viewed = -1;
function fillTable() {
AddCriteriaJS.getAllCriteria(function(criteria) {
// Delete all the rows except for the "pattern" row
dwr.util.removeAllRows("criteriabody", { filter:function(tr) {
return (tr.id != "pattern");
}});
// Create a new set cloned from the pattern row
var person, id;
criteria.sort(function(p1, p2) { return p1.label.localeCompare(p2.label); });
if (criteria.length == 0)
$("tableCriterion").style.display = "none";
for (var i = 0; i < criteria.length; i++) {
person = criteria[i];
id = person.id;
dwr.util.cloneNode("pattern", { idSuffix:id });
dwr.util.setValue("tableCriterion" + id, person.label);
dwr.util.setValue("tableCriterionMin" + id, person.min);
dwr.util.setValue("tableCriterionMax" + id, person.max);
$("tableCriterion").style.display = "";
$("pattern" + id).style.display = "";
peopleCache[id] = person;
}
});
}
function editClicked(eleid) {
// we were an id of the form "edit{id}", eg "edit42". We lookup the "42"
var person = peopleCache[eleid.substring(4)];
dwr.util.setValues(person);
}
function deleteClicked(eleid) {
// we were an id of the form "delete{id}", eg "delete42". We lookup the "42"
var person = peopleCache[eleid.substring(6)];
if (confirm("Are you sure you want to delete " + person.label + "?")) {
dwr.engine.beginBatch();
AddCriteriaJS.deleteCriterion(person);
fillTable();
dwr.engine.endBatch();
}
}
function writePerson() {
var person = { id:viewed, label:null, min:null, max:null };
dwr.util.getValues(person);
dwr.engine.beginBatch();
AddCriteriaJS.setCriterion(person);
fillTable();
dwr.engine.endBatch();
}
function clearPerson() {
viewed = -1;
dwr.util.setValues({ id:-1, label:null, min:null, max:null });
}
</script>
</head>
<body>
<h2 align="center"><fmt:message key="conference.titleMenu" /></h2>
<form:form commandName="formConference" name="monForm" onsubmit="return submitIfNotEnter(this)">
<fieldset><legend>Criteria</legend>
<table class="plain">
<tr>
<td>Label:</td>
<td><input id="label" type="text"/></td>
</tr>
<tr>
<td>Min:</td>
<td><input id="min" type="text"/></td>
</tr>
<tr>
<td>Max:</td>
<td><input id="max" type="text"/></td>
</tr>
<tr>
<td colspan="2" align="right"><small>(ID=<span id="id">-1</span>)</small>
<a href="#" onclick="writePerson()">Save</a>
<a href="#" onclick="clearPerson()">Clear</a>
</td>
</tr>
</table>
</fieldset>
<br />
<table border="1" id="tableCriterion" style="display: none;">
<thead>
<tr>
<th>Criterion</th>
<th>Min</th>
<th>Max</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="criteriabody">
<tr id="pattern" style="display: none;">
<td><span id="tableCriterion">Criterion</span></td>
<td><span id="tableCriterionMin">Min</span></td>
<td><span id="tableCriterionMax">Max</span></td>
<td>
<a id="edit" href="#" onclick="editClicked(this.id)" >Edit</a>
<a id="delete" href="#" onclick="deleteClicked(this.id)" >Delete</a>
</td>
</tr>
</tbody>
</table>
<br />
<input type="submit" align="middle" name="_target2" value="Back">
<input type="submit" align="middle" name="_target4" value="Next"/>
</form:form>
<script type="text/javascript">
init();
</script>
<br />
<br />
<a href="<c:url value="main.htm"/>">Home</a>
</body>
</html>