📄 common.js
字号:
var currtr,seltr;
function NVL(v) {
return isnull(v)?"":v;
}
function isnull(v){
return typeof(v)=="undefined";
}
Date.prototype.addDay=function(n){
return new Date(this.getFullYear(),this.getMonth(),this.getDate()+n);
}
Date.prototype.minus=function(d){
return (this.getTime()-d.getTime())/(24*60*60*1000);
}
Date.prototype.getDays=function() {
return new Date(this.getFullYear(),this.getMonth()+1,0).getDate();
}
Array.prototype.del=function(e) {
bdelete=false;
for (var i=0; i<this.length; i++) {
if (bdelete) {
this[i-1]=this[i];
continue;
}
if (this[i] == e) {
bdelete=true;
}
}
if (bdelete) {
this.length--;
}
}
Array.prototype.contain=function(e) {
for (var i=0; i < this.length; i++) {
if (this[i] == e) {
return true;
}
}
return false;
}
Array.prototype.getIndex=function(e) {
for(var i=0;i<this.length;i++) {
if(this[i]==e) return i;
}
return -1;
}
String.prototype.trimAll=function() {
var v=this;
while(v.charAt(0)==' ') {
v=v.substr(1);
}
while(v.charAt(v.length-1) == ' ') {
v=v.substr(0,v.length-1);
}
return v;
}
function gainfocus() {
}
function form(frm) {
frm.vo = [];
for(var i=0;i<frm.elements.length;i++){
var elem=frm.elements[i];
if((elem.tagName=="INPUT" && elem.type=="text") || elem.tagName=="TEXTAREA"){
elem.onfocus=function(){
this.select();
}
}
}
frm.changefocus=function(e){
if(!isnull(e.type) && e.type=="button") return;
var flag=false;
var counter=0;
while(counter++<2){
for(var i=0;i<this.elements.length;i++) {
if(e==this.elements[i]){
flag=true;
continue;
}
if(flag){
if(!this.isfocusable(this.elements[i])) continue;
this.elements[i].focus();
return;
}
}
}
}
frm.isfocusable=function(e){
return !(e.readOnly ||
e.style.display=="none" ||
e.disabled ||
e.type=="hidden");
}
frm.onkeyup=function(){
var e=event.srcElement;
if(event.keyCode==10){
this.btnSubmit.click();
}
if(event.keyCode==13){
if(event.ctrlKey){
this.btnSubmit.click();
} else {
if (e.tagName.toLowerCase() != 'textarea') {
this.changefocus(e);
}
}
}
}
frm.onsubmit = function() {
this.trimAll();
return this.validate();
}
frm.validate = function() {
for (var i = 0; i < this.vo.length; i++) {
if (!this.vo[i].validate()) {
return false;
}
}
return true;
}
frm.addValid = function(src, vf, data) {
this.vo[this.vo.length] = new validObj(src, vf, data);
}
frm.trimAll=function() {
for(var i=0;i<this.elements.length;i++){
var e=this.elements[i];
if(e.tagName=="INPUT" && e.type=="text") {
e.value=e.value.trimAll();
}
}
}
return frm;
}
function validObj(src, vf, d) {
this.source = src;
this.validate = vf;
this.data = d;
this.getValue = function() {
return this.source.value;
}
this.focus = function() {
this.source.focus();
}
this.select = function() {
this.source.select();
}
}
function validEmail() {
if(this.getValue() != ""){
if (!checkEmail(this.getValue())) {
rdShowMessageDialog("电子邮箱格式不正确")
this.focus();
this.select();
return false;
}
}
return true;
}
function validTextLength(){
if(this.source.value.length > this.data){
rdShowMessageDialog("超出输入规定长度!(应小于" + this.data + ")");
this.focus();
this.select();
return false;
}
return true;
}
function validBeWebUser(){
if(this.source.value != "" && this.data.checked){
rdShowMessageDialog("请确认是否会员及入会日期!");
return false;
}
return true;
}
function validateDate(){
if(this.source.value > this.data.value)
{
rdShowMessageDialog("开始日期不能大于结束日期");
return false;
}
return true;
}
function validExpDate(){
if(this.source.value > this.data.value)
{
rdShowMessageDialog("开展日期不能大于撤展日期");
return false;
}
return true;
}
function validStartExpDate(){
if(this.source.value > this.data.value)
{
rdShowMessageDialog("开始日期不能大于开展日期");
return false;
}
return true;
}
function validEndExpDate(){
if(this.source.value > this.data.value)
{
rdShowMessageDialog("撤展日期不能大于结束日期");
return false;
}
return true;
}
function validCreateDate(){
if(this.source.value > this.data.value)
{
rdShowMessageDialog("当前日期不能大于开始日期");
return false;
}
return true;
}
function validAmendsDate(){
if(this.source.value > this.data.value)
{
rdShowMessageDialog("礼赔登记时间不能大于要求礼赔时间")
return false;
}
return true;
}
function validApplyDate(){
if(this.source.value > this.data.value)
{
rdShowMessageDialog("撤展日期不能小于申请日期")
return false;
}
return true;
}
function validDouble(){
if(checkNum(this.getValue())){
return true;
}
if(this.getValue() != ""){
if(!checkDouble(this.getValue())){
rdShowMessageDialog(this.data + "数值格式不正确");
this.focus();
this.select();
return false;
}
}
return true;
}
function validNotSelect(){
if(this.getValue() == ""){
rdShowMessageDialog(this.data + "必须选择.");
this.focus();
return false;
}
return true;
}
function validNotNull(){
if(this.getValue().replace(/ /g,"") == ""){
rdShowMessageDialog(this.data + "不能为空.");
this.focus();
this.select();
return false;
}
return true;
}
function validPassword(){
if (this.getValue() != this.data.value) {
rdShowMessageDialog("密码与确认密码必须相同!");
this.focus();
this.select();
return false;
}
return true;
}
function validNotZero(){
if (parseFloat(this.getValue()) == 0) {
rdShowMessageDialog(this.data + "不能为0!");
this.focus();
this.select();
return false;
}
return true;
}
function validNum() {
if(this.getValue() != ""){
if (!checkNum(this.getValue())) {
rdShowMessageDialog(this.data + "必须是数字。");
this.focus();
this.select();
return false;
}
}
return true;
}
function checkEmail(value) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(value)){
return true;
}
return false;
}
function checkDouble(value){
if(/^\d+\.\d+$/.test(value)){
return true;
}
return false;
}
function checkNum(value) {
return !/\D/.test(value);
}
//this is test function
function testValid() {
if (this.getValue() < 10) {
rdShowMessageDialog("number must be greater than 10");
this.focus();
this.select();
return false;
}
return true;
}
var obj;
function MDown(){
obj=qf.form;
obj.setCapture();
if(obj != null && typeof(obj.style) != "undefined"){
pX=event.x-obj.style.pixelLeft;
pY=event.y-obj.style.pixelTop;
}
}
function MMove(){
if(obj != null && typeof(obj.style) != "undefined"){
obj.style.left=event.x-pX;
obj.style.top=event.y-pY;
}
}
function MUp(){
if(obj != null && typeof(obj.style) != "undefined"){
obj.releaseCapture();
obj=null;
}
}
function QueryForm(form) {
document.onmouseup=MUp;
document.onmousemove=MMove;
this.form = form;
this.orgValues=[];
elems=form.elements;
for(var i=0; i<elems.length; i++) {
this.orgValues[i]=elems[i].value;
}
title=document.createElement("DIV");
title.style.height="25";
title.style.paddingTop="5";
title.style.cursor="move";
title.className="title-pic";
title.onmousedown=MDown;
title.align="right";
img=document.createElement("IMG");
img.src="/hicesc/images/page_close.gif";
img.parent=this;
img.style.cursor="hand";
img.onclick=function() {this.parent.hide();};
img.onmousedown=function() {event.cancelBubble = true;};
title.appendChild(img);
span=document.createElement("SPAN");
span.style.width="10";
title.appendChild(span);
form.insertBefore(title,form.firstChild);
form.style.display="none";
form.style.position="absolute";
form.style.backgroundColor="white";
form.style.border="solid 1px black";
this.display=function() {
style=this.form.style;
style.display="";
style.left=(document.body.clientWidth-this.form.style.posWidth)/2;
style.top=(document.body.clientHeight-this.form.style.posHeight)/2;
}
this.hide=function() {
this.form.style.display="none";
elems=this.form.elements;
for(var i=0;i<elems.length;i++) {
elems[i].value=this.orgValues[i];
}
}
this.go=function(pgNumber) {
cp = this.form.pageNumber.value-0;
if (pgNumber > 0 && pgNumber <= pgCount) {
if (cp != pgNumber) {
this.form.pageNumber.value=pgNumber+"";
this.form.action.value="list";
this.form.submit();
}
} else {
confirmMsg("你输入的页码必须在1 - " + pgCount + "之间");
}
}
this.next=function() {
cp = this.form.pageNumber.value-0;
if (cp < pgCount) {
this.go(cp+1);
}
}
this.first=function() {
cp = this.form.pageNumber.value-0;
if (cp > 1) {
this.go(1);
}
}
this.previous=function() {
cp = this.form.pageNumber.value-0;
if (cp > 1) {
this.go(cp - 1);
}
}
this.last=function() {
cp = this.form.pageNumber.value-0;
if (cp < pgCount) {
this.go(pgCount);
}
}
form.onkeypress=function() {
if(event.keyCode==13) find();
}
}
document.execCommand("2D-position",false,true);
// -- 查询 --
var selectId;
function selectRadio(radios,value) {
if (radios == null) {
return;
}
if (!radios.length) {
radios.click();
selectId=radios.value;
return;
}
if (value == null || value == "") {
radios[0].click();
selectId=radios[0].value;
return;
}
bSelected=false;
for (var i = 0; i < radios.length; i++) {
if (radios[i].value == value) {
radios[i].click();
bSelected=true;
selectId=radios[i].value;
break;
}
}
if (!bSelected) {
radios[0].click();
selectId=radios[0].value;
}
}
function confirmMsg(msg) {
rdShowMessageDialog(msg);
}
function confirmDelete() {
return (rdShowConfirmDialog("你确认要删除吗?") == rdConstOK);
}
function selecttr(rdo,idx,src) {
if (seltr) seltr.className="tr";
seltr=src;
if (rdo.length) {
rdo[idx].click();
} else {
rdo.click();
}
src.className = "selectedtr";
}
function hightr(src) {
if (currtr) currtr.className="tr";
if (seltr!=null && currtr==seltr) seltr.className = "selectedtr";
currtr = src;
src.className = "hightr";
event.cancelBubble = true;
}
function cancelhigh() {
if (currtr) currtr.className="tr";
if (seltr!=null && currtr==seltr) seltr.className = "selectedtr";
}
function loadXml(url) {
var xmldoc=new ActiveXObject("Msxml2.DOMDocument");
xmldoc.async = false;
xmldoc.load(url);
return xmldoc.childNodes[1];
}
function loadList(slt,url) {
clearList(slt);
var root = loadXml(url);
for(var i=0;i<root.childNodes.length;i++) {
var node=root.childNodes[i];
var opt=document.createElement("option");
for(var j=0;j<node.attributes.length;j++) {
var attr=node.attributes[j];
eval("opt."+attr.name+"='"+attr.nodeValue+"'");
}
opt.text=node.childNodes[0].nodeValue;
slt.options[slt.options.length]=opt;
}
}
function clearList(slt) {
for(var i=slt.options.length-1;i>=0;i--){
slt.options[i]=null;
}
}
function verifyname(url){
var root = loadXml(url);
return root.childNodes[0].childNodes[0].nodeValue == "true";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -