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

📄 script.js

📁 实现了基本的oa功能:个人日志。。。
💻 JS
📖 第 1 页 / 共 5 页
字号:
        str += d.getSeconds();

        return str;
    }

    /**
     * 计算字符串str存储到数据库需要的长度(就是字节数)
     */
    var enCharDBLength = 1;
    var chCharDBLength = 3;
    function countDBLength(str){
        var i,code,enCharCount,chCharCount;
        enCharCount = 0;
        chCharCount = 0;
        for(i=0;i<str.length;i++){
            code = str.charCodeAt(i);
            if( code>0xff )
                chCharCount ++;
            else
                enCharCount ++;
        }
        return ((chCharCount*chCharDBLength)+(enCharCount*enCharDBLength))

        /**var i,length,code;
        length=0;
        for(i=0;i< str.length;i++){
            code=str.charCodeAt(i);
            do{
                length++;
            }while( (code=code>>8)>0 );
        }

        return length;*/
    }

    /*
    * 判断字符串str的长度是否超过了length指定的长度,如果是,则弹出提醒对话框
    * strName, 指出录入项目的名称,如:组织描述
    * hint,提示的内容
    */
   function isTooLongByHint(str ,length, strName, hint){
      if( countDBLength(str) > length ){
        var newStr = hint.replace("[enLength]",((length-length%enCharDBLength)/enCharDBLength)+"" );
        newStr = newStr.replace("[chLength]",((length-length%chCharDBLength)/chCharDBLength)+"" );

        alert(strName + newStr);
        return true;
      }
      return false;
   }
   /*
    * 判断int的长度是否超过了int指定的长度,如果是,则弹出提醒对话框
    * strName, 指出录入项目的名称,如:组织描述
    * hint,提示的内容
    */
   function isTooLongIntByHint(str, strName, hint){
      if( trim(str).length>8 ){
        alert(strName + hint);
        return true;
      }
      return false;
   }
   /*
    * 判断long的长度是否超过了long指定的长度,如果是,则弹出提醒对话框
    * strName, 指出录入项目的名称,如:组织描述
    * hint,提示的内容
    */
   function isTooLongLongByHint(str, strName, hint){
      if( trim(str).length > 16 ){
        alert(strName + hint);
        return true;
      }
      return false;
   }
   /*
    * 判断输入值是否为int型及int型的长度是否超过了指定的长度,如果是,则弹出提醒对话框
    *hint1提示不是int型 ,hint2提示长度超过了规定范围
    * strName, 指出录入项目的名称,如:组织描述
    * hint,提示的内容
    */
   function isNotIntOrTooLongByHint(str, strName, hint1,hint2){

      if( !isInt( str ) ){
          alert( strName+hint1 );
          return true;
     }else{
         if( trim(str).length>8 ){
            alert(strName + hint2);
            return true;
          }
      }
     return false;
   }
   /*
    * 判断long的长度是否超过了long指定的长度,如果是,则弹出提醒对话框
    * hint1提示不是int型 ,hint2提示长度超过了规定范围
    * strName, 指出录入项目的名称,如:组织描述
    * hint,提示的内容
    */
   function isNotLongOrTooLongByHint(str, strName, hint1,hint2){
      if( !isInt( str ) ){
          alert( strName+hint1 );
          return true;
     }else{
         if( trim(str).length>16 ){
            alert(strName + hint2);
            return true;
          }
      }
    return false;
   }

