<commit_before><%
webgl_id = @monograph_presenter.webgl_id
webgl = FactoryService.webgl_unity(webgl_id)
@unity_progress = javascript_path 'unity_progress_heliotrope'
@unity_loader = "/webgl/#{webgl_id}/#{webgl.unity_loader}"
@unity_json = "/webgl/#{webgl_id}/#{webgl.unity_json}"
%>
<script src="<%= @unity_progress %>"></script>
<script src="<%= @unity_loader %>"></script>
<script>
  // this has to go right after @unity_loader is loaded to guarantee no random JS errors get alert-boxed
  UnityLoader.Error.handler = function(e, t){
    // NOP to stop the nuisance alert boxes for *all* (even non-Unity) JS errors
  }
</script>
<script>
  var gameInstance = undefined;
  var gameReady = false;
  // Toggling for focus of canvas
  function GameControlReady () {
    gameReady = true;
  }

  $(document).on('turbolinks:load', function() {
    // load the webgl if the webgl tab is already active
    if ($('#webgl-tab').hasClass('active')) {
      if (typeof gameInstance === 'undefined') {


        gameInstance = UnityLoader.instantiate("gameContainer", "<%= @unity_json %>", {onProgress: UnityProgressHeliotrope});

        function FocusCanvas(focus) {
          if (gameReady) {
            var SendMessage = gameInstance.SendMessage;
            SendMessage("GameControl", "FocusCanvas", focus);
          }
        }

        document.addEventListener('click', function(e) {
          if (e.target.id == "#canvas") {
            // Clicked on canvas
            FocusCanvas("1");
              } else {
            // Clicked outside of canvas
            FocusCanvas("0");
          }
        });

        document.addEventListener('keydown', function(event) {
          if (event.defaultPrevented) {
            return; // Do nothing if the event was already processed
          }

          switch (event.key) {
            case "Tab":
              FocusCanvas("0");
            break;
            default:
            return;
          }

        }, true);

        // Take user to a POI when passed a string from WebGL
        function goToParagraph() {
          // don't do anything quite yet - here to prevent errors
          var goToParagraph = null;
        }
      }
    }
    // or load the webgl if the tab is clicked
    $("a[href='#webgl']").bind('click', function() {
      if (typeof gameInstance === 'undefined') {


        gameInstance = UnityLoader.instantiate("gameContainer", "<%= @unity_json %>", {onProgress: UnityProgressHeliotrope});

        function FocusCanvas(focus) {
          if (gameReady) {
            var SendMessage = gameInstance.SendMessage;
            SendMessage("GameControl", "FocusCanvas", focus);
          }
        }

        document.addEventListener('click', function(e) {
          if (e.target.id == "#canvas") {
            // Clicked on canvas
            FocusCanvas("1");
              } else {
            // Clicked outside of canvas
            FocusCanvas("0");
          }
        });

        document.addEventListener('keydown', function(event) {
          if (event.defaultPrevented) {
            return; // Do nothing if the event was already processed
          }

          switch (event.key) {
            case "Tab":
              FocusCanvas("0");
            break;
            default:
            return;
          }

        }, true);

        // Take user to a POI when passed a string from WebGL
        function goToParagraph() {
          // don't do anything quite yet - here to prevent errors
          var goToParagraph = null;
        }
      }
    });
  });
</script>
<div class="webgl-content">
  <div id="gameContainer" style="width: 1024px; height: 600px" tabindex="0"></div>
</div><commit_msg>Resolves #1641 3D Model links to text in 'standalone' mode shouldn't link to the epub paragraph (for now) but to a handle<commit_after><%
webgl_id = @monograph_presenter.webgl_id
webgl = FactoryService.webgl_unity(webgl_id)
@unity_progress = javascript_path 'unity_progress_heliotrope'
@unity_loader = "/webgl/#{webgl_id}/#{webgl.unity_loader}"
@unity_json = "/webgl/#{webgl_id}/#{webgl.unity_json}"
%>
<script src="<%= @unity_progress %>"></script>
<script src="<%= @unity_loader %>"></script>
<script>
  // this has to go right after @unity_loader is loaded to guarantee no random JS errors get alert-boxed
  UnityLoader.Error.handler = function(e, t){
    // NOP to stop the nuisance alert boxes for *all* (even non-Unity) JS errors
  }
</script>
<script>
  var gameInstance = undefined;
  var gameReady = false;
  // Toggling for focus of canvas
  function GameControlReady () {
    gameReady = true;
  }

  // Take user to a POI when passed a string from WebGL
  function goToParagraph(p) {
    var paragraphHandle = "http://hdl.handle.net/2027/fulcrum.9231782/" + "par" + p;
    $('#paragraphHandle').html('<a href="' + paragraphHandle + '" target="_blank">' + paragraphHandle + '</a>');
    $('#goToParagraphModal').modal();
  }

  $(document).on('turbolinks:load', function() {
    // load the webgl if the webgl tab is already active
    if ($('#webgl-tab').hasClass('active')) {
      if (typeof gameInstance === 'undefined') {


        gameInstance = UnityLoader.instantiate("gameContainer", "<%= @unity_json %>", {onProgress: UnityProgressHeliotrope});

        function FocusCanvas(focus) {
          if (gameReady) {
            var SendMessage = gameInstance.SendMessage;
            SendMessage("GameControl", "FocusCanvas", focus);
          }
        }

        document.addEventListener('click', function(e) {
          if (e.target.id == "#canvas") {
            // Clicked on canvas
            FocusCanvas("1");
              } else {
            // Clicked outside of canvas
            FocusCanvas("0");
          }
        });

        document.addEventListener('keydown', function(event) {
          if (event.defaultPrevented) {
            return; // Do nothing if the event was already processed
          }

          switch (event.key) {
            case "Tab":
              FocusCanvas("0");
            break;
            default:
            return;
          }

        }, true);
      }
    }
    // or load the webgl if the tab is clicked
    $("a[href='#webgl']").bind('click', function() {
      if (typeof gameInstance === 'undefined') {


        gameInstance = UnityLoader.instantiate("gameContainer", "<%= @unity_json %>", {onProgress: UnityProgressHeliotrope});

        function FocusCanvas(focus) {
          if (gameReady) {
            var SendMessage = gameInstance.SendMessage;
            SendMessage("GameControl", "FocusCanvas", focus);
          }
        }

        document.addEventListener('click', function(e) {
          if (e.target.id == "#canvas") {
            // Clicked on canvas
            FocusCanvas("1");
              } else {
            // Clicked outside of canvas
            FocusCanvas("0");
          }
        });

        document.addEventListener('keydown', function(event) {
          if (event.defaultPrevented) {
            return; // Do nothing if the event was already processed
          }

          switch (event.key) {
            case "Tab":
              FocusCanvas("0");
            break;
            default:
            return;
          }

        }, true);
      }
    });
  });
</script>
<div class="webgl-content">
  <div id="gameContainer" style="width: 1024px; height: 600px" tabindex="0"></div>
</div>

<div class="modal fade" id="goToParagraphModal" tabindex="-1" role="dialog" aria-labelledby="goToParagraphModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      </div>
      <div class="modal-body">
        <p>To view a textual reference to this stratigraphic unit in the publication, please use the following permalink (will open in a new window):</p>

        <p id="paragraphHandle"></p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
{'fraction_non_alphanumeric': 0.1363747553816047, 'fraction_numerical': 0.005503913894324853, 'mean_word_length': 2.261667331471879, 'pattern_counts': {'":': 4, '<': 61, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3602745', 'n_tokens_mistral': 2372, 'n_tokens_neox': 2276, 'n_words': 593}