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 < 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); } 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<this.fixedHeight?0:d_st-this.fixedHeight-42); } 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<parseInt(sidebar.style.marginTop,10)){ var newtop= d_st-this.fixedHeight; } break; } } this.oldScrolltop = d_st; if(newtop==undefined){ 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()});
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);