Created
October 5, 2014 14:25
-
-
Save itorres/2b88920c18af52b686c8 to your computer and use it in GitHub Desktop.
A quick hack to get an object with the devices in firefoxosdevices.org.
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
function firefoxosdevicesIndex() { | |
var r = { 'd': {}, 's': {} }; | |
devices = document.querySelectorAll(".ag-device"); | |
for (var i = 0; i < devices.length; i++) { | |
var model = devices[i].querySelector(".ag-name").textContent.trim(); | |
var specs = devices[i].querySelectorAll("dt"); | |
r['d'][model] = {}; | |
for (var j = 0; j < specs.length; j++) { | |
var spec = specs[j].textContent.trim(), | |
value = specs[j].nextSibling.textContent.trim(); | |
r['d'][model][spec] = value; | |
if (r['s'][spec] === undefined) { | |
r['s'][spec] = {}; | |
} | |
if (r['s'][spec][value] === undefined) { | |
r['s'][spec][value] = []; | |
} | |
r['s'][spec][value].push(model); | |
} | |
r['d'][model]["name"] = model; | |
} | |
return r; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment