<!--[
if
!IE]><!-->
<style>
button.btn {
margin-bottom: -4px;
margin-right: 3px;
background-color: white;
width: 20px !important;
padding: 4px;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
span.play {
border-color: transparent transparent transparent black;
border-style: solid;
border-width: 4px 0 4px 8px;
float: left;
height: 0px;
width: 0px;
text-indent: -999px;
}
</style>
<!--<![endif]-->
<h2>ChatBoxy v2.3</h2>
<span id=
"nameboxy"
style=
"font-weight: bold;"
onClick=
"chatboxy.name.change()"
>Ghost</span>
<input type=
"text"
id=
"c_msg"
style=
"padding-left:16px; width:400px;"
onkeypress=
"chatboxy.submit.enter(event)"
/>
<button id=
"sendboxy"
onClick=
"chatboxy.submit.send()"
>Send</button>
Color: <span id=
"colorboxy"
></span>
FPS: <input type=
"text"
id=
"fpsboxy"
style=
"width:40px"
value=
"1000"
onclick=
"select()"
onchange=
"chatboxy.cookie();"
/>(ms)
<hr style=
"border: thin dotted lightgrey;"
/>
<div id=
"chatboxy"
></div>
<script type=
"text/javascript"
>
var
chatboxy =
new
function
() {
var
nameboxy =
null
;
var
colorboxy =
null
;
var
fpsboxy =
null
;
var
lastmsg =
null
;
var
lastimer =
null
;
var
lastJUrl =
"YourLink1"
;
var
nowJUrl =
"YourLink2"
;
var
postUrl =
"https://docs.google.com/spreadsheet/formResponse?formkey=YourKey&ifq"
;
var
imgwait =
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTVA-utxy-xqQ3jVRVnd1kBgpibrm3GMwNIlJiN3oMX8exC1RRyio6MAO-eS98i4qsh9keJVH1yzLM7X-uN0a4uJqtJgMYtSVABZqul62N5paZtLk6W6PliF_u2W7PATLU4wDiRXbqaAOQ/"
;
var
imgdone =
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjdGBbw46KLNdYV9OC4PCkiJ3k2T8uNeoC50NjNo0qZ_GH2yEMYdaGtjBMJkW6CxR3_6HwotrumjT47QoZFB-KU96qpZCXN08mTZKHl4t0HBi1bTQOcSdhbceApFRpG91JTV2k27pb_4hV/"
;
var
imgerror =
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi01-qF-M5pyNPJHFlhuUkO6ZnqL_W92ClTH7kMQ5NNw-7NyzTOpZYZjyyxYtrtWrJrvDmuWqxykkzl4DqlzSU8usktT-GsdX7XKVbE1w8LT0iOu1-vNM6wtL2xl-5Ry_z4zFwx4YN4FMkU/s64/blocked_login.png"
;
var
picture = /^((((ht|f)tps?:\/\/)|(www.))[-a-zA-Z0-9@:%_\+.~
#?&//=]+)\.(jpg|jpeg|gif|png|bmp)/i
var
youtube = /^http:\/\/w{0,3}\.youtube[^
' '
\n\r]+/
var
hyperlink = /^(((ht|f)tps?:\/\/)|(www.))[a-zA-Z0-9_\-.:
#/~}?]+/i
return
{
getJsonp :
function
(url, func) {
var
cp = url.indexOf(
"callback=?"
);
var
today =
new
Date();
var
rnd = today.getFullYear() +
''
+
today.getMonth() +
''
+
today.getDate() +
''
+
today.getDay() +
''
+
today.getHours() +
''
+
today.getMinutes() +
''
+
today.getSeconds() +
''
+
Math.round(Math.random()*99);
var
rm = document.getElementById(
'scriptBoxy'
);
if
(rm) rm.parentNode.removeChild(rm);
var
script = document.createElement(
'script'
);
script.type =
'text/javascript'
;
script.id =
'scriptBoxy'
;
script.src = url.substring(0, cp)+
"callback="
+func+url.substring(cp+10, url.length)+
"&rnd="
+rnd;
document.getElementsByTagName(
'head'
)[0].appendChild(script);
},
lastscan :
function
(json) {
try
{
var
msg = json.feed.entry[0].title.$t+
''
+json.feed.entry[0].content.$t;
}
catch
(e) {
var
msg =
""
;
}
if
(json && lastmsg != msg) {
lastmsg = msg;
this
.getJsonp(nowJUrl,
'chatboxy.refresh'
);
}
else
{
this
.getJsonp(lastJUrl,
'chatboxy.delay'
);
}
},
delay :
function
(json) {
if
(lastimer) {
window.clearInterval(lastimer);
lastimer =
null
;
}
lastimer = window.setTimeout(
function
() {
chatboxy.lastscan(json);
}, fpsboxy);
},
refresh :
function
(json) {
var
title =
""
;
var
content =
""
;
var
name =
""
;
var
color =
""
;
var
date =
""
;
var
time =
""
;
var
chat =
""
;
var
output =
""
;
for
(
var
i = 0; i < json.feed.entry.length; ++i) {
title = json.feed.entry[i].title.$t;
content = json.feed.entry[i].content.$t;
date = content.substring(3, content.indexOf(
" "
,3));
time = content.substring(content.indexOf(
" "
,3), content.indexOf(
", c: @"
));
chat = content.substring(content.indexOf(
", c: @"
)+6, content.length);
name = title.substring(title.indexOf(
"@"
)+1, title.length);
color = title.substring(0, title.indexOf(
"@"
));
output += time +
"<span style=\"color:orange;\"> ‹ </span><span style=\"color:"
+ color +
";font-weight: bold;\">"
+
name +
"</span><span style=\"color:orange;\"> › </span> "
+
this
.msgFilter(chat) +
"<br />"
;
}
document.getElementById(
"chatboxy"
).innerHTML = output;
this
.lastscan();
},
msgFilter :
function
(msg) {
var
pos = 0;
var
nextpos = 0;
var
output =
""
;
for
(
var
i=0;nextpos!=-1;i++) {
nextpos = msg.indexOf(
" "
,pos+1);
str = msg.substring(pos, nextpos!=-1?nextpos:nextpos.length);
if
(picture.test(str)) {
var
reviseIE =
""
;
if
(navigator.userAgent.toLowerCase().indexOf(
"msie"
) == -1)
reviseIE =
"style=\"display:none;\""
;
output +=
"<img src=\""
+str+
"\""
+
"onerror=\"chatboxy.image.error(this)\""
+
"onload=\"chatboxy.image.resize(this);\""
+ reviseIE +
" />"
;
}
else
if
(youtube.test(str)) {
var
vp = str.indexOf(
"v="
) + 2;
var
v = str.substring(vp, str.indexOf(
"&"
, vp)!=-1?str.indexOf(
"&"
, vp):str.length);
output +=
" <button class=\"btn\" onclick=\"window.open('http://www.youtube.com/embed/"
+
v +
"?autoplay=1&loop=1&playlist="
+ v +
"', 'images', 'catalogmode, scrollbars, width=480, height=390')\" />"
+
"<span class=\"play\">Play</span></button>"
+
"<a target=\"_blank\" href=\"http://youtu.be/"
+ v +
"\">Youtu.be/"
+ v +
"</a>"
;
}
else
if
(hyperlink.test(str)) {
output +=
" <a target=\"_blank\" href=\""
+ str +
"\">"
+ str +
"</a>"
;
}
else
{
output +=
" "
+ str;
}
pos = nextpos + 1;
}
return
output;
},
image :
new
function
() {
return
{
resize :
function
(image) {
if
(
typeof
image.width !=
'undefined'
) {
var
w = image.width;
var
h = image.height;
image.removeAttribute(
'onload'
);
if
(w > 0 && h>0 && w <= 200 && h <=200) {
image.title =
"("
+w+
" x "
+h+
")"
;
if
(navigator.userAgent.toLowerCase().indexOf(
"msie"
) == -1)
image.style.display =
"inline"
;
}
else
if
(w > 200 && w < 800 && h > 200 && h < 600) {
image.title =
"(Size: "
+w+
" x "
+h+
")"
;
image.parentNode.insertBefore(document.createElement(
'br'
), image);
var
p = image.parentNode;
if
(p.lastChild == image) {
p.appendChild(document.createElement(
'br'
));
}
else
{
p.insertBefore(document.createElement(
'br'
), image.nextSibling);
}
if
(navigator.userAgent.toLowerCase().indexOf(
"msie"
) == -1)
image.style.display =
"inline"
;
}
else
{
image.title =
"(Size: "
+w+
" x "
+h+
") Open in New Window"
;
image.parentNode.insertBefore(document.createElement(
'br'
), image);
var
alink = document.createElement(
'a'
);
alink.target =
"_blank"
;
alink.href = image.src;
if
(h > w) {
w = w/h*600;
h = 600;
}
else
{
h = h/w*800;
w = 800;
}
image.width = w;
image.height = h;
if
(navigator.userAgent.toLowerCase().indexOf(
"msie"
) == -1)
image.style.display =
"inline"
;
alink.appendChild(image.cloneNode(
true
));
image.parentNode.replaceChild(alink, image);
}
}
},
error :
function
(image) {
image.removeAttribute(
'onload'
);
image.removeAttribute(
'onerror'
);
var
alink = document.createElement(
'a'
);
alink.target =
"_blank"
;
alink.href = image.src;
image.src = imgerror;
if
(navigator.userAgent.toLowerCase().indexOf(
"msie"
) == -1)
image.style.display =
"inline"
;
alink.appendChild(image.cloneNode(
true
));
image.parentNode.replaceChild(alink, image);
}
};
},
name :
new
function
() {
return
{
change :
function
() {
var
name = document.getElementById(
'nameboxy'
);
name.onclick =
function
(){};
name.innerHTML =
"<input type='text' style='text-align:center;width:80px;' "
+
"onmouseover='focus()' onfocus='select()' "
+
"onblur='chatboxy.name.mouse(this)' "
+
"onkeyup='chatboxy.name.keyboard(event,this)'"
+
"value='"
+ name.innerHTML +
"'>"
;
},
mouse :
function
(me) {
var
name = document.getElementById(
'nameboxy'
);
name.onclick = chatboxy.name.change;
name.innerHTML = me.value;
nameboxy = me.value;
chatboxy.cookie();
},
keyboard :
function
(e, me) {
e = e||window.event;
var
key = e.charCode||e.keyCode;
if
(key==13) {
this
.mouse(me);
}
}
};
},
color :
new
function
() {
return
{
create :
function
() {
var
bb =
""
;
var
thecolor = document.getElementById(
'colorboxy'
);
var
colors =
new
Array(
"Black"
,
"Hotpink"
,
"Tomato"
,
"Darkorange"
,
"Gold"
,
"Lime"
,
"Greenyellow"
,
"Green"
,
"Skyblue"
,
"Royalblue"
,
"Blue"
,
"Darkslateblue"
,
"Purple"
,
"Mediumorchid"
);
for
(
var
i=0;i<colors.length;i++) {
bb = colors[i] != colorboxy?
"0px solid"
:
"3px solid"
;
thecolor.innerHTML +=
"<div style='border-bottom: "
+ bb +
"; color: "
+
colors[i] +
"; display: inline; cursor: pointer;' onClick='chatboxy.color.change(this)' title='"
+ colors[i] +
"'>■</div> "
;
}
},
change :
function
(me) {
this
.clear();
me.style.borderBottom =
"3px solid"
;
colorboxy = me.title;
document.getElementById(
'nameboxy'
).style.color = colorboxy;
chatboxy.cookie();
},
clear :
function
() {
var
thecolor = document.getElementById(
'colorboxy'
);
var
colors = thecolor.getElementsByTagName(
'div'
);
for
(
var
i=0;i<colors.length;i++) {
colors[i].style.borderBottom =
"0px solid"
;
}
}
};
},
submit :
new
function
() {
return
{
send :
function
() {
var
msg = document.getElementById(
'c_msg'
).value;
var
params = {
'entry.0.single'
:colorboxy +
'@'
+nameboxy,
'entry.1.single'
:
'@'
+msg};
this
.wait();
this
.post(params);
},
enter :
function
(e) {
e = e||window.event;
var
key = e.charCode||e.keyCode;
if
(key==13) {
this
.send();
}
},
post :
function
(params) {
var
rm = document.getElementById(
'formBoxy'
);
if
(rm) rm.parentNode.removeChild(rm);
var
form = document.createElement(
'form'
);
form.target =
'iframeboxy'
;
form.id =
'formBoxy'
;
form.method =
'post'
;
form.action = postUrl;
for
(
var
key
in
params) {
var
input = document.createElement(
'input'
);
input.type =
'hidden'
;
input.name = key;
input.value = params[key];
form.appendChild(input);
}
document.getElementsByTagName(
'body'
)[0].appendChild(form);
form.submit();
},
wait :
function
() {
var
msg = document.getElementById(
'c_msg'
);
msg.style.background =
"url("
+ imgwait +
")"
;
msg.style.backgroundRepeat =
"no-repeat"
;
msg.disabled =
true
;
var
btn = document.getElementById(
'sendboxy'
);
btn.disabled =
true
;
},
done :
function
() {
var
msg = document.getElementById(
'c_msg'
);
msg.style.background =
"url("
+ imgdone +
")"
;
msg.style.backgroundRepeat =
"no-repeat"
;
msg.value =
""
;
msg.disabled =
false
;
var
btn = document.getElementById(
'sendboxy'
);
btn.disabled =
false
;
msg.select();
window.clearInterval(lastimer);
lastimer =
null
;
chatboxy.getJsonp(lastJUrl,
'chatboxy.lastscan'
);
}
};
},
fps :
function
() {
window.clearInterval(lastimer);
lastimer =
null
;
this
.lastscan();
},
cookie :
function
() {
var
c_name =
this
.getCookie(
"nameboxy"
);
var
c_color =
this
.getCookie(
"colorboxy"
);
var
c_fps =
this
.getCookie(
"fpsboxy"
);
if
(c_name && nameboxy) {
document.cookie =
"nameboxy="
+ escape(nameboxy);
}
else
if
(c_name && !nameboxy) {
nameboxy = c_name;
document.getElementById(
'nameboxy'
).innerHTML = nameboxy;
}
else
{
nameboxy =
"Ghost"
;
document.cookie =
"nameboxy="
+ escape(nameboxy);
}
if
(c_color && colorboxy) {
document.cookie =
"colorboxy="
+ escape(colorboxy);
}
else
if
(c_color && !colorboxy) {
colorboxy = c_color;
document.getElementById(
'nameboxy'
).style.color = colorboxy;
}
else
{
colorboxy =
"Black"
;
document.cookie =
"colorboxy="
+ escape(colorboxy);
}
if
(c_fps && fpsboxy) {
fpsboxy = document.getElementById(
'fpsboxy'
).value;
document.cookie =
"fpsboxy="
+ escape(fpsboxy);
this
.fps();
}
else
if
(c_fps && !fpsboxy) {
fpsboxy = c_fps;
document.getElementById(
'fpsboxy'
).value = Number(fpsboxy);
}
else
{
fpsboxy =
"1000"
;
document.cookie =
"fpsboxy="
+ escape(fpsboxy);
}
},
getCookie :
function
(name) {
var
n = name +
"="
;
var
nlen = n.length;
var
clen = document.cookie.length;
var
i = 0;
while
(i < clen) {
var
j = i + nlen;
if
(document.cookie.substring(i, j) == n) {
var
endstr = document.cookie.indexOf(
";"
, j);
if
(endstr == -1)
endstr = clen;
return
unescape(document.cookie.substring(j, endstr));
}
i = document.cookie.indexOf(
" "
, i) + 1;
if
(i == 0)
break
;
}
return
null
;
},
init :
function
() {
this
.cookie();
this
.color.create();
document.getElementsByTagName(
'body'
)[0].innerHTML +=
"<iframe name=\"iframeboxy\" onload=\"chatboxy.submit.done()\" style=\"display:none;\"></iframe>"
;
}
};
};
chatboxy.init();
</script>