⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zeal.js

📁 使用java算法实现繁体中文和简体中文的转化
💻 JS
字号:
function Map() {
	this.map  = new Object();
	// Map API
	this.add      = function(k,o){ this.map[k] = o;    }
	this.remove   = function( k ){ delete this.map[k]; }
	this.get      = function( k ){ return k==null ? null : this.map[k]; }
	this.first    = function(   ){ return this.get( this.nextKey( ) ); }
	this.next     = function( k ){ return this.get( this.nextKey(k) ); }
	this.nextKey  = function( k ){
		for (i in this.map) {
			if (!k) return i;
			if (k==i) k=null; /*tricky*/
		}
		return null;
	}
}

function Mutex( cmdObject, methodName ) {
  // define static variable and method
  if (!Mutex.Wait) Mutex.Wait = new Map();
  Mutex.SLICE = function( cmdID, startID ) {
    Mutex.Wait.get(cmdID).attempt( Mutex.Wait.get(startID) );
  }
  // define instance method
  this.attempt = function( start ) {
	start = start || Mutex.Wait.first();
    for (var j=start; j; j=Mutex.Wait.next(j.c.muteid)) {
      if (j.enter || (j.number && (j.number < this.number ||
           (j.number == this.number && j.c.muteid < this.c.muteid) ) ) )
       return setTimeout("Mutex.SLICE("+this.c.muteid+","+j.c.muteid+")",200);
    }
	
    this.c[ this.methodID ](this);
    //this.done();
  }
  this.done = function(){
	  this.number = 0; 
	  Mutex.Wait.remove( this.c.muteid );
  }

  // constructor logic
  this.c        = cmdObject;
  this.methodID = methodName;
  Mutex.Wait.add( this.c.muteid, this ); //enter and number are �false?
  this.enter    = true;
  this.number   = (new Date()).getTime();
  this.enter    = false;
  this.attempt( Mutex.Wait.first() );
}
var NEXT_CMD_ID = 0;
function genNextCmdID(){
	NEXT_CMD_ID++;
	if(NEXT_CMD_ID > 1888888826) NEXT_CMD_ID = 0;
	return NEXT_CMD_ID;
}

$.ajaxSetup( {
  type: "GET",
  timeout: 15000
} );

jQuery.fn.extend({ 
	dyniframesize: function(bWidthResize){		
		this.css('display','block');
		if (this[0].contentDocument && this[0].contentDocument.body.offsetHeight){
			//ns6 syntax
			this.height(this[0].contentDocument.body.offsetHeight);
			if(!$.isempty(bWidthResize) && bWidthResize == true){
				this.width(this[0].contentDocument.body.offsetWidth);
			}
		}
		else if (this[0].Document && this[0].Document.body.scrollHeight){
			//ie5+ syntax
			this.height(this[0].Document.body.scrollHeight);
			if(!$.isempty(bWidthResize) && bWidthResize == true){
				this.width(this[0].Document.body.scrollWidth);
			}
		}
	},
	loadRemoteCont: function(url, dotitle, bcached, params, callback, ifModified){
		if(!$.isempty(bcached) && bcached == true && $(this).html().length > 0) return this;
		callback = callback || function(){};

		b_isLoadOK++;
			
		var self = this;
		self.muteid = genNextCmdID();
		self.go = function(selfMutex){
			// If the second parameter was provided
			if ( params )
				// If it's a function
				if ( jQuery.isFunction( params ) ) {
					// We assume that it's the callback
					callback = params;
					params = null;

				// Otherwise, build a param string
				} else {
					params = jQuery.param( params );
				}
			self.html('<div align="center"><img src="/pic/loading.gif" border="0" align="center" /></div>');
			$.ajax({
				url: url,
				data: params,
				ifModified: ifModified,
				complete: function(res, status){
					if ( status == "success" || !ifModified && status == "notmodified" ){
						// remove all events avoid ie memory leak.
						$('*',self).unbind();
						self.html(($.isempty(dotitle) ? res.responseText : '<div class="block"><div class="modrighthead">'+dotitle+'</div><div Class="partrightsmb">' + res.responseText + '</div></div>'));
						b_isLoadOK--;
					}

					// Add delay to account for Safari's delay in globalEval
					setTimeout(function(){
						self.each( callback, [res.responseText, status, res] );
					}, 13);
					selfMutex.done();
				},
				error: function(res, status){				
					self.html('<div align="center">Error requesting page ' + s.url + '</div>');
					selfMutex.done();
				}
			});
			return this;		
		}
		new Mutex(self,"go");
		
		return this;
	},
	genFrameCont: function(opts){
		opts = $.extend({
			src:'',
			width:0,
			height:0,
			dosize:false,
			dotitle:false
		},opts);
		b_isLoadOK++;
		var self = this;
		self.muteid = genNextCmdID();
		self.go = function(selfMutex){
			var ret = '';
			var frmName = 'frm_'+self.attr('id');
			var js = function(){			
				$('#'+frmName).css('visibility','visible');
				self.css('background','transparent').show();
				if(opts.dosize){
					$('#'+frmName).dyniframesize();
					//self.height($('#'+frmName).height());
				}
				b_isLoadOK--;
				selfMutex.done();
			};
			ret = '<iframe ALLOWTRANSPARENCY="true" id="'+frmName+'" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" style="padding:0px"></iframe>';
			if(opts.dotitle){
				ret = '<div class="block"><div class="modrighthead">'+opts.dotitle+'</div><div Class="partrightsmb">' + ret + '</div></div>';
			}
			self.css({
				background:'transparent url(/pic/loading.gif) no-repeat top center'
			}).html(ret);
			$('#'+frmName)
				.load(js)
				.error(selfMutex.done)
				.css({width:opts.width,height:opts.height})
				.attr('src',opts.src);
		}
		new Mutex(self,"go");
		return this;
	}
});

