Skip to content

Instantly share code, notes, and snippets.

@itorres
Created October 5, 2014 14:25
Show Gist options
  • Save itorres/2b88920c18af52b686c8 to your computer and use it in GitHub Desktop.
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.
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