I'm using the Lightbox code by Lokesh Dhakar. One error:"Parsing error: Unexpected token )" Help

littlemoon

New Coder
Jan 26, 2020
3
0
2
I've tried deleting ), both and one by one, as well as } and ;. Even deleted all of them at once, error still there. Help would be very much appreciated!

JavaScript:
Lightbox.prototype.keyboardAction = function(event) {
    var KEYCODE_ESC        = 27;
    var KEYCODE_LEFTARROW  = 37;
    var KEYCODE_RIGHTARROW = 39;

    var keycode = event.keyCode;
    if (keycode === KEYCODE_ESC) {
      // Prevent bubbling so as to not affect other components on the page.
      event.stopPropagation();
      this.end();
    } else if (keycode === KEYCODE_LEFTARROW) {
      if (this.currentImageIndex !== 0) {
        this.changeImage(this.currentImageIndex - 1);
      } else if (this.options.wrapAround && this.album.length > 1) {
        this.changeImage(this.album.length - 1);
      }
    } else if (keycode === KEYCODE_RIGHTARROW) {
      if (this.currentImageIndex !== this.album.length - 1) {
        this.changeImage(this.currentImageIndex + 1);
      } else if (this.options.wrapAround && this.album.length > 1) {
        this.changeImage(0);
      }
    }
  };

  // Closing time. :-(
  Lightbox.prototype.end = function() {
    this.disableKeyboardNav();
    $(window).off('resize', this.sizeOverlay);
    this.$lightbox.fadeOut(this.options.fadeDuration);
    this.$overlay.fadeOut(this.options.fadeDuration);

    if (this.options.disableScrolling) {
      $('body').removeClass('lb-disable-scrolling');
    }
  };

  return new Lightbox();
  }));  <-------THIS IS WHERE IT SAYS THE ERROR IS.
 
Last edited by a moderator:
Jun 26, 2019
76
21
8
Which environment are you working in? Is there a link to a full example that your code is based on?

I tried your code in repl.it (node js) and it seems that the last 2 lines can be deleted ... was getting different errors. This code probably needs more framework to make sense (at least to me).