非常不错的一个javascript 类
/*
* Author:aoao
* Homepage:http://www.loaoao.com
* Email:loaoao@gmail.com / QQ:2222342
* Copyright (c) 2006 aoao
* Licensed under a Creative Commons Attribution 2.5 License (http://creativecommons.org/licenses/by/2.5/)
*/
var jscc = new Object();
var loaoao = new Object();//^_^//
jscc = {
init:function(){/*_*/},
path:"/scripts/jscc/",
include:function (file){
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 );
}
};
// Cookies
jscc.cookie = {
create:function (name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
},
read:function(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;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);
}
return null;
}
};
jscc.getPageSize=function(){
// reference lightbox (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 Strict
yScroll = document.documentElement.scrollTop;
} else if (document.body) {// all other Explorers
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.body) {seHeight = document.body.clientHeight;}
try{
if(seHeight>s_h){
var newtop=(d_st
else{
// Thank you dron (http://www.ucren.com/)
switch (d_st-this.oldScrolltop>0)
{
case true:
if (d_st-this.fixedHeight > s_t -seHeight){
var newtop= d_st -this.fixedHeight - (s_h-seHeight)-68;
}
break;
case false:
if (d_st-this.fixedHeight
}
break;
}
}
this.oldScrolltop = d_st;
if(newtop==undefined){ return;};
newtop=(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 reference 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 document.getElementById('wrapper').className = 'col2';
} else {
document.getElementById('wrapper').className = 'col3';
}
if(document.all) {
if (_width document.getElementById('wrapper').style.width="750px"
} else {
document.getElementById('wrapper').style.width="auto"
}
}
}
};
//jscc.addEvent(window,"load",function(e){jscc.widgets.wraphandler.init()});
jscc.widgets.styleSwitcher = {
// jscc.widgets.styleSwitcher reference StyleSwitcher functions( written by Paul Sowden http://www.idontsmoke.co.uk/ss/ . For the details, visit ALA: http://www.alistapart.com/stories/alternate/)
init:function(e) {
var cookie = jscc.cookie.read("style");
var title = cookie ? cookie : this.getPreferred();
title = (title==null?"left":title);
this.setActive(title);
var operactioner = document.getElementById("themes").getElementsByTagName("A");
operactioner[0].onclick=function() {
jscc.widgets.styleSwitcher.setActive("left");
return false;
};
operactioner[1].onclick=function() {
jscc.widgets.styleSwitcher.setActive("right");
return false;
};
this.switcher(title);
},
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(title);
//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");
}
return null;
},
switcher:function(theme){
if(!document.getElementById(["theme_"+theme])) { return;}
var notheme=(theme=="left"?"right":"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.set();
return 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(){
try{
var searchControl = new GSearchControl();
}
catch(e){
return;
}
var options = new 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);

PHP中的命名规范:如何使用驼峰命名法命名类、方法和变量在PHP编程中,良好的命名规范是一种重要的编码实践。它可以提高代码的可读性和可维护性,并且使团队合作更加顺畅。在本文中,我们将探讨一个常见的命名规范:驼峰命名法,并提供一些示例来说明如何在PHP中使用它来命名类、方法和变量。一、什么是驼峰命名法?驼峰命名法是一种常用的命名约定,其中每个单词的首字母大写,

PHP报错:无法重复声明类,解决方法!对开发者而言,遇到问题是常有的事情。而在PHP开发中,经常会遇到一个常见的错误:无法重复声明类。这个问题看似简单,但如果不及时解决,会导致代码无法正确执行。本文将介绍这个问题的原因,并提供解决方法,以供参考。当我们在PHP代码中定义一个类时,如果在同一个文件或多个文件中多次定义同一个类,就会出现无法重复声明类的错误。这是

PHP中的封装技术及应用封装是面向对象编程中的一个重要概念,它指的是将数据和对数据的操作封装在一起,以便提供对外部程序的统一访问接口。在PHP中,封装可以通过访问控制修饰符和类的定义来实现。本文将介绍PHP中的封装技术及其应用场景,并提供一些具体的代码示例。一、封装的访问控制修饰符在PHP中,封装主要通过访问控制修饰符来实现。PHP提供了三个访问控制修饰符,

在Java开发过程中,有时候会遇到一个错误:java.lang.ClassNotFoundException。它表示在Java虚拟机(JVM)中找不到所需的类文件。这个错误会导致程序不能正常运行,如果不及时解决,会延误开发进度。本文将介绍Java中找不到类的原因和解决方法。一、原因1.类的路径错误在Java中,包路径和类路径很重要。如果类路径设置错误或者类文

什么是面向对象编程?面向对象编程(OOP)是一种编程范式,它将现实世界中的实体抽象为类,并使用对象来表示这些实体。类定义了对象的属性和行为,而对象则实例化了类。OOP的主要优点在于它可以使代码更易于理解、维护和重用。OOP的基本概念OOP的主要概念包括类、对象、属性和方法。类是对象的蓝图,它定义了对象的属性和行为。对象是类的实例,它具有类的所有属性和行为。属性是对象的特征,它可以存储数据。方法是对象的函数,它可以对对象的数据进行操作。OOP的优点OOP的主要优点包括:可重用性:OOP可以使代码更

PHP8中如何使用Attributes为类添加自定义注解?自定义注解是一种在类或方法上添加元数据的方式,它可以帮助我们在运行时获取和处理特定的类或方法上的附加信息。在PHP8中,引入了Attributes的概念,它使我们可以轻松地为类添加自定义注解。本文将介绍如何在PHP8中使用Attributes来实现类的自定义注解,并提供具体的代码示例。在PHP8中,自

PHP代码封装技巧:如何使用类和对象封装可重复使用的代码块摘要:在开发中,经常遇到需要重复使用的代码块。为了提高代码的可维护性和可重用性,我们可以使用类和对象的封装技巧来对这些代码块进行封装。本文将介绍如何使用类和对象封装可重复使用的代码块,并提供几个具体的代码示例。使用类和对象的封装优势使用类和对象的封装有以下几个优势:1.1提高代码的可维护性通过将重复

介绍匿名函数(也称为lambda)返回Closure类的对象。这个类有一些额外的方法,可以进一步控制匿名函数。语法Closure{ /*Methods*/ private__construct(void) publicstaticbind(Closure$closure,object$newthis[,mixed$newscope="static"


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),