Syntax error (Unexpected Identifier)

Asked

Viewed 1,082 times

1

I have the following script, where I am getting the following error on the console:

Uncaught Syntaxerror: Unexpected Identifier

$('#qr-canvas').WebCodeCam({
            ReadQRCode: true, // false or true
            ReadBarcode: true, // false or true
            width: 320,
            height: 240,
            videoSource: {  
                    id: true,      //default Videosource
                    maxWidth: 640, //max Videosource resolution width
                    maxHeight: 480 //max Videosource resolution height
            },
            flipVertical: false,  // false or true
            flipHorizontal: false,  // false or true
            zoom: -1, // if zoom = -1, auto zoom for optimal resolution else int
            beep: "/wordpress/wp-content/themes/better-health/webcodecamjs-master/audio/beep.mp3", // string, audio file location
            autoBrightnessValue: false, // functional when value autoBrightnessValue is int
            brightness: 0, // int 
            grayScale: false, // false or true
            contrast: 0, // int 
            threshold: 0, // int 
            sharpness: [], //or matrix, example for sharpness ->  [0, -1, 0, -1, 5, -1, 0, -1, 0]
            resultFunction: function(resText, lastImageSrc) {
                        resText as decoded code, lastImageSrc as image source
                        example:
                        alert(resText);

            },
            getUserMediaError: function() {
                        callback funtion to getUserMediaError
                        example:
                        alert('Sorry, the browser you are using doesn\'t support getUserMedia');

            },
            cameraError: function(error) {
                        /* callback funtion to cameraError, 
                        example:
                        var p, message = 'Error detected with the following parameters:\n';
                        for (p in error) {
                                message += p + ': ' + error[p] + '\n';
                        }
                        alert(message);
                        */
            }
        });
         $('#qr-canvas').WebCodeCam();

I can’t identify the mistake

  • Inside "resultFunction" and "getUserMediaError" have comments that need to be removed "resText as decoded code, lastImageSrc as image source ...." and "callback funtion to getUserMediaError ....."

1 answer

0


You are using comments in javascript without defining that these lines are really a comment as for example:

resText as decoded code, lastImageSrc as image source example:

Try it like this:

  $('#qr-canvas').WebCodeCam({
    ReadQRCode: true, // false or true
    ReadBarcode: true, // false or true
    width: 320,
    height: 240,
    videoSource: {
      id: true,      //default Videosource
      maxWidth: 640, //max Videosource resolution width
      maxHeight: 480 //max Videosource resolution height
    },
    flipVertical: false,  // false or true
    flipHorizontal: false,  // false or true
    zoom: -1, // if zoom = -1, auto zoom for optimal resolution else int
    beep: "/wordpress/wp-content/themes/better-health/webcodecamjs-master/audio/beep.mp3", // string, audio file location
    autoBrightnessValue: false, // functional when value autoBrightnessValue is int
    brightness: 0, // int 
    grayScale: false, // false or true
    contrast: 0, // int 
    threshold: 0, // int 
    sharpness: [], //or matrix, example for sharpness ->  [0, -1, 0, -1, 5, -1, 0, -1, 0]
    resultFunction: function (resText, lastImageSrc) {
      alert(resText);

    },
    getUserMediaError: function () {
      alert('Sorry, the browser you are using doesn\'t support getUserMedia');
    },
    cameraError: function (error) {
      /* callback funtion to cameraError, 
      example:
      var p, message = 'Error detected with the following parameters:\n';
      for (p in error) {
              message += p + ': ' + error[p] + '\n';
      }
      alert(message);
      */
    }
  });
  $('#qr-canvas').WebCodeCam();

Browser other questions tagged

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