用户:AnnAngela/common.js

来自萌娘文库
< 用户:AnnAngela
AnnAngela讨论 | 贡献2015年1月13日 (二) 18:21的版本 (Edited from the Last Vesion 1036 of 用户:AnnAngela/common.js //QuickEdit by AnnAngela the Patroller on Computer via Wikiplus)
跳转至: 导航搜索

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件
importScriptURI('http://www.moesound.org/wikiplus/Main.new.js');
( function( $, undefined ) {
 
function showTime( $target ) {
	var dateNode = UTCLiveClockConfig.node;
	if( !dateNode ) {
		return;
	}
	var now = new Date();
	var hh = now.getUTCHours();
	var mm = now.getUTCMinutes();
	var ss = now.getUTCSeconds();
	if ( typeof $target === 'undefined' ) {
		$target = $( dateNode ).find( 'a:first' );
	}
	$target.text( '强制刷新页面' );
 
	setTimeout( function(){
		showTime( $target );	
	}, 1000 );
}
 
function liveClock() {
 
	if ( typeof( UTCLiveClockConfig ) === 'undefined' ) {
		window.UTCLiveClockConfig = {};
	}
	var portletId = UTCLiveClockConfig.portletId || 'p-personal';
	var nextNode = UTCLiveClockConfig.nextNodeId ? document.getElementById( UTCLiveClockConfig.nextNodeId ) : undefined;
	UTCLiveClockConfig.node = addPortletLink(
		portletId,
		wgScript + '?title=' + encodeURIComponent( wgPageName ) + '&action=purge',
		'',
		'purge',
		undefined,
		undefined,
		nextNode
	);
	if( !UTCLiveClockConfig.node ) {
		return;
	}
 
	showTime();
}
$( document ).ready( liveClock );
 
} )( jQuery );
/*
* Author:+Eridanus Sora
* Work for hitokoto showing
*/
function hitokoto(){
	var self = this;
	this.API = 'http://api.hitokoto.us/rand?encode=jsc&charset=utf-8';
	this.Interval = 5000;
	this.loadScript = function(){
		$("head").append('<script id="hitokoto_loader" src="' + self.API + '" />');
	}
	this.setIntervalEvent = function(Event,Interval){
		setInterval(Event,Interval);
	}
	this.displayHitokoto = function(Hitokoto){
		console.log("You get a new Hitokoto:" + Hitokoto.hitokoto);
		var author  = Hitokoto.author;
		var cat     = Hitokoto.cat;
		var catname = Hitokoto.catname;
		var date    = Hitokoto.date;
		var id      = Hitokoto.id;
		var source  = Hitokoto.source;
		var content = Hitokoto.hitokoto;
		var like    = Hitokoto.like;
		var desc = "「" + content + "」  Author : " + author + " @ " + date + "  Category : " + catname;
		$("#hitokoto").children().fadeOut('slow',function(){
			$("#hitokoto").html($("<span></span>").attr("title",desc));
			$("#hitokoto span").append($("<a>" + content + "</a>").attr({"href":"http://hitokoto.us/view/" + id,"target":"_blank"}).css("display","none").animate({
				opacity: 1},
				0, function() {
				    $(this).fadeIn('slow');
			}).after($('<a id="toHitokoto" title="一言(ヒトコト)">一言</a>').attr({'href':'http://hitokoto.us/','target':'_blank'}).css('display','none').animate({
				opacity: 1},
				0, function() {
				    $(this).fadeIn('slow');
			}).before($('<span id="spliter" title=""> —— </span>').css('display','none').animate({
				opacity: 1},
				0, function() {
				    $(this).fadeIn('slow');
			}))));
			$("head").find('#hitokoto_loader').remove();
		});
	}
	this.init = function(){
		window.hitokoto = this.displayHitokoto;
		this.loadScript();
		this.setIntervalEvent(this.loadScript,this.Interval);
	}
}
$(document).ready(function(){
	$("#siteSub").after('<div id="hitokoto"><span></span></div>');
	H = new hitokoto();
	H.init();
})