text: // Modified from https://tutorialzine.com/2016/07/take-a-selfie-with-js
  
  // References to all the element we will need.
  var video = document.querySelector('#camera-stream'),
      image = document.querySelector('#snap'),
      start_camera = document.querySelector('#start-camera'),
      controls = document.querySelector('.controls'),
      take_photo_btn = document.querySelector('#take-photo'),
      delete_photo_btn = document.querySelector('#delete-photo'),
      error_message = document.querySelector('#error-message');
  
  
  // The getUserMedia interface is used for handling camera input.
  // Some browsers need a prefix so here we're covering all the options
  navigator.getMedia = ( navigator.getUserMedia ||
                        navigator.webkitGetUserMedia ||
                        navigator.mozGetUserMedia ||
                        navigator.msGetUserMedia);
  
  
  if(!navigator.getMedia){
    displayErrorMessage("Your browser doesn't have support for the navigator.getUserMedia interface.");
  }
  else{
  
    // Request the camera.
    navigator.getMedia(
      {
        video: true
      },
      // Success Callback
      function(stream){
  
        // Create an object URL for the video stream and
        // set it as src of our HTLM video element.
        // video.src = window.URL.createObjectURL(stream);
        try {
          video.srcObject = stream;
        } catch (error) {
          video.src = window.URL.createObjectURL(stream);
        }
  
        // Play the video element to start the stream.
        video.play();
        video.onplay = function() {
          showVideo();
        };
  
      },
      // Error Callback
      function(err){
        displayErrorMessage("There was an error with accessing the camera stream: " + err.name, err);
      }
    );
  
  }
  
  // Mobile browsers cannot play video without user input,
  // so here we're using a button to start it manually.
  start_camera.addEventListener("click", function(e){
  
    e.preventDefault();
  
    // Start video playback manually.
    video.play();
    showVideo();
  
  });
  
  
  function showVideo(){
    // Display the video stream and the controls.
  
    hideUI();
    video.classList.add("visible");
    controls.classList.add("visible");
  }
  
  function displayErrorMessage(error_msg, error){
    error = error || "";
    if(error){
      console.log(error);
    }
  
    error_message.innerText = error_msg;
  
    hideUI();
    error_message.classList.add("visible");
  }
  
  
  function hideUI(){
    // Helper function for clearing the app UI.
  
    controls.classList.remove("visible");
    start_camera.classList.remove("visible");
    video.classList.remove("visible");
    snap.classList.remove("visible");
    error_message.classList.remove("visible");
  }
  
  // document.getElementById("take-photo").autofocus = true;
  