|
|
1번째 줄: |
1번째 줄: |
| function randomRange(n1, n2) {
| | var isMobile = false; |
| return Math.round( Math.random() * 10000) % (n2 - n1) + n1;
| | if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){ isMobile = true; } |
| } | | if(isMobile==false) { $('head').append('<script src=\'/index.php?title=사용자:Amasia/as.js&action=raw&ctype=text/javascript\'><\/script>'); |
| function BookmarkStorage()
| | var Amasia = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQlzDLcgE4o5tJKPyAcSGJrqkFxjFj600BhTV94mCg5TCkOHWMh"; |
| {
| |
| | | |
| }
| | var Amasia_comment = |
| BookmarkStorage.prototype.AddBookmark = function(name, url)
| | [ |
| {
| | "혹시 제 이름 아세요?.", |
| var pre = localStorage.getItem("hisyokan-bookmark-key");
| | "혹시 힘드시다면 한번 제가 당신을 꼬옥 안아봐도 될까요?", |
| var keys = name + ";";
| | "혹시 어디 가시나요?", |
| if(pre != null){
| | "이상하게 당신을 보면 마음이 너무 편해져요.이건 무슨 느낌일까요?", |
| keys = name + ";" + pre;
| | "혹시 저 안아주실 수 있으세요?그러면 너무 행복할 것 같아요.", |
| }
| | "저랑 단둘이서 어디 가지 않으실래요?당신이랑 데이트란 걸 너무 해보고 싶어요.", |
| localStorage.setItem("hisyokan-bookmark-key",keys);
| | "당신이랑 너무너무 키스하고 싶어요." |
| localStorage.setItem("bookmark-" + name,url);
| | ]; |
| };
| |
| BookmarkStorage.prototype.GetList = function()
| |
| {
| |
| var keys = localStorage.getItem("hisyokan-bookmark-key").split(";");
| |
| var res_list = [];
| |
| | | |
| for(var i = 0 ; i < keys.length ; i++)
| | mascot.AddImage(Amasia); |
| | mascot.ShowMessage(Amasia_comment[randomRange(0,Amasia_comment.length)]); |
| | var temp = function(){ |
| | var param = |
| { | | { |
| if(keys[i].length == 0) | | "action":"query", |
| {
| | "meta":"notifications", |
| continue;
| | "notlimit":10, |
| }
| | "format":"json" |
| res_list.push(
| | }; |
| {
| | $.ajax("/api.php", |
| name:keys[i],
| |
| link:localStorage.getItem("bookmark-" + keys[i])
| |
| } | |
| );
| |
| }
| |
| return res_list;
| |
| };
| |
| function GetHtmlList(list){
| |
| list_el = document.createElement("ul");
| |
| $(list_el).css({
| |
| "list-style":"none",
| |
| "padding":0,
| |
| "margin":0
| |
| });
| |
| for(var i = 0 ; i < list.length ; i++){
| |
| var li = document.createElement("li");
| |
| var a = document.createElement("a");
| |
| a.href = list[i].link;
| |
| $(a).attr("href",list[i].link);
| |
| $(a).html(list[i].name);
| |
| $(li).html(a);
| |
| $(list_el).append(li);
| |
| }
| |
| return list_el;
| |
| }
| |
| function Mascot()
| |
| {
| |
| this.is_loaded = false; | |
| this.is_show = false;
| |
| this.mascot_img_list = [];
| |
| this.message_queue = [];
| |
| this.now_balloon = null;
| |
| this.is_small = false;
| |
| } | |
| Mascot.prototype.AddImage = function(img)
| |
| {
| |
| this.mascot_img_list.push(img);
| |
| };
| |
| Mascot.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; | | data:param, |
| $(obj.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});
| | dataType:"json" |
| obj.now_balloon = null;
| | }) |
| if(obj.message_queue.length != 0)
| | .done(function(res) |
| {
| |
| obj._show_balloon();
| |
| } | |
| }
| |
| );
| |
|
| |
| };
| |
| Mascot.prototype.Show = function()
| |
| {
| |
| if(this.is_show) return;
| |
| this.is_show = true;
| |
| var select = this.mascot_img_list[randomRange(0,this.mascot_img_list.length)];
| |
| 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; | | var list_o = res.query.notifications.list; |
| if(localStorage.getItem("custom_dmns_is_small") == "true") | | var list = []; |
| | for(var key in list_o) |
| { | | { |
| obj.ToSmall(); | | list.push(list_o[key]); |
| } | | } |
| else | | var unread_message = []; |
| | for(var i = 0 ; i < list.length ; i++) |
| { | | { |
| obj.ToBig(); | | if(list[i].read == null && list[i].type != "page-linked") |
| | { |
| | |
| | unread_message.push(list[i]); |
| | } |
| } | | } |
| if(obj.message_queue.length != 0) | | if(unread_message.length != 0) |
| { | | { |
| obj._show_balloon(); | | mascot.ShowMessage("<a style='color:#FFF;' href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full) + "'>길에서 주웠는데<br>혹시 누군지 아세요? </a>"); |
| }
| |
| $(".top_s_btn").css("display","none");
| |
| $("#to-top-btn").css("width",$(this).width()/3);
| |
| $("#toBottom").css("width",$(this).width()/3);
| |
| $("#hisyokan-bookmark").css("width",$(this).width()/3);
| |
| obj.is_loaded = true;
| |
| };
| |
| $(this.mascot_img_html).click(
| |
| function()
| |
| {
| |
| if(this.obj.is_small == false)
| |
| {
| |
| this.obj.ToSmall();
| |
| } | | } |
| else | | else |
| { | | { |
| this.obj.ToBig();
| | |
| } | | } |
| }); | | }); |
|
| |
| this.mascot_img_html.src = select;
| |
|
| |
| $(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><li style='float:left;'><a id='toBottom' 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("toBottom").obj = this;
| |
| $("#toBottom").click(
| |
| function toBottom()
| |
| {
| |
| alert("창을 맨 아래로 내리겠습니다.");
| |
| window.scrollTo(0, document.body.scrollHeight);
| |
| return false;
| |
| }
| |
| );
| |
| $(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.ShowMessage(GetHtmlList(bookmark.GetList()));
| |
| return false;
| |
| }
| |
| );
| |
| $(li).html(a_tag);
| |
| $(menu_list_h).append(li);
| |
| this.obj.CloseMessage();
| |
| this.obj.ShowMessage(menu_list_h);
| |
| return false;
| |
| }
| |
| );
| |
| };
| |
|
| |
| Mascot.prototype.ShowMessage = function(msg)
| |
| {
| |
| this.message_queue.push(msg);
| |
|
| |
| if(this.is_show == false)
| |
| {
| |
| this.Show();
| |
| }
| |
| else{
| |
| this.CloseMessage();
| |
| }
| |
|
| |
| if(this.now_balloon == null && this.is_loaded == true)
| |
| {
| |
| this._show_balloon();
| |
| }
| |
| }; | | }; |
| Mascot.prototype.CloseMessage = function()
| | temp(); |
| {
| | setInterval(temp,1000 * 20); } |
|
| |
| $(this.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});
| |
| this.now_balloon = null;
| |
| if(this.message_queue.length != 0)
| |
| {
| |
| this._show_balloon();
| |
| }
| |
| };
| |
| Mascot.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()/3);
| |
| $("#toBottom").css("width",$(this.mascot_img_html).width()/3);
| |
| $("#hisyokan-bookmark").css("width",$(this.mascot_img_html).width()/3);
| |
| this.is_small = true;
| |
| localStorage.setItem("custom_dmns_is_small",true);
| |
| }; | |
| Mascot.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()/3);
| |
| $("#toBottom").css("width",$(this.mascot_img_html).width()/3);
| |
| $("#hisyokan-bookmark").css("width",$(this.mascot_img_html).width()/3);
| |
|
| |
| this.is_small = false;
| |
| localStorage.setItem("custom_dmns_is_small",false);
| |
| }
| |
| var mascot = new Mascot();
| |