-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
134 lines (119 loc) · 4.67 KB
/
index.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<html>
<head>
<script type="text/javascript">
var site_name = "Latest Tweets";//removeTags(JSON.parse(httpGet("https://api.github.com/gists/???????")).files["gistfile1.txt"].content);
var username = window.location.search.substr(1).split("/")[0];
if (null == username) username = "";
var listname = window.location.search.substr(1).split("/")[1];
if (null == listname) listname = "";
document.write("<title>" + ((0 != username.length) ? "@" + username + ((listname.length > 0) ? "/" + listname : "") + " - " : "") + site_name + "</title>");
function removeTags(html) {
return html.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
}
function getUrlParam(name) {
if (name = (new RegExp('[?&]' + encodeURIComponent(name) + '=([^&]*)')).exec(window.location.search))
return decodeURIComponent(name[1]);
}
function httpGet(url) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", url, false);
xmlHttp.send();
return xmlHttp.responseText;
}
function httpGetAccept(url, accept) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", url, false);
xmlHttp.setRequestHeader("Accept", accept);
xmlHttp.send();
return xmlHttp.responseText;
}
</script>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<style type="text/css">
body, input, textarea, select, button, * {
font-family: 'Open Sans', sans-serif;
font-size: 12px;
}
td {
padding: 0px;
vertical-align: top;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
.smaller {
color: #999;
font-size: 10px;
}
img {
border-radius: 3px;
}
</style>
</head>
<body style="background-color: rgb(246, 245, 245);">
<div align=center><div align=left style="display: inline-block;">
<form name="myForm" action="javascript:updateUrl();">
<label for="username">Twitter username @</label><input id="username" placeholder="example" style="margin-left: 0px;"></input>
<input id=myButton name=myButton type=submit value="Go"></input>
</form>
<div id="twitterFollowees"></div>
</div></div>
<script type="text/javascript">
document.getElementById("username").value = username;
if (username.length <= 0) {
document.getElementById("username").focus();
}
function updateUrl() {
window.location.search = document.getElementById("username").value;
}
function doThisThing() {
var out = document.getElementById("outputBox");
try {
var scriptTag = document.createElement("script");
scriptTag.type = "text/javascript";
if (listname.length <= 0)
scriptTag.src = "https://api.twitter.com/1/statuses/friends/" + username + ".json?callback=twitterFolloweesCallback2";
else
scriptTag.src = "https://api.twitter.com/1/lists/members.json?slug=" + listname + "&owner_screen_name=" + username + "&callback=twitterFolloweesCallback3";
document.body.appendChild(scriptTag);
} catch (exc) {
document.getElementById("twitterFollowees").textContent = "Exception: " + exc;
}
}
if (username.length > 0)
doThisThing();
function GetMoreInfoLink(screen_name) {
return "<span> <a href=\"https://twitter.com/" + screen_name + "\" target=_blank>...</a></span>";
}
function TimePassedToAlpha(seconds) {
var max = 60 * 60 * 24 * 7;
if (seconds > max) return 0;
else return Math.pow((max - seconds) / max, 30);
}
function GetRecencyStyle(status) {
if (null == status) return "";
var created_at = new Date(Date.parse(status.created_at)).getTime() / 1000;
var now = new Date().getTime() / 1000;
return " style=\"background-color: rgba(255, 255, 0, " + TimePassedToAlpha(now - created_at) + ");\"";
}
function twitterFolloweesCallback2(json) {
var out = document.getElementById("twitterFollowees");
var innerHTML = "";
innerHTML += "<table>";
for (var i = 0; i < json.length; i++) {
innerHTML += "<tr" + GetRecencyStyle(json[i].status) + "><td style='padding-right: 3px;'>";
innerHTML += "<img src=\"" + json[i].profile_image_url_https + "\" width=16 height=16></td><td style='padding-right: 3px;'>";
innerHTML += removeTags(json[i].name) + " <span class='smaller'>@" + removeTags(json[i].screen_name) + "</span></td>";
if (null != json[i].status) innerHTML += "<td><span>" + json[i].status.text + "</span>" + GetMoreInfoLink(removeTags(json[i].screen_name)) + "</td>";
innerHTML += "</tr>";
};
innerHTML += "</table>";
out.innerHTML = innerHTML;
}
function twitterFolloweesCallback3(json) {
return twitterFolloweesCallback2(json.users);
}
</script>
</body>
</html>