2 Ajax Chat for TRPG ver.2.6
3 (c)2007-2009 Cake All Rights Reserved.
4 Mail : cake_67@users.sourceforge.jp
5 Home : http://trpgtools-onweb.sourceforge.jp/
8 * JaveScriptライブラリ:index.php用
11 columnId = 'pc_input_0';
13 var cookieSaveScript = './cookie_save.php';
14 var cookieLoadScript = './cookie_load.php';
17 function comment(Obj) {
19 var pc_input = Obj.pc_input.value;
22 var name = convert($("#name_on").attr("value"));
23 var pc_name = Obj.pc_name.value;
25 alert("PC名を入力してください。");
28 var pc_color = Obj.pc_color.value;
33 +'&c='+convert(pc_name)//PC
35 +'&m='+convert(pc_input);//本文
38 var whisper_to_name = Obj.whisper_to.value;
39 var whisper_to_hash = Obj.whisper_to_hash.value;
40 if(whisper_to_name && whisper_to_name != '全員' && whisper_to_hash) {
42 +'&w='+convert(whisper_to_name)//whisperto
43 +'&h='+whisper_to_hash;//whisperto_hash
47 if (Obj.show_status.checked) {
48 params = params+'&s='+'1';
50 params = params+'&s='+'0';
54 if (Obj.status.value) {
55 params = params+'&t='+convert(Obj.status.value);
59 // params = params+'&a='+Obj.status.value;
61 if ($("#pwd_on").attr("value")) {
62 var pwd = convert($("#pwd_on").attr("value"));
66 params+'&p='+pwd;//PWD
70 +'&e='+(new Date()).getTime();//cacheの更新
75 Obj.pc_input.value = "";
83 function writeComment(params)
87 url: writescript+params,
88 success: function(data) {
90 window.mainframe.getLog(true);
96 function isMember(name, action, params, pwd) {
104 success: function(data) {
105 var name_array = new Array();
106 var memberData = data.split("\n");
107 $.each(memberData, function(i){
108 var memberDataDetail = memberData[i].split("<>");
109 if (obfuscateLog == '1') {
110 var plName = deObfLog(memberDataDetail[0]);
112 var plName = memberDataDetail[0];
121 if (action=="logout") {
122 $("#logout").click();
125 if (action=="login") {
126 alert('そのお名前でログインはできません。');
131 if (action=="login") {
132 writeComment(params);
134 $("#online1").show();
135 $("#online2").show();
136 $("#offline").hide();
138 $("#name_on").val(name);
139 if (!$("#pc_name_0").val()) {
140 $("#pc_name_0").val(name);
142 $("#pwd_on").val(pwd);
143 $("#pc_input_0").focus();
145 $(".whisper_to").each(function(idx, Obj){
149 $(".whisper_to_hash").each(function(idx, Obj){
155 window.mainframe.login();
159 error: function(data) {
160 alert('参加者情報取得に失敗しました');
166 // ウインドウサイズ変更でフォームサイズ変更
167 function changeSize() {
168 var winWidth = getWinWidth();
169 var winHeight = getWinHeight() - 80;
170 $(".input_comment").css({width: winWidth-275});
171 $(".status").css({width: winWidth-313});
172 $("#mainframe").css({height: winHeight-40});
173 $("#offline_win").css({left: winWidth-280});
178 function insert(Obj, selfId, text, backlength) {
179 // 自分自身には挿入できない(ダイスショートカット対応)
180 if (Obj.id == selfId) {
186 var textLength = text.length;
188 if (Obj.selectionStart) {
189 var position = Obj.selectionStart;
190 Obj.value = Obj.value.substring(0, position)+text+Obj.value.substring(position, Obj.value.length);
191 Obj.setSelectionRange(position + textLength, position + textLength - backlength);
194 if (document.selection) {
195 var sel = document.selection.createRange();
197 sel.move('character', -backlength);
201 Obj.value = Obj.value+text;
207 function changeColor(Obj, Ev) {
208 if(Ev != "37" && Ev != "39" && Ev != "8" && Ev != "16" && Ev != "17" && Ev != "18"){
209 Obj.form.pc_color.style.color = Obj.value;
210 Obj.form.pc_color.value = Obj.value;
211 Obj.form.pc_color_select.style.color = Obj.value;
212 Obj.form.pc_name.style.color = Obj.value;
217 function insertTag(tag, columnId) {
218 insert(document.getElementById(columnId), '','<'+tag+'></'+tag+'>', tag.length+3)
222 function insertFontTag(columnId) {
223 var size = prompt("フォントサイズを指定してください(1~7または-4~+4)", "");
224 var color = prompt("フォント色を指定してください", "");
226 if (!size && !color) {
231 tag= tag+" size="+size;
234 tag= tag+" color="+color;
236 tag = tag+"></font>";
237 insert(document.getElementById(columnId), '', tag, 7)
241 // 入室中にリロード・ページ遷移で自動退室
243 var name = $("#name_on").attr("value");
245 isMember(name, 'logout', '', '');
250 function pageLoad() {
252 $("#online1").hide();
253 $("#online2").hide();
254 $("#cfchange").hide();
256 $("#cfinput").checked = false;
258 $("#name_on").disabled = true;
259 $("#pwd_on").disabled = true;
260 $("#my_hash").disabled = true;
261 $("#name_on").val("");
262 $("#pwd_on").val("");
263 $("#my_hash").val("");
265 $(".whisper_to").each(function(idx, Obj){
269 $(".whisper_to_hash").each(function(idx, Obj){
273 $("#cfchange").hide();
275 $("#cfinput").checked = false;
279 $(".console").draggable({
284 $(".console").draggable('enable');
286 $("#help_win").css({left: document.body.clientWidth-380});
287 $("#help_win_acc_list").accordion({
296 function doLogin(name, pwd) {
297 if (!name || name == noname) {
298 alert("お名前を入力してください。");
303 if (name.search(/[\'\"#\$\%&<>\/\\\`\=]/i) != -1) {
304 alert("一部の半角記号をお名前に使う事はできません。削除するか全角にしてみてください。");
309 var ngNames = new Array(noname, systemName, '現在のカード', 'deckCardSet', 'deck', 'my', 'plName');
311 for(i=0; i<ngNames.length; i++){
312 if (name==ngNames[i]){
318 alert("そのお名前ではログインできません");
325 '?n='+convert(name)//名前
328 params+'&p='+convert(pwd);//PWD
332 +'&e='+(new Date()).getTime();//cacheの更新
334 // 現在の入室者と同じ名前かどうかチェックしてログイン
335 isMember(name, 'login', params, pwd);
339 function doLogout(name) {
344 if($("#pwd_on").attr("value")) {
347 +'&p='+convert($("#pwd_on").attr("value"));//PWD
351 +'&e='+(new Date()).getTime();//cacheの更新
353 writeComment(params);
357 function selectedColumnId(Obj, isPc) {
359 if (columnId!=Obj.id) {
363 formObjId = Obj.form.id;
369 function changeWhisperConfig(name, whisperTo) {
370 var whisper_to_id = '#whisper_to_'+formObjId;
371 var whisper_to_hash_id = '#whisper_to_hash_'+formObjId;
372 var whisper_mark_id = '#whisper_mark_'+formObjId;
373 var formId = "#"+columnId;
375 if (whisper_to_hash_id) {
376 var whisperIcon = whisperOnIcon;
378 if ($(whisper_mark_id).attr("src")==whisperOnIcon) {
379 var whisperIcon = whisperOnIcon;
382 if (whisper_to_hash_id) {
383 $(whisper_to_id).val(name);
384 $(whisper_to_hash_id).val(whisperTo);
385 $(whisper_mark_id).attr("src", whisperIcon);
386 $(whisper_mark_id).attr("title", "クリックでささやき解除");
391 // ささやき設定変更クリア(indexから)
392 function changeWhisperConfigClear(Obj) {
393 var whisper_to_id = '#whisper_to_'+Obj.form.id;
394 var whisper_to_hash_id = '#whisper_to_hash_'+Obj.form.id;
395 var whisper_mark_id = '#whisper_mark_'+Obj.form.id;
397 $(whisper_to_id).val("全員");
398 $(whisper_to_hash_id).val("");
399 $(whisper_mark_id).attr("src", whisperOffIcon);
400 $(whisper_mark_id).attr("title", "「ささやき」状態を表示");
403 // ダイスショートカット欄にカーソルを当てるとその欄拡張
404 function expandDiceShortcut(Obj) {
405 var winWidth = document.body.clientWidth;
407 var diceShortCut = $(".diceShortCut");
408 diceShortCut.css('width', '40px');
410 Obj.style.width = winWidth-380;
413 // ダイスショートカット欄からカーソルを離したら元通り
414 function shrinkDiceShortcut(Obj) {
415 var diceShortCut = $(".diceShortCut");
416 diceShortCut.css('width', '');
421 function cookieWrite() {
422 if (!checkCookie()) {
426 var Expires = (60 * 60 * 24 * 1000 * CookieExpire);
429 var cookieValue = get_cookie_content();
431 var str = setCookie(cookieValue, Expires);
433 document.cookie = str;
435 alert("クッキーを記録しました");
440 function cookieDelete() {
441 if (!checkCookie()) {
445 var str = setCookie("", "");
447 document.cookie = str;
449 alert("クッキーを削除しました");
454 function checkCookie() {
455 if (!navigator.cookieEnabled) {
456 alert("クッキーが無効になっています。ブラウザの設定を変更してください。");
459 // クッキー名あるいは有効期限:どちらかがない場合クッキー使用しない
460 if (!CookieName || CookieExpire=="0") {
461 alert('チャット側の設定により、クッキー機能は無効です。');
469 function setCookie(cookieValue, Expires) {
470 var str = CookieName+"="+encodeURIComponent(cookieValue);
473 domain = location.hostname;
474 str += "; domain="+domain;
476 path = location.pathname.replace("index.php", "");
477 str += "; path="+path;
479 if (CookieExpire!='') {
480 var nowtime = new Date().getTime();
481 expires = new Date(nowtime + Expires);
482 expires = expires.toGMTString();
483 str += "; expires="+expires;
485 str += "; expires="+0;
492 function cookiesaveFile() {
493 if (!checkCookie()) {
498 var filename = prompt('現在のクッキーをファイルで保管します。\nファイル名を指定して下さい。','');
499 if (filename == null) {
504 var cookieValue = get_cookie_content();
506 var url = cookieSaveScript
508 +'f='+encodeURIComponent(filename)
509 +'&c='+encodeURIComponent(cookieValue);
516 function isFile(id) {
517 var fileName = $(id).val();
519 alert('ファイルを指定して下さい');
526 function openUrl(url, target) {
530 window.open(url, target);
534 function openNewWindow(location, target, noBar, width, height, scroll) {
541 if (!width || width <= 0) {
544 if (!height || height <= 0) {
545 height = document.body.clientHeight - 80;
548 showBar = 'toolbar=no,location=no,directorybottuns=no,menubar=no';
550 showBar = 'toolbar=yes,location=yes,directorybottuns=yes,menubar=yes';
553 setScroll = 'scrollbars=yes';
555 setScroll = 'scrollbars=no';
557 var options = 'width='+width
561 +',status=yes,resizable=yes';
562 return window.open(location, target, options);