사용자:다메즈마/common.js: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
 
(같은 사용자의 중간 판 96개는 보이지 않습니다)
1번째 줄: 1번째 줄:
function randomRange(n1, n2) {
function randomRange(n1, n2) {
   return Math.floor( (Math.random() * (n2 - n1)) + n1 );
   return Math.round( Math.random() * 10000) % (n2 - n1) + n1;
}
var damezuma_hisyokan = null;
function Mascot2()
{
     
this.is_loaded = false;
this.is_show = false;
this.mascot_img_list = [];
this.message_queue =  [];
this.now_balloon = null;
this.is_small = false;
this.imgSrc = "";
this.comments = [];
}
}
function Mascot()
Mascot2.prototype.CloseMessage = function()
{
{
var libra =  
$(this.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});
this.now_balloon = null;
if(this.message_queue.length != 0)
{
{
img:"/images/3/3d/리브레_위키_마스코트.png",
this._show_balloon();
comment:"한번만 더 '노브라'라고 하면 차단할테니 각오하세요"
}
};
};
var libra2 = libra;
Mascot2.prototype.ShowMessageNow = function(msg)
libra2.img = "/images/8/8b/리브라_대반달.png";
{
var libra3 =
this.message_queue.unshift(msg);
if(this.is_show == false)
{
{
img:"/images/d/d3/백팩커리브라.png",
this.Show();
comment:"자 얼릉 문서수정하러 가자고"
}
};
else{
var libren =
this.CloseMessage();
}
if(this.now_balloon == null && this.is_loaded == true)
{
{
img:"/images/b/be/리브렌_100.png",
this._show_balloon();
comment:"나 팩맨아니라고!"
}
};
};
var itsurea_moe =
Mascot2.prototype._show_balloon = function()
{
{
img:"/images/a/a3/150610.png",
this.now_balloon = document.createElement("div");
comment:"ㄹㅍㄷ ㄴㅁ는 자살하시길 왜 안 자살요?"
$(this.now_balloon).css("position","fixed");
};
$(this.now_balloon).css("display","none");
var itsurea_moe2 = itsurea_moe;
$(this.now_balloon).html(this.message_queue[0]);
itsurea_moe2.comment = "아 시발 죽창 존나 아프네 내가 야비군 좋아서 갔다 온건줄 아나";
$(this.now_balloon).css("background-color","#000");
var mascot_list =
$(this.now_balloon).css("color","#FFF");
[
$(this.now_balloon).css("max-width","225px");
libra,
$(this.now_balloon).css("padding","16px");
libra2,
$(document.body).append(this.now_balloon);
libra3,
libren,
itsurea_moe,
itsurea_moe2
];
var select = mascot_list[randomRange(0,mascot_list.length)];
var comment = select.comment;
   
   
var wrap_div = document.createElement("div");
$(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);
this.mascot_img_html = document.createElement("img");
this.balloon = document.createElement("div");
$(this.balloon).css("display","none");
$(this.balloon).css("position","fixed");
this.mascot_img_html.balloon = this.balloon;
this.mascot_img_html.onload = function()
{
$(".top_s_btn").css("display","none");
$(this.balloon).css("display","");
$(this.balloon).html(comment);
$(this.balloon).css("background-color","#000");
$(this.balloon).css("color","#FFF");
$(this.balloon).css("max-width","225px");
$(this.balloon).css("padding","16px");
$(this.balloon).css("bottom",$(this).height()/2 +16 - $(this.balloon).height()/2 + 32);
$(this.balloon).css("right",$(this).width() + 32);
$(this.balloon).css("border-radius",5);
 
var balloon = this.balloon;
}
this.mascot_img_html.src = select.img;
   
   
$(wrap_div).css("position","fixed");
$(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);
$(wrap_div).css("right","16px");
$(this.now_balloon).css("border-radius",5);
$(wrap_div).css("bottom","16px");
$(this.now_balloon).fadeIn(1000);
$(wrap_div).append(this.mascot_img_html);
this.message_queue.shift();
this.now_balloon.obj = this;
$(this.mascot_img_html).css("height",256);
$(this.now_balloon).click
$(wrap_div).append("<a href='#' style='text-align:center;display:inline-block;line-height:32px;width:100%;background-color:#000;color:#FFF;font-weight:bold;'>위로</a>");
(
function()
$(document.body).append(wrap_div);
$(document.body).append(this.balloon);
this.mascot_img_html.is_small = false;
$(this.mascot_img_html).click(function()
{
{
if(this.is_small == false)
var obj = this.obj;
$(obj.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});
obj.now_balloon = null;
if(obj.message_queue.length != 0)
{
{
$(this).css("height",128);
obj._show_balloon();
}
}
else
}
{
);
$(this).css("height",256);
}
};
this.is_small = !this.is_small;
Mascot2.prototype.ShowMessage = function(msg)
$(this.parentElement).css("width",$(this).width());
});
$(this.balloon).click(function(){
$(this).fadeOut();
});
 
}
Mascot.prototype.ShowMessage = function(msg)
{
{
$(this.balloon).css("background-color","#000");
this.message_queue.push(msg);
$(this.balloon).css("color","#FFF");
$(this.balloon).css("max-width","225px");
if(this.is_show == false)
$(this.balloon).css("padding","16px");
{
$(this.balloon).css("bottom",$(this.mascot_img_html).height()/2 +32 - $(this.balloon).height()/2);
this.Show();
$(this.balloon).css("right",$(this.mascot_img_html).width() + 32);
}
$(this.balloon).css("border-radius",5);
if(this.now_balloon == null && this.is_loaded == true)
$(this.balloon).html(msg);
{
$(this.balloon).fadeIn();
this._show_balloon();
}
};
};
Mascot.prototype.Hide = function()
Mascot2.prototype.ToSmall = function()
{
{
$(this.balloon).fadeOut();
$(this.mascot_img_html).css("width",96);
if(this.now_balloon != null)
{
$(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);
$(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);
}
$("#to-top-btn").css("width",$(this.mascot_img_html).width()/2);
$("#hisyokan-bookmark").css("width",$(this.mascot_img_html).width()/2);
this.is_small = true;
localStorage.setItem("custom_dmns_is_small",true);
};
};
 
