2008/08/27 16:26

유용한 java script

  // 문자열에서 한글 제거
  function delKor(strValue){
    var tmp = "";

    for(var i=0;i<strValue.length;i++) {
      var code=strValue.charCodeAt(i);

      if (code > 128) {
        if(!tmp){
          tmp = strValue;
        }
        
        tmp = tmp.replace(strValue.substring(i, i + 1), "");
      }
    }

    return trim(tmp);
  }

  // 숫자 체크
  function isNumber(value)
  {
    if (value.match(/^[0-9]*$/g))
      return true;
    else
      return false;
  }

  // 문자열 trim
  String.prototype.trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
  }

  // checkbox 전체 선택
  function checkAll( checkObject )
  {
    if(!checkObject) return;

    if(checkObject.length)
    {
      for( var i=0; i<checkObject.length ; i++)
      {
        if(!checkObject[i].disabled)
        {
          checkObject[i].checked = true;
        }
      }
    }
    else
    {
      if(!checkObject.disabled)
      {
        checkObject.checked = true;
      }
    }
  }

  // checkbox 전체 선택 해제
  function uncheckAll( checkObject )
  {
    if(!checkObject) return;

    if(checkObject.length)
    {
      for( var i=0; i<checkObject.length ; i++)
      {         
        if(!checkObject[i].disabled)
        {
          checkObject[i].checked = false;
        }
      }
    }
    else
    {
      if(!checkObject.disabled)
      {
        checkObject.checked = false;
      }
    }
  }

  // checkbox 체크된 개수 반환
  function getCheckCount( checkObject )
  {
    var cnt = 0;
    if(checkObject.length)
    {
      for( var i=0; i<checkObject.length ; i++)
      {
        if(checkObject[i].checked)
        {
          cnt++;
        }
      }
    }
    else
    {
      if(checkObject.checked)
      {
        cnt++
      }
    }
    return cnt;
  }
 
  // selectbox 전체 선택
  function selectAll( checkObject )
  {
    var items = checkObject.options;
    for( var i=0; i<items.length ; i++)
    {
      items[i].selected = true;
    }
  }

  // selectbox 전체 선택 해제
  function unselectAll( checkObject )
  {
    var items = checkObject.options;
    for( var i=0; i<items.length ; i++)
    {
      items[i].selected = false;
    }   
  }
 
  // select1 에서 선택된 option들을 select2로 옮김
  function moveSelect( select1, select2 )
  {
      var items = select1.options;
      for( var i=0; i<items.length; i++)
      {
          if( items[i].selected )
          {
              var opt = document.createElement("OPTION");
              if(IE)
              {
                select2.insertBefore(opt);
              }
              else
              {
                select2.appendChild(opt,null);
              }
              opt.value = items[i].value;             
              opt.innerHTML = items[i].innerHTML;
              select1.removeChild(items[i]);
              i--;
          }
      }
  }
 
  // 팝업창 띄우기
  function open_window(url, name, width, height, feature)
  {
    var oWnd;

    if (IE && width < window.screen.width && height < window.screen.height)
    {
        var windowX = Math.ceil( (window.screen.width  - width) / 2 );
        var windowY = Math.ceil( (window.screen.height - height) / 2 );

        oWnd = window.open(url, name, feature+",width=" + width +",height=" + height+",left="+windowX+",top="+windowY + ",resizable=yes");
    }
    else
    {
        oWnd = window.open(url, name, feature+",width=" + width +",height=" + height + ",resizable=yes");
    }

    return oWnd;
  }

  // 팝업창 리사이즈
  function resizepopup(wid,minH)    
  {
    if (IE) {
      var winW = wid, winH = 200;
      winW = wid;
      winH = document.body.scrollHeight;
     
      if(winH > 750)
      {
        winH = 750;
      }
      if(winH < minH)
      {
        winH = minH
      }

      var deltaW = 0;
      var deltaH = 0;
      if(document.body.clientHeight)
      {
        deltaW = winW - document.body.clientWidth;
        deltaH = winH - document.body.clientHeight;
      }else
      {
        deltaW = winW - window.innerWidth;
        deltaH = winH - window.innerHeight;
      }
      if(deltaH>=4) deltaH = deltaH-4;

      var windowX = Math.ceil( (window.screen.width  - winW) / 2 );
      var windowY = Math.ceil( (window.screen.height - winH) / 2 );

      window.moveTo(windowX, windowY);
     
      window.resizeBy(deltaW, deltaH);

    } else {
      var width_adjustment = 6;
      var height_adjustment = 32;
     
      var oW = window.document.body;
      var oW = oW.clip ? oW.clip.width : oW.offsetWidth;

      var oH = window.document.body;
      var oH = oH.clip ? oH.clip.height : oH.offsetHeight;
     
      var myW = 0, myH = 0, d = window.document.documentElement, b = window.document.body;

      if( window.innerWidth ) {
        myW = window.innerWidth; myH = window.innerHeight;
      }
      else if( b && b.clientWidth ) {
        myW = b.clientWidth; myH = b.clientHeight;
      }
      else if( d && d.clientWidth ) {
        myW = d.clientWidth; myH = d.clientHeight;
      }

      //alert(oH+","+myH);

      if( window.opera && !document.childNodes ) { myW += 16; }
      var winW = parseInt(wid) + width_adjustment;
      var winH = oH+50 ;//+ ( (oH + 200 ) - myH ) + height_adjustment;
     
      if(winH > 750)
      {
        winH = 750;
      }
      if(winH<minH) winH = minH

      var windowX = Math.ceil( (window.screen.width  - wid) / 2 );
      var windowY = Math.ceil( (window.screen.height - winH) / 2 );

      window.moveTo(windowX, windowY);
     
      window.resizeTo( winW, winH );     
    }
  }
