-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.JS.php
More file actions
60 lines (55 loc) · 1.98 KB
/
index.JS.php
File metadata and controls
60 lines (55 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
//NOTE: DO NOT INCLUDE ANYTHING REGARDING A CHATROOM HERE.
/* What?
* When you go to chirped.it/ (with or without a #topic) we send down some javascript that reads the #topic, and makes a GET for chatroom.php?topic=theTopic or homepage.php. Then I take the response and set it to the innerHTML of the <body>
Thing is we can't read beyond the # in a url
*/
require('lib/header.php');
?>
<script type="text/javascript">
window.url = window.location.href;
window.topic = 'no-topic'; //default
if (url.indexOf('/#') > 0) {
topic = url.substr(url.indexOf('/#') + 2, url.length);
console.error('fetching chatroom #' + topic);
function requireJS(src) {
var pageJS = document.createElement('script');
pageJS.src = src;
doc.body.appendChild(pageJS);
}
function chatroomResponse(resp) {
console.error('got response on ' + topic);
doc.body.innerHTML = resp;
requireJS('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
requireJS('/js/tweet.js');
requireJS('/js/chatroom.js');
}
if (topic !== 'devin') {
GET('/chatroom.php?topic=' + topic, chatroomResponse);
} else {
GET('/chatroom.devin.php?topic=' + topic, chatroomResponse);
}
} else {
console.error('fetching homepagea!');
GET('/homepage.php', function(resp) {
console.error('homepage rolling in!');
doc.body.innerHTML = resp;
requireJS('/js/homepage.js');
});
}
</script>
</head>
<span></span>
<body>
<h1 id="message" style="margin-top:60px;"></h1>
<script type="text/javascript">
if (topic === 'no-topic') {
var end = 'If you\'re reading this it probably isn\'t loading. Email Devin: devinrhode2@gmail.com';
d.id('message').innerText = 'loading an awesome homepage..' + end;
} else {
d.id('message').innerText = 'loading an awesome chat on #' + topic + end;
}
</script>
<!-- body needs to be replaced with.. either the chatroom or the homepage.. -->
</body>
</html>