Several bug fixes:
[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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
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/';
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 $('.more_link').click(function(){ $('.content.bottom').slideDown('fast'); $('.network').focus(); return false; });
92 $('.formconnectwindow').submit(function(){
93 init_data.channel = $('#channel').val();
94 return false;
95 });
96 $('a.connect').click(function(){ $('.formconnectwindow').submit(); return false; });
97 }
98 </script>
99
100
101 <script id="tmpl_about_box" type="text/x-jquery-tmpl">
102 <h2>Kiwi IRC</h2>
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>
104 <button class="about_close">Close</button>
105 <p class="info">${about}</p>
106 <p class="revisions">Front: ${front_revision}<br />Gateway: ${gateway_revision}</p>
107 </script>
108
109 <script id="tmpl_change_nick" type="text/x-jquery-tmpl">
110 <div class="newnick box">
111 Your new nick:<br />
112 <form class="form_newnick">
113 <input type="text" class="txtnewnick" /><br />
114 <button class="butnewnick" type="submit">Change</button> <a class="link cancelnewnick">Cancel</a>
115 </form>
116 </div>
117 </script>
118
119
120 <script id="tmpl_plugins" type="text/x-jquery-tmpl">
121 <div class="list">
122 <h2>Kiwi plugins</h2>
123 <p>
124 <select multiple="multiple" id="plugin_list">
125 </select>
126 <button id="plugins_list_unload">Unload</button>
127 </p>
128 </div>
129 <div class="load">
130 Plugin file URL:<br />
131 <form>
132 <input type="text" class="txtpluginfile" /><br />
133 <button class="butnewnick" type="submit">Load..</button> <a class="link cancelpluginfile">Cancel</a>
134 </form>
135 </div>
136 </script>
137
138 <script id="tmpl_user_box" type="text/x-jquery-tmpl">
139 <div class="userbox">
140 <input type="hidden" class="userbox_nick" value="${nick}" />
141 <a href="#" class="userbox_query">Message</a>
142 <a href="#" class="userbox_whois">Info</a>
143 </div>
144 </script>
145
146 </head>
147
148 <body>
149
150 <div id="kiwi">
151 <div class="connectwindow">
152 <h1 class="logo">Kiwi IRC</h1>
153 <div id="login">
154 <form class="formconnectwindow">
155 <div class="content top">
156 <ul>
157 <li><label for="nick">Your nickname:</label>
158 <input type="text" id="nick" name="nick" class="nick" placeholder="Your nick.." /></li>
159 </ul>
160 <a class="connect" href="">Connect..</a>
161 </div>
162
163 <div class="more" style="<?php if(SERVER_SET) echo "display:none;"; ?>">
164 <a href="" class="more_link">More</a>
165 <div class="content bottom">
166 <ul>
167 <li><label for="network">Server:</label>
168 <input type="text" id="network" name="network" class="network" value="<?php echo htmlentities($server); ?>" /></li>
169 <li><label for="channel">Channel:</label>
170 <input type="text" id="channel" name="channel" class="channel" value="#kiwiirc" /></li>
171 </ul>
172 <a class="connect" href="">Connect..</a>
173 </div>
174 </div>
175 </form>
176 </div>
177 </div>
178
179
180
181 <div class="windowlist">
182 <div class="poweredby">Powered by Kiwi IRC</div>
183 <ul></ul>
184 </div>
185
186 <div class="cur_topic"></div>
187
188 <div class="userlist">
189 <ul></ul>
190 </div>
191
192 <div id="windows" class="windows"><div class="scroller" style="width:100%;"></div></div>
193
194 <div class="control">
195 <div class="msginput">
196 <div class="nick"><a href="#"></a>:</div>
197 <input type="text" name="kiwi_msginput" id="kiwi_msginput" />
198 </div>
199 <div class="plugins">
200 <ul>
201 <li><a class="load_plugin_file">Plugins</a></li>
202 <?php if(isset($_GET['debug'])){ ?>
203 <li><a class="reload_css">Reload CSS</a></li>
204 <?php } ?>
205 </ul>
206 </div>
207 </div>
208 </div>
209
210 </body>
211 </html>