이올린에 북마크하기(0) 이올린에 추천하기(0)

Trackback 0 Comment 0
2008/08/22 10:59

언제쯤... - 김건모


언제쯤... - 김건모 

눈물이 나 이렇게 널 미워해도
나의 가슴이 자꾸만 널 느껴
아무리 웃으려해도 그냥 표정만 웃고있어
내 안에 슬픔은 너의 이별과 다투며

언제쯤 넌 날 떠나는거니
언제쯤 난 널 모두 잊고 웃을수있니
언제쯤 넌 내 눈물속에서 말라
지나간 추억이 되어
내 안에서 넌 떠나는거니

웃음이 나 거울앞에 선 내 모습
너무 초라해 나도 내가 낯설어
겉으론 웃고있지만 나의 가슴이 자꾸 울어
내 안에 이별과 아직도 싸우며

언제쯤 넌 날 떠나는거니
언제쯤 난 널 모두 잊고 웃을수있니
언제쯤 넌 내 눈물속에서 말라
지나간 추억이 되어
내 안에서 넌 떠나는거니

나의 두 손이 아직도 널 만져
눈물에 가득 젖어서
나의 가슴속에 머물고있는
너의 이별이 아직도 낯설어

언제쯤 넌 날 떠나는거니
언제쯤 난 널 모두 잊고 웃을수있니
언제쯤 넌 내 눈물속에서 말라
지나간 추억이 되어
내 안에서 넌 떠나는거니


난 아직도 니가 보고싶다




------------------------------------------------------------------------


사실 김건모를 가수로서 좋아하진 않는데
이번 앨범 첫 번째 노래 언제쯤...

와 닿는다....
꼭 경험을 해야 와닿는건 아니다.
와 닿는다....

감성적으로 안 살려고 하는데 왜 노래만 들으면 이러니!!!!!!!! 대체!!!!!!

이올린에 북마크하기(0) 이올린에 추천하기(0)

Trackback 0 Comment 0
2008/07/10 12:58

NOT EMPTY, like NOT NULL

이 참 간단한 문제를 이렇게 고민고민 하다가 이제서야 찾아서 포스팅^^

empty => 비어있다!!!!
EL에서는 어떻게 쓰일까????? NULL 이다!!!
반대로 NOT NULL 로 쓸떄는 어떻게 표현해야 할까???

not empty 이다. ${ example.box != null } 이렇게 백날 써봤자 소용없다는 얘기!!

${ not empty example.box } 이렇게 써야 한다.


EL is more forgiving than is the Java programming language regarding null values in expressions. In the Java programming language, the expression a.getB().getC() throws a NullPointerException if a.getB() returns null. Not so in EL. The EL expression ${a.b.c} returns null if ${a.b} is null -- it does not throw an exception. This makes writing expressions easier. To check for null explicitly, use either the empty operator, or compare the expression to null using == or the is keyword, like this:

   <c:if test="${a.b is null}">
   <c:if test="${empty a.b}">
   <c:if test="${a.b == null}">

JSP 2.0 Expression Language Tech Tip

EL은 expression의 null 값에 관해서는 자바 프로그래밍 언어보다 더 관대하다. 자바 프로그래밍 언어에서는 a.getB()가 null을 리턴하면, a.getB().getC()NullPointerException를 발생시킨다. 하지만 EL에서는 만약 ${a.b}가 null이면 EL expression ${a.b.c}는 null을 리턴하고 예외를 발생시키지 않는다. 이는 식을 쉽게 작성할 수 있도록 도와준다. Null에 대해 좀 더 명쾌하게 이해하고자 한다면, empty연산자를 사용하거나 ==를 이용해서 식과 null을 비교해보거나, is 키워드를 사용해볼 수 있다.

   <c:if test="${a.b is null}">
   <c:if test="${empty a.b}">

<c:if test="${a.b == null}">

이올린에 북마크하기(0) 이올린에 추천하기(0)

Trackback 0 Comment 0