Mascot2.prototype.ToBig = function()
var mascot = new Mascot();
{
var temp = function(){
$(this.mascot_img_html).css("width",256);
var param =  
if(this.now_balloon != null)
{
{
"action":"query",
$(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);
"meta":"notifications",
$(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);
"notlimit":10,
}
"format":"json"
$("#to-top-btn").css("width",$(this.mascot_img_html).width()/2);
};
$("#hisyokan-bookmark").css("width",$(this.mascot_img_html).width()/2);
$.ajax("/api.php",
this.is_small = false;
localStorage.setItem("custom_dmns_is_small",false);
}
Mascot2.prototype.Show = function()
{
if(this.is_show) return;
this.is_show = true;
var select = this.imgSrc;
var wrap_div = document.createElement("div");
this.mascot_img_html = document.createElement("img");
this.mascot_img_html.obj = this;
if(localStorage.getItem("custom_dmns_is_small") == "true")
{
{
data:param,
this.ToSmall();
dataType:"json"
}
})
else
.done(function(res)
{
{
var list_o = res.query.notifications.list;
this.ToBig();
var list = [];
}
for(var key in list_o)
this.mascot_img_html.onload = function()
{
var obj = this.obj;
if(localStorage.getItem("custom_dmns_is_small") == "true")
{
obj.ToSmall();
}
else
{
{
list.push(list_o[key]);
obj.ToBig();
}
}
var unread_message = [];
if(obj.message_queue.length != 0)
for(var i = 0 ; i < list.length ; i++)
{
{
if(list[i].read == null && list[i].type != "page-linked")
obj._show_balloon();
{
unread_message.push(list[i]);
}
}
}
if(unread_message.length != 0)
$(".top_s_btn").css("display","none");
$("#to-top-btn").css("width",$(this).width()/2);
$("#hisyokan-bookmark").css("width",$(this).width()/2);
obj.is_loaded = true;
};
$(this.mascot_img_html).click(
function()
{
if(this.obj.is_small == false)
{
{
mascot.ShowMessage("<a href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full)  + "'>알림이 도착했어요</a>");
this.obj.ToSmall();
}
}
else
else
{
{
this.obj.ToBig();
}
}
});
});
this.mascot_img_html.src =  select.replace("bbs.","");
$(this.mascot_img_html).css("display","block");
$(wrap_div).css("position","fixed");
$(wrap_div).css("right","16px");
$(wrap_div).css("bottom","16px");
$(wrap_div).append(this.mascot_img_html);
$(wrap_div).append("<ul style='list-style:none;padding: 0px;margin:0px;display:inline;'><li style='float:left;'><a id='to-top-btn' href='#' style='text-align:center;display:inline-block;line-height:32px;width:100%;background-color:#000;color:#FFF;font-weight:bold;'>위로</a></li><li style='float:left;'> <a id='hisyokan-bookmark' href='#' style='text-align:center;display:inline-block;line-height:32px;width:100%;background-color:#000;color:#FFF;font-weight:bold;'>메뉴</a></li></ul>");
$(document.body).append(wrap_div);
document.getElementById("hisyokan-bookmark").obj = this;
$("#hisyokan-bookmark").click(
function()
{
var menu_list_h = document.createElement("ul");
$(menu_list_h).css("list-style","none");
$(menu_list_h).css("margin",0);
$(menu_list_h).css("padding",0);
var li = document.createElement("li");
var a_tag = document.createElement("a");
a_tag.href = "#";
a_tag.obj = this.obj;
$(a_tag).css("display","inline-block");
$(a_tag).css("line-height","16px");
$(a_tag).css("padding","2px");
$(a_tag).css("color","#FFF");
$(a_tag).html("이 페이지 등록");
$(a_tag).click(
function()
{
var link =  document.location.href;
var name = document.title;
name = name.replace(" - 리브레 위키","");
var bookmark = new BookmarkStorage();
bookmark.AddBookmark(name,link);
this.obj.CloseMessage();
this.obj.ShowMessage("등록되었습니다");
return false;
}
);
$(li).html(a_tag);
$(menu_list_h).append(li);
li = document.createElement("li");
a_tag = document.createElement("a");
a_tag.href = "#";
a_tag.obj = this.obj;
$(a_tag).css("display","inline-block");
$(a_tag).css("line-height","16px");
$(a_tag).css("padding","2px");
$(a_tag).css("color","#FFF");
$(a_tag).html("북마크 리스트");
$(a_tag).click(function(){
var bookmark = new BookmarkStorage();
this.obj.ShowMessageNow(GetHtmlList(bookmark.GetList()));
return false;
});
$(li).html(a_tag);
$(menu_list_h).append(li);
li = document.createElement("li");
a_tag = document.createElement("a");
a_tag.href = "#";
a_tag.obj = this.obj;
$(a_tag).css("display","inline-block");
$(a_tag).css("line-height","16px");
$(a_tag).css("padding","2px");
$(a_tag).css("color","#FFF");
$(a_tag).html("쌓인 메시지 지우기");
$(a_tag).click(function(){
this.obj.message_queue = [];
return false;
});
$(li).html(a_tag);
$(menu_list_h).append(li);
this.obj.ShowMessageNow(menu_list_h);
return false;
}
);
var ttttt = this.comments["대사"].split("\n");
this.ShowMessage(ttttt[randomRange(0,ttttt.length - 1)])
};
var user_name = mw.config.get("wgUserName");
param = null;
if(location.host.startsWith("bbs"))
{
param = {
data:{
action:"parse",
format:"json",
prop:"text|modules",
page:"사용자:"+user_name+"/비서함",
pst:"",
origin: window.location.origin
},
method:"POST",
dataType:"json",
crossDomain: true,
'xhrFields': {
'withCredentials': true
      }
};
}
else
{
param = {
data:{
action:"parse",
format:"json",
prop:"text|modules",
page:"사용자:"+user_name+"/비서함",
pst:""
},
method:"POST",
dataType:"json"
};
};
temp();
}
setInterval(temp,1000 * 20);
$.ajax("//librewiki.net/api.php",param).done(function(res){
 
ggg = {};
var temp = document.createElement("div");
temp.innerHTML = res.parse.text["*"];
var pres = temp.getElementsByTagName("pre");
var img = temp.getElementsByTagName("img");
 
for(var key in Object.keys(pres)){
  pres[key].id =decodeURI(pres[key].id.replace(/\./gi,"%").replace(/_/gi," ")) ;
  ggg[pres[key].id] = $(pres[key]).text();
 
}
damezuma_hisyokan = new Mascot2();
damezuma_hisyokan.imgSrc = img[0].src;
damezuma_hisyokan.comments = ggg;
damezuma_hisyokan.Show();
 
});

2018년 8월 27일 (월) 03:49 기준 최신판

function randomRange(n1, n2) {
  return Math.round( Math.random()  * 10000) % (n2 - n1) + n1;
}
var damezuma_hisyokan = null;
function Mascot2()
{
       
	this.is_loaded = false;
	this.is_show = false;
	this.mascot_img_list = [];
	this.message_queue =  [];
	this.now_balloon = null;
	this.is_small = false;
	this.imgSrc = "";
	this.comments = [];
		
}
Mascot2.prototype.CloseMessage = function()
{
 
	$(this.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});
	this.now_balloon = null;
	if(this.message_queue.length != 0)
	{
		this._show_balloon();
	}
};
Mascot2.prototype.ShowMessageNow = function(msg)
{
	this.message_queue.unshift(msg);
	if(this.is_show == false)
	{
		this.Show();
	}
	else{
		this.CloseMessage();
	}
	if(this.now_balloon == null && this.is_loaded == true)
	{
		this._show_balloon();
	}
};
Mascot2.prototype._show_balloon = function()
{
	this.now_balloon = document.createElement("div");
	$(this.now_balloon).css("position","fixed");
	$(this.now_balloon).css("display","none");
	$(this.now_balloon).html(this.message_queue[0]);
	$(this.now_balloon).css("background-color","#000");
	$(this.now_balloon).css("color","#FFF");
	$(this.now_balloon).css("max-width","225px");
	$(this.now_balloon).css("padding","16px");
	$(document.body).append(this.now_balloon);
 
	$(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);
 
	$(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);
	$(this.now_balloon).css("border-radius",5);
	$(this.now_balloon).fadeIn(1000);
	this.message_queue.shift();
	this.now_balloon.obj = this;
	$(this.now_balloon).click
	(
	function()
	{
		var obj = this.obj;
		$(obj.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});
		obj.now_balloon = null;
		if(obj.message_queue.length != 0)
		{
			obj._show_balloon();
		}
	}
	);
 
};
Mascot2.prototype.ShowMessage = function(msg)
{
	this.message_queue.push(msg);
 
	if(this.is_show == false)
	{
		this.Show();
	}
	if(this.now_balloon == null && this.is_loaded == true)
	{
		this._show_balloon();
	}
};
Mascot2.prototype.ToSmall = function()
{
	$(this.mascot_img_html).css("width",96);
	if(this.now_balloon != null)
	{
		$(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);
		$(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);
	}
	$("#to-top-btn").css("width",$(this.mascot_img_html).width()/2);
	$("#hisyokan-bookmark").css("width",$(this.mascot_img_html).width()/2);
	this.is_small = true;
	localStorage.setItem("custom_dmns_is_small",true);
};
Mascot2.prototype.ToBig = function()
{
	$(this.mascot_img_html).css("width",256);
	if(this.now_balloon != null)
	{
		$(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);
		$(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);
	}
	$("#to-top-btn").css("width",$(this.mascot_img_html).width()/2);
	$("#hisyokan-bookmark").css("width",$(this.mascot_img_html).width()/2);
 
	this.is_small = false;
	localStorage.setItem("custom_dmns_is_small",false);
}
Mascot2.prototype.Show = function()
{
	if(this.is_show) return;
	this.is_show = true;
	var select = this.imgSrc;
	var wrap_div = document.createElement("div");
	this.mascot_img_html = document.createElement("img");
	this.mascot_img_html.obj = this;
	if(localStorage.getItem("custom_dmns_is_small") == "true")
	{
			this.ToSmall();
	}
	else
	{
			this.ToBig();
	}
	this.mascot_img_html.onload = function()
	{
		var obj = this.obj;
		if(localStorage.getItem("custom_dmns_is_small") == "true")
		{
			obj.ToSmall();
		}
		else
		{
			obj.ToBig();
		}
		if(obj.message_queue.length != 0)
		{
			obj._show_balloon();
		}
		$(".top_s_btn").css("display","none");
		$("#to-top-btn").css("width",$(this).width()/2);
		$("#hisyokan-bookmark").css("width",$(this).width()/2);
		obj.is_loaded = true;
	};
	$(this.mascot_img_html).click(
	function()
	{
		if(this.obj.is_small == false)
		{
			this.obj.ToSmall();
		}
		else
		{
			this.obj.ToBig();
		}
	});
 
	this.mascot_img_html.src =  select.replace("bbs.","");
 
	$(this.mascot_img_html).css("display","block");
	$(wrap_div).css("position","fixed");
	$(wrap_div).css("right","16px");
	$(wrap_div).css("bottom","16px");
	$(wrap_div).append(this.mascot_img_html);
	$(wrap_div).append("<ul style='list-style:none;padding: 0px;margin:0px;display:inline;'><li style='float:left;'><a id='to-top-btn' href='#' style='text-align:center;display:inline-block;line-height:32px;width:100%;background-color:#000;color:#FFF;font-weight:bold;'>위로</a></li><li style='float:left;'> <a id='hisyokan-bookmark' href='#' style='text-align:center;display:inline-block;line-height:32px;width:100%;background-color:#000;color:#FFF;font-weight:bold;'>메뉴</a></li></ul>");
	$(document.body).append(wrap_div);
	document.getElementById("hisyokan-bookmark").obj = this;
	$("#hisyokan-bookmark").click(
	function()
	{
		var menu_list_h = document.createElement("ul");
		$(menu_list_h).css("list-style","none");
		$(menu_list_h).css("margin",0);
		$(menu_list_h).css("padding",0);
 
		var li = document.createElement("li");
		var a_tag = document.createElement("a");
		a_tag.href = "#";
		a_tag.obj = this.obj;
		$(a_tag).css("display","inline-block");
		$(a_tag).css("line-height","16px");
		$(a_tag).css("padding","2px");
		$(a_tag).css("color","#FFF");
		$(a_tag).html("이 페이지 등록");
		$(a_tag).click(
		function()
		{
			var link =  document.location.href;
			var name = document.title;
			name = name.replace(" - 리브레 위키","");
			var bookmark = new BookmarkStorage();
			bookmark.AddBookmark(name,link);
			this.obj.CloseMessage();
			this.obj.ShowMessage("등록되었습니다");
			return false;
		}
		);
		$(li).html(a_tag);
		$(menu_list_h).append(li);
 
		li = document.createElement("li");
		a_tag = document.createElement("a");
		a_tag.href = "#";
		a_tag.obj = this.obj;
		$(a_tag).css("display","inline-block");
		$(a_tag).css("line-height","16px");
		$(a_tag).css("padding","2px");
		$(a_tag).css("color","#FFF");
		$(a_tag).html("북마크 리스트");
		$(a_tag).click(function(){
 
			var bookmark = new BookmarkStorage();
			this.obj.ShowMessageNow(GetHtmlList(bookmark.GetList()));
			return false;
		});
		$(li).html(a_tag);
		$(menu_list_h).append(li);
 
		li = document.createElement("li");
		a_tag = document.createElement("a");
		a_tag.href = "#";
		a_tag.obj = this.obj;
		$(a_tag).css("display","inline-block");
		$(a_tag).css("line-height","16px");
		$(a_tag).css("padding","2px");
		$(a_tag).css("color","#FFF");
		$(a_tag).html("쌓인 메시지 지우기");
		$(a_tag).click(function(){
			this.obj.message_queue = [];
			return false;
		});
		$(li).html(a_tag);
		$(menu_list_h).append(li);
 
		this.obj.ShowMessageNow(menu_list_h);
		return false;
	}
	);
	var ttttt = this.comments["대사"].split("\n");
	this.ShowMessage(ttttt[randomRange(0,ttttt.length - 1)])
 
	
};

