@@ -200,30 +200,10 @@ const renderGroupVideo = (group, video) => {
200200 openVideo ( video , inNewTab ) ;
201201 } ;
202202
203- const link = ( selector , opts , children ) => {
204- if ( ! opts . href ) { return m ( selector , { href : '#' , ...opts } , children ) ; }
205- let url = decodeURIComponent ( opts . href . replace ( / ^ h t t p s ? : \/ \/ ( w w w \. ) ? / , '' ) ) ;
206- if ( opts . target === '_blank' ) { url += ' ⇗' ; }
207- let el ;
208- return m ( selector , {
209- onmouseenter ( e ) {
210- e . stopPropagation ( ) ;
211- el = document . createElement ( 'div' ) ;
212- el . className = 'mouseover-link' ;
213- el . textContent = url ;
214- document . body . append ( el ) ;
215- } ,
216- onmouseleave ( ) {
217- if ( el ) { el . remove ( ) ; }
218- } ,
219- ...opts
220- } , children ) ;
221- } ;
222-
223203 const userView = ( user ) => {
224204 if ( ! user ) { return null ; }
225- return link ( ( user . url ? 'a' : 'span' ) + '.user' , {
226- href : user . url ,
205+ return m ( ( user . url ? 'a' : 'span' ) + '.user' , {
206+ href : user . url || '#' ,
227207 target : '_blank' ,
228208 } , [
229209 user . image ?
@@ -242,7 +222,7 @@ const renderGroupVideo = (group, video) => {
242222 const image = game . image ||
243223 'http://static-cdn.jtvnw.net/ttv-boxart/' +
244224 encodeURIComponent ( game . name ) + '-138x190.jpg' ;
245- return link ( 'a.game' , {
225+ return m ( 'a.game' , {
246226 href : url ,
247227 target : '_blank' ,
248228 'data-title' : game . name ,
@@ -251,9 +231,9 @@ const renderGroupVideo = (group, video) => {
251231
252232 const sourceView = ( source ) => {
253233 return m ( 'span.source' , [
254- link ( ( source . url ? 'a' : 'span' ) + '.favicon' , {
234+ m ( ( source . url ? 'a' : 'span' ) + '.favicon' , {
255235 className : 'source-' + source . source ,
256- href : source . url ,
236+ href : source . url || '#' ,
257237 target : '_blank' ,
258238 } )
259239 ] . concat ( source . users ?
@@ -267,7 +247,7 @@ const renderGroupVideo = (group, video) => {
267247 if ( video . silentQueued ) { vidClass += '.silent-queued' ; }
268248 if ( video . playing ) { vidClass += '.playing' ; }
269249 const $video = m ( 'li.video' + vidClass , [
270- link ( 'a.left-side' , { href : video . url , disabled : true } , [
250+ m ( 'a.left-side' , { href : video . url , disabled : true } , [
271251 m ( 'img.lazy' , {
272252 'data-src' : video . thumbnail || '' ,
273253 onclick : open . bind ( null , false ) ,
@@ -373,7 +353,7 @@ const renderGroupVideo = (group, video) => {
373353 e . preventDefault ( ) ;
374354 } ,
375355 } , m . trust ( '×' ) ) ,
376- link ( 'a.title' , {
356+ m ( 'a.title' , {
377357 href : video . url ,
378358 onclick : open . bind ( null , false )
379359 } , video . title ) ,
@@ -401,10 +381,30 @@ const renderGroupVideo = (group, video) => {
401381 ] )
402382 ] ) ;
403383
384+ hoverLinks ( $video ) ;
404385 video . $video = $video ;
405386 return $video ;
406387} ;
407388
389+ const hoverLinks = ( $video ) => {
390+ for ( let $link of $video . querySelectorAll ( 'a' ) ) {
391+ let url = decodeURIComponent ( $link . href )
392+ . replace ( / ^ h t t p s ? : \/ \/ ( w w w \. ) ? / , '' ) ;
393+ if ( $link . target === '_blank' ) { url += ' ⇗' ; }
394+ let el ;
395+ $link . addEventListener ( 'mouseenter' , ( e ) => {
396+ e . stopPropagation ( ) ;
397+ el = document . createElement ( 'div' ) ;
398+ el . className = 'mouseover-link' ;
399+ el . textContent = url ;
400+ document . body . append ( el ) ;
401+ } ) ;
402+ $link . addEventListener ( 'mouseleave' , ( ) => {
403+ if ( el ) { el . remove ( ) ; }
404+ } ) ;
405+ }
406+ } ;
407+
408408const renderVideos = ( group ) => {
409409 group . rendered = true ;
410410 if ( ! group . videos . length ) {
0 commit comments