fix crash when connection to IRC server failed. Added partial support for ERROR comma...
[KiwiIRC.git] / index.php
1 <?php
2
3 $node_config = json_decode(file_get_contents("node/config.json"), true);
4
5 switch(true){
6 case stripos($_SERVER['HTTP_USER_AGENT'], 'android') > 0:
7 $agent = "android"; $touchscreen = true;
8 break;
9
10 case stripos($_SERVER['HTTP_USER_AGENT'], 'iphone') > 0:
11 $agent = "iphone"; $touchscreen = true;
12 break;
13
14 case stripos($_SERVER['HTTP_USER_AGENT'], 'ipod') > 0:
15 $agent = "ipod"; $touchscreen = true;
16 break;
17
18 case stripos($_SERVER['HTTP_USER_AGENT'], 'ipad') > 0:
19 $agent = "ipad"; $touchscreen = true;
20 break;
21
22 default:
23 $agent = "normal";
24 $touchscreen = false;
25 }
26
27 define("SERVER_SET", isset($_GET['server']));
28 $server = isset($_GET['server']) ? $_GET['server'] : "irc.anonnet.org";
29 $nick = isset($_GET['nick']) ? $_GET['nick'] : "";
30 // Channel is set via javascript using location.hash
31
32 $node_server = $_SERVER['HTTP_HOST'];
33
34 ?>
35 <!DOCTYPE html>
36 <html xmlns="http://www.w3.org/1999/xhtml">
37 <head>
38 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
39
40 <?php if(in_array($agent, array("android", "ipad", "iphone", "ipad"))){ ?>
41 <meta name="viewport" content="width=device-width,user-scalable=no" />
42 <?php } ?>
43
44 <title>Kiwi IRC</title>
45 <link rel="stylesheet" type="text/css" href="css/default.css">
46 <link rel="stylesheet" type="text/css" href="css/ui.css">
47
48 <?php if($touchscreen){ ?>
49 <link rel="stylesheet" type="text/css" href="css/touchscreen_tweaks.css">
50 <?php } ?>
51
52 <script src="http://<?php echo $node_server; ?>:7777/socket.io/socket.io.js"></script>
53 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
54 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
55 <script type="text/javascript" src="js/jquery.json-2.2.min.js"></script>
56 <script type="text/javascript" src="js/util.js"></script>
57 <script type="text/javascript" src="js/gateway.js"></script>
58 <script type="text/javascript" src="js/front.js"></script>
59 <script type="text/javascript" src="js/iscroll.js"></script>
60
61 <?php if(in_array($agent, array("android", "ipad", "iphone", "ipad"))){ ?>
62 <script type="text/javascript" src="js/touchscreen_tweaks.js"></script>
63 <?php } ?>
64
65 <script type="text/javascript">
66 var agent = '<?php echo $agent; ?>';
67 var touchscreen = <?php echo ($touchscreen) ? 'true' : 'false'; ?>;
68 var init_data = {};
69 var kiwi_server = '<?php echo ($node_config['listen_ssl'] ? "https" : "http")."://".$node_server; ?>:7777/kiwi';
70 var touch_scroll;
71
72 $(document).ready(function(){
73 manageDebug(false);
74
75 //#channel,##channel,&channel
76 var chans = document.location.hash.match(/[#&]+[^ ,\007]+/g);
77 if(chans != null && chans.length > 0) {
78 init_data.channel = chans.join(',');
79 $('#channel').val(init_data.channel);
80 }
81
82 front.init();
83 gateway.start(kiwi_server);
84
85 addEvents();
86 $('.nick').focus();
87 });
88
89
90 function addEvents(){
91 $('#kiwi .more_link').click(function(){ $('.content.bottom').slideDown('fast'); $('.network').focus(); return false; });
92 $('#kiwi .formconnectwindow').submit(function(){
93 init_data.channel = $('#channel').val();
94 return false;
95 });
96 $('#kiwi a.connect').click(function(){ $('.formconnectwindow').submit(); return false; });
97 $('#kiwi .messages a.chan').live('click', function() {
98 front.joinChannel($(this).text());
99 return false;
100 });
101 }
102 </script>
103
104
105 <script id="tmpl_about_box" type="text/x-jquery-tmpl">
106 <h2>Kiwi IRC</h2>
107 <p>An alternative to downloading an irc client. Kiwi IRC is the best web app you'll use for the next couple years.</p>
108 <button class="about_close">Close</button>
109 <p class="info">${about}</p>
110 <p class="revisions">Front: ${front_revision}<br />Gateway: ${gateway_revision}</p>
111 </script>
112
113 <script id="tmpl_change_nick" type="text/x-jquery-tmpl">
114 <div class="newnick box">
115 Your new nick:<br />
116 <form class="form_newnick">
117 <input type="text" class="txtnewnick" /><br />
118 <button class="butnewnick" type="submit">Change</button> <a class="link cancelnewnick">Cancel</a>
119 </form>
120 </div>
121 </script>
122
123
124 <script id="tmpl_plugins" type="text/x-jquery-tmpl">
125 <div class="list">
126 <h2>Kiwi plugins</h2>
127 <p>
128 <select multiple="multiple" id="plugin_list">
129 </select>
130 <button id="plugins_list_unload">Unload</button>
131 </p>
132 </div>
133 <div class="load">
134 Plugin file URL:<br />
135 <form>
136 <input type="text" class="txtpluginfile" /><br />
137 <button class="butnewnick" type="submit">Load..</button> <a class="link cancelpluginfile">Cancel</a>
138 </form>
139 </div>
140 </script>
141
142 <script id="tmpl_user_box" type="text/x-jquery-tmpl">
143 <div class="userbox">
144 <input type="hidden" class="userbox_nick" value="${nick}" />
145 <a href="#" class="userbox_query">Message</a>
146 <a href="#" class="userbox_whois">Info</a>
147 </div>
148 </script>
149
150 </head>
151
152 <body>
153
154 <div id="kiwi">
155 <div class="connectwindow">
156 <h1 class="logo">Kiwi IRC</h1>
157 <div id="login">
158 <form class="formconnectwindow">
159 <div class="content top">
160 <ul>
161 <li><label for="nick">Your nickname:</label>
162 <input type="text" id="nick" name="nick" class="nick" placeholder="Your nick.." /></li>
163 </ul>
164 <a class="connect" href="">Connect..</a>
165 </div>
166
167 <div class="more" style="<?php if(SERVER_SET) echo "display:none;"; ?>">
168 <a href="" class="more_link">More</a>
169 <div class="content bottom">
170 <ul>
171 <li><label for="network">Server:</label>
172 <input type="text" id="network" name="network" class="network" value="<?php echo htmlentities($server); ?>" /></li>
173 <li><label for="channel">Channel:</label>
174 <input type="text" id="channel" name="channel" class="channel" value="#kiwiirc" /></li>
175 </ul>
176 <a class="connect" href="">Connect..</a>
177 </div>
178 </div>
179 </form>
180 </div>
181 </div>
182
183
184
185 <div class="windowlist">
186 <div class="poweredby">Powered by Kiwi IRC</div>
187 <ul></ul>
188 </div>
189
190 <div class="cur_topic">
191 <!--
192 <ul class="edit" style="float:right;">
193 <li>
194 <img src="img/more.png" />
195 <ul id="kiwi_menu">
196 <li>Item 1</li>
197 <li>Item 2</li>
198 <li>Item 3</li>
199 </ul>
200 </li>
201 </ul>
202 -->
203 <div class="topic" style="margin-right:5em; overflow:hidden; white-space: pre-wrap; word-wrap: break-word;"></div>
204 </div>
205
206 <div class="userlist">
207 <ul></ul>
208 </div>
209
210 <div id="windows" class="windows"><div class="scroller" style="width:100%;"></div></div>
211
212 <div class="control">
213 <div class="msginput">
214 <div class="nick"><a href="#"></a>:</div>
215 <input type="text" name="kiwi_msginput" id="kiwi_msginput" />
216 </div>
217 <div class="plugins">
218 <ul>
219 <li><a class="load_plugin_file">Plugins</a></li>
220 <?php if(isset($_GET['debug'])){ ?>
221 <li><a class="reload_css">Reload CSS</a></li>
222 <?php } ?>
223 </ul>
224 </div>
225 </div>
226 </div>
227
228 </body>
229 </html>