<commit_before><% provide :page_title, @title || "Title" %>
<%# https://github.com/mlibrary/heliotrope/issues/1228 %>
<% content_for :head do %>
  <meta name="turbolinks-cache-control" content="no-cache">
  <script type="text/javascript" src="https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js"></script>
  <% if @parent_presenter.doi.present? %>
    <script async src="https://badge.dimensions.ai/badge.js" charset="utf-8"></script>
  <% end %>
  <% if defined? @subdomain %>
    <%# only include hypothes.is for leverpress, um press and its subpresses at this point %>
    <% if %w[leverpress michigan cjs cseas csas lrccs ummaa].include? @subdomain %>
    <!-- hypothes.is -->
      <script type="text/javascript">
        window.hypothesisConfig = function () {
          return {
            openSidebar: false,
            theme: 'clean', // "clean" or "classic"
            enableMultiFrameSupport: true,
            onLayoutChange: function(state) {
              var $frame = $('.annotator-frame');
              var $reader = $("#reader");
            },
            enableExperimentalNewNoteButton: true
          };
        };
      </script>
      <script src="https://cdn.hypothes.is/hypothesis"></script>
    <% end %>
  <% end %>
  <% if @parent_presenter.webgl? %>
    <%
# load what we need to show the webgl/3-d model if needed
webgl_id = @parent_presenter.webgl_id
webgl = Webgl::Unity.from_directory(UnpackService.root_path_from_noid(webgl_id, 'webgl'))
@unity_loader = "/webgl/#{webgl_id}/#{webgl.unity_loader}"
@unity_json = "/webgl/#{webgl_id}/#{webgl.unity_json}"
    %>
       <!-- browser detection here -->
     <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>
  <% end %>
<% end %>

