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