google_screenshot.zip

index.html

출처 : https://play.google.com/

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Insert title here</title>

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<style>
.screenshot-carousel {position:relative; height:400px; width:650px;}
.screenshot-carousel .screenshot-carousel-outer-container {height:400px; overflow:hidden; position:absolute; width:650px;}
.screenshot-carousel .screenshot-carousel-outer-container .screenshot-carousel-content-container {height:400px; width:10000px; white-space:nowrap;}
.screenshot-carousel .screenshot-carousel-outer-container .screenshot-carousel-content-container .screenshot-image-wrapper {
 display:inline-block; float:left;
}
.screenshot-carousel .screenshot-carousel-outer-container .screenshot-carousel-content-container .screenshot-image-wrapper .screenshot-image {
 display:inline-block; max-height:400px; max-width:250px; vertical-align:bottom; padding-right:10px; border:0; margin:0;
}
.screenshot-carousel .screenshot-carousel-button-previous,
.screenshot-carousel .screenshot-carousel-button-next,
.screenshot-carousel .screenshot-carousel-left-fade,
.screenshot-carousel .screenshot-carousel-right-fade {position:absolute;}
.screenshot-carousel .screenshot-carousel-button-previous,
.screenshot-carousel .screenshot-carousel-button-next {margin-top:184px; z-index:20; cursor:pointer;}
.screenshot-carousel .screenshot-carousel-button-previous {background:no-repeat url('images/sprites.png') -248px 0; height:32px; width:32px; display:none;}
.screenshot-carousel .screenshot-carousel-button-next {background:no-repeat url('images/sprites.png') -91px -266px; height:32px; width:32px; right:0; display:none;}
.screenshot-carousel .screenshot-carousel-left-fade,
.screenshot-carousel .screenshot-carousel-right-fade {width:50px; height:400px; z-index:10; cursor:pointer;}
.screenshot-carousel .screenshot-carousel-left-fade {display:none;}
.screenshot-carousel .screenshot-carousel-right-fade {right:0; display:none;}
/* -moz-opacity:0.4;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";filter:alpha(opacity=40);margin-top:70px;opacity:0.4 */
</style>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script>
(function($) {
 $.fn.extend({
  screenshot : function(opt) {
   var settings = {
    speed : 400
   }
   $.extend(true, settings, opt);
   
   var _this = $(this);
   var _outer = _this.find('.screenshot-carousel-outer-container');
   var _content = _outer.find('.screenshot-carousel-content-container');
   var _wrapper = _content.find('.screenshot-image-wrapper');
   var _leftFade = _this.find('.screenshot-carousel-left-fade');
   var _rightFade = _this.find('.screenshot-carousel-right-fade');
   var _btnPrev = _this.find('.screenshot-carousel-button-previous').add(_leftFade);
   var _btnNext = _this.find('.screenshot-carousel-button-next').add(_rightFade);
   var pos = 0;
   var outerWidth = _outer.width();
   //var wrapperWidth = _wrapper.eq(0).outerWidth(true);
   var wrapperWidth = _wrapper.eq(0).width();
   var contentWidth = wrapperWidth * _wrapper.length;
   _content.width(contentWidth);
   
   if(contentWidth > outerWidth) {
       _btnNext.show();
   } else {
       return false;
   }
   
   _btnPrev.on({
    'mouseenter' : function() {
     _leftFade.stop().animate({width:75}, {duration:100});
    },
    'mouseleave' : function() {
     _leftFade.stop().animate({width:50}, {duration:100});
    },
    'click' : function() {
     if(pos == contentWidth - outerWidth) {
      pos -= 450;
     } else {
      pos -= wrapperWidth * 2;
     }
     
     if(pos < 0) {
      pos = 0;
      _btnPrev.hide();
     }
     
     _outer.stop().animate({
      scrollLeft : pos
     }, {
      duration:settings.speed,
      easing : 'easeOutExpo'
     });
     _btnNext.show();
    }
   });
   
   _btnNext.on({
    'mouseenter' : function() {
     _rightFade.stop().animate({width:75}, {duration:100});
    },
    'mouseleave' : function() {
     _rightFade.stop().animate({width:50}, {duration:100});
    },
    'click' : function() {
     if(pos == 0) {
      pos += 450;
     } else {
      pos += wrapperWidth * 2;
     }
     
     if(pos + outerWidth > contentWidth) {
      pos = contentWidth - outerWidth;
      _btnNext.hide();
     }
     
     _outer.stop().animate({
      scrollLeft : pos
     }, {
      duration:settings.speed,
      easing : 'easeOutExpo'
     });
     _btnPrev.show();
    }
   });
   
  }
 });
})(jQuery);

