⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gwp.js

📁 基于java的jsp开发的在线考试系统 基于java的jsp开发的在线考试系统
💻 JS
📖 第 1 页 / 共 3 页
字号:
		numNoChar=numNo.charAt(i)  
		if (inChars.indexOf(numNoChar, 0) == -1){
			alert("请您输入整数!");
			document.all(sName).focus(); 
			return false;  
		}
	}
	return true;
}
//EMail校验
function isEmail(sName){
	if (document.all(sName).value.trim()!=""){
		var email=(document.all(sName).value.trim());
		inChars = "/;,:{}[]|*%$#!()`<>?";
		for (i=0; i< inChars.length; i++){
			badChar = inChars.charAt(i)
			if (email.indexOf(badChar,0) > -1){
				alert("您的Email输入不正确!");
				document.all(sName).value.focus();
				return false;  
			} 
		}
		atEmail = email.indexOf("@",1)
		dotEmail = email.indexOf(".",atEmail)  
		if (atEmail == -1 || email.indexOf("@", atEmail+1) != -1 || dotEmail == -1 || atEmail +2 > dotEmail || dotEmail +3 > email.length){  
			alert("您的Email输入不正确!");
			document.all(sName).focus();
			return false;  
	    }
    }  
}
//电话号码校验  
function isTel(sName){  
	var tel=document.all(sName).value.trim();  
	var inChars = "-()1234567890,";  
	for (i=0;i<tel.length;i++){  
		telchar=tel.charAt(i)  
		if (inChars.indexOf(telchar, 0) == -1){ 
			alert("电话号码只能输入'-()1234567890,'!");
			document.all(sName).focus(); 
			return false;  
		}  
	}  
}
//=======(数据校验)**结束**=======

