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

📄 script.js

📁 实现了基本的oa功能:个人日志。。。
💻 JS
📖 第 1 页 / 共 5 页
字号:

    var dl1 = "!";
    var dl2 = "|";
    var dl3 = "^";

   /*
    * 判断字符串str的长度是否为零,且为零时显示hint信息
    */
   function isNullByHint(str , hint){
       if(str.length == 0){
          alert(hint);
          return true;
       }
       return false;
   }

   /*
    * 判断字符串str的长度是否为零
    */
   function isNull(str){
       if(trim(str).length == 0){
          return true;
       }
       return false;
   }

   /**
    * 判断字符串str是否为无符号整数,并在不是无符号整数时返回提示信息
    */
   function isNotIntByHint( str , hint ){
       if( isInt( str ) ){
           return false;
       }
       alert( hint );
       return true;
   }

   /**
    * 判断字符串str是否为无符号整数
    */
  function isInt(str){
      var tem = str + "";
      var intPattern = new RegExp("^\\d+$","g");
      return tem.match(intPattern) == tem;
   }

   function isNotTimeByHint( str , hint ){
       if( isTime( str ) ){
           return false;
       }
       alert( hint );
       return true;
   }

  function isTime(str){
      var tem = trim(str + "");
      var timePattern = new RegExp("^([0-1]?\\d|2[0-3]):[0-5]?\\d:[0-5]?\\d","g");
      return tem.match(timePattern) == tem;
  }

   /**
    * 判断字符串str是否为无符号浮点数,并在不是无符号浮点数时返回提示信息
    */
   function isNotFloatByHint( str , hint ){
       if( isFloat( str ) ){
           return false;
       }
       alert( hint );
       return true;
   }

   /**
    * 判断字符串str是否为无符号复点数,可以包含E指数
    */
   function isFloat(str){
      var tem = str + "";
      var floatPattern = new RegExp("^\\d+(\\.\\d+)?([E|e][+|-]?\\d+)?$","g");
      return tem.match(floatPattern) == tem;
   }

   /**
    * 判断字符串str是否为有符号整数,并在不是有符号整数时返回提示信息
    */
   function isNotSignedIntByHint( str , hint ){
       if( isSignedInt( str ) ){
           return false;
       }
       alert( hint );
       return true;
   }

   /**
    * 判断字符串str是否为有符号整数
    */
   function isSignedInt(str){
      var tem = str + "";
      var signedIntPattern = new RegExp("^[+|-]?\\d+$","g");
      return tem.match(signedIntPattern) == tem;
   }

   /**
    * 判断字符串str是否为有符号浮点数,并在不是有符号浮点数时返回提示信息
    */
   function isNotSignedFloatByHint( str , hint ){
       if( isSignedFloat( str ) ){
           return false;
       }
       alert( hint );
       return true;
   }

   /**
    * 判断字符串str是否为有符号浮点数,可以包含E指数
    */
   function isSignedFloat(str){
      var tem = str + "";
      var floatPattern = new RegExp("^[+|-]?\\d+(\\.\\d+)?([E|e][+|-]?\\d+)?$","g");
      return tem.match(floatPattern) == tem;
   }

   /**
    * 判断字符串str是否为数值,并在不是数值时返回提示信息
    */
   function isNotNumberByHint( str , hint ){
       if( isNumber( str ) ){
           return false;
       }
       alert( hint );
       return true;
   }

   /**
    * 判断字符串str是否为数值
    */
   function isNumber( str ){
      return isSignedFloat( str );
   }

   /**
    * 判断字符串type是否为系统支持的数值类型
    */
   function isNumberType( type ){
       if ( type == "INT" ) return true;
       if ( type == "FLOAT" ) return true;
       if ( type == "SIGNED_INT" ) return true;
       if ( type == "SIGNED_FLOAT" ) return true;
       return false;
   }

   /**
    * 判断value是否在[ min( bound1 , bound2 )  , max( bound1 , bound2 ) ]中,并在不是时返回提示信息
    * 注意:如果 bound1,bound2,value 如果有一个不是 number,或者type不是系统支持的数值类型,将返回提示信息
    */
   function isNotBetween1ByHint( bound1 , bound2 , value , type , hint ){
       if( isBetween1( bound1 , bound2 , value , type ) ){
           return false;
       }
       alert( hint );
       return true;
   }

   /**
    * 判断value是否在[ min( bound1 , bound2 )  , max( bound1 , bound2 ) ]中
    * 注意:如果 bound1,bound2,value 如果有一个不是 number,或者type不是系统支持的数值类型,将返回 false
    */
   function isBetween1( bound1 , bound2 , value , type ){
       if ( !isNumber( bound1 ) || !isNumber( bound2 ) || !isNumber( value ) || !isNumberType( type ) ){
          return false;
       }
       return isGreaterEqual( value , Math.min( bound1 , bound2 ) , type ) &&
              isLessEqual( value , Math.max( bound1 , bound2 ) , type );
   }

   /**
    * 判断value是否在( min( bound1 , bound2 )  , max( bound1 , bound2 ) ]中,并在不是时返回提示信息
    * 注意:如果 bound1,bound2,value 如果有一个不是 number ,或者type不是系统支持的数值类型,将返回提示信息
    */
   function isNotBetween2ByHint( bound1 , bound2 , value , type , hint ){
       if( isBetween2( bound1 , bound2 , value , type ) ){
           return false;
       }
       alert( hint );
       return true;
   }

   /**
    * 判断value是否在( min( bound1 , bound2 )  , max( bound1 , bound2 ) ]中
    * 注意:如果 bound1,bound2,value 如果有一个不是 number,或者type不是系统支持的数值类型,将返回 false
    */
   function isBetween2( bound1 , bound2 , value , type ){
       if ( !isNumber( bound1 ) || !isNumber( bound2 ) || !isNumber( value ) || !isNumberType( type ) ){
          return false;
       }
       return isGreaterThan( value , Math.min( bound1 , bound2 ) , type ) &&
              isLessEqual( value , Math.max( bound1 , bound2 ) , type );
   }

   /**
    * 判断value是否在( min( bound1 , bound2 )  , max( bound1 , bound2 ) )中,并在不是时返回提示信息
    * 注意:如果 bound1,bound2,value 如果有一个不是 number,或者type不是系统支持的数值类型, 将返回提示信息
    */
   function isNotBetween3ByHint( bound1 , bound2 , value , type , hint ){
       if( isBetween3( bound1 , bound2 , value , type ) ){
           return false;
       }
       alert( hint );
       return true;
   }

   /**
    * 判断value是否在( min( bound1 , bound2 )  , max( bound1 , bound2 ) )中
    * 注意:如果 bound1,bound2,value 如果有一个不是 number ,或者type不是系统支持的数值类型,将返回 false
    */
   function isBetween3( bound1 , bound2 , value , type ){
       if ( !isNumber( bound1 ) || !isNumber( bound2 ) || !isNumber( value ) || !isNumberType( type ) ){
          return false;
       }
       return isGreaterThan( value , Math.min( bound1 , bound2 ) , type ) &&
              isLessThan( value , Math.max( bound1 , bound2 ) , type );
   }

   /**
    * 判断value是否在[ min( bound1 , bound2 )  , max( bound1 , bound2 ) )中,并在不是时返回提示信息
    * 注意:如果 bound1,bound2,value 如果有一个不是 number ,或者type不是系统支持的数值类型,将返回提示信息
    */
   function isNotBetween4ByHint( bound1 , bound2 , value , type , hint ){
       if( isBetween4( bound1 , bound2 , value , type ) ){
           return false;
       }
       alert( hint );
       return true;
   }

   /**
    * 判断value是否在[ min( bound1 , bound2 )  , max( bound1 , bound2 ) )中
    * 注意:如果 bound1,bound2,value 如果有一个不是 number ,或者type不是系统支持的数值类型,将返回 false
    */
   function isBetween4( bound1 , bound2 , value , type ){
       if ( !isNumber( bound1 ) || !isNumber( bound2 ) || !isNumber( value ) || !isNumberType( type ) ){
          return false;
       }
       return isGreaterEqual( value , Math.min( bound1 , bound2 ) , type ) &&
              isLessThan( value , Math.max( bound1 , bound2 ) , type );
   }

   /**
    * 判断 str1,str2 在类型type下是否等于关系,并在存在时返回提示信息
    * 注意:如果 str1 , str2 不能转化为type类型 ,或type为此函数不支持的值则返回false
    */
   function isEqualByHint( str1 , str2 , type , hint ){
       if( isEqual( str1 , str2 , type ) ){
           alert( hint );
           return true;
       }
       return false;
   }

   /**
    * 判断 str1,str2 在类型type下是否等于关系
    * 注意:如果 str1 , str2 不能转化为type类型 ,或type为此函数不支持的值则返回false
    */
   function isEqual( str1 , str2 , type ){
       if ( type == "STRING" ){
          return str1 == str2;
       }
       if ( type == "INT" ){
          if ( !isInt( str1 ) ){
             return false;
          }
          if ( !isInt( str2 ) ){
             return false;
          }
          return parseInt( str1 ) == parseInt( str2 );
       }
       if ( type == "FLOAT" ){
          if ( !isFloat( str1 ) ){
             return false;
          }
          if ( !isFloat( str2 ) ){
             return false;
          }
          return parseFloat( str1 ) == parseFloat( str2 );
       }
       if ( type == "SIGNED_INT" ){
          if ( !isSignedInt( str1 ) ){
             return false;
          }
          if ( !isSignedInt( str2 ) ){
             return false;
          }
          return parseInt( str1 ) == parseInt( str2 );
       }
       if ( type == "SIGNED_FLOAT" ){
          if ( !isSignedFloat( str1 ) ){
             return false;
          }
          if ( !isSignedFloat( str2 ) ){
             return false;
          }
          return parseFloat( str1 ) == parseFloat( str2 );
       }
       return false;
   }

   /**
    * 判断 str1,str2 在类型type下是否存在大于等于关系,并在存在时返回提示信息
    * 注意:如果 str1 , str2 不能转化为type类型 ,或type为此函数不支持的值则返回false
    */
   function isGreaterEqualByHint( str1 , str2 , type , hint ){
       if( isGreaterEqual( str1 , str2 , type ) ){
           alert( hint );
           return true;
       }
       return false;
   }

   /**
    * 判断 str1,str2 在类型type下是否存在大于等于关系
    * 注意:如果 str1 , str2 不能转化为type类型 ,或type为此函数不支持的值则返回false
    */
   function isGreaterEqual( str1 , str2 , type ){
       if ( type == "STRING" ){
          return str1 >= str2;
       }
       if ( type == "INT" ){
          if ( !isInt( str1 ) ){
             return false;
          }
          if ( !isInt( str2 ) ){
             return false;
          }
          return parseInt( str1 ) >= parseInt( str2 );
       }
       if ( type == "FLOAT" ){
          if ( !isFloat( str1 ) ){
             return false;
          }
          if ( !isFloat( str2 ) ){
             return false;
          }
          return parseFloat( str1 ) >= parseFloat( str2 );
       }
       if ( type == "SIGNED_INT" ){
          if ( !isSignedInt( str1 ) ){
             return false;
          }
          if ( !isSignedInt( str2 ) ){
             return false;
          }
          return parseInt( str1 ) >= parseInt( str2 );
       }
       if ( type == "SIGNED_FLOAT" ){
          if ( !isSignedFloat( str1 ) ){
             return false;
          }
          if ( !isSignedFloat( str2 ) ){
             return false;
          }
          return parseFloat( str1 ) >= parseFloat( str2 );
       }
       return false;
   }

   /**
    * 判断 str1,str2 在类型type下是否存在大于关系,并在存在时返回提示信息
    * 注意:如果 str1 , str2 不能转化为type类型 ,或type为此函数不支持的值则返回false
    */
   function isGreaterThanByHint( str1 , str2 , type , hint ){
       if( isGreaterThan( str1 , str2 , type ) ){
           alert( hint );
           return true;
       }
       return false;
   }

   /**
    * 判断 str1,str2 在类型type下是否存在大于关系
    * 注意:如果 str1 , str2 不能转化为type类型 ,或type为此函数不支持的值则返回false
    */
   function isGreaterThan( str1 , str2 , type ){
       if ( type == "STRING" ){
          return str1 > str2;
       }
       if ( type == "INT" ){
          if ( !isInt( str1 ) ){
             return false;
          }
          if ( !isInt( str2 ) ){
             return false;
          }
          return parseInt( str1 ) > parseInt( str2 );
       }
       if ( type == "FLOAT" ){
          if ( !isFloat( str1 ) ){
             return false;
          }
          if ( !isFloat( str2 ) ){
             return false;
          }
          return parseFloat( str1 ) > parseFloat( str2 );
       }
       if ( type == "SIGNED_INT" ){

⌨️ 快捷键说明

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