jQuery(function($) {
 $('.screenshot-carousel').screenshot();
});
</script>

</head>
<body>

<div class="screenshot-carousel">
 <div class="screenshot-carousel-button-previous"></div>
 <img src="images/left_fade.png" class="screenshot-carousel-left-fade" />
 <div class="screenshot-carousel-outer-container">
  <div class="screenshot-carousel-content-container">
   <div class="screenshot-image-wrapper"><img src="images/screenshot5.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot1.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot2.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot3.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot4.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot1.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot2.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot3.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot4.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot1.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot2.png" class="screenshot-image" /></div>
   <div class="screenshot-image-wrapper"><img src="images/screenshot3.png" class="screenshot-image" /></div>
  </div>
 </div>
 <img src="images/right_fade.png" class="screenshot-carousel-right-fade" />
 <div class="screenshot-carousel-button-next"></div>
</div>

</body>
</html>

 

 

tstore_screenshot1.zip  

 tstore_screenshot2.zip


tstore_screenshot1 : tstore에 있는 방식대로 처리, 속도가 느리고 이미지 하나씩 슬라이딩 됨
tstore_screenshot2 : tstore에 있는 방식을 개선하여 처리, 속도 및 이미지 맞춤 개선

출처 : http://www.tstore.co.kr 

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Insert title here</title>

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<style>
.scnshot_wrap {
 width:532px;
 height:350px;
 position:relative;
}
.scnshot_wrap .scnshot_outer {
 width:530px;
 border-left:1px solid #3a3a3a;
 overflow:hidden;
}
.scnshot_wrap .scnshot_outer ul {
 width:10000px;
 margin:0;
 padding:0;
}
.scnshot_wrap .scnshot_outer ul li {
 float:left;
 display:inline-block;
 overflow:hidden;
}
.scnshot_wrap .scnshot_outer img {
 width:220px;
 height:350px;
 border:0;
 margin-right:5px;
}
.scnshot_wrap .scnshot_prev {
 position:absolute;
 top:145px;
 left:0;
 z-index:10;
 display:none;
}
.scnshot_wrap .scnshot_next {
 position:absolute;
 top:145px;
 right:0;
 z-index:10;
 display:none;
}
</style>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script>
(function ($) {
 $.fn.extend({
  thumbnailSlide : function(opt) {
   var settings = {
    speed : 400
   }
   $.extend(true, settings, opt);
   
   var _this = $(this);
   var _outer = _this.find('.scnshot_outer');
   var _content = _outer.find('ul');
   var _item = _content.find('li');
   if(_item.length < 1) {
    return false;
   }
   var _btnPrev = _this.find('.scnshot_prev');
   var _btnNext = _this.find('.scnshot_next');
   var pos = 0;
   var outerWidth = _outer.width();
   var itemWidth = _item.eq(0).width();
   var contentWidth = itemWidth * _item.length;
   _content.width(contentWidth);
   
   if(contentWidth - 5 > outerWidth) {
    _btnNext.show();
   } else {
    return false;
   }
   _outer.css({borderRight:'1px solid #3a3a3a'});
   
   _btnPrev.on('click', function() {
    if(pos == contentWidth - outerWidth - 5) {
     pos -= 420;
    } else {
     pos -= itemWidth * 2;
    }
    
    if(pos < 0) {
     pos = 0;
     _btnPrev.hide();
    }
    
    _outer.stop().animate({
     scrollLeft : pos
    }, {
     duration:settings.speed,
     easing : 'easeOutExpo'
    });
    _btnNext.show();
   });
   
   _btnNext.on('click', function() {
    if(pos == 0) {
     pos += 420;
    } else {
     pos += itemWidth * 2;
    }
    
    if(pos + outerWidth > contentWidth) {
     pos = contentWidth - outerWidth - 5;
     _btnNext.hide();
    }
    
    _outer.stop().animate({
     scrollLeft : pos
    }, {
     duration:settings.speed,
     easing : 'easeOutExpo'
    });
    _btnPrev.show();
   });
  }
 });
})(jQuery);

