X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=public%2Fscripts%2Fchatclient.js;h=05ccd2d09eaa1b09dae27f5e1481f50f8df03d14;hb=1be6ea0fbb0fd661c1d589add81b3423c1eb9ecc;hp=4b35312c6fee80f2df68a689ddc0991b2f5d9a7a;hpb=4209c7c3930f0002ac031fdaa1af2ad72cc8f3ec;p=webchat%2FWebChat.git
diff --git a/public/scripts/chatclient.js b/public/scripts/chatclient.js
index 4b35312..05ccd2d 100644
--- a/public/scripts/chatclient.js
+++ b/public/scripts/chatclient.js
@@ -44,10 +44,16 @@ $(document).ready(function(){
$("#help_frame").css("display","none");
});
$("input[name=openPastlog]").click(openPastlogEventListener);
+ $("#whisper_list_view").click(function(e){
+ $("#whisper_list").toggle();
+ });
+ $("#decoration_list_view").click(function(e){
+ $("#decoration_list").toggle();
+ });
document.chat_form.onsubmit = function(){return false;};
document.enter_form.onsubmit = function(){return false;};
- $socket = io.connect(location.hostname + "/" + document.chat_form.rno.value + "?token="+ encodeURIComponent(document.chat_form.token.value));
+ $socket = io.connect(location.hostname + "/" + document.chat_form.rno.value + "?token="+ encodeURIComponent(document.chat_form._csrf.value));
$socket.on("error",getErrorMessage);
$socket.on("send roominfo",sendRoomInfoListerner);
$socket.on("send romcount",sendRomCountListerner);
@@ -184,6 +190,7 @@ function ParseMessage(msg)
$names[msg.name].time = date.getTime();
namepart = $("")
.attr("href",GetNameLink(msg.name))
+ .attr("target","_blank")
.css("color",color)
.text(util.htmlspecialchars(msg.name));
}else{
@@ -215,9 +222,13 @@ function GetNameLink(name)
function createNameList()
{
var date = new Date();
+ $("#whisper_list").empty();
+ $("#whisper_list").append("
");
+
$("#namelist").empty();
$("#namelist").append("");
$("#namelist > ul").append($("").append(sprintf($romcount_msg,$romcount)));
+
for(var name in $names)
{
var diff = date.getTime() - $names[name].time;
@@ -227,13 +238,79 @@ function createNameList()
{
var atag = $("")
.attr("href",GetNameLink(name))
+ .attr("target","_blank")
.css("color",$names[name].color)
.text(name);
+ var spantag = $("")
+ .click(clickNameEventListener)
+ .text(name);
+ $("#whisper_list > ul").append($("").append(spantag));
$("#namelist > ul").append($("").append(atag));
}
}
}
+function clickNameEventListener(e)
+{
+ document.chat_form.message.value = "/tell " + $(this).text();
+ document.chat_form.message.focus();
+}
+
+function AddBold()
+{
+ var text = GetSelection(document.chat_form.message);
+ ReplaceSelection(document.chat_form.message,sprintf("[b]%s[/b]",text));
+}
+
+function AddItalic()
+{
+ var text = GetSelection(document.chat_form.message);
+ ReplaceSelection(document.chat_form.message,sprintf("[i]%s[/i]",text));
+}
+
+function AddStrike()
+{
+ var text = GetSelection(document.chat_form.message);
+ ReplaceSelection(document.chat_form.message,sprintf("[s]%s[/s]",text));
+}
+
+function AddFontSize(size)
+{
+ var text = GetSelection(document.chat_form.message);
+ ReplaceSelection(document.chat_form.message,sprintf("[size=%f]%s[/size]",size,text));
+}
+
+function GetSelection(element)
+{
+ if (document.selection) {
+ element.focus();
+ var sel = document.selection.createRange();
+ return sel.text;
+ } else if (element.selectionStart || element.selectionStart === 0) {
+ var startPos = element.selectionStart;
+ var endPos = element.selectionEnd;
+ var scrollTop = element.scrollTop;
+ return element.value.substring(startPos,endPos);
+ }else{
+ return "";
+ }
+}
+
+function ReplaceSelection(element,text)
+{
+ if (document.selection) {
+ element.focus();
+ var sel = document.selection.createRange();
+ sel.text = text;
+ } else if (element.selectionStart || element.selectionStart === 0) {
+ var startPos = element.selectionStart;
+ var endPos = element.selectionEnd;
+ element.value = element.value.substring(0, startPos) + text + element.value.substring(endPos, element.value.length);
+ } else{
+ element.value = text;
+ }
+}
+
function enterEventListener()
{
if(document.enter_form.name.value == "")