|
|
|
|
|
|
|
|
|
|
|
export function spanAllZeroes(s: string): string { |
|
|
return s.replace(/(0+)/g, '<span class="zero">$1</span>'); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function spanAll(s: string, offset: number = 0): string { |
|
|
const letters = s.split(''); |
|
|
|
|
|
return letters |
|
|
.map( |
|
|
(n, i) => `<span class="digit value-${n} position-${i + offset}">${spanAllZeroes(n)}</span>`, |
|
|
) |
|
|
.join(''); |
|
|
} |
|
|
|
|
|
function spanLeadingZeroesSimple(group: string): string { |
|
|
return group.replace(/^(0+)/, '<span class="zero">$1</span>'); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function spanLeadingZeroes(address: string): string { |
|
|
const groups = address.split(':'); |
|
|
|
|
|
return groups.map((g) => spanLeadingZeroesSimple(g)).join(':'); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function simpleGroup(addressString: string, offset: number = 0): string[] { |
|
|
const groups = addressString.split(':'); |
|
|
|
|
|
return groups.map((g, i) => { |
|
|
if (/group-v4/.test(g)) { |
|
|
return g; |
|
|
} |
|
|
|
|
|
return `<span class="hover-group group-${i + offset}">${spanLeadingZeroesSimple(g)}</span>`; |
|
|
}); |
|
|
} |
|
|
|