jQuery(function($) {
 $('.scnshot_wrap').thumbnailSlide();
});
</script>

</head>
<body>

<div class="scnshot_wrap">
 <a href="#" class="scnshot_prev">
  <img src="images/btn_prev05.png" alt="이전" />
 </a>
 <div class="scnshot_outer">
  <ul>
   <li><img src="images/screenshot1.png" /></li>
   <li><img src="images/screenshot2.png" /></li>
   <li><img src="images/screenshot3.png" /></li>
   <li><img src="images/screenshot4.png" /></li>
   <li><img src="images/screenshot5.png" /></li>
   <li><img src="images/screenshot1.png" /></li>
   <li><img src="images/screenshot2.png" /></li>
   <li><img src="images/screenshot3.png" /></li>
   <li><img src="images/screenshot4.png" /></li>
   <li><img src="images/screenshot5.png" /></li>
  </ul>
 </div>
 <a href="#" class="scnshot_next">
  <img src="images/btn_next05.png" alt="다음" />
 </a>
</div>


</body>
</html>

 

 

참고 : http://buildinternet.com/2009/03/sliding-boxes-and-captions-with-jquery/
데모 : http://s3.amazonaws.com/buildinternet/live-tutorials/sliding-boxes/index.htm

Source : slidingBoxes.zip

 

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Insert title here</title>

