MCPcopy
hub / github.com/wecatch/china_regions / parseCountry

Function parseCountry

main.js:246–275  ·  view source on GitHub ↗
(html, parentUrl)

Source from the content-addressed store, hash-verified

244
245// countytr
246function parseCountry(html, parentUrl) {
247 let $ = renderDom(html);
248 let result = [];
249 $("tr.countytr").each(function(index, element) {
250 let td0 = null,
251 td1 = null,
252 url = "";
253 if ($(this).find("a").length == 0) {
254 td0 = $(this).find("td").first();
255 td1 = $(this).find("td").last();
256 } else {
257 td0 = $(this).find("a").first();
258 td1 = $(this).find("a").last();
259 }
260 let id = td0.text();
261 let name = td1.text();
262 if (td0.attr("href")) {
263 url = joinUrl(parentUrl, td0.attr("href"));
264 }
265 result.push({
266 id: id,
267 name: name,
268 url: url
269 });
270 });
271
272
273 return result;
274
275}
276
277
278// towntr

Callers 2

mainFunction · 0.85
pullCountryDataSyncFunction · 0.85

Calls 2

renderDomFunction · 0.85
joinUrlFunction · 0.85

Tested by

no test coverage detected