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.
31 lines
766 B
31 lines
766 B
2 years ago
|
/**
|
||
|
* 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
|
||
|
}
|