Uncaught Syntaxerror: Unexpected token 'Else'

Asked

Viewed 118 times

-1

I’m trying to put a button on next episode, it’s working normal, the problem is that it appears in the movies, where it should only appear in episodes of series. I tried to solve the error by making the class of the button return a value that would only appear if it was in "Episodes", if it was elsewhere it would return "Array", so I tried to use the css so when it has "Array" in the class it would hide the button with the display: One, but did not work and gave error: Uncaught Syntaxerror: Unexpected token 'Else'

If anyone can help I’d appreciate it

Note: use the Wordpress theme "Dooplay" version 2.4.1

Code:

player.once('play', () => {


    <?php
     $postmeta = doo_postmeta_episodes($postid);
     $tmdbids  = doo_isset($postmeta,'ids');
    $temporad = doo_isset($postmeta,'temporada');
    $episode  = doo_isset($postmeta,'episodio');
     $episode_pagi = DDbmoviesHelpers::EpisodeNav($tmdbids,$temporad,$episode);
     $next_episode = doo_isset($episode_pagi,'next');
     $link_next = !empty($next_episode) ? $next_episode['permalink'].'" title="'.$next_episode['title'].'"' : 'href="#" class="nonex"';
    ?>
 

$('.jw-media').append(`<a class="<?php echo $postmeta ?>" target="_parent" href="<?php echo $link_next ?>" id="proximoep">Próximo Episódio <i class="fas fa-forward"></i></a>`);

});

    player.on('time', e => {

        let duration    = player.getDuration();
        let currentTime = Math.floor(e.position);


     if(currentTime > duration - 120){
            $('#proximoep').hasClass('Array');
            $('#proximoep').css('display', 'none');
     } else {  
            $('#proximoep').css('display', 'inline-block');
           }  else {
            $('#proximoep').css('display', 'none');
        }
    });
  • 1

    Your if has two else. That doesn’t make much sense.

  • I understand, you know some way to fix this, or you could recommend me some documentation on, I’ll be very grateful

1 answer

0

The code has both Else in a row, being the condition if a condition of true or false

It should have a code with the following structure

if(condição) {

   //código quando a condição é verdadeira
} else if ( condição2) {
  
  //código quando a 2 condição é verdadeira~
} else {
 
  /código quando todas as anteriores condições são falsas
}

From what I understand of the idea of your code, at the end of it, you’re missing a if

once the function hasClass return a bool

where the code should be as follows

if(currentTime > duration - 120){
    if($('#proximoep').hasClass('Array')) {
        $('#proximoep').css('display', 'none');
    } else {  
        $('#proximoep').css('display', 'inline-block');
    }
 } else {
    $('#proximoep').css('display', 'none');
 }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.