Last active
August 29, 2015 13:56
-
-
Save aleskiontherun/9258020 to your computer and use it in GitHub Desktop.
Log "country - cities" from Ryanair compact destination cities list
This file contains hidden or 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
/** | |
* 1. Selct a city in the "From" field list | |
* 2. Open the "To" field list | |
* | |
* Some times there is a simple cities list without countries, which is very uncomfortable | |
* This gist is for those cases | |
* | |
* 3. Copy this code into your Firebug (or other) console and execute | |
* | |
* Don't forget to perform step 2 every time you select a new "From" city | |
* | |
*/ | |
var findCountry = function(city) { | |
var c, cc, els = $("#fromRoutes .routeBlock > *"); | |
els.each(function(a, b) { | |
var t = $(b).text(); | |
if (b.tagName == "H4") | |
c = $(b).text(); | |
else if ($(b).text() == city) | |
cc = c; | |
}); | |
return cc; | |
}; | |
var o = {}; | |
$("#toRoutes .routeBlock > a").each(function(a, b) { | |
var c = $(b).text(); | |
var cc = findCountry(c); | |
if (cc == "Ireland" || cc == "UK") | |
return; | |
if (!o[cc]) o[cc] = []; | |
o[cc].push(c); | |
}); | |
console.dir(o); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment