maybe fix subtitle html
Seva Luchianov
4 years ago
251 | 251 | console.log("curr index", subtitles[curr_subtitle_index]); |
252 | 252 | if (curr_subtitle_index >= 0) { |
253 | 253 | if (time_ms >= subtitles[curr_subtitle_index].start && time_ms < subtitles[curr_subtitle_index].end) { |
254 | $(".subtitle-wrapper").text(subtitles[curr_subtitle_index].text); | |
254 | set_subtitles(subtitles[curr_subtitle_index].text); | |
255 | 255 | } else { |
256 | $(".subtitle-wrapper").text(""); | |
256 | set_subtitles(""); | |
257 | 257 | } |
258 | 258 | } |
259 | 259 | } else { |
260 | 260 | // Amazing, time_ms is the EXACT start time of a subtitle |
261 | $(".subtitle-wrapper").text(subtitles[curr_subtitle_index].text); | |
261 | set_subtitles(subtitles[curr_subtitle_index].text); | |
262 | 262 | } |
263 | 263 | } else { |
264 | 264 | if (curr_subtitle_index >= 0 && |
265 | 265 | time_ms >= subtitles[curr_subtitle_index].end |
266 | 266 | ) { |
267 | $(".subtitle-wrapper").text(""); | |
267 | set_subtitles(""); | |
268 | 268 | } |
269 | 269 | if (curr_subtitle_index + 1 < subtitles.length && |
270 | 270 | time_ms >= subtitles[curr_subtitle_index + 1].start |
271 | 271 | ) { |
272 | 272 | curr_subtitle_index++; |
273 | $(".subtitle-wrapper").text(subtitles[curr_subtitle_index].text); | |
273 | set_subtitles(subtitles[curr_subtitle_index].text); | |
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
359 | 359 | }, |
360 | 360 | update_viewer: update_viewer |
361 | 361 | }; |
362 | ||
363 | function set_subtitles(data) { | |
364 | $(".subtitle-wrapper").text( | |
365 | $("<div></div>").html(data).text() | |
366 | ); | |
367 | } | |
362 | 368 | |
363 | 369 | function update_viewer(viewer) { |
364 | 370 | let $user_status = $(".viewer-list").find(`#${viewer.user_id}`); |