* admin.js ver 1.1 *

// 서버로 부터 결과값을 받아서 화면 값에 바로 수정한다.
function updateSisulIDCheck(divID, id, url, keyword) {
 
 if($(id).value.replace(/\s/gi, '') !='' ) {
     var myRand = parseInt(Math.random()*9999999999);
     var params = 'siid=' + $(id).value + keyword + 'myRand=' + myRand;
        var ajaxObj = new Ajax.Updater(divID, url, {method: 'post', parameters: params});
 } else {
  alert(msg3);
  clearText($(divID));
  $(id).focus();
 }
}



* ajax.js ver 1.1 *

// 브라우저 분기문
var request = null;

try {
  request = new XMLHttpRequest();
} catch (trymicrosoft) {
  try {
    request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (othermicrosoft) {
    try {
      request = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (failed) {
      request = null;
    }
  }
}

if (request == null)
   alert("Error creating request object!");

  
function ajaxsubmit(url, method, param) {
 
  request.open(method, url, true);
  request.onreadystatechange = showConfirmation;
  request.setRequestHeader("Content-Type",
                           "application/x-www-form-urlencoded");
  request.send(param);
 
}  



* com.js ver 1.2 *

// enter key
function handleEnter(hkey) {
   
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
   
    if (keyCode == 13) {

        switch(hkey) {
      case '1' : formSend(); break;
      case '2' : updateSisulIDCheck('siidChk', 'siid', '/acheck.do', '&keyword=siid&'); break;
      case '3' : break;
      case '4' : break;
      default:
       }
 
    } else {
     
        return true;
        
    }    
   
}



* RegExp.js ver 1.1 *

// 표준정규식
   var Pattern = {
         PARTICULAR : /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\'\"\|]/
   , KorEng  :  /^[가-힣a-zA-Z]*$/  
         , ENGLISH :  /^([a-zA-Z]+)$/ /* /^(\w[^0-9_]+)$/ */
         , NUMBER :   /^(\d+)$/
         , ENGNUM :   /^(\w+)$/
         , SPACE :    /\s/gi
         , EMAIL :    /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/
         , PHONE :    /^(0(\d{0,1}))-(\d{2,3})-(\d{3})$/
         , IDPWD :    /^(\w{4,12})$/
         , SSN :      /^(\d{13})$/
         , POST :     /^((\d{3}))-(\d{3})$/
     }

    //* 패턴에 따른 값 유무 체크
 //  문자가 하나로 있을시 true 를 반환한다.
    String.prototype.isValues = function() {
       return this.length > 0 && this != null;
    }

    //* 정규표현식 검사
    String.prototype.isValidFormat = function(format) {
  return this.search(format) != -1
    }

    //* 영문자 + 숫자
    String.prototype.isWord = function() {
  return this.isValidFormat(Pattern.ENGNUM);
    }

 //* 숫자
 String.prototype.isNum = function() {
  return this.isValidFormat(Pattern.NUMBER);
 }

 //* 영문자
 String.prototype.isEng = function() {
  return this.isValidFormat(Pattern.ENGLISH);
 }

 //* 특수문자 여부
 String.prototype.isParticular = function() {
  return this.isValidFormat(Pattern.PARTICULAR);
 }

 //* 한글
 String.prototype.isKor = function() {
  for (var i=0; i<this.length; i++) {
   chrCode = this.charCodeAt(i);
            if (chrCode > 128) { return true; break; }
  }
  return false;
 }

    //* 전화번호
 String.prototype.isPhone = function() {
  return this.isValidFormat(Pattern.PHONE);
 }

 //* 이메일
 String.prototype.isEmail = function() {
  return this.isValidFormat(Pattern.EMAIL);
 }

 //* 공백
 String.prototype.isSpace = function() {
  return this.isValidFormat(Pattern.SPACE);
 }

 //* 공백제거
 String.prototype.trim = function() {
  return this.replace(Pattern.SPACE, "");
 }

 //* 문자 전체 치환
 String.prototype.replaceAll = function(replace, string) {
  var tmpStr = this.trim();
  if (tmpStr != "" && replace != string)
        while ( tmpStr.indexOf(replace) > -1 ) { tmpStr = tmpStr.replace(replace, string); }
  return tmpStr;
 }

 //* 아이디/비밀번호
 String.prototype.isIDPWD = function() {
  return this.isValidFormat(Pattern.IDPWD);
 }

 //* 주민등록번호
 String.prototype.isSSN = function() {
  if (this.isValidFormat(Pattern.SSN)) {
   var chk = 0;
   for (var i=0; i<6; i++)  { chk += ( (i+2) * parseInt( this.charAt(i) )); }
   for (var i=6; i<12; i++) { chk += ( (i%8+2) * parseInt( this.charAt(i) )); }
   chk = (11 - (chk % 11)) % 10;
   if ( chk = parseInt(this.charAt(12)) ) return true;
   return false;
  }
  return false;
 }

   //* 우편번호
   String.prototype.isPost = function() {
     return this.isValidFormat(Pattern.POST);
   }

  
   //* 한글과 영문자만 입력
   String.prototype.isKorEng = function() {
   return this.isValidFormat(Pattern.KorEng);
   }



* text-util.js ver 1.1 *

function replaceText(el, text) {
  if (el != null) {
    clearText(el);
    var newNode = document.createTextNode(text);
    el.appendChild(newNode);
  }
}

function clearText(el) {
  if (el != null) {
    if (el.childNodes) {
      for (var i = 0; i < el.childNodes.length; i++) {
        var childNode = el.childNodes[i];
        el.removeChild(childNode);
      }
    }
  }
}

function getText(el) {
  var text = "";
  if (el != null) {
    if (el.childNodes) {
      for (var i = 0; i < el.childNodes.length; i++) {
        var childNode = el.childNodes[i];
        if (childNode.nodeValue != null) {
          text = text + childNode.nodeValue;
        }
      }
    }
  }
  return text;
}

'開發日誌' 카테고리의 다른 글

flex..  (0) 2011.03.03
쩝.. 시설관리, 직원관리 DB  (0) 2011.02.28
간략한 브리핑..  (0) 2011.02.23