From 0fc67a37aab5f1bcb1d7ffd324f044d9ae1e12d7 Mon Sep 17 00:00:00 2001 From: konekoneko Date: Mon, 4 Mar 2013 16:35:13 +0900 Subject: [PATCH] =?utf8?q?=E7=B0=A1=E6=98=93=E8=A3=85=E9=A3=BE=E6=A9=9F?= =?utf8?q?=E8=83=BD=E3=82=92=E4=BB=98=E3=81=91=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- public/chat.ejs | 10 ++++++++++ public/scripts/chatclient.js | 45 ++++++++++++++++++++++++++++++++++++++++++++ public/stylesheets/enter.css | 2 +- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/public/chat.ejs b/public/chat.ejs index 93f2fb1..eedcddd 100644 --- a/public/chat.ejs +++ b/public/chat.ejs @@ -91,6 +91,16 @@
+ + 装飾 +
+ 太字 + 斜体 + 取り消し線 + 叫び声 + ささやき声 +
+
diff --git a/public/scripts/chatclient.js b/public/scripts/chatclient.js index 83cd6fb..fc9e227 100644 --- a/public/scripts/chatclient.js +++ b/public/scripts/chatclient.js @@ -47,6 +47,9 @@ $(document).ready(function(){ $("#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;}; @@ -248,6 +251,48 @@ function createNameList() function clickNameEventListener(e) { document.chat_form.message.value = "/tell " + $(this).text(); + document.chat_form.message.focus(); +} + +function AddBold() +{ + InsertAtCaret(document.chat_form.message,"[b][/b]"); +} + +function AddItalic() +{ + InsertAtCaret(document.chat_form.message,"[i][/i]"); +} + +function AddStrike() +{ + InsertAtCaret(document.chat_form.message,"[s][/s]"); +} + +function AddFontSize(size) +{ + InsertAtCaret(document.chat_form.message,sprintf("[size=%f][/size]",size)); +} + +function InsertAtCaret(element, text) { + if (document.selection) { + element.focus(); + var sel = document.selection.createRange(); + sel.text = text; + element.focus(); + } else if (element.selectionStart || element.selectionStart === 0) { + var startPos = element.selectionStart; + var endPos = element.selectionEnd; + var scrollTop = element.scrollTop; + element.value = element.value.substring(0, startPos) + text + element.value.substring(endPos, element.value.length); + element.focus(); + element.selectionStart = startPos + text.length; + element.selectionEnd = startPos + text.length; + element.scrollTop = scrollTop; + } else { + element.value += text; + element.focus(); + } } function enterEventListener() diff --git a/public/stylesheets/enter.css b/public/stylesheets/enter.css index 7930624..9dcd5b2 100644 --- a/public/stylesheets/enter.css +++ b/public/stylesheets/enter.css @@ -6,7 +6,7 @@ margin-right:1em; } -#whisper_list{ +#whisper_list,#decoration_list{ display:none; } -- 2.11.0