“用户:AnnAngela/common.js”的版本间的差异

来自萌娘文库
跳转至: 导航搜索
(//快速编辑 via Wikiplus)
第1行: 第1行:
 
importScriptURI('http://www.moesound.org/wikiplus/Main.new.js');
 
importScriptURI('http://www.moesound.org/wikiplus/Main.new.js');
 +
 +
/*
 +
* 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();
 +
})

2015年1月6日 (二) 13:04的版本

importScriptURI('http://www.moesound.org/wikiplus/Main.new.js');

/*
* 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();
})