<% provide :body do %>
  <% if defined? @presenter.file_set_coins_title %>
    <span class="Z3988" title="<%= @presenter.file_set_coins_title %>" aria-hidden="true"></span>
  <% end %>
  <!-- TODO: add logic to display survey if book is free -->
  <% if @parent_presenter.open_access? %>
    <%= render 'shared/survey_nonmodal' %>
  <% end %>
  <div class="skip"></div>
  <div id="epub" class="<%= @subdomain %>">
    <div id="reader"></div>

    <script type="text/javascript">
      if ( true ) {

        <% if %w[leverpress michigan cjs cseas csas lrccs ummaa].include? @subdomain %>
          // Create custom annotator button that is aware of its state
          AnnotationTool = cozy.Control.Widget.Toggle.extend({
            defaultTemplate: '<button data-hypothesis-trigger class="button--sm annotation" data-toggle="button" aria-label="Open Annotations"><i class="fa fa-pencil" title="Open annotation panel" aria-hidden="true"></i></button><div class="annotation-count" data-hypothesis-annotation-count></div>',


            initialize: function(options) {

              cozy.Control.Widget.Toggle.prototype.initialize.apply(this, arguments);

              this.options.states = [{
                stateName: 'close-annotator',
                onClick: this.openAnnotator.bind(this)
              },
              {
                stateName: 'open-annotator',
                onClick: this.closeAnnotator.bind(this)
              }];
            },

            _onAddExtra: function(container) {
              // super._onAddExtra(container);
              cozy.Control.Widget.Toggle.prototype._onAddExtra.apply(this, arguments);
              this.setupHook();
              return container;
            },

            openAnnotator: function(self, reader) {
              this.options.$panel.removeClass("annotator-collapsed");
              self.state('open-annotator');
            },

            closeAnnotator: function(self, reader) {
              this.options.$panel.addClass("annotator-collapsed");
              self.state('close-annotator');
            },

            setupHook: function() {
              var reader = this._reader;
              reader.rendition.hooks.content.register(function(contents, view) {
                contents.window.addEventListener('scrolltorange', function (e) {
                  var range = e.detail;
                  var cfi = new reader.CFI(range, contents.cfiBase).toString();
                  if (cfi) {
                    reader.gotoPage(cfi);
                  }
                  e.preventDefault();
                });
              })
            }
          })
        <% end %>

        // Configure and initiate reader
        var reader = cozy.reader('reader', {
          // See https://tools.lib.umich.edu/jira/browse/HELIO-3350 and https://stackoverflow.com/a/47331356
          // Hopefully this line can be removed eventually. Note these are the epub FileSet's NOIDs.
          <% if %w[cc08hh07v x059c8342 t722h883s ws859h272 4t64gq185].include? @presenter.id %>...(bowser.safari && bowser.version >= 13 ? {flow: 'scrolled-doc'} : {}),<% end %>
          href: "<%= "#{main_app.epub_url.gsub!(/\?.*/, '')}/" %>",
          skipLink: '.skip',
          download_links: <%= @ebook_download_presenter.csb_download_links.to_json.html_safe %>,
          loader_template: '<div class="fulcrum-loading"><div class="rect rect1"></div><div class="circle circ1"></div><div class="rect rect2"></div><div class="circle circ2"></div></div>',
          <% if %w[leverpress michigan mps uncpress].include? @subdomain %>
          injectStylesheet: '/css/fulcrum_enhanced_display.css',
          <% end %>
          metadata: {
            doi: '<%= @citable_link %>',<commit_msg>add NOID for another video-containing EPUB<commit_after><% provide :page_title, @title || "Title" %>
<%# https://github.com/mlibrary/heliotrope/issues/1228 %>
<% content_for :head do %>
  <meta name="turbolinks-cache-control" content="no-cache">
  <script type="text/javascript" src="https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js"></script>
  <% if @parent_presenter.doi.present? %>
    <script async src="https://badge.dimensions.ai/badge.js" charset="utf-8"></script>
  <% end %>
  <% if defined? @subdomain %>
    <%# only include hypothes.is for leverpress, um press and its subpresses at this point %>
    <% if %w[leverpress michigan cjs cseas csas lrccs ummaa].include? @subdomain %>
    <!-- hypothes.is -->
      <script type="text/javascript">
        window.hypothesisConfig = function () {
          return {
            openSidebar: false,
            theme: 'clean', // "clean" or "classic"
            enableMultiFrameSupport: true,
            onLayoutChange: function(state) {
              var $frame = $('.annotator-frame');
              var $reader = $("#reader");
            },
            enableExperimentalNewNoteButton: true
          };
        };
      </script>
      <script src="https://cdn.hypothes.is/hypothesis"></script>
    <% end %>
  <% end %>
  <% if @parent_presenter.webgl? %>
    <%
# load what we need to show the webgl/3-d model if needed
webgl_id = @parent_presenter.webgl_id
webgl = Webgl::Unity.from_directory(UnpackService.root_path_from_noid(webgl_id, 'webgl'))
@unity_loader = "/webgl/#{webgl_id}/#{webgl.unity_loader}"
@unity_json = "/webgl/#{webgl_id}/#{webgl.unity_json}"
    %>
       <!-- browser detection here -->
     <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>
  <% end %>
<% end %>

<% provide :body do %>
  <% if defined? @presenter.file_set_coins_title %>
    <span class="Z3988" title="<%= @presenter.file_set_coins_title %>" aria-hidden="true"></span>
  <% end %>
  <!-- TODO: add logic to display survey if book is free -->
  <% if @parent_presenter.open_access? %>
    <%= render 'shared/survey_nonmodal' %>
  <% end %>
  <div class="skip"></div>
  <div id="epub" class="<%= @subdomain %>">
    <div id="reader"></div>

    <script type="text/javascript">
      if ( true ) {

        <% if %w[leverpress michigan cjs cseas csas lrccs ummaa].include? @subdomain %>
          // Create custom annotator button that is aware of its state
          AnnotationTool = cozy.Control.Widget.Toggle.extend({
            defaultTemplate: '<button data-hypothesis-trigger class="button--sm annotation" data-toggle="button" aria-label="Open Annotations"><i class="fa fa-pencil" title="Open annotation panel" aria-hidden="true"></i></button><div class="annotation-count" data-hypothesis-annotation-count></div>',


            initialize: function(options) {

              cozy.Control.Widget.Toggle.prototype.initialize.apply(this, arguments);

              this.options.states = [{
                stateName: 'close-annotator',
                onClick: this.openAnnotator.bind(this)
              },
              {
                stateName: 'open-annotator',
                onClick: this.closeAnnotator.bind(this)
              }];
            },

            _onAddExtra: function(container) {
              // super._onAddExtra(container);
              cozy.Control.Widget.Toggle.prototype._onAddExtra.apply(this, arguments);
              this.setupHook();
              return container;
            },

            openAnnotator: function(self, reader) {
              this.options.$panel.removeClass("annotator-collapsed");
              self.state('open-annotator');
            },

            closeAnnotator: function(self, reader) {
              this.options.$panel.addClass("annotator-collapsed");
              self.state('close-annotator');
            },

            setupHook: function() {
              var reader = this._reader;
              reader.rendition.hooks.content.register(function(contents, view) {
                contents.window.addEventListener('scrolltorange', function (e) {
                  var range = e.detail;
                  var cfi = new reader.CFI(range, contents.cfiBase).toString();
                  if (cfi) {
                    reader.gotoPage(cfi);
                  }
                  e.preventDefault();
                });
              })
            }
          })
        <% end %>

        // Configure and initiate reader
        var reader = cozy.reader('reader', {
          // See https://tools.lib.umich.edu/jira/browse/HELIO-3350 and https://stackoverflow.com/a/47331356
          // Hopefully this line can be removed eventually. Note these are the epub FileSet's NOIDs.
          <% if %w[cc08hh07v x059c8342 t722h883s ws859h272 4t64gq185 3n204094k].include? @presenter.id %>...(bowser.safari && bowser.version >= 13 ? {flow: 'scrolled-doc'} : {}),<% end %>
          href: "<%= "#{main_app.epub_url.gsub!(/\?.*/, '')}/" %>",
          skipLink: '.skip',
          download_links: <%= @ebook_download_presenter.csb_download_links.to_json.html_safe %>,
          loader_template: '<div class="fulcrum-loading"><div class="rect rect1"></div><div class="circle circ1"></div><div class="rect rect2"></div><div class="circle circ2"></div></div>',
          <% if %w[leverpress michigan mps uncpress].include? @subdomain %>
          injectStylesheet: '/css/fulcrum_enhanced_display.css',
          <% end %>
          metadata: {
            doi: '<%= @citable_link %>',
{'fraction_non_alphanumeric': 0.15043787392699212, 'fraction_numerical': 0.01118529437266973, 'mean_word_length': 2.3431884057971013, 'pattern_counts': {'":': 0, '<': 147, '<?xml version=': 0, '>': 149, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1052898', 'n_tokens_mistral': 3657, 'n_tokens_neox': 3372, 'n_words': 686}