/
index.php
266 lines (200 loc) · 7.75 KB
/
index.php
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PageRankGraph</title>
<link rel="stylesheet" type="text/css" href="http://static.openheatmap.com/css/mainstyle.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://static.openheatmap.com/scripts/urlparam.js"></script>
<script src="jquery.networkgraph.js" type="text/javascript"></script>
<script type='text/javascript'>
g_networkGraph = null;
$(function()
{
$('#websiteform').bind('submit', onFormSubmit);
g_networkGraph = new $().NetworkGraph('#graph_container');
g_networkGraph.drawNode = drawDomainNode;
if (window.location.hash.length>1)
{
$('#websiteaddress').val(window.location.hash.substr(1));
startGraphLoad('http://'+window.location.hash.substr(1));
}
});
function onFormSubmit()
{
var websiteAddress = 'http://'+$('#websiteaddress').val();
window.location.hash = '#'+$('#websiteaddress').val();
startGraphLoad(websiteAddress);
return false;
}
function startGraphLoad(websiteAddress)
{
$('#loading_message').html('<img src="loading.gif"/>');
g_networkGraph.removeAll();
removeAllDomainNodes();
var fetchURL = 'getgraphdata.php?domain='+encodeURIComponent(websiteAddress);
$.getJSON(fetchURL, onGraphDataLoaded);
}
function onGraphDataLoaded(data)
{
$('#loading_message').empty();
var mainDomain = data.domain;
var inboundLinks = data.inbound_links;
var maxJuice = 0;
var totalJuice = 0;
for (var inboundDomain in inboundLinks)
{
var inboundLink = inboundLinks[inboundDomain];
var inboundPageRank = inboundLink.page_rank;
var inboundLinkCount = inboundLink.link_count;
var inboundInfo = inboundLink.domain_info;
var inboundPageCount = inboundInfo.page_count;
// What we really want is the total number of outbound links from this domain, but
// since that isn't available, use the total number of pages on the domain as a very
// rough approximation
var juice = (inboundLinkCount*(inboundPageRank/inboundPageCount));
inboundLink.juice = juice;
maxJuice = Math.max(maxJuice, juice);
totalJuice += juice;
}
g_networkGraph.addNode(mainDomain, {
'isUnmoveable': true,
'startX': (g_networkGraph.width/2),
'startY': (g_networkGraph.height/2),
'tooltip': 'Rank '+data.page_rank+' from '+data.inbound_link_count+' links'
});
for (var inboundDomain in inboundLinks)
{
var inboundLink = inboundLinks[inboundDomain];
var juice = inboundLink.juice;
var normalizedJuice = (juice/maxJuice);
var juicePercentage = Math.ceil((juice/totalJuice)*100);
var strength = Math.max( 0.1, (2.0*normalizedJuice));
var width = Math.max(1.0, (10.0*normalizedJuice));
g_networkGraph.addNode(inboundDomain, {
'tooltip': juicePercentage+'% contribution from '+inboundLink.link_count+' links'
});
g_networkGraph.addEdge(mainDomain, inboundDomain, {
'strength': strength,
'edgeWidth': width
});
var inboundInfo = inboundLink.domain_info;
var interconnectLinks = inboundInfo.inbound_links;
for (var interconnectDomain in interconnectLinks)
{
if (typeof inboundLinks[interconnectDomain] === 'undefined')
continue;
// g_networkGraph.addEdge(inboundDomain, interconnectDomain, {
// 'strength': 0.01,
// 'edgeColor': 'rgba(0,0,0,0)'
// });
}
}
}
function drawDomainNode(context, node)
{
var id = getSelectorForNode(node);
var nodeSelector = '#'+id;
var domainNode = $(nodeSelector);
if (domainNode.length==0)
domainNode = createDomainNode(node);
var x = (node.x-(domainNode.width()/2));
var y = (node.y-(domainNode.height()/2));
domainNode.css({
'left': x,
'top': y
});
}
function removeAllDomainNodes()
{
$('.domain_node').remove();
}
function getSelectorForNode(node)
{
var id = node.id;
id = id.replace(/[^a-zA-Z0-9]/g, '_');
return 'domain_node_'+id;
}
function createDomainNode(node)
{
var label = node.id;
label = label.replace('http://', '');
label = label.replace('www.', '');
label = label.replace('.com', '');
var url = 'http://blekko.com/ws/'
+encodeURIComponent('http://'+node.id.replace('http://', ''))
+'+/seo';
var id = getSelectorForNode(node);
var tooltip = node.data.tooltip;
var result = $(
'<div '
+'class="domain_node" '
+'id="'+id+'" '
+'style="'
+'position: absolute; '
+'background: rgba(224, 224, 224, 0.5); '
+'border-color: rgba(0, 0, 0, 0.5); '
+'border-style: solid; '
+'border-width: 1px; '
+'" '
+'title="'+tooltip+'" '
+'>'
+'<a '
+'href="'+url+'" '
+'target="_blank" '
+'>'
+label
+'</a>'
+'</div>'
);
$('#graph_container').append(result);
return result;
}
</script>
</head>
<body>
<div class="ui-corner-all" style="font-size: 175%; margin-top: 0px; margin-left: 150px; width: 800px;">
<div style="float:left; width: 620px;"><h2>Where do search rankings come from?</h2>
<br>
Search engines use algorithms like <a href="http://en.wikipedia.org/wiki/PageRank">PageRank</a> to decide which sites show up high on the results page, and which are banished to the bottom.
</div>
<div style="float:right;"><img src="pageranklogo.png"/></div>
<div style="clear: both;"></div>
<div>
<a href="">PageRankGraph</a> helps you understand how these rankings are calculated, by showing the sites that link to a domain, with an estimate of how much influence each site has on the target domain's score.
</div>
<br>
<div>
Enter a website address below, and you'll get a map of all the links (<i>requires Firefox, Chrome or Safari</i>)
</div>
<br>
<form id="websiteform" style="height:24px;">
http://<input type="text" size="40" name="websiteaddress" id="websiteaddress" value=""/>
<input type="submit" value="Go"/>
<span id="loading_message"></span>
</form>
<br>
<div id="graph_container" style="width: 800px; height: 400px; position: relative;">
</div>
<div>
Created by <a href="http://petewarden.typepad.com/">Pete Warden</a>
</div>
<br>
<div>
<a href="http://blekko.com">Blekko</a> made this possible by releasing detailed SEO information on the sites they index. If you find this tool useful, check out the great features their search interface offers.
</div>
<br>
<div>
The calculations are only very approximate, the full process of generating rankings is complex and closely-guarded and the source data is incomplete, but this should give you a feel for how much links from different sites are worth.
</div>
<br>
<div>
The lines in the graph represent inbound links that are boosting the target site's ranking. The more juice a domain is delivering, the thicker and stronger the connection is. This means that the most helpful domains are drawn close to the center of the picture, while less important ones are left on the edges. If you mouse-over each domain, you'll see a tooltip giving more information.
</div>
<br>
<div>
Full code for PageRankGraph is available at <a href="http://github.com/petewarden/pagerankgraph">github.com/petewarden/pagerankgraph</a>
</div>
<br>
</div>
</body>
</html>