forked from caius/github_id
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
131 lines (106 loc) · 3.57 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Find your GitHub user id</title>
<style type="text/css" media="screen">
body {
font-size: 200%;
text-align: center;
margin: auto 0;
margin-top: 5em;
font-family: Courier, monospace;
}
label {
display: block;
}
input[type=text] {
font-size: 80%;
}
#success,
form p {
display: none;
}
#footer {
margin-top: 5em;
font-size: 50%;
color: #555;
}
#footer a {
color: #555;
text-decoration: none;
border-bottom: 1px dotted;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
function get_github_id_for (username, callback) {
$.getJSON('https://api.github.com/users/' + username + "?callback=?", {},
function(json){
var id = json["data"]["id"]
if (id) {
callback(username, id)
}
return false
});
}
function add_twitter_link_for (username, id) {
var tweet = $('<a>').text("Tweet this").attr('href', "https://twitter.com?status=" + encodeURIComponent("Found out I'm GitHub user " + id + " by using http://caius.github.com/github_id/#" + username + " #GitHub_id")).insertAfter("#success h1")
}
function show_user (username, id) {
$('#username').text(username)
$('#id').text(id)
$('form').hide()
$('#success').show()
}
$(document).ready(function() {
if (document.location.hash) {
// $('form p').show()
var name = document.location.hash.match(/^#(.*?)$/)[1]
get_github_id_for(name, function(username, id) {
show_user(username, id)
// $('form p').hide()
$('form h1').hide()
$('form').show()
})
}
$('form').submit(function(event) {
event.preventDefault()
$('form p').show()
var name = $("#github_username").val().trim()
get_github_id_for(name, function(username, id) {
add_twitter_link_for(username, id)
show_user(username, id)
document.location.hash = "#" + username
})
return false
});
});
</script>
<!-- <script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3041721-6']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script> -->
</head>
<body>
<div id="success">
<h1><span id="username"></span> is GitHub user #<span id="id"></span></h1>
</div>
<form id="input" action="#" accept-charset="utf-8">
<h1>Find GitHub User ID</h1>
<input type="text" name="github_username" id="github_username" placeholder="GitHub Username" />
<br />
<input type="submit" value="Find id →" />
<p>Finding…</p>
</form>
<div id="footer">
<p>A hack born out of idle curiosity by GitHub user #696: <a href="http://caius.name/">Caius Durling</a></p>
</div>
</body>
</html>