편집 후 새 문서의 위키텍스트 (new_wikitext) | '/*
마스코트 클래스 및 그 객체를 생성한다. 객체의 이름은 mascot.
*/
function randomRange(n1, n2) {
return Math.round( Math.random() * 10000) % (n2 - n1) + n1;
}
function BookmarkStorage()
{
}
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++)
{
if(keys[i].length == 0)
{
continue;
}
res_list.push(
{
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;
$(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);
$("#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;
$(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.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()
{
$(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);
$("#hisyokan-bookmark").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);
$("#hisyokan-bookmark").css("width",$(this.mascot_img_html).width()/2);
this.is_small = false;
localStorage.setItem("custom_dmns_is_small",false);
}
var mascot = new Mascot();' |
편집 중 추가된 줄 (added_lines) | [
0 => '/*',
1 => '마스코트 클래스 및 그 객체를 생성한다. 객체의 이름은 mascot.',
2 => '*/',
3 => 'function randomRange(n1, n2) {',
4 => ' return Math.round( Math.random() * 10000) % (n2 - n1) + n1;',
5 => '}',
6 => 'function BookmarkStorage()',
7 => '{',
8 => ' ',
9 => '}',
10 => 'BookmarkStorage.prototype.AddBookmark = function(name, url)',
11 => '{',
12 => ' var pre = localStorage.getItem("hisyokan-bookmark-key");',
13 => ' var keys = name + ";";',
14 => ' if(pre != null){',
15 => ' keys = name + ";" + pre;',
16 => ' }',
17 => ' localStorage.setItem("hisyokan-bookmark-key",keys);',
18 => ' localStorage.setItem("bookmark-" + name,url);',
19 => '};',
20 => 'BookmarkStorage.prototype.GetList = function()',
21 => '{',
22 => ' var keys = localStorage.getItem("hisyokan-bookmark-key").split(";");',
23 => ' var res_list = [];',
24 => ' ',
25 => ' for(var i = 0 ; i < keys.length ; i++)',
26 => ' {',
27 => ' if(keys[i].length == 0)',
28 => ' {',
29 => ' continue;',
30 => ' }',
31 => ' res_list.push(',
32 => ' {',
33 => ' name:keys[i],',
34 => ' link:localStorage.getItem("bookmark-" + keys[i])',
35 => ' }',
36 => ' );',
37 => ' }',
38 => ' return res_list;',
39 => '};',
40 => ' function GetHtmlList(list){',
41 => ' list_el = document.createElement("ul");',
42 => ' $(list_el).css({',
43 => ' "list-style":"none",',
44 => ' "padding":0,',
45 => ' "margin":0',
46 => ' });',
47 => ' for(var i = 0 ; i < list.length ; i++){',
48 => ' var li = document.createElement("li");',
49 => ' var a = document.createElement("a");',
50 => ' a.href = list[i].link;',
51 => ' $(a).attr("href",list[i].link);',
52 => ' $(a).html(list[i].name);',
53 => ' $(li).html(a);',
54 => ' $(list_el).append(li);',
55 => ' }',
56 => ' return list_el;',
57 => ' }',
58 => 'function Mascot()',
59 => '{',
60 => ' this.is_loaded = false;',
61 => ' this.is_show = false;',
62 => ' this.mascot_img_list = [];',
63 => ' this.message_queue = [];',
64 => ' this.now_balloon = null;',
65 => ' this.is_small = false;',
66 => '}',
67 => 'Mascot.prototype.AddImage = function(img)',
68 => '{',
69 => ' this.mascot_img_list.push(img);',
70 => '};',
71 => 'Mascot.prototype._show_balloon = function()',
72 => '{',
73 => ' this.now_balloon = document.createElement("div");',
74 => ' $(this.now_balloon).css("position","fixed");',
75 => ' $(this.now_balloon).css("display","none");',
76 => ' $(this.now_balloon).html(this.message_queue[0]);',
77 => ' $(this.now_balloon).css("background-color","#000");',
78 => ' $(this.now_balloon).css("color","#FFF");',
79 => ' $(this.now_balloon).css("max-width","225px");',
80 => ' $(this.now_balloon).css("padding","16px");',
81 => ' $(document.body).append(this.now_balloon);',
82 => ' ',
83 => ' $(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);',
84 => ' ',
85 => ' $(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);',
86 => ' $(this.now_balloon).css("border-radius",5);',
87 => ' $(this.now_balloon).fadeIn(1000);',
88 => ' this.message_queue.shift();',
89 => ' this.now_balloon.obj = this;',
90 => ' $(this.now_balloon).click',
91 => ' (',
92 => ' function()',
93 => ' {',
94 => ' var obj = this.obj;',
95 => ' $(obj.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});',
96 => ' obj.now_balloon = null;',
97 => ' if(obj.message_queue.length != 0)',
98 => ' {',
99 => ' obj._show_balloon();',
100 => ' }',
101 => ' }',
102 => ' );',
103 => ' ',
104 => '};',
105 => 'Mascot.prototype.Show = function()',
106 => '{',
107 => ' if(this.is_show) return;',
108 => ' this.is_show = true;',
109 => ' var select = this.mascot_img_list[randomRange(0,this.mascot_img_list.length)];',
110 => ' var wrap_div = document.createElement("div");',
111 => ' this.mascot_img_html = document.createElement("img");',
112 => ' this.mascot_img_html.obj = this;',
113 => ' if(localStorage.getItem("custom_dmns_is_small") == "true")',
114 => ' {',
115 => ' this.ToSmall();',
116 => ' }',
117 => ' else',
118 => ' {',
119 => ' this.ToBig();',
120 => ' }',
121 => ' this.mascot_img_html.onload = function()',
122 => ' {',
123 => ' var obj = this.obj;',
124 => ' if(localStorage.getItem("custom_dmns_is_small") == "true")',
125 => ' {',
126 => ' obj.ToSmall();',
127 => ' }',
128 => ' else',
129 => ' {',
130 => ' obj.ToBig();',
131 => ' }',
132 => ' if(obj.message_queue.length != 0)',
133 => ' {',
134 => ' obj._show_balloon();',
135 => ' }',
136 => ' $(".top_s_btn").css("display","none");',
137 => ' $("#to-top-btn").css("width",$(this).width()/2);',
138 => ' $("#hisyokan-bookmark").css("width",$(this).width()/2);',
139 => ' obj.is_loaded = true;',
140 => ' };',
141 => ' $(this.mascot_img_html).click(',
142 => ' function()',
143 => ' {',
144 => ' if(this.obj.is_small == false)',
145 => ' {',
146 => ' this.obj.ToSmall();',
147 => ' }',
148 => ' else',
149 => ' {',
150 => ' this.obj.ToBig();',
151 => ' }',
152 => ' });',
153 => ' ',
154 => ' this.mascot_img_html.src = select;',
155 => ' ',
156 => ' $(this.mascot_img_html).css("display","block");',
157 => ' $(wrap_div).css("position","fixed");',
158 => ' $(wrap_div).css("right","16px");',
159 => ' $(wrap_div).css("bottom","16px");',
160 => ' $(wrap_div).append(this.mascot_img_html);',
161 => ' $(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>");',
162 => ' $(document.body).append(wrap_div);',
163 => ' document.getElementById("hisyokan-bookmark").obj = this;',
164 => ' $("#hisyokan-bookmark").click(',
165 => ' function()',
166 => ' {',
167 => ' var menu_list_h = document.createElement("ul");',
168 => ' $(menu_list_h).css("list-style","none");',
169 => ' $(menu_list_h).css("margin",0);',
170 => ' $(menu_list_h).css("padding",0);',
171 => ' ',
172 => ' var li = document.createElement("li");',
173 => ' var a_tag = document.createElement("a");',
174 => ' a_tag.href = "#";',
175 => ' a_tag.obj = this.obj;',
176 => ' $(a_tag).css("display","inline-block");',
177 => ' $(a_tag).css("line-height","16px");',
178 => ' $(a_tag).css("padding","2px");',
179 => ' $(a_tag).css("color","#FFF");',
180 => ' $(a_tag).html("이 페이지 등록");',
181 => ' $(a_tag).click(',
182 => ' function()',
183 => ' {',
184 => ' var link = document.location.href;',
185 => ' var name = document.title;',
186 => ' name = name.replace(" - 리브레 위키","");',
187 => ' var bookmark = new BookmarkStorage();',
188 => ' bookmark.AddBookmark(name,link);',
189 => ' this.obj.CloseMessage();',
190 => ' this.obj.ShowMessage("등록되었습니다");',
191 => ' return false;',
192 => ' }',
193 => ' );',
194 => ' $(li).html(a_tag);',
195 => ' $(menu_list_h).append(li);',
196 => ' ',
197 => ' li = document.createElement("li");',
198 => ' a_tag = document.createElement("a");',
199 => ' a_tag.href = "#";',
200 => ' a_tag.obj = this.obj;',
201 => ' $(a_tag).css("display","inline-block");',
202 => ' $(a_tag).css("line-height","16px");',
203 => ' $(a_tag).css("padding","2px");',
204 => ' $(a_tag).css("color","#FFF");',
205 => ' $(a_tag).html("북마크 리스트");',
206 => ' $(a_tag).click(',
207 => ' function()',
208 => ' {',
209 => ' var bookmark = new BookmarkStorage();',
210 => ' this.obj.ShowMessage(GetHtmlList(bookmark.GetList()));',
211 => ' return false;',
212 => ' }',
213 => ' );',
214 => ' $(li).html(a_tag);',
215 => ' $(menu_list_h).append(li);',
216 => ' this.obj.CloseMessage();',
217 => ' this.obj.ShowMessage(menu_list_h);',
218 => ' return false;',
219 => ' }',
220 => ' );',
221 => '};',
222 => 'Mascot.prototype.ShowMessage = function(msg)',
223 => '{',
224 => ' this.message_queue.push(msg);',
225 => ' ',
226 => ' if(this.is_show == false)',
227 => ' {',
228 => ' this.Show();',
229 => ' }',
230 => ' else{',
231 => ' this.CloseMessage();',
232 => ' }',
233 => ' ',
234 => ' if(this.now_balloon == null && this.is_loaded == true)',
235 => ' {',
236 => ' this._show_balloon();',
237 => ' }',
238 => '};',
239 => 'Mascot.prototype.CloseMessage = function()',
240 => '{',
241 => ' ',
242 => ' $(this.now_balloon).fadeOut(1000).delay(1000,function(){$(this).remove();});',
243 => ' this.now_balloon = null;',
244 => ' if(this.message_queue.length != 0)',
245 => ' {',
246 => ' this._show_balloon();',
247 => ' }',
248 => '};',
249 => 'Mascot.prototype.ToSmall = function()',
250 => '{',
251 => ' $(this.mascot_img_html).css("width",96);',
252 => ' if(this.now_balloon != null)',
253 => ' {',
254 => ' $(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);',
255 => ' $(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);',
256 => ' }',
257 => ' $("#to-top-btn").css("width",$(this.mascot_img_html).width()/2);',
258 => ' $("#hisyokan-bookmark").css("width",$(this.mascot_img_html).width()/2);',
259 => ' this.is_small = true;',
260 => ' localStorage.setItem("custom_dmns_is_small",true);',
261 => '};',
262 => 'Mascot.prototype.ToBig = function()',
263 => '{',
264 => ' $(this.mascot_img_html).css("width",256);',
265 => ' if(this.now_balloon != null)',
266 => ' {',
267 => ' $(this.now_balloon).css("bottom",$(this.mascot_img_html).height()/2 +16 - $(this.now_balloon).height()/2 + 32);',
268 => ' $(this.now_balloon).css("right",$(this.mascot_img_html).width() + 32);',
269 => ' }',
270 => ' $("#to-top-btn").css("width",$(this.mascot_img_html).width()/2);',
271 => ' $("#hisyokan-bookmark").css("width",$(this.mascot_img_html).width()/2);',
272 => ' ',
273 => ' this.is_small = false;',
274 => ' localStorage.setItem("custom_dmns_is_small",false);',
275 => '}',
276 => 'var mascot = new Mascot();'
] |