OSDN Git Service

trpgchat ver2.4
[trpgtools-onweb/AjaxChat.git] / lib / js / index-js.php
1 <?php
2 /*
3  * Ajax Chat for TRPG ver.2.4
4  * (c)2007-2009 Cake All rights reserved.
5  * Mail : cake_67@users.sourceforge.jp
6  * Home : http://trpgtools-onweb.sourceforge.jp/
7  */
8 /*****************
9  *  JaveScriptライブラリ:index.php用
10  *****************/
11
12 require_once './trpgchat-ini.php';
13
14 ?>
15 <script type="text/javascript">
16 <!--
17
18 //変数の設定
19 var noname = '<?php print NONAME; ?>';
20 var writescript = './write.php';
21 var pc_num = '<?php print PC_NUM; ?>';
22 var pc_show = '<?php print PC_SHOW_ICON; ?>';
23 var pc_hide = '<?php print PC_HIDE_ICON; ?>';
24
25 // 起動時の処理
26 $(function(){
27     pageLoad();
28
29     // ログイン
30     $("#login").click(function(){
31
32         //ログイン書き込み
33         var name = $("#name_off").attr("value");
34         var pwd = $("#pwd_off").attr("value");
35
36         if (pwd == undefined) {
37             var pwd = "";
38         }
39
40         if (!doLogin(name, pwd)) {
41             return false;
42         }
43
44         //フォームチェンジ
45         $("#online1").show();
46         $("#online2").show();
47         $("#offline").hide();
48         document.getElementById("name_on").value = name;
49         document.getElementById("pc_name_0").value = name;
50         document.getElementById("pwd_on").value = pwd;
51         document.getElementById("my_hash").value = "<?php echo create_hash($data['n'],$data['p']); ?>";
52         document.getElementById("pc_input_0").focus();
53         $("#cfchange").hide();
54         if (document.getElementById("cfinput")) { 
55             document.getElementById("cfinput").checked = false;
56         }
57
58         // 更新
59         window.mainframe.login();
60     });
61
62
63     //ログアウト
64     $("#logout").click(function(){
65         var name = convert($("#name_on").attr("value"));
66
67         // ログアウト書き込み
68         doLogout(name);
69
70         //フォームチェンジ
71         $("#online1").hide();
72         $("#online2").hide();
73         $("#offline").show();
74         $("#dice_shortcut").hide();
75         $(".status_column").hide();
76         $("#consumer_rule").hide();
77         $("#consumer_rule_icon").src == '<?php $self_url = get_self_url(); str_replace('./image','image',str_replace('index.php','',$self_url).CONSUMER_RULES_CLOSE_ICON); ?>';
78         $(".add_pc").hide();
79         $(".show_status").each(function(){
80             this.checked = false;
81         });
82         $("#whisper").click();
83         document.getElementById("name_on").value = "";
84         document.getElementById("pwd_on").value = "";
85         document.getElementById("my_hash").value = "";
86         $("#name_off").focus();
87
88         // 更新
89         window.mainframe.logout();
90
91     });
92     // ウィンドウサイズに合わせる
93     changeSize();//
94
95 });
96
97 // クッキーの書き込み
98 function cookieWrite() {
99     if (!navigator.cookieEnabled) {
100         alert("クッキーが無効になっています。ブラウザの設定を変更してください。");
101         return false;
102     }
103     // クッキー名
104     var CookieName = "<?php print COOKIE;?>";
105     // クッキー保存期間
106     var Expires = (60 * 60 * 24 * 1000 * <?php print COOKEI_EXPIRE; ?>);
107     // どちらかがない場合クッキー使用しない
108     if (!CookieName || !Expires) {
109         alert('チャット側の設定により、クッキー保管機能は無効です。');
110     }
111
112     // 値のセット
113     // ログイン名
114     var COOKIE = "name_off="+$("#name_off").attr("value");
115
116     // ダイスショートカット
117     <?php
118     for ($i=1;$i<=10;$i++) {
119          print '        if ($("#dice_'.$i.'").attr("value")) {COOKIE += "&dice_'.$i.'="+$("#dice_'.$i.'").attr("value"); }'."\n"; 
120     }
121          ?>
122
123     // PC設定
124     if (document.getElementsByName("pc_color_select_0")[0].value+"") { COOKIE += "&pc_color_select_0="+document.getElementsByName("pc_color_select_0")[0].value+"";}
125     if ($("#pc_color_0").attr("value")+"") { COOKIE += "&pc_color_0="+$("#pc_color_0").attr("value")+"";}
126     if ($("#pc_status_0").attr("value")) { COOKIE += "&pc_status_0="+$("#pc_status_0").attr("value"); }
127 <?php
128     if (PC_NUM > 1) {
129         for ($i=1; $i<=PC_NUM-1; $i++) {
130             print '    if ($("#pc_name_'.$i.'").attr("value")) {COOKIE += "&pc_name_'.$i.'="+$("#pc_name_'.$i.'").attr("value"); }'."\n";
131             print '    if (document.getElementsByName("pc_color_select_'.$i.'")[0].value+"") { COOKIE += "&pc_color_select_'.$i.'="+document.getElementsByName("pc_color_select_'.$i.'")[0].value+"";}'."\n";
132             print '    if ($("#pc_color_'.$i.'").attr("value")+"") { COOKIE += "&pc_color_'.$i.'="+$("#pc_color_'.$i.'").attr("value")+""; }'."\n";
133             print '    if ($("#pc_status_'.$i.'").attr("value")) { COOKIE += "&pc_status_'.$i.'="+$("#pc_status_'.$i.'").attr("value"); }'."\n";
134         }
135     }
136 ?>
137
138     // チャット画面設定
139     COOKIE += "&fontsize="+window.mainframe.document.getElementById("fontsize").value;
140     COOKIE += "&linespace="+window.mainframe.document.getElementById("linespace").value;
141     COOKIE += "&hr="+window.mainframe.document.getElementById("hr").value;
142     var str = CookieName+"="+encodeURIComponent(COOKIE);
143     domain = location.hostname.replace(/^[^\.]*/, "");
144     str += "; domain="+domain;
145     path = location.pathname.replace("index.php", "");
146     str += "; path="+path;
147     var nowtime = new Date().getTime();
148     expires = new Date(nowtime + Expires);
149     expires = expires.toGMTString();
150     str += "; expires="+expires;
151
152     document.cookie = str;
153
154     alert("クッキーを記録しました");
155     return true;
156 }
157
158 // クッキーの削除
159 function cookieDelete() {
160     if (!navigator.cookieEnabled) {
161         alert("クッキーが無効になっています。ブラウザの設定を変更してください。");
162         return false;
163     }
164     // クッキー名
165     var CookieName = "<?php print COOKIE;?>";
166     // クッキー保存期間
167     var Expires = (60 * 60 * 24 * 1000 * <?php print COOKEI_EXPIRE; ?>);
168     // どちらかがない場合クッキー使用しない
169     if (!CookieName || !Expires) {
170         alert('チャット側の設定により、クッキー保管機能は無効です。');
171     }
172
173     // 値のセット
174     var COOKIE = "";
175
176     var str = CookieName+"="+escape(COOKIE);
177     domain = location.hostname.replace(/^[^\.]*/, "");
178     str += "; domain="+domain;
179     path = location.pathname;
180     str += "; path="+path;
181     str += "; expires=0";
182
183     document.cookie = str;
184
185     alert("クッキーを削除しました");
186     return true;
187 }
188
189 -->
190 </script>