웹 프론트엔드 JS 튜토리얼 아주 좋은 자바스크립트 class_javascript 기술

아주 좋은 자바스크립트 class_javascript 기술

May 16, 2016 pm 07:24 PM
친절한

아주 좋은 자바스크립트 클래스입니다

코드 복사 코드는 다음과 같습니다.

/*  
 *  저자:aoao
 *    홈페이지:http://www.loaoao.com
 *  이메일:loaoao@gmail.com / QQ:2222342
 *  저작권 (c) 2006 aaoao
);
var loaoao = new Object();//^_^//
jscc = {    
    init:function(){/*_*/},
    경로:"/scripts/jscc /",
    include:function (파일){
        var j=document.createElement("script");
        j.setAttribute('type','text/javascript');
        j.setAttribute('src',jscc.path file '.js');
        document.getElementsByTagName("head")[0].appendChild(j);
    }
};

jscc.addEvent = function( obj, type, fn ) {
    if ( obj.attachEvent ) {        
      obj['e' type fn] = fn;
      obj[type fn] = function(){obj['e' type fn]( window.event );}
      obj.attachEvent( 'on' type, obj[type fn] );
    } else {
      obj.addEventListener( type, fn, false );
    }
};
// 쿠키
jscc.cookie = {
    create:function (이름, 값, 일) {
      if (일) {
        var date = new Date();
        date.setTime(date.getTime() (일*24*60*60*1000));
        var expires = "; expires=" date.toGMTString();
      }
      그렇지 않으면 만료 = "";
      document.cookie = 이름 "=" 값 만료 "; path=/";
    },
    읽기:함수(이름) {
      var nameEQ = 이름   "=";
      var ca = document.cookie.split(';');
      for(var i=0;i < ca.length;i ) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
      }
      null을 반환합니다.
    }
};


