i like to eat grass / if my belly gets sickly / it tastes good to me
4
   
Award
Favorite
Favorited
Unfavorite
Download
"elements = countries.slots[0];
var new_countries = [];
for_country = (e = 0) => {
if (!elements.length) {
return console.log('FOR_COUNTRY_DONE');
}
var edit_process = {
url: 'actions/EditProcess?sId=' + account.user.steamID,
data: { xml: 1, type: "locationUpdate", country: elements[e] }
}
, array = [];
array.push(elements[e], []);
http_request(edit_process.url, edit_process.data, (body, response, error) => {
states = Cheerio(Cheerio.load(body)('state')).find('state').prevObject;
if (states.length > 1) {
states.slice(1).each((index, item) => {
array[1].push([item.attribs.key, []]);
});
(for_state = (s = 0) => {
if (s == array[1].length) {
return finish();
}
edit_process.data.state = array[1][s][0];
http_request(edit_process.url, edit_process.data, (body, response, error) => {
cities = Cheerio(Cheerio.load(body)('city')).find('city').prevObject;
if (cities.length > 1) {
cities.slice(1).each((index, item) => {
array[1][s][1].push(item.attribs.key);
});
}
for_state(s+1);
}, 'POST', false, true);
})();
} else {
finish();
}
}, 'POST', false, true);
finish = () => {
//console.dir(array,{depth: null});
new_countries.push(array);
elements.shift();
console.log('remaining: ' + elements.length);
for_country();
};
};
/*//////////////////////////////////////////////////////////////////////////////
pool:
[
[ 'COUNTRY', [ [ 'STATE1', [<CITIES1>]], [ 'STATE2', [<CITIES2>]] ]
];

[0][0] = COUNTRY
[0][0][0] = STATE1
[0][0][1] = CITIES1
[0][1][0] = STATE2
[0][1][1] = CITIES2
*/"