heya guys.
im working on a PR Checker plugin for jQuery but i cant seem to get the hashing to work.
The hashing it returns is invalid and im unsure why exactly.
Take a look at the code
Usage in jQuery is like so:
but if you alert the pr its the url obv because i havent built in te ajax yet but can anyone understand why this is not working ?
Heres the code i have studied
http://www.v7n.com/forums/coding-forum/30174-javascript-php.html
im working on a PR Checker plugin for jQuery but i cant seem to get the hashing to work.
The hashing it returns is invalid and im unsure why exactly.
Take a look at the code
Code:
(
$.fn.PageRank = function(callback)
{
var _library = new Object();
//Creat the system library
var HASH_SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer."
_library.parseUrl = function(a)
{
var b = {};
/*
* parse the url to extract its parts
*/
if (a = a.match(/((s?ftp|https?):\/\/){1}([^\/:]+)?(:([0-9]+))?([^\?#]+)?(\?([^#]+))?(#(.+))?/)) {
b.scheme = a[2] ? a[2] : "http";
b.host = a[3] ? a[3] : null;
b.port = a[5] ? a[5] : null;
b.path = a[6] ? a[6] : null;
b.args = a[8] ? a[8] : null;
b.anchor = a[10] ? a[10] : null
}
return b
}
_library.toHex = function(a){
return (a < 16 ? "0" : "") + a.toString(16)
}
_library.hexEncodeU32 = function(a) {
var b = _library.toHex(a >>> 24);
b += _library.toHex(a >>> 16 & 255);
b += _library.toHex(a >>> 8 & 255);
return b + _library.toHex(a & 255)
}
_library.generateHash = function(a)
{
for (var b = 16909125, c = 0; c < a.length; c++)
{
b ^= HASH_SEED.charCodeAt(c % 87) ^ a.charCodeAt(c);
b = b >>> 23 | b << 9;
}
return _library.hexEncodeU32(b)
}
var CheckPageRank = function(url)
{
urlSegments = _library.parseUrl(url);
if(urlSegments && urlSegments.host)
{
checkLocation = "http://www.google.com/search?client=navclient-auto&ch=8" + _library.generateHash(urlSegments.host) + "&features=Rank&q=info:" + urlSegments.host;
return checkLocation
}
return false;
}
//Return the callback
$(this).each(function(){
page_rank = CheckPageRank(this.href);
callback(page_rank);
})
}
)(jQuery);
Usage in jQuery is like so:
Code:
$(document).ready(function() {
$('a').PageRank(function(pr){
$(this).append('Pr: ' pr);
})
})
but if you alert the pr its the url obv because i havent built in te ajax yet but can anyone understand why this is not working ?
Heres the code i have studied
http://www.v7n.com/forums/coding-forum/30174-javascript-php.html