Fix issue #6 (Clickable channel names) - double-click channel names to /join them
[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 $('.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 $('a.chan').live('dblclick', function() { front.joinChannel($(this).text()); });
98 }
99 </script>
100
101
102 <script id="tmpl_about_box" type="text/x-jquery-tmpl">
103 <h2>Kiwi IRC</h2>
104 <p>An alternative to downloading an irc client. Kiwi IRC is the best web app you'll use for the next couple years.</p>
105 <button class="about_close">Close</button>
106 <p class="info">${about}</p>
107 <p class="revisions">Front: ${front_revision}<br />Gateway: ${gateway_revision}</p>
108 </script>
109
110 <script id="tmpl_change_nick" type="text/x-jquery-tmpl">
111 <div class="newnick box">
112 Your new nick:<br />
113 <form class="form_newnick">
114 <input type="text" class="txtnewnick" /><br />
115 <button class="butnewnick" type="submit">Change</button> <a class="link cancelnewnick">Cancel</a>
116 </form>
117 </div>
118 </script>
119
120
121 <script id="tmpl_plugins" type="text/x-jquery-tmpl">
122 <div class="list">
123 <h2>Kiwi plugins</h2>
124 <p>
125 <select multiple="multiple" id="plugin_list">
126 </select>
127 <button id="plugins_list_unload">Unload</button>
128 </p>
129 </div>
130 <div class="load">
131 Plugin file URL:<br />
132 <form>
133 <input type="text" class="txtpluginfile" /><br />
134 <button class="butnewnick" type="submit">Load..</button> <a class="link cancelpluginfile">Cancel</a>
135 </form>
136 </div>
137 </script>
138
139 <script id="tmpl_user_box" type="text/x-jquery-tmpl">
140 <div class="userbox">
141 <input type="hidden" class="userbox_nick" value="${nick}" />
142 <a href="#" class="userbox_query">Message</a>
143 <a href="#" class="userbox_whois">Info</a>
144 </div>
145 </script>
146
147 </head>
148
149 <body>
150
151 <div id="kiwi">
152 <div class="connectwindow">
153 <h1 class="logo">Kiwi IRC</h1>
154 <div id="login">
155 <form class="formconnectwindow">
156 <div class="content top">
157 <ul>
158 <li><label for="nick">Your nickname:</label>
159 <input type="text" id="nick" name="nick" class="nick" placeholder="Your nick.." /></li>
160 </ul>
161 <a class="connect" href="">Connect..</a>
162 </div>
163
164 <div class="more" style="<?php if(SERVER_SET) echo "display:none;"; ?>">
165 <a href="" class="more_link">More</a>
166 <div class="content bottom">
167 <ul>
168 <li><label for="network">Server:</label>
169 <input type="text" id="network" name="network" class="network" value="<?php echo htmlentities($server); ?>" /></li>
170 <li><label for="channel">Channel:</label>
171 <input type="text" id="channel" name="channel" class="channel" value="#kiwiirc" /></li>
172 </ul>
173 <a class="connect" href="">Connect..</a>
174 </div>
175 </div>
176 </form>
177 </div>
178 </div>
179
180
181
182 <div class="windowlist">
183 <div class="poweredby">Powered by Kiwi IRC</div>
184 <ul></ul>
185 </div>
186
187 <div class="cur_topic">
188 <!--
189 <ul class="edit" style="float:right;">
190 <li>
191 <img src="img/more.png" />
192 <ul id="kiwi_menu">
193 <li>Item 1</li>
194 <li>Item 2</li>
195 <li>Item 3</li>
196 </ul>
197 </li>
198 </ul>
199 -->
200 <div class="topic" style="margin-right:5em; overflow:hidden; white-space: pre-wrap; word-wrap: break-word;"></div>
201 </div>
202
203 <div class="userlist">
204 <ul></ul>
205 </div>
206
207 <div id="windows" class="windows"><div class="scroller" style="width:100%;"></div></div>
208
209 <div class="control">
210 <div class="msginput">
211 <div class="nick"><a href="#"></a>:</div>
212 <input type="text" name="kiwi_msginput" id="kiwi_msginput" />
213 </div>
214 <div class="plugins">
215 <ul>
216 <li><a class="load_plugin_file">Plugins</a></li>
217 <?php if(isset($_GET['debug'])){ ?>
218 <li><a class="reload_css">Reload CSS</a></li>
219 <?php } ?>
220 </ul>
221 </div>
222 </div>
223 </div>
224
225 </body>
226 </html>