// temp Id generator
SEQUENCE = {
value : -1,
next : function() {
this.value = ++this.value;
return this.value;
};
//reset form element
function clearForm(formName) {
var formObj = document.forms[formName];
var formEl = formObj.elements;
for (var i=0; i<formEl.length; i++)
{
var element = formEl[i];
if (element.type == 'submit') { continue; }
if (element.type == 'reset') { continue; }
if (element.type == 'button') { continue; }
if (element.type == 'hidden') { continue; }
if (element.type == 'text') { element.value = ''; }
if (element.type == 'textarea') { element.value = ''; }
if (element.type == 'checkbox') { element.checked = false; }
if (element.type == 'radio') { element.checked = false; }
if (element.type == 'select-multiple') { element.selectedIndex = -1; }
if (element.type == 'select-one') { element.selectedIndex = -1; }
}
}
//define stringBuffer object in present project
function StringBuffer() {
this.__strings__ = new Array;
}
StringBuffer.prototype.append = function(str) {
this.__strings__.push(str);
return this;
};
StringBuffer.prototype.toString = function() {
return this.__strings__.join("");
};
//extend one method,'startWith' for original string object
if(!String.prototype.startWith){
String.prototype.startWith = function(param){
if(!param){
return false;
}else{
if(String(this).substring(0,String(param).length)==param){
return true;
}else{
return false;
}
}
};
}
/**
*
* @param divId one container
* @param info operation result message to show in the up DIV, such as: "Add Successfully!"
* @param isSuccess one sign whether operate successfully.Just two values:true or false.true means success.
* @returns undefined
*/
function showOperationResultInfo(divId,info,isSuccess){
$("#"+divId).removeAttr("style");
if(isSuccess){
$("#"+divId).attr("style","color:green");
}else{
$("#"+divId).attr("style","color:red");
}
$("#"+divId).empty();
$("#"+divId).html(info);
}
//refresh current page after ajax request
function deleteItemById(link){
$.ajax({
url :link,
cache:false,
context:document.body,
success:function(data){
if(!data.startWith("error")){
location.href="http://<%=request.getServerName()%>:<%=request.getServerPort()%><%=request.getContextPath() %>/demoWebSite/generateReport.action";
}else{
showOperationResultInfo("errorInfo",Messages.deleteFailureMess+",cause:"+data,false);
return false;
}
}
});
}
//obtain java version in the local PC by the plugin 'deployJava.js'
<script src="${contextPath}/js/plugins/deployJava.js"></script>
<script type="text/javascript">
var versions = deployJava.getJREs();
var reg = /1.6.|1.7.|1.8.|1.9./;
var result = reg.exec(versions);
if(null == result){
$("#appletUploadControl").innerHTML = "Your java version is: <b>" + versions + "</b>, please install java1.6 or upper version<br/>" + "You could download latest JDK from here:" + "<a href='http://www.oracle.com/technetwork/java/javase/downloads/index.html', target='_blank'>oracle-java</a>";
}
</script>