KaiOS webapp for InfoFer scraper
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
766 B

/**
* Create <span class="{IR|IC|}">IR|IRN|IC|R|R-E</span> <span>74</span> inside element
* @param {string} rank
* @param {string} number
* @param {HTMLElement|undefined} element
* @returns {HTMLSpanElement|HTMLElement}
*/
function trainIdSpan(rank, number, element) {
if (!element) {
element = document.createElement('span')
}
var rankSpan = document.createElement('span')
element.appendChild(rankSpan)
rankSpan.textContent = rank
if (rank.startsWith('IC')) {
rankSpan.classList.add('IC')
}
else if (rank.startsWith('IR')) {
rankSpan.classList.add('IR')
}
element.appendChild(document.createTextNode(' '))
var numberSpan = document.createElement('span')
element.appendChild(numberSpan)
numberSpan.textContent = number
return element
}