jscc.getPageSize=function(){
    // 참조 라이트박스(http://www.huddletogether.com/projects/lightbox/lightbox.js)
     var theWidth,theHeight ;
    if (window.innerHeight&&window.scrollMaxY) {
        theWidth = window.innerWidth;
        theHeight = window.innerHeight  window.scrollMaxY;
     } 
    else if (document.body){
        theWidth=((document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth : document.body.offsetWidth );
        theHeight=((document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight  : document.body.offsetHeight );
    }
    var winWidth ,winHeight; 
    if (self.innerHeight) {    
        winWidth = self.innerWidth;
        winHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        winWidth = document.documentElement.clientWidth;
        winHeight = document.documentElement.clientHeight;
    } else if (document.body) {
        winWidth = document.body.clientWidth;
        winHeight = document.body.clientHeight;
    }
    var pWidth=(theWidth>winWidth?theWidth:winWidth)
    var pHeight=(theHeight>winHeight?theHeight:winHeight)

    var yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop){     // Explorer 6 엄격
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {// 다른 모든 탐색기
        yScroll = document.body.scrollTop;
    }
    var getPageSize = new Array(pWidth,pHeight,winWidth,winHeight,yScroll) 
    return getPageSize;
}


jscc.widgets = {/**/};
jscc.widgets.fixedsidebar = {
    fixedHeight:0,
    oldScrolltop:0,
    init: function(){
        if (!document.getElementById("sidebar")) return;
        jscc.addEvent(window,"scroll",function(e){jscc.widgets.fixedsidebar.setFixed()});
        jscc.addEvent(window,"resize",function(e){jscc.widgets.fixedsidebar.setFixed()});
        this.fixedHeight=document.getElementById("sidebar").offsetTop;
        this.setFixed();
    },
    setFixed:function(){
        var sidebar=document.getElementById("sidebar");
        var ref=document.getElementById("main");
        var s_t=sidebar.offsetTop;
        var s_h=sidebar.offsetHeight;
        var s_th=s_t s_h;
        var r_th=ref.offsetTop ref.offsetHeight;
        var d_st;
        if(document.documentElement.scrollTop){
            d_st=document.documentElement.scrollTop;
        }
        else{
           d_st=document.body.scrollTop
           }
        if(r_th>(s_t s_h)){
            var seHeight=0; 
            if (self.innerHeight) {    seHeight = self.innerHeight;} else if (document.documentElement && document.documentElement.clientHeight) {    seHeight = document.documentElement.clientHeight;} else if(document. 본문) {se높이 = document.body.clientHeight;}
            시도해 보세요{
               if(seHeight>s_h){
                 var newtop=(d_st                }
               else{
               // 감사합니다 dron(http://www.ucren.com/)
              스위치(d_st-this.oldScrolltop>0)                     {
                   대소문자 참:
                      if (d_st-this.fixedHeight > s_t -seHeight){
                     var    newtop= d_st -this.fixedHeight - (s_h-seHeight)-68;
                      }
                   휴식;
                   사례 false:
                     if (d_st-this.fixedHeight                      var newtop= d_st-this.fixedHeight;
                      }
                   휴식;
                   }
               }
               this.oldScrolltop = d_st;
                if(newtop==undefine){ return;};
                newtop=(newtop<0?0:newtop);
               sidebar.style.marginTop= newtop "px";
            }
            catch(e){
              //alert(e.description);
           }
        }
        else{
            sidebar.style.marginTop="0px";
        }
    }    
};
//jscc.addEvent(window,"load",function(e){jscc.widgets.fixedsidebar.init()});

jscc.widgets.wraphandler = {
    //jscc.widgets.wraphandler 참조 http://www.collylogic.com/includes/resizer.js (http://www.collylogic.com/ ?/comments/redesign-notes-1-width-based-layout/)
    init: function() {    
        //if (!document.getElementById) return;
            if( document.getElementById('wrapper').className=="col3"){    
           jscc.wraphandler.setWrapper();
            jscc.addEvent(window,"resize",jscc.wraphandler.setWrapper);
            }
            else{return}
      },
      setWrapper: function() {
       var getPS=jscc.getPageSize();
       var _width=getPS[2];
         if (_width < 940) {
            document.getElementById('wrapper').className = 'col2';
          } else {
            document.getElementById('wrapper').className = 'col3';
         }
          if(document.all) {
           if (_width < 780) {
           document.getElementById('wrapper').style.width="750px" 🎜>              } 그 외 {
               document.getElementById('wrapper').style.width="auto"
             }             
          }
      }
};
//jscc.addEvent(window,"load",function(e){jscc.widgets.wraphandler.init()});


jscc.widgets.styleSwitcher = {
    // jscc.widgets.styleSwitcher  참조 StyleSwitcher 함수(Paul Sowden이 작성 http://www.idontsmoke.co.uk/ss/ . For 자세한 내용은 ALA를 방문하세요: http://www.alistapart.com/stories/alternate/)
    init:function(e) {
        var cookie = jscc.cookie.read("style");
        var 제목 = 쿠키 ? 쿠키 : this.getPreferred();
        제목 = (제목==null?"왼쪽":제목);
        this.setActive(제목);
        var operactioner = document.getElementById("themes").getElementsByTagName("A");
    operactioner[0].onclick=function() {
        jscc.widgets.styleSwitcher.setActive("left");
        false를 반환합니다.
    };
    operactioner[1].onclick=function() {
        jscc.widgets.styleSwitcher.setActive("right");
        false를 반환합니다.
    };
    this.switcher(제목);
    },
    setActive:function(title){
        var i, a, main;
         for(i=0;(a = document.getElementsByTagName("link")[i]); i ) {
        if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
               a.disabled = true;
                if(a.getAttribute("title") == title) a.disabled = false;
            }
        }
        this.switcher(제목);
        //jscc.cookie.create("style", title,"365");    
    },
    getActive:function(){
    var i, a;
    for(i=0; (a = document.getElementsByTagName("link")[i]); i ) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");}
      return null;
    },
    getPreferred:function (){
      var i, a;
      for(i=0; (a = document.getElementsByTagName("link")[i]); i ) {
        if(a.getAttribute("rel").indexOf("style") != -1
           && a.getAttribute("rel").indexOf("alt") == -1
          && a.getAttribute("title")
          ) return a.getAttribute("title") ;
      }
      null을 반환합니다.
    },
    switcher:function(theme){
        if(!document.getElementById(["theme_" theme])) { return;}
        var notheme=(theme=="left" ?"오른쪽":"왼쪽");
        document.getElementById(["theme_" notheme]).style.display="inline";
        document.getElementById(["theme_" theme]).style.display="none";
    },
    end:function(e){
      var title = this.getActive();
      jscc.cookie.create("style", title,"365");
    }
};
//jscc.addEvent(window,"load",function(e){jscc.widgets.styleSwitcher.init()});
jscc.addEvent(window,"unload",function(e){jscc.widgets.styleSwitcher.end()});

jscc.widgets.toTop = {
    init:function(){
        document.getElementById("toTop").onclick=function(e){
            jscc.widgets.toTop. 세트();
            false를 반환합니다.
        }        
    },
    waitTimer:null,
    set:function(){
        var d_st=document.documentElement.scrollTop;
        if(window.navigator.userAgent.indexOf("MSIE")>=1){
            for (var i=d_st; i>10; i-=Math.floor(i/6)){
            window.scrollTo(0,i);
            }
            window.scrollTo(0,10);
        }
        else{
        window.scrollTo(0,Math.floor(d_st / 2));

         if(d_st>10){
                waitTimer=setTimeout("jscc.widgets.toTop.set()",20);
          }
            else{
                 clearTimeout(waitTimer);
           }
        }
    }
}
jscc.api={
    google:{
        init:function(){
        시도{
         var searchControl = 새로운 GSearchControl();
        }
            잡기(e){
             반환;
            }

        var 옵션 = 새 GdrawOptions();
        options.setSearchFormRoot(document.getElementById("googleSearchForm"));
        options.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
         searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF);
        searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);

        var siteSearch = new GwebSearch();
        siteSearch.setUserDefinedLabel("站内搜索");
        siteSearch.setUserDefinedClassSuffix("siteSearch");
        siteSearch.setSiteRestriction("www.loaoao.com");
        searchControl.addSearcher(siteSearch);
        var labSearch = new GwebSearch();
        labSearch.setUserDefinedLabel("嗷嗷的实验室搜索");
        labSearch.setUserDefinedClassSuffix("labSearch");
        labSearch.setSiteRestriction("lab.loaoao.com");
        searchControl.addSearcher(labSearch);
        var wwwSearch = new GwebSearch();
        wwwSearch.setUserDefinedLabel("Google搜索");
        labSearch.setUserDefinedClassSuffix("wwwSearch");
        searchControl.addSearcher(wwwSearch);

        searchControl.draw(document.getElementById("googleSearchResults"), options);
        //    searchControl.execute("css");
        }
    }
}
loaoao.com = function(){
    if (!document.getElementById) return;
    jscc.widgets.styleSwitcher.init();
    jscc.widgets.fixedsidebar.init();
    jscc.widgets.toTop.init();    
    jscc.api.google.init();    


};
jscc.addEvent(window,"load",loaoao.com);

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