var user_name = mw.config.get("wgUserName");
param = null;
if(location.host.startsWith("bbs"))
{
param = {
	data:{
		action:"parse",
		format:"json",
		prop:"text|modules",
		page:"사용자:"+user_name+"/비서함",
		pst:"",
		origin: window.location.origin
	},
	method:"POST",
	dataType:"json",
	crossDomain: true,
	'xhrFields': {
		'withCredentials': true
      }
};
 }
else
{
param = {
	data:{
		action:"parse",
		format:"json",
		prop:"text|modules",
		page:"사용자:"+user_name+"/비서함",
		pst:""
	},
	method:"POST",
	dataType:"json"
};
}
$.ajax("//librewiki.net/api.php",param).done(function(res){

ggg = {};
var temp = document.createElement("div");
temp.innerHTML = res.parse.text["*"];
var pres = temp.getElementsByTagName("pre");
var img = temp.getElementsByTagName("img");

for(var key in Object.keys(pres)){
  pres[key].id =decodeURI(pres[key].id.replace(/\./gi,"%").replace(/_/gi," ")) ;
  ggg[pres[key].id] = $(pres[key]).text();
			  
}
damezuma_hisyokan = new Mascot2();
damezuma_hisyokan.imgSrc = img[0].src;
damezuma_hisyokan.comments = ggg;
damezuma_hisyokan.Show();

});