사용자:CrMT/common.js: 두 판 사이의 차이

잔글 (집에서 하기에 너무 눈치 보여서 (...))
잔글 (문서를 비움)
1번째 줄: 1번째 줄:
/* user:다메즈마 */
/*
function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
}


function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
    }
    return "";
}
function randomRange(n1, n2) {
  return Math.floor( (Math.random() * (n2 - n1)) + n1 );
}
if($(document).width() > 1000)
{
var akarin =
{
img:"http://a2.img.mobypicture.com/8622e6c3bff4bdfc59f55a6fd6a92dba_view.jpg",
};
var ayase =
{
img:"http://pds26.egloos.com/pds/201305/12/49/b0012149_518ea3bd93d70.jpg",
};
var mascot_list =
[
akarin,
ayase,
];
var select = mascot_list[randomRange(0,mascot_list.length)];
var comment = select.comment;
var wrap_div = document.createElement("div");
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()
{
}
this.mascot_img_html.src = select.img;
$(wrap_div).css("position","fixed");
$(wrap_div).css("right","16px");
$(wrap_div).css("bottom","16px");
$(wrap_div).append(this.mascot_img_html);
$(this.mascot_img_html).css("display","block");
if(getCookie("custom_dmns_is_small") == "true")
{
$(this.mascot_img_html).css("height",128);
this.mascot_img_html.is_small = true;
}
else
{
$(this.mascot_img_html).css("height",256);
this.mascot_img_html.is_small = false;
}
$(wrap_div).append("<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>");
$(document.body).append(wrap_div);
$(document.body).append(this.balloon);
this.mascot_img_html.object = this;
$(this.mascot_img_html).click(function()
{
if(this.is_small == false)
{
this.object.ToSmall();
}
else
{
this.object.ToBig();
}
});
$(this.balloon).click(function(){
$(this).fadeOut();
});
}
Mascot.prototype.ShowMessage = function(msg)
{
$(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.mascot_img_html).height()/2 +32 - $(this.balloon).height()/2);
$(this.balloon).css("right",$(this.mascot_img_html).width() + 32);
$(this.balloon).css("border-radius",5);
$(this.balloon).html(msg);
$(this.balloon).fadeIn();
};
Mascot.prototype.Hide = function()
{
$(this.balloon).fadeOut();
};
Mascot.prototype.ToSmall = function()
{
$(this.mascot_img_html).css("height",128);
$(this.balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.balloon).height()/2 + 32);
$(this.balloon).css("right",$(this.mascot_img_html).width() + 32);
$("#to-top-btn").css("width",$(this.mascot_img_html).width());
this.mascot_img_html.is_small = true;
setCookie("custom_dmns_is_small",true,1);
};
Mascot.prototype.ToBig = function()
{
$(this.mascot_img_html).css("height",256);
$(this.balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.balloon).height()/2 + 32);
$(this.balloon).css("right",$(this.mascot_img_html).width() + 32);
$("#to-top-btn").css("width",$(this.mascot_img_html).width());
this.mascot_img_html.is_small = false;
setCookie("custom_dmns_is_small",false,1);
}
var mascot = new Mascot();
var temp = function(){
var param =
{
"action":"query",
"meta":"notifications",
"notlimit":10,
"format":"json"
};
$.ajax("/api.php",
{
data:param,
dataType:"json"
})
.done(function(res)
{
var list_o = res.query.notifications.list;
var list = [];
for(var key in list_o)
{
list.push(list_o[key]);
}
var unread_message = [];
for(var i = 0 ; i < list.length ; i++)
{
if(list[i].read == null && list[i].type != "page-linked")
{
unread_message.push(list[i]);
}
}
if(unread_message.length != 0)
{
mascot.ShowMessage("<a href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full)  + "'>알림이 도착했어요</a>");
}
else
{
}
});
};
temp();
setInterval(temp,1000 * 20);
*/

2016년 10월 23일 (일) 13:49 판