This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create an object named "app" which we can define methods on | |
var app = { | |
// returns an array of each url to prefetch | |
searchUniqueWithLimit: function(selector,limit){ | |
// returns an array for selector | |
var hrefs = $(selector).map(function(index, domElement){ | |
return $(this).attr("href"); | |
}); | |
// returns the array of hrefs without duplicates | |
return $.unique(hrefs).slice ( 0, limit?limit:5 ); |