(xmlTvFile: string, currentXmlTvId: string)
| 2216 | } |
| 2217 | |
| 2218 | newM3uPicker(xmlTvFile: string, currentXmlTvId: string): [HTMLDivElement, HTMLInputElement, HTMLDataListElement] { |
| 2219 | const container = document.createElement('div'); |
| 2220 | const input = document.createElement('input'); |
| 2221 | input.setAttribute('type', 'text'); |
| 2222 | |
| 2223 | // Initially, set value to '-' if input is empty |
| 2224 | input.value = (currentXmlTvId) ? currentXmlTvId : '-'; |
| 2225 | |
| 2226 | // When input is focused, remove '-' from it |
| 2227 | input.addEventListener('focus', (evt) => { |
| 2228 | const target = evt.target as HTMLInputElement; |
| 2229 | target.value = (target.value === '-') ? '' : target.value; |
| 2230 | }); |
| 2231 | |
| 2232 | // When input lose focus or take a value, if it's empty, set value to '-' |
| 2233 | input.addEventListener('blur', setFallbackValue); |
| 2234 | input.addEventListener('change', setFallbackValue); |
| 2235 | function setFallbackValue(evt: Event) { |
| 2236 | const target = evt.target as HTMLInputElement; |
| 2237 | target.value = (target.value) ? target.value : '-'; |
| 2238 | } |
| 2239 | |
| 2240 | container.appendChild(input); |
| 2241 | |
| 2242 | const datalist = document.createElement('datalist'); |
| 2243 | |
| 2244 | const option = document.createElement('option'); |
| 2245 | option.setAttribute('value', '-'); |
| 2246 | option.innerText = '-'; |
| 2247 | datalist.appendChild(option); |
| 2248 | |
| 2249 | const m3u: Object = SERVER['xepg']['epgMapping']; |
| 2250 | |
| 2251 | if (m3u) { |
| 2252 | const programIds = getOwnObjProps(m3u); |
| 2253 | |
| 2254 | programIds.forEach((programId) => { |
| 2255 | const chanel: Object = m3u[programId]; |
| 2256 | if (chanel.hasOwnProperty('tvg-name')) { |
| 2257 | const option = document.createElement('option'); |
| 2258 | option.setAttribute('value', chanel["tvg-name"]); |
| 2259 | option.innerText = programId; |
| 2260 | datalist.appendChild(option); |
| 2261 | } else { |
| 2262 | const option = document.createElement('option'); |
| 2263 | option.setAttribute('value', chanel["tvg-name"]); |
| 2264 | option.innerText = '-'; |
| 2265 | datalist.appendChild(option); |
| 2266 | } |
| 2267 | }); |
| 2268 | } |
| 2269 | |
| 2270 | container.appendChild(datalist); |
| 2271 | |
| 2272 | return [container, input, datalist]; |
| 2273 | } |
| 2274 | |
| 2275 | getPrograms(file: string, set: string, active: boolean): any { |
no test coverage detected