//流程定制和表单定制系统的函数
	//选择模块函数
	function selModal(idField, nameField) {
		var rtnValue = window.showModalDialog("controller?nextpage=ModalSelect&command=ModalManagerCmd&canexecute=true&aaa=" + Math.random(), "", "dialogWidth:300px;dialogHeight:400px;center:1;status:0;scroll:1");
		if (rtnValue != null && rtnValue.trim() != "") {
			var values = rtnValue.split("щ");
			document.getElementsByName(idField)[0].value = values[0];
			document.getElementsByName(nameField)[0].value = values[1];
		}
	}
	//获取浏览器当前URI,如:http://www.langchao.com.cn
	function getUri() {
		var protocol = window.location.protocol;
		var host = window.location.host;
		host = protocol+"//"+host;
		return host;	
	}
	
	//获取Word对象,若获取失败则弹出提示并返回null
	function getWord() {
		try{
			return new ActiveXObject("Word.Application");    //启动word
		}
		catch (e) {
			alert("对不起,初始化Word对象失败!\n请确认您是否安装了Microsoft Word 97或更高版本;\n并且将本站点添加到可信站点列表。");
			return null;
		}
	}
	
	//获取Excel对象,若获取失败则弹出提示并返回null
	function getExcel() {
		try{
			return new ActiveXObject("Excel.Application");    //启动word
		}
		catch (e) {
			alert("对不起,初始化Excel对象失败!\n请确认您是否安装了Microsoft Excel 97或更高版本;\n并且将本站点添加到可信站点列表。");
			return null;
		}
	}
	
	//对指定文件进行Base64编码,并返回编码后的字符串
	function encoding(filename){
		try {
			newMothod1.filename = filename;
			newMothod1.encode();                 //将需要编辑的文件编码
			var encodeString = newMothod1.encodeString;
			return encodeString;
		}
		catch (e) {
			alert("对不起,处理文件时错误!\n请确认文件是否保存并关闭!");
			return null;
		}
	}

	//对传入的经过Base64编码的字符串进行解码,并返回解码后的文件全名
	function decoding(encodeString){
		newMothod1.decodeValue(encodeString);//将编码后文件进行解码
		var decodefile = newMothod1.decodefile;
		return decodefile;
	}
	//初始化模板编辑对话框
	function initTemplateEditor() {
		var success;
		if (data["mimetype"].toLowerCase() == "application/msword") {
			success = editTemplateWord();
		}
		else if(data["mimetype"].toLowerCase() == "application/vnd.ms-excel") {
			success = editTemplateExcel();
		}
		else {
			alert("对不起,模板类型不正确!");
			success = false;
		}
		if (success == false) {
			window.close();
		}
	}
	//编辑Word模板
	function editTemplateWord() {
		app = getWord();
		if (app == null) {
			return false;
		}
		if (data["value"] == null || data["value"].trim() == "") {
			var url = getUri() + "/GWPWEB/resource/doc/word.doc";
			newMothod1.downFileFromUrl(url);
			fileName = newMothod1.DownLoadFileName;
		}
		else {
			fileName = decoding(data["value"]);
		}
		app.Documents.Open(fileName);
		if (data["templateName"] == "print.doc" && confirm("是否在打印模板中添加新的表单数据?")) {
			var xml = new ActiveXObject("Microsoft.XMLDOM");
			xml.async=false;
			xml.loadXML("<all>" + field + "</all>");
			var root = xml.documentElement;
			for (var i = 0; i < root.childNodes.length; i++) {
				if (root.childNodes.item(i).nodeType == 1) {
					app.Selection.TypeText("щ" + root.childNodes.item(i).attributes.getNamedItem("displayname").nodeValue + "щ");
					app.Selection.TypeParagraph();
				}
			}
		}
		app.visible = true;
		return true;	
	}
	//编辑Excel模板
	function editTemplateExcel() {
		app = getExcel();
		if (app == null) {
			return false;
		}
		if (data["value"] == null || data["value"].trim() == "") {
			var url = getUri() + "/GWPWEB/resource/doc/excel.xls";
			newMothod1.downFileFromUrl(url);
			fileName = newMothod1.DownLoadFileName;
		}
		else {
			fileName = decoding(data["value"]);
		}
		var book = app.Workbooks.Open(fileName);
		book.Application.Visible = true;
		return true;
	}
	//模板编辑完成
	function editTemplateComplete() {
		if (document.forms[0].templateName.value == null || document.forms[0].templateName.value.trim() == "") {
			alert("对不起,模板名称不能为空!");
			document.forms[0].templateName.focus();
			return;
		}
		data["templateName"] = document.forms[0].templateName.value.trim();
		data["value"] = encoding(fileName);
		if (data["value"] != null) {
			window.returnValue = data;
			window.close();
		}
	}
	
	//删除选定的模板
	function deleteTemplate() {
		if (!confirm("您确定要删除指定的模板吗?")) {
			return;
		}
		var sel = document.forms[0].TemplateList.options;
		for (var i = sel.length - 1; i > 0; i--) {
			if (sel[i].selected == true) {
				templates.splice(parseInt(sel[i].value), 1, null);
				document.forms[0].TemplateList.remove(i);
			}
		}
	}
	
	//模板完成
	function completeTemplate() {
		var templateNode = "";
		var tempString = "";
		for (var i = 0; i < templates.length; i++) {
			if (templates[i] != null) {
				tempString += "<encodefile";
	   			for ( templateNode in templates[i] ) {
	    			if (templateNode != "value") {
	    				tempString += " " + templateNode + "=\"" + templates[i][templateNode] + "\"";
	    			}
	   			}
	   			tempString +=">" + templates[i]["value"] + "</encodefile>";
	   		}
  		}
  		window.returnValue = tempString;
  		window.close();
	}
	//新建正文模板
	function newTemplate(mimeType) {
		var newEl = new Array();
		newEl["templateName"] = "";
		newEl["template"] = "1";
		newEl["mimetype"] = mimeType;
		newEl["value"] = "";
		var newData = new Array();
		newData["template"] = newEl;
		newData["fields"] = field;
		result = showModalDialog("controller?nextpage=TemplateEdit&command=&canexecute=false&aaa=" + Math.random(), newData, "dialogWidth:250px; dialogHeight:100px; status:no; center:yes; scroll:no");
		if (result != null) {
			if (templates.length == 0) {
				templates[1] = result;
			}
			else {
				templates.push(result);
			}
			var myel = document.createElement("option");
			myel.value = new Number(templates.length - 1).toString();
			myel.text = result["templateName"];
			document.forms[0].TemplateList.add(myel);
		}
	}
	//修改选定的模板
	function modifyTemplate() {
		var selItem = document.forms[0].TemplateList.options[document.forms[0].TemplateList.selectedIndex];
		var myel = templates[parseInt(selItem.value)];
		if (myel == null) {
			myel = new Array();
			myel["templateName"] = "print.doc";
			myel["template"] = "0";
			myel["mimetype"] = "application/msword";
			myel["value"] = "";
		}
		var newData = new Array();
		newData["template"] = myel;
		newData["fields"] = field;
		var result = showModalDialog("controller?nextpage=TemplateEdit&command=&canexecute=false&aaa=" + Math.random(), newData, "dialogWidth:250px; dialogHeight:100px; status:no; center:yes; scroll:no");
		//myel["templateName"] = "aaaaa";
		//var result = myel;
		if (result != null) {
			selItem.text = result["templateName"];
			templates.splice(parseInt(selItem.value), 1, result);
		}
	}
	
	function HTMLencode(strToCode) { 
		strToCode = strToCode.replace(/</g,"&lt;");
		strToCode = strToCode.replace(/>/g,"&gt;");
		return strToCode;
	}
	//保存表单
	function saveForm(n, nextpage, command, canexecute, complete) {
		if (document.FormEditor.isFormAttribute() == true) {
			alert("对不起,表单属性页打开时不能保存表单!");
			return;
		}
		if (document.forms[n].Ins_Form_Moid.value == null || document.forms[n].Ins_Form_Moid.value.trim() == "") {
			alert("对不起,您还没有选择表单所属模块!");
			document.ModSel.focus();
			return;
		}
		document.forms[n].Ins_Form_IsComplete.value = complete;
		document.forms[n].Ins_Form_FormName.value = document.FormEditor.getFormName();
		document.forms[n].Ins_Form_Caption.value = document.FormEditor.getFormTitle();
		document.forms[n].Ins_Form_FormOrder.value = document.FormEditor.getFormNum();
		document.forms[n].Ins_Form_Html.value = HTMLencode(document.FormEditor.getFormStr());
		document.forms[n].Ins_Form_FieldList.value = document.FormEditor.getFieldStr();
		document.forms[n].Ins_Form_LocalAction.value = document.FormEditor.getLocalAction();
		if (document.forms[n].Ins_Form_FormName.value == null || document.forms[n].Ins_Form_FormName.value.trim() == "") {
			alert("对不起,表单名称不能为空!");
			return;
		}
		if (document.forms[n].Ins_Form_Caption.value == null || document.forms[n].Ins_Form_Caption.value.trim() == "") {
			alert("对不起,表单标题不能为空!");
			return;
		}
		pageshow(n, nextpage, command, canexecute);
	}
	//初始化表单数据
	function initForm() {
		if (document.forms[0].Ins_Form_FormId.value == null || document.forms[0].Ins_Form_FormId.value.trim() == "") {
			document.getElementById("tdModSel").style.removeAttribute("display");
		}
		else {
			document.FormEditor.setFormName(document.myform.Ins_Form_FormName.value);
			document.FormEditor.setFormTitle(document.myform.Ins_Form_Caption.value);
			document.FormEditor.setFormNum(document.myform.Ins_Form_FormOrder.value);
			document.FormEditor.setFormStr(document.myform.Ins_Form_Html.value);
			document.FormEditor.setFieldStr(document.myform.Ins_Form_FieldList.value);
			document.FormEditor.setLocalAction(document.myform.Ins_Form_LocalAction.value);
			document.FormEditor.savaform();
		}
	}
	//表单定制的模板按钮响应函数
	function template() {
		if (document.FormEditor.isFormAttribute() == true) {
			alert("对不起,表单属性页打开时不能设置表单模板!");
			return;
		}
		var data = new Array();
		data["template"] = document.forms[0].Ins_Form_TemplateList.value;
		data["fields"] = document.FormEditor.getFieldStr();
		var result = showModalDialog("controller?nextpage=TemplateList&command=&canexecute=false&aaa=" + Math.random(), data, "dialogWidth:350px; dialogHeight:250px; status:no; center:yes; scroll:no");
		if (result != null) {
			document.forms[0].Ins_Form_TemplateList.value = result;
		}
	}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -