관리 메뉴

I LOVE EJ

스크립트 참조하기 본문

Web publishing/jQuery

스크립트 참조하기

BeOne 2016. 12. 20. 01:49

http://www.kilf.re.kr/

http://cafe.naver.com/mintchoco/27


https://www.sanghun.go.kr/nation/nationMain.do#n

https://www.sanghun.go.kr/nation/js/descript.js



//main page slide 

//2016.12.07 go dong hyun  

$(document).ready(function(){

   var rolling_set =setInterval(function(){ rolling();}, 5000);

   var dot_num = 0;

   var banner_hap = $("#slides_ul li").size(); //배너전체 숫자

   var max_banner = banner_hap-1 ; //배너 인덱스 번호는 0 부터 시작 하므로 -1 해줌...

   var banner_move = "move"; //배너상태

   var dot_click_num; //클릭한 도트 넘버

   var banner_num =1; //배너 버튼 대체텍스트

   

   //배너 버튼 자동으로 생성하기

for(i=0; i < banner_hap; i++){

$(".slide_dot").append("<li><a class='dot_a' href='#na'>slide "+banner_num+"</a></li>"); 

banner_num++;

}

   $("#slides_ul li").css("display","none");

   $("#slides_ul li:first").css("display","block");

   $(".slide_dot a:first").addClass("current");


   function rolling(){

//console.log("banner_click: "+banner_click+ " / banner_move : "+banner_move);

banner_fadeOut();

if(dot_num == max_banner ){

dot_num=0;

}else{

dot_num+=1;

}

banner_fadeIn();

}

function banner_fadeOut(){

$("#slides_ul li").fadeOut(800);

$(".slide_dot a").removeClass("current");

}

function banner_fadeIn(){

$("#slides_ul li:nth("+dot_num+")").fadeIn(800);

$(".slide_dot a:nth("+dot_num+")").addClass("current");

}


$(".slides_stop").click(function(){

if(banner_move == "move"){

clearInterval(rolling_set); 

banner_move = "stop";

$(".slides_stop img").attr({"src":"/nation/images/main/play.png","alt":"play"})

}else if(banner_move == "stop"){

rolling_set = setInterval(function(){rolling();}, 5000);

banner_move = "move"

$(".slides_stop img").attr({"src":"/nation/images/main/stop.png","alt":"stop"})

}

}

);


$(".slide_dot li").bind('click',function(){

dot_click_num = $(this).index();

//console.log(dot_click_num);

if(dot_num != dot_click_num){

dot_num = dot_click_num;

clearInterval(rolling_set);

banner_fadeOut();

banner_fadeIn();

   if(banner_move=="move"){

rolling_set =setInterval(function(){ rolling();}, 5000);

}

}

});


});