$(document.body).prepend('<div id="feedListHref"></div>');
$('#feedListPopOut').hover(function(){
	var pos = {};
	$(this).offset({ margin: false, scroll: true, relativeTo: $(document.body) }, pos);
	$('#feedListHref')
		.css({top:(pos.top+16),left:(pos.left+26)})
		.show()		
		.loadRemoteCont('/feedlist.php?showinframe=1',null,true);
},function(){});
$('#feedListHref').hover(function(){},function(){
	$(this).hide();
});

$(document).ready(function(){
	// messageboard
	$('#messageBoardHolder').loadRemoteCont('/comment.php?showinframe=0','给我留言');
	// recently entrys
	$('#recentEntryListHolder').loadRemoteCont('/entrylist_recently.php','最新日志');
	// hottest entrys
	$('#hotestToptenHolder').loadRemoteCont('/blog/EntryTopten.php?showinframe=1','近期热文');
	// calendar
	$('#calendarFrameHolder').loadRemoteCont('/blog/calendarframe.php?showinframe=1&oldestentry=2005-04','日历');
	// feedlist
	//$('#feedListHref').loadRemoteCont('/feedlist.php?showinframe=1');

	var pGADC = $('#googleADinContent');
	if(pGADC.length > 0){
		pGADC.genFrameCont({src:'/google_Banner_300X250.html',width:300,height:250});
	}
	else{
		$('#bannerForLeftTop').genFrameCont({src:($.browser.mozilla ? '/google_Banner_LeftTop_notff.html' : '/google_Banner_LeftTop.html'),width:632,height:65});
	}
	pGADC = null;
	if(!bIsHomePage){				
		//$('#bannerForRightMiddle').genFrameCont({src:'/google_Banner_180X60rnd.html',width:200,height:60});
		$('#bannerForLeftBottom').genFrameCont({src:'/google_Banner_468X15_lnk.html',width:632,height:20});
	}
	$('#bannerForMiddleBottom').genFrameCont({src:'/fav_douban_to_joyo.html',width:140,dosize:true,dotitle:'<a href="http://www.joyo.com/browse/browse.asp?source=ZealLi&nodeID=53263" title="DVDs on joyo.com">看/读/听荐</a>'});
	$('#bannerForRightBottom').html('<div id="favGoogleReader"></div><div id="bookmarkDelicious"></div><div id="favDouban"></div>');
	if(bIsHomePage){
		$('#favGoogleReader').genFrameCont({src:'/fav_GoogleReader.html',width:200,height:200,dosize:true,dotitle:'GReader Zeal Shared'});
		$('#bookmarkDelicious').loadRemoteCont('/bookmark_delicious.php','del.icio.us ZealLinks');
	}
	$('#favDouban').genFrameCont({src:'/fav_douban.html',width:200,dosize:true,dotitle:'<a href="http://www.douban.com/people/zeal/" target="_blank" title="访问我的豆瓣">我想看/听/读的</a>'});

	b_isLoadOK--;	
	
	var bCanFix = (!$.browser.msie || parseFloat($.browser.version) >= 7);
	if(bCanFix) $('#zealNavigatorBar').css('position','fixed');
	$('#navBarHolder').height($('#zealNavigatorBar').height()+10);
	var reposBar = function(){
		if(bCanFix) return;
		var pos = {};
		$('#navBarHolder').offset({ margin: false, scroll: true, relativeTo: $(document.body) }, pos);
		$('#zealNavigatorBar').css({
			top: pos.top + $(document).scrollTop(),
			left: pos.left
		})
	}
	;

	$(window)
	.scroll(reposBar)
	.resize(reposBar)
	;

	reposBar();

})
;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -