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

Function parseTown

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

Source from the content-addressed store, hash-verified

277
278// towntr
279function parseTown(html, parentUrl) {
280 let $ = renderDom(html);
281 let result = [];
282 $("tr.towntr").each(function(index, element) {
283 let td0 = null,
284 td1 = null,
285 url = "";
286 if ($(this).find("a").length == 0) {
287 td0 = $(this).find("td").first();
288 td1 = $(this).find("td").last();
289 } else {
290 td0 = $(this).find("a").first();
291 td1 = $(this).find("a").last();
292 }
293 let id = td0.text();
294 let name = td1.text();
295 if (td0.attr("href")) {
296 url = joinUrl(parentUrl, td0.attr("href"));
297 }
298 result.push({
299 id: id,
300 name: name,
301 url: url
302 });
303 });
304
305
306 return result;
307}
308
309// villagetr
310function parseVillage(html) {

Callers 3

mainFunction · 0.85
pullCountryDataSyncFunction · 0.85
pullTownDataSyncFunction · 0.85

Calls 2

renderDomFunction · 0.85
joinUrlFunction · 0.85

Tested by

no test coverage detected