편집 후 새 문서의 위키텍스트 (new_wikitext) | '//<!--[[사용자:다메즈마/mascot notification.js]]에서 이츠레아 부분 삭제-->
//<!--[[사용자:다메즈마/hisyokan.js]]을 변형한 [[사용자:Skim/secretary.js]] 사용-->
function randomRange(n1, n2) {
return Math.round( Math.random() * 10000) % (n2 - n1) + n1;
}
function Mascot()
{
this.is_loaded = false;
this.is_show = false;
this.mascot_img_list = [];
this.message_queue = [];
this.now_balloon = null;
this.is_small = true;
}
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;
$(obj.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});
obj.now_balloon = null;
if(obj.message_queue.length != 0)
{
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;
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);
$("#to-bottom-btn").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;
$(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='to-bottom-btn' 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);
$("#to-top-btn").click(
function()
{$('html, body').animate({scrollTop:0}, 'slow');}
);
$("#to-bottom-btn").click(
function()
{$('html, body').animate({scrollTop:document.body.scrollHeight}, 'slow');}
);
};
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()
{
$(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()/2);
$("#to-bottom-btn").css("width",$(this.mascot_img_html).width()/2);
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()/2);
$("#to-bottom-btn").css("width",$(this.mascot_img_html).width()/2)
this.is_small = false;
localStorage.setItem("custom_dmns_is_small",false);
}
var mascot = new Mascot();
//마스코트를 수정하실 분은 이 부분 부터 변경하시면 됩니다.
$(document).ready(function(){
/*
아랫 줄 큰 따옴표(") 사이에 이미지 주소를 넣으면 이미지를 불러올 수 있습니다 (gif도 가능).
리브레 위키 내의 이미지의 경우 "https://librewiki.net"을 생략 가능하며, 외부 이미지는 이미지 주소를 다 쓰셔야합니다.
*/
var secretary1 = "http://cfile22.uf.tistory.com/image/145998354F23F60818F202"; //리디버그
//var secretary2 = "/images/8/8b/리브라_대반달.png"; //리브라1
//var secretary3 = "/images/d/d3/백팩커리브라.png"; //리브라2
//var secretary4 = "/images/b/be/리브렌_100.png"; //리브렌
/*
마스코트의 코멘트는 아래 대괄호 안의 문장을 바꾸시면 됩니다.
문장을 추가할 시에는 콤마(,)를 넣어야 합니다.
*/
var secretary1_comment =
[
"삑! 위키러입니다.",
];
var secretary2_comment =
[
"한번만 더 '노브라'라고 하면 차단할테니 각오하세요",
];
var secretary3_comment =
[
"자 얼릉 문서수정하러 가자고",
];
var secretary4_comment =
[
"나 팩맨아니라고!",
];
var secretaries = [secretary1, secretary2, secretary3, secretary4];
var secretaries_comment = [secretary1_comment, secretary2_comment, secretary3_comment, secretary4_comment];
var index = randomRange(0,secretaries.length);
mascot.AddImage(secretaries[index]);
mascot.ShowMessage(secretaries_comment[index][randomRange(0,secretaries_comment[index].length)]);
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)
{//메세지 알람 멘트를 수정 하려면 '>와 </a>사이를 변경하세요.
if(index == 0)
{
mascot.ShowMessage("<a style='color:#FFF;' href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full) + "'>알림이 왔습니버그.</a>");
}
if(index == 1)
{
mascot.ShowMessage("<a style='color:#FFF;' href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full) + "'>알림이 왔어요.</a>");
}
if(index == 2)
{
mascot.ShowMessage("<a style='color:#FFF;' href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full) + "'>알림이 왔어요.</a>");
}
if(index == 3)
{
mascot.ShowMessage("<a style='color:#FFF;' href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full) + "'>알림이 왔어요.</a>");
}
}
});
};
temp();
setInterval(temp,1000 * 20);
});' |
편집 중 추가된 줄 (added_lines) | [
0 => '//<!--[[사용자:다메즈마/mascot notification.js]]에서 이츠레아 부분 삭제-->',
1 => '//<!--[[사용자:다메즈마/hisyokan.js]]을 변형한 [[사용자:Skim/secretary.js]] 사용-->',
2 => ' ',
3 => 'function randomRange(n1, n2) {',
4 => ' return Math.round( Math.random() * 10000) % (n2 - n1) + n1;',
5 => '}',
6 => ' ',
7 => 'function Mascot()',
8 => '{',
9 => ' this.is_loaded = false;',
10 => ' this.is_show = false;',
11 => ' this.mascot_img_list = [];',
12 => ' this.message_queue = [];',
13 => ' this.now_balloon = null;',
14 => ' this.is_small = true;',
15 => '}',
16 => ' ',
17 => 'Mascot.prototype.AddImage = function(img)',
18 => '{',
19 => ' this.mascot_img_list.push(img);',
20 => '};',
21 => ' ',
22 => 'Mascot.prototype._show_balloon = function()',
23 => '{',
24 => ' this.now_balloon = document.createElement("div");',
25 => ' $(this.now_balloon).css("position","fixed");',
26 => ' $(this.now_balloon).css("display","none");',
27 => ' $(this.now_balloon).html(this.message_queue[0]);',
28 => ' $(this.now_balloon).css("background-color","#000");',
29 => ' $(this.now_balloon).css("color","#FFF");',
30 => ' $(this.now_balloon).css("max-width","225px");',
31 => ' $(this.now_balloon).css("padding","16px");',
32 => ' $(document.body).append(this.now_balloon);',
33 => ' ',
34 => ' $(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);',
35 => ' ',
36 => ' $(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);',
37 => ' $(this.now_balloon).css("border-radius",5);',
38 => ' $(this.now_balloon).fadeIn(1000);',
39 => ' this.message_queue.shift();',
40 => ' this.now_balloon.obj = this;',
41 => ' $(this.now_balloon).click',
42 => ' (',
43 => ' function()',
44 => ' {',
45 => ' var obj = this.obj;',
46 => ' $(obj.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});',
47 => ' obj.now_balloon = null;',
48 => ' if(obj.message_queue.length != 0)',
49 => ' {',
50 => ' obj._show_balloon();',
51 => ' }',
52 => ' }',
53 => ' );',
54 => '};',
55 => ' ',
56 => 'Mascot.prototype.Show = function()',
57 => '{',
58 => ' if(this.is_show) return;',
59 => ' this.is_show = true;',
60 => ' var select = this.mascot_img_list[randomRange(0,this.mascot_img_list.length)];',
61 => ' var wrap_div = document.createElement("div");',
62 => ' this.mascot_img_html = document.createElement("img");',
63 => ' this.mascot_img_html.obj = this;',
64 => ' if(localStorage.getItem("custom_dmns_is_small") == "true")',
65 => ' {',
66 => ' this.ToSmall();',
67 => ' }',
68 => ' else',
69 => ' {',
70 => ' this.ToBig();',
71 => ' }',
72 => ' this.mascot_img_html.onload = function()',
73 => ' {',
74 => ' var obj = this.obj;',
75 => ' if(localStorage.getItem("custom_dmns_is_small") == "true")',
76 => ' {',
77 => ' obj.ToSmall();',
78 => ' }',
79 => ' else',
80 => ' {',
81 => ' obj.ToBig();',
82 => ' }',
83 => ' if(obj.message_queue.length != 0)',
84 => ' {',
85 => ' obj._show_balloon();',
86 => ' }',
87 => ' $(".top_s_btn").css("display","none");',
88 => ' $("#to-top-btn").css("width",$(this).width()/2);',
89 => ' $("#to-bottom-btn").css("width",$(this).width()/2);',
90 => ' obj.is_loaded = true;',
91 => ' };',
92 => ' $(this.mascot_img_html).click(',
93 => ' function()',
94 => ' {',
95 => ' if(this.obj.is_small == false)',
96 => ' {',
97 => ' this.obj.ToSmall();',
98 => ' }',
99 => ' else',
100 => ' {',
101 => ' this.obj.ToBig();',
102 => ' }',
103 => ' });',
104 => ' ',
105 => ' this.mascot_img_html.src = select;',
106 => ' ',
107 => ' $(this.mascot_img_html).css("display","block");',
108 => ' $(wrap_div).css("position","fixed");',
109 => ' $(wrap_div).css("right","16px");',
110 => ' $(wrap_div).css("bottom","16px");',
111 => ' $(wrap_div).append(this.mascot_img_html);',
112 => ' $(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='to-bottom-btn' href='#' style='text-align:center;display:inline-block;line-height:32px;width:100%;background-color:#000;color:#FFF;font-weight:bold;'>아래로</a></li></ul>");',
113 => ' $(document.body).append(wrap_div);',
114 => ' $("#to-top-btn").click(',
115 => ' function()',
116 => ' {$('html, body').animate({scrollTop:0}, 'slow');}',
117 => ' );',
118 => ' ',
119 => ' $("#to-bottom-btn").click(',
120 => ' function()',
121 => ' {$('html, body').animate({scrollTop:document.body.scrollHeight}, 'slow');}',
122 => ' );',
123 => '};',
124 => ' ',
125 => 'Mascot.prototype.ShowMessage = function(msg)',
126 => '{',
127 => ' this.message_queue.push(msg);',
128 => ' ',
129 => ' if(this.is_show == false)',
130 => ' {',
131 => ' this.Show();',
132 => ' }',
133 => ' else{',
134 => ' this.CloseMessage();',
135 => ' }',
136 => ' ',
137 => ' if(this.now_balloon == null && this.is_loaded == true)',
138 => ' {',
139 => ' this._show_balloon();',
140 => ' }',
141 => '};',
142 => ' ',
143 => 'Mascot.prototype.CloseMessage = function()',
144 => '{',
145 => ' $(this.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});',
146 => ' this.now_balloon = null;',
147 => ' if(this.message_queue.length != 0)',
148 => ' {',
149 => ' this._show_balloon();',
150 => ' }',
151 => '};',
152 => ' ',
153 => 'Mascot.prototype.ToSmall = function()',
154 => '{',
155 => ' $(this.mascot_img_html).css("width",96);',
156 => ' if(this.now_balloon != null)',
157 => ' {',
158 => ' $(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);',
159 => ' $(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);',
160 => ' }',
161 => ' $("#to-top-btn").css("width",$(this.mascot_img_html).width()/2);',
162 => ' $("#to-bottom-btn").css("width",$(this.mascot_img_html).width()/2);',
163 => ' this.is_small = true;',
164 => ' localStorage.setItem("custom_dmns_is_small",true);',
165 => '};',
166 => ' ',
167 => 'Mascot.prototype.ToBig = function()',
168 => '{',
169 => ' $(this.mascot_img_html).css("width",256);',
170 => ' if(this.now_balloon != null)',
171 => ' {',
172 => ' $(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);',
173 => ' $(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);',
174 => ' }',
175 => ' $("#to-top-btn").css("width",$(this.mascot_img_html).width()/2);',
176 => ' $("#to-bottom-btn").css("width",$(this.mascot_img_html).width()/2)',
177 => ' this.is_small = false;',
178 => ' localStorage.setItem("custom_dmns_is_small",false);',
179 => '}',
180 => ' ',
181 => 'var mascot = new Mascot();',
182 => ' ',
183 => '//마스코트를 수정하실 분은 이 부분 부터 변경하시면 됩니다.',
184 => ' ',
185 => '$(document).ready(function(){',
186 => '/*',
187 => '아랫 줄 큰 따옴표(") 사이에 이미지 주소를 넣으면 이미지를 불러올 수 있습니다 (gif도 가능).',
188 => '리브레 위키 내의 이미지의 경우 "https://librewiki.net"을 생략 가능하며, 외부 이미지는 이미지 주소를 다 쓰셔야합니다.',
189 => '*/',
190 => ' ',
191 => 'var secretary1 = "http://cfile22.uf.tistory.com/image/145998354F23F60818F202"; //리디버그',
192 => '//var secretary2 = "/images/8/8b/리브라_대반달.png"; //리브라1',
193 => '//var secretary3 = "/images/d/d3/백팩커리브라.png"; //리브라2',
194 => '//var secretary4 = "/images/b/be/리브렌_100.png"; //리브렌',
195 => ' ',
196 => '/*',
197 => '마스코트의 코멘트는 아래 대괄호 안의 문장을 바꾸시면 됩니다.',
198 => '문장을 추가할 시에는 콤마(,)를 넣어야 합니다.',
199 => '*/',
200 => ' ',
201 => 'var secretary1_comment = ',
202 => '[',
203 => '"삑! 위키러입니다.",',
204 => '];',
205 => ' ',
206 => 'var secretary2_comment =',
207 => '[',
208 => '"한번만 더 '노브라'라고 하면 차단할테니 각오하세요",',
209 => '];',
210 => ' ',
211 => 'var secretary3_comment =',
212 => '[',
213 => '"자 얼릉 문서수정하러 가자고",',
214 => '];',
215 => ' ',
216 => 'var secretary4_comment =',
217 => '[',
218 => '"나 팩맨아니라고!",',
219 => '];',
220 => ' ',
221 => 'var secretaries = [secretary1, secretary2, secretary3, secretary4];',
222 => 'var secretaries_comment = [secretary1_comment, secretary2_comment, secretary3_comment, secretary4_comment];',
223 => 'var index = randomRange(0,secretaries.length);',
224 => ' ',
225 => 'mascot.AddImage(secretaries[index]);',
226 => 'mascot.ShowMessage(secretaries_comment[index][randomRange(0,secretaries_comment[index].length)]);',
227 => ' ',
228 => 'var temp = function(){',
229 => ' var param = ',
230 => ' {',
231 => ' "action":"query",',
232 => ' "meta":"notifications",',
233 => ' "notlimit":10,',
234 => ' "format":"json"',
235 => ' };',
236 => ' $.ajax("/api.php",',
237 => ' {',
238 => ' data:param,',
239 => ' dataType:"json"',
240 => ' })',
241 => ' .done(function(res)',
242 => ' {',
243 => ' var list_o = res.query.notifications.list;',
244 => ' var list = [];',
245 => ' for(var key in list_o)',
246 => ' {',
247 => ' list.push(list_o[key]);',
248 => ' }',
249 => ' var unread_message = [];',
250 => ' for(var i = 0 ; i < list.length ; i++)',
251 => ' {',
252 => ' if(list[i].read == null && list[i].type != "page-linked")',
253 => ' {',
254 => ' unread_message.push(list[i]);',
255 => ' }',
256 => ' }',
257 => ' if(unread_message.length != 0)',
258 => ' {//메세지 알람 멘트를 수정 하려면 '>와 </a>사이를 변경하세요.',
259 => ' ',
260 => ' if(index == 0)',
261 => ' {',
262 => ' mascot.ShowMessage("<a style='color:#FFF;' href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full) + "'>알림이 왔습니버그.</a>");',
263 => ' }',
264 => ' ',
265 => ' if(index == 1)',
266 => ' {',
267 => ' mascot.ShowMessage("<a style='color:#FFF;' href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full) + "'>알림이 왔어요.</a>");',
268 => ' }',
269 => ' ',
270 => ' if(index == 2)',
271 => ' {',
272 => ' mascot.ShowMessage("<a style='color:#FFF;' href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full) + "'>알림이 왔어요.</a>");',
273 => ' }',
274 => ' ',
275 => ' if(index == 3)',
276 => ' {',
277 => ' mascot.ShowMessage("<a style='color:#FFF;' href='/wiki/"+ encodeURIComponent(unread_message[unread_message.length - 1].title.full) + "'>알림이 왔어요.</a>");',
278 => ' }',
279 => ' }',
280 => ' });',
281 => '};',
282 => 'temp();',
283 => 'setInterval(temp,1000 * 20);',
284 => '});'
] |