PHP 오류: 클래스를 반복적으로 선언할 수 없습니다. 해결 방법! PHP 오류: 클래스를 반복적으로 선언할 수 없습니다. 해결 방법! Aug 25, 2023 pm 04:13 PM

PHP 오류: 클래스를 반복적으로 선언할 수 없습니다. 해결 방법!

PHP의 명명 규칙: 클래스, 메소드 및 변수에 카멜 표기법을 사용하는 방법 PHP의 명명 규칙: 클래스, 메소드 및 변수에 카멜 표기법을 사용하는 방법 Jul 30, 2023 pm 02:43 PM

PHP의 명명 규칙: 클래스, 메소드 및 변수에 카멜 표기법을 사용하는 방법

Java에서 클래스를 찾을 수 없습니다. java.lang.ClassNotFoundException을 해결하는 방법은 무엇입니까? Java에서 클래스를 찾을 수 없습니다. java.lang.ClassNotFoundException을 해결하는 방법은 무엇입니까? Jun 25, 2023 am 10:37 AM

Java에서 클래스를 찾을 수 없습니다. java.lang.ClassNotFoundException을 해결하는 방법은 무엇입니까?

PHP의 패키징 기술 및 응용 PHP의 패키징 기술 및 응용 Oct 12, 2023 pm 01:43 PM

PHP의 패키징 기술 및 응용

속성을 사용하여 PHP8의 클래스에 사용자 정의 주석을 추가하는 방법은 무엇입니까? 속성을 사용하여 PHP8의 클래스에 사용자 정의 주석을 추가하는 방법은 무엇입니까? Oct 18, 2023 am 10:16 AM

속성을 사용하여 PHP8의 클래스에 사용자 정의 주석을 추가하는 방법은 무엇입니까?

'PHP의 객체 지향 프로그래밍 소개: 개념에서 실습까지' 'PHP의 객체 지향 프로그래밍 소개: 개념에서 실습까지' Feb 25, 2024 pm 09:04 PM

'PHP의 객체 지향 프로그래밍 소개: 개념에서 실습까지'

PHP 코드 캡슐화 팁: 클래스와 객체를 사용하여 재사용 가능한 코드 블록을 캡슐화하는 방법 PHP 코드 캡슐화 팁: 클래스와 객체를 사용하여 재사용 가능한 코드 블록을 캡슐화하는 방법 Jul 29, 2023 pm 11:19 PM

PHP 코드 캡슐화 팁: 클래스와 객체를 사용하여 재사용 가능한 코드 블록을 캡슐화하는 방법

PHP 클로저 클래스 PHP 클로저 클래스 Aug 19, 2023 am 11:01 AM

PHP 클로저 클래스

See all articles