<style>
.img_box{}
.img_box article {width:300px; height:250px; position:relative; float:left; margin:10px; overflow:hidden; border:solid 2px #8399af; background:#161613;}
.img_box article img {width:300px; height:250px; position:absolute; top:0; left:0; border:0;}
.img_box article .boxcaption {width: 100%; height:100px; position:absolute; top:250px; left:0; background: #000; opacity:.8; /* For IE 5-7 */ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80 ); /* For IE 8 */-MS-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";}
.img_box article.caption .boxcaption {top:208px;}
.img_box article.captionfull .boxcaption {top:250px;}
.img_box article .boxcaption h3,
.img_box article.slideright h3,
.img_box article.thecombo h3,
.img_box article.slideup h3 {margin:10px 10px 4px 10px; color:#fff; font:22px Arial, sans-serif; letter-spacing:-1px; font-weight:bold;}
.img_box article .boxcaption p,
.img_box article.slideright p,
.img_box article.thecombo p,
.img_box article.slideup p {padding:0 10px; color:#afafaf; font-weight:bold; font:12px "Lucida Grande", Arial, sans-serif;}
.img_box article .boxcaption p a,
.img_box article.slideright p a,
.img_box article.thecombo p a,
.img_box article.slideup p a {color:#666;}
</style>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
jQuery(function($) {
 $('.img_box article.caption').hover(function() {
  $('.cover', this).stop().animate({
   top : 150
  }, {
   queue : false,
   duration : 160
  });
 }, function() {
  $('.cover', this).stop().animate({
   top : 208
  }, {
   queue : false,
   duration : 160
  });
 });
 
 $('.img_box article.captionfull').hover(function() {
  $('.cover', this).stop().animate({
   top : 150
  }, {
   queue : false,
   duration : 160
  });
 }, function() {
  $('.cover', this).stop().animate({
   top : 250
  }, {
   queue : false,
   duration : 160
  });
 });
 
 $('.img_box article.slideright').hover(function() {
  $('.cover', this).stop().animate({
   left : 300
  }, {
   queue : false,
   duration : 300
  });
 }, function() {
  $('.cover', this).stop().animate({
   left : 0
  }, {
   queue : false,
   duration : 300
  });
 });
 
 $('.img_box article.thecombo').hover(function() {
  $('.cover', this).stop().animate({
   left : 300,
   top : 250
  }, {
   queue : false,
   duration : 300
  });
 }, function() {
  $('.cover', this).stop().animate({
   left : 0,
   top : 0
  }, {
   queue : false,
   duration : 300
  });
 });
 
 $('.img_box article.slideup').hover(function() {
  $('.cover', this).stop().animate({
   top : -250
  }, {
   queue : false,
   duration : 300
  });
 }, function() {
  $('.cover', this).stop().animate({
   top : 0
  }, {
   queue : false,
   duration : 300
  });
 });
 
 $('.img_box article.peek').hover(function() {
  $('.cover', this).stop().animate({
   top : 90
  }, {
   queue : false,
   duration : 160
  });
 }, function() {
  $('.cover', this).stop().animate({
   top : 0
  }, {
   queue : false,
   duration : 160
  });
 });
 
});
</script>

</head>
<body>

<section class="img_box">
 <article class="captionfull">
  <img src="images/florian.jpg" />
  <div class="cover boxcaption">
   <h3>타이틀1</h3>
   <p>
    내용입니다.<br />
    <a href="">내용입니다.</a>
   </p>
  </div>
 </article>
 
 <article class="caption">
  <img src="images/jareck.jpg" />
  <div class="cover boxcaption">
   <h3>타이틀2</h3>
   <p>
    내용입니다.<br />
    <a href="">내용입니다.</a>
   </p>
  </div>
 </article>
 
 <article class="slideright">
  <img src="images/kamil.jpg" class="cover" />
  <div>
   <h3>타이틀3</h3>
   <p>
    내용입니다.<br />
    <a href="">내용입니다.</a>
   </p>
  </div>
 </article>
 
 <article class="thecombo">
  <img src="images/martin.jpg" class="cover" />
  <div>
   <h3>타이틀4</h3>
   <p>
    내용입니다.<br />
    <a href="">내용입니다.</a>
   </p>
  </div>
 </article>
 
 <article class="slideup">
  <img src="images/nonsense.jpg" class="cover" />
  <div>
   <h3>타이틀5</h3>
   <p>
    내용입니다.<br />
    <a href="">내용입니다.</a>
   </p>
  </div>
 </article>
 
 <article class="peek">
  <img src="images/birss.jpg" style="height:90px;" />
  <img src="images/buildinternet.jpg" class="cover" />
 </article>
 
</section>

</body>
</html> 





 

 참고 : http://stackoverflow.com/questions/1275383/jquery-remove-select-options-based-on-another-select-selected-need-support-for

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">

jQuery(function($) {
    $('#sel1').on('change', function() {
        var val = this.value;
       
        if(val) {
            $.ajax({
                url:val + '.xml',
                type:'POST',
                dataType:'xml',
                success:function(xml) {
                    var sel2 = $('#sel2');
                    $('option', sel2).each(function(i) {
                        if(i > 0) {
                            $(this).remove();
                        }
                    });
                    $(xml).find('list data').each(function() {
                        sel2.append(
                            $('<option>').text($(this).text()).val($(this).text())
                        );
                    });
                },
                error:function() {
                    alert('error');
                }
            });
        } else {
            // selectbox 모두 비우기 $(select).empty();
            var sel2 = $('#sel2');
            $('option', sel2).each(function(i) {
                if(i > 0) {
                    $(this).remove();
                }
            });
        }
    });
});

</script>
</head>
<body>

<select id="sel1" name="sel1">
    <option value="">전체</option>
    <option value="korea">대한민국</option>
    <option value="usa">미국</option>
</select>

<select id="sel2" name="sel2">
    <option value="">전체</option>
</select>

</body>
</html> 

 

<?xml version="1.0" encoding="UTF-8" ?>
<list>
    <data>korea1</data>
    <data>korea2</data>
</list> 

 

<?xml version="1.0" encoding="UTF-8" ?>
<list>
    <data>usa1</data>
    <data>usa2</data>
    <data>usa3</data>
</list> 

 

 


출처 : http://mytory.co.kr/archives/812
         http://mytory.co.kr/archives/783
         http://stackoverflow.com/questions/3220995/jquery-document-onclick-doesnt-work-when-clicking-an-embed-flash-on-ie-bu

var $layerPopupObj = $('.layerPopupBox');
var left = ( $(window).scrollLeft() + ($(window).width() - $layerPopupObj.width()) / 2 );
var top = ( $(window).scrollTop() + ($(window).height() - $layerPopupObj.height()) / 2 );
$layerPopupObj.css({'left':left,'top':top, 'position':'absolute'});
$('body').css('position','relative').append($layerPopupObj);

jQuery의 .scrollLeft() 함수는 좌우로 스크롤된 화면이 왼쪽부터 몇 px인지 구하는 함수다. 보통은 0일 거다.

jQuery의 .scrollTop() 함수는 스크롤된 화면이 맨 위에서부터 몇 px인지 구하는 함수다.

jQuery의 .width() 함수는 너비를 구하는 함수인데, $(window).width() 를 하면 현재 화면의 너비를 구한다. 윈도우를 전체화면으로 하지 말고 사이즈를 줄여 놓고 값을 구해 보면 전체 가로 사이즈보다 작게 나오는 것을 알 수 있다.

jQuery의 .height() 함수 역시 마찬가지인데, $(window).height() 라고 하면 윈도우에서 메뉴바 같은 것들을 빼고 실제 사용되는 부분의 높이만 구해 준다. 나는 높이 800px 화면의 노트북을 사용한데, 실제 사용되는 영역은 675px이었다.


레이어를 Modal 처럼 띄우기 위한 배경 검은 막 씌우기

jQuery modal window를 만드는 튜토리얼에서 그 방법을 발견했다. 우리가 해왔던 방식하고 크게 다르지 않았다. 이것만 가지고 플러그인을 만들어 볼까 하는 생각도 들었다.

자, 반투명 검은 막을 만드는 방법은 간단하다.(예제부터 보길 바라면 아래 파일을 사용하면 된다.)

cfile25.uf.13211E484D4BC96836139F.html

일단, HTML의 어딘가에 아래 코드를 끼워 넣는다. 어디든 별 상관 없지만 찾기 편한 곳에 둬야 할 거다.

<div id="mask"></div>
 

다음은 CSS인데 아래처럼 해 준다.

#mask {
position:absolute;
left:0;
top:0;
z-index:9000;
background-color:#000;
display:none;
}
 

마지막으로 jQuery 코드를 짜 보자.

function wrapWindowByMask(){
//화면의 높이와 너비를 구한다.
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//마스크의 높이와 너비를 화면 것으로 만들어 전체 화면을 채운다.
$('#mask').css({'width':maskWidth,'height':maskHeight});
//애니메이션 효과
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
}
 

자, 위 함수를 사용하면 반투명의 검은 마스크가 나타날 것이다. 그럼 어떻게 닫을까?

두 가지가 있을 것이다.

1.mordal window의 닫기 버튼을 눌렀을 때

2.반투명 검은 막을 눌렀을 때

두 경우 모두를 지원하기 위해서 click할 때 일어나는 이벤트를 두 군데 걸어야겠다.

이건 원본에서 그냥 긁어 온 코드다. .window는 검은 막 위에 뜬 mordal window다.

//닫기 버튼을 눌렀을 때
$('.window .close').click(function (e) {
//링크 기본동작은 작동하지 않도록 한다.
e.preventDefault();
$('#mask, .window').hide();
});
//검은 막을 눌렀을 때
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
 

위 코드들은 당연히 jQuery(document).ready(function(){ /*코드 넣는 부분*/ }) 으로 감싸 줘야 한다.

완성된 코드는 아래와 같다.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
#mask {
position:absolute;
z-index:9000;
background-color:#000;
display:none;
left:0;
top:0;
}
.window{
display: none;
position:absolute;
left:100px;
top:100px;
z-index:10000;
}
</style>
<script>
function wrapWindowByMask(){
//화면의 높이와 너비를 구한다.
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//마스크의 높이와 너비를 화면 것으로 만들어 전체 화면을 채운다.
$('#mask').css({'width':maskWidth,'height':maskHeight});
//애니메이션 효과 - 일단 1초동안 까맣게 됐다가 80% 불투명도로 간다.
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//윈도우 같은 거 띄운다.
$('.window').show();
}
$(document).ready(function(){
//검은 막 띄우기
$('.openMask').click(function(e){
e.preventDefault();
wrapWindowByMask();
});
//닫기 버튼을 눌렀을 때
$('.window .close').click(function (e) {
//링크 기본동작은 작동하지 않도록 한다.
e.preventDefault();
$('#mask, .window').hide();
});
//검은 막을 눌렀을 때
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
});
</script>
</head>
<body>
<div id="mask"></div>
<div class="window">
<input type="button" href="#" class="close" value="나는야 닫기 버튼(.window .close)"/>
</div>
<a href="#" class="openMask">검은 막 띄우기</a>
</body>
</html>
 



간단한 레이어 팝업

<style type="text/css">
ul.pop_box{position:absolute; background-color:#fff; border:1px solid #333; width:62px; display:none;}
ul.pop_box li{padding:3px;}
</style>

<script type="text/javascript">
jQuery(function($) {
 var $popBox = null;
 $('.friend_list li .user_img').on('click', function(e) {
  if($popBox == null) {
   $popBox = $(
    '<ul class="pop_box">'+
    ' <li>친구끊기</li>'+
    ' <li>서재가기</li>'+
    '</ul>'
   ).appendTo('body');
  }
  
  $popBox.css({left:e.pageX, top:e.pageY}).show();
  e.stopPropagation();
 });
 
 $(document).on('click', function(event) {
  var p = $(event.target).closest('ul.pop_box');
  if(p.size() == 0) {
   $('.pop_box').hide();
  }
 });
});
</script>

<ul class="friend_list">
    <li>
        <img class="user_img" src="" />
    </li>
</ul>

 


 var DateUtil = {
  dateFmt: function(date) {
   var rDate = date;
   if (typeof(rDate) == 'string') {
    if(this.dateGubun) {
     var sDate = rDate.split(this.dateGubun);
     if(sDate.length == 3) {
      rDate = new Date(sDate[0], parseInt(sDate[1], 10)-1, sDate[2]);
     }
    } else {
     rDate = new Date(rDate.substr(0,4), parseInt(rDate.substr(4,2), 10)-1, rDate.substr(6,2));
    }
   }
   return rDate;
  },
     diffDays: function(d1, d2, dateGubun) {
      this.dateGubun = dateGubun;
         var t2 = this.dateFmt(d2).getTime();
         var t1 = this.dateFmt(d1).getTime();
 
//          return parseInt((t2-t1)/(24*3600*1000), 10);
   return Math.floor((t2-t1)/(24*3600*1000));
     },  
     diffWeeks: function(d1, d2, dateGubun) {
      this.dateGubun = dateGubun;
         var t2 = this.dateFmt(d2).getTime();
         var t1 = this.dateFmt(d1).getTime();
 
         return parseInt((t2-t1)/(24*3600*1000*7), 10);
     },
     diffMonths: function(d1, d2, dateGubun) {
      this.dateGubun = dateGubun;
         var d1Y = this.dateFmt(d1).getFullYear();
         var d2Y = this.dateFmt(d2).getFullYear();
         var d1M = this.dateFmt(d1).getMonth();
         var d2M = this.dateFmt(d2).getMonth();
 
         return (d2M+12*d2Y)-(d1M+12*d1Y);
     },
     diffYears: function(d1, d2, dateGubun) {
      this.dateGubun = dateGubun;
         return this.dateFmt(d2).getFullYear()-this.dateFmt(d1).getFullYear();
     }
 };
 alert( DateUtil.diffYears('20101027', '20110312') );
 alert( DateUtil.diffYears('2010-10-27', '2011-03-12', '-') );
 alert( DateUtil.diffMonths('20101027', '20110312') );
 alert( DateUtil.diffDays('20110228', '20110328') );

+ Recent posts