/*
    * 判断是否是float型的以及长度是否超过了指定的长度,如果是,则弹出提醒对话框
    * length1小数点以前的位数,length2小数点以后的位数
    * hint1提示不是float型 ,hint2提示小数点以前超过了规定范围,hint3提示小点以后超过规定长度
    * strName, 指出录入项目的名称,如:组织描述
    */
   function isNotFloatOrTooLongByHint(str,length1,length2, strName, hint1,hint2,hint3){
            if( !isFloat( str ) ){
                  alert( strName+hint1 );
                  return true;
             }else{
                return isFloatTooLongByHint(str,length1,length2,strName,hint2,hint3);
              }
            return false;
    }
    /*
    * 判断float型的长度是否超过了指定的长度,如果是,则弹出提醒对话框
    * length2小数点以前的位数,length3小数点以后的位数
    * hint1提示不是float型 ,hint2提示小数点以前超过了规定范围,hint3提示小点以后超过规定长度
    * strName, 指出录入项目的名称,如:组织描述
    */
   function isFloatTooLongByHint(str,length1,length2, strName,hint2,hint3){
            str = parseFloat(str)+"";
            str = trim(str);
            var pos = str.indexOf(".");
            var pos1 = str.indexOf("E");
            var len1,len2;
            if( pos<0 ){
               len1 = str.length;
               len2 = 0;
            }else{
               len2 = str.length-pos-1;
               len1 = str.length-len2-1;
            }
              if( len1>length1 ){
                    alert(strName + hint2);
                    return true;
                  }
              if(len2>length2){
                    alert(strName + hint3);
                    return true;
                  }
            return false;
    }

   /*
    * 判断字符串是否是一个有效的email地址
    * theStr, 要检查的字符串
    * 如果是,则返回true;否则,返回false
    */
   function isEmail(theStr)
    {
        var atIndex = theStr.indexOf("@");
        var dotIndex = theStr.indexOf(".",atIndex);
        var flag = true;

        if(atIndex < 1) return false;
        if(dotIndex < (atIndex+2)) return false;
        if(atIndex != theStr.lastIndexOf("@")) return false;

        var theSub = theStr.substring(0,dotIndex+1);
        if(theStr.length <= theSub.length) return fasle;

        return true;
    }

    /*
    * 判断字符串是否是一个有效的email地址,如果不是,则弹出提醒对话框
    * strName, 指出录入项目的名称,如:组织描述
    * hint,提示的内容
    */
   function isNotEmailByHint(theStr, strName, hint){
      if( !isEmail(theStr) ){
        alert(strName + hint);
        return true;
      }

      return false;
   }

    /*
    * 判断字符串是否是一个有效的邮政编码
    * theStr, 要检查的字符串
    * 如果是,则返回true;否则,返回false
    */
   function isPostalCode(theStr)
    {
        theStr = trim(theStr);

        if(theStr.length != 6) return false;
        if(!isSignedInt(theStr)) return false;

        return true;
    }

   /*
    * 判断字符串是否是一个有效的邮政编码,如果不是,则弹出提醒对话框
    * strName, 指出录入项目的名称,如:组织描述
    * hint,提示的内容
    */
   function isNotPostalCodeByHint(theStr, strName, hint){
      if( !isPostalCode(theStr) ){
        alert(strName + hint);
        return true;
      }

      return false;
   }

   /*
    * 判断字符串是否是一个有效的身份证号码
    *
    */
   function isIDCard(idcard){
        idcard = trim(idcard);
        if (idcard.length == 15){
            if (isNaN(idcard))
                return false;
        }
        else if (idcard.length == 18){
            if (isNaN(idcard)){
                if (isNaN(idcard.substring(0, 17)))
                    return false;
                else if (idcard.charAt(17) != 'X')
                    return false;
            }
        }
        else{
            return false;
        }
        return true;
   }

   /*
    * 判断字符串是否是一个有效的身份证号码,如果不是,则弹出提醒对话框
    * hint, 弹出的提示信息
    */
    function isIDCardByHint(idcard, hint){
        if (isIDCard(idcard))
            return true;
        alert(hint);
        return false;
    }

   /*
    * 判断字符串是否是一个有效的英文名,如果不是,则弹出提醒对话框
    * hint, 弹出的提示信息
    */
    function isEnName(str){
        var i,length,code;
        length=0;
        for(i=0;i< str.length;i++){
            code=str.charCodeAt(i);
            if ((code= code >> 8) > 0)
                return false;
        }
        return true;
    }

/*
* This is used in the <ehr:popup> tag
* It is to display the long text.
* @author liuheyuan
*/
var ehrPopup = window.createPopup();
function displayPopup(id)
{
    var display=document.getElementById(id);
    ehrPopup.document.body.innerHTML = display.innerHTML;
    var popupBody = ehrPopup.document.body;
    // The following popup object is used only to detect what height the
    // displayed popup object should be using the scrollHeight property.
    // This is important because the size of the popup object varies
    // depending on the length of the definition text. This first
    // popup object is not seen by the user.
    ehrPopup.show(0, 0, 300, 0);
    var realHeight = popupBody.scrollHeight;
    // Hides the dimension detector popup object.
    ehrPopup.hide();
    // Shows the actual popup object with correct height.
    ehrPopup.show(0, 15, 300, realHeight,event.srcElement);
    return false;
}
/*
* This is used to display the employee photo
* @author liuheyuan
*/
var bToggle = 1
<!-- Toggle the sizingMethod property to resize the image.  -->
function fnToggle(oObj,imageMsg,scaleMsg) {
    if (bToggle) {
        bToggle = 0;
        oDiv.filters(0).sizingMethod="image";
        oObj.innerText=imageMsg;}
    else {
        bToggle = 1;
        oDiv.filters(0).sizingMethod="scale";
        oObj.innerText=scaleMsg;}
}

/*
 * display emloyee phohto ,modified the above function
 * author lichuanjun
 */
function fnToggle1(oObj,ob1,ob2,imageMsg,scaleMsg) {
    var img1,img2;
    img1=document.getElementById(ob1);
    img2=document.getElementById(ob2);
    
    if (bToggle) {
        bToggle = 0;
        // langs fixed 2004.2.26 
//        img1.style.display="none";
//        img2.style.display="block";
//        oObj.innerText=imageMsg;}

        img1.style.display="block";
        img2.style.display="none";
        oObj.innerText=scaleMsg;
        // langs fixed end
    } else {
        bToggle = 1;
        // langs fixed 2004.2.26 
//        img1.style.display="block";
//        img2.style.display="none";
//        oObj.innerText=scaleMsg;

        img1.style.display="none";
        img2.style.display="block";
        oObj.innerText=imageMsg;
        // langs fixed end
    }
}

 /*
    * 判断字符串str的长度是否超过了length指定的长度,如果是,返回true,否则返回false
    */
   function isTooLongNotHint(str ,length){
      if( countDBLength(str) > length ){
        return true;
      }
      return false;
   }
  /**
    * This is used to check the customField value .
    */
      function checkCustomField(notNull){
             var message="";
             for(var j=0;j<=i;j++){
                 if(isNull(infoForm.elements['customFieldValueList['+j+'].fieldvalue'].value) || isTooLongNotHint(infoForm.elements['customFieldValueList['+j+'].fieldvalue'].value,1024)){
                     message+=customFieldName[j]+notNull;
                 }
             }
             return message;
        }
    /**
    * This is used to check the customField value .
    */
      function checkCandidateCustomField(notNull){
             var message="";
             for(var j=0;j<=i;j++){
                 if(isNull(candidateInfoForm.elements['customFieldValueList['+j+'].fieldvalue'].value) || isTooLongNotHint(candidateInfoForm.elements['customFieldValueList['+j+'].fieldvalue'].value,1024)){
                     message+=customFieldName[j]+notNull;
                 }
             }
              return message;
        }

     function checkIncludePercent(str){
        if( str.indexOf('%') >=0 )
           return true;
        return false;
     }

     /* langs added 2003.12.16 for recruit */
     /**
     * check illegal char in customField value.
     * if find illegal char return false;else return true.
     * add by macheng
     */
     function checkIllegalChar(str,hint){
        if(str.indexOf("<")>=0 ){
            alert(hint+"< ");
            return false;
        }
        if(str.indexOf(">")>=0 ){
            alert(hint+"> ");
            return false;
        }
 

⌨️ 快捷键说明

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