<commit_before>function Adventure(map) {
  this.display_inline = false;
  this.map = map;
  this.root_template =
  ['{{#.}}',
     '<div id="{{name}}" title="{{title}}" class="option" style="position: absolute; left: {{position.left}}; top: {{position.top}}; background-color: white;min-height: 40px;">',
     '<a href="{{nav name}}"><img src="{{content.thumbnail}}" alt="{{title}}"/></a>',
     '</div>',
     '{{/.}}'
    ].join('\n');

  this.links_template =
  ['<br/>{{#.}}',
   '<div id="{{.}}" class="link">',
   '{{{link .}}}',
   '</div>',
   '{{/.}}',
   '<div class="col-md-3"><a href="#/">Home</a></div>'
  ].join('\n');

  this.content_template =
  ['<div class="notes">{{{notes}}}</div><div class="fullsize-image"><img width="750px" src="{{image}}"/></div>'
  ].join('\n');
}

// Looking at this code now I don't know why navigate is not part of Adventure
// itself.

function start(adventure) {
  $(adventure.stage).html(adventure.root());
}

function navigate(name, adventure) {

  if (adventure.display_inline) {
    // Navigate to the given node
    $(adventure.stage).html(adventure.node(name).html);
    // Upodate the Title Header
    $(adventure.title_header).html('<h1 id="node-title-header">' +  adventure.node(name).title  + '</h1>');
  }

  // We want to display the large image in another window
  if (typeof(adventure.popup) !== 'undefined') {
    adventure.popup.setNotes(adventure.node(name).html);
  }
  
}

Adventure.prototype.displayInline = function(setting) {
  this.display_inline = setting;
};

Adventure.prototype.setRootTemplate = function(template) {
  this.root_template = template;
};

Adventure.prototype.setStage = function(stage) {
  this.stage = stage;
};

Adventure.prototype.setTitleHeader = function(title_header) {
  this.title_header = title_header;
};

Adventure.prototype.setPopup = function(popup) {
  this.popup = popup;
};

Adventure.prototype.draggable = function(decorate_function) {
  for (var i=0; i < this.map.root.length; i++) {

        // This seems messy and un-encapsulated.  How do we get it to work via 
        // the stage?

        var option = document.getElementById(this.map.root[i].name);
        // var option = this.stage.find('#' + this.map.root[i].name);
        interact(option).draggable({onmove: decorate_function}).inertia(true);
      }
};

Adventure.prototype.root = function() {

  var self = this; // It's all about the context...

  Handlebars.registerHelper('nav', function(name) {

    // Crossroads is global - is this a good idea?
    // Have I got this right? Do I need to add a route for every name or
    // is {name} a parameter?
    crossroads.addRoute('/node/{name}', function(name) {
      navigate(name, self);
    });
    // Nasty duplication of URL pattern - not DRY
    return '#/node/' + name;
  });

  var root_options = [];
<commit_msg>remove draggable, it's not reliable.<commit_after>function Adventure(map) {
  this.display_inline = false;
  this.map = map;
  this.root_template =
  ['{{#.}}',
     '<div id="{{name}}" title="{{title}}" class="option" style="position: absolute; left: {{position.left}}; top: {{position.top}}; background-color: white;min-height: 40px;">',
     '<a href="{{nav name}}"><img src="{{content.thumbnail}}" alt="{{title}}"/></a>',
     '</div>',
     '{{/.}}'
    ].join('\n');

  this.links_template =
  ['<br/>{{#.}}',
   '<div id="{{.}}" class="link">',
   '{{{link .}}}',
   '</div>',
   '{{/.}}',
   '<div class="col-md-3"><a href="#/">Home</a></div>'
  ].join('\n');

  this.content_template =
  ['<div class="notes">{{{notes}}}</div><div class="fullsize-image"><img width="750px" src="{{image}}"/></div>'
  ].join('\n');
}

// Looking at this code now I don't know why navigate is not part of Adventure
// itself.

function start(adventure) {
  $(adventure.stage).html(adventure.root());
}

function navigate(name, adventure) {

  if (adventure.display_inline) {
    // Navigate to the given node
    $(adventure.stage).html(adventure.node(name).html);
    // Upodate the Title Header
    $(adventure.title_header).html('<h1 id="node-title-header">' +  adventure.node(name).title  + '</h1>');
  }

  // We want to display the large image in another window
  if (typeof(adventure.popup) !== 'undefined') {
    adventure.popup.setNotes(adventure.node(name).html);
  }
  
}

Adventure.prototype.displayInline = function(setting) {
  this.display_inline = setting;
};

Adventure.prototype.setRootTemplate = function(template) {
  this.root_template = template;
};

Adventure.prototype.setStage = function(stage) {
  this.stage = stage;
};

Adventure.prototype.setTitleHeader = function(title_header) {
  this.title_header = title_header;
};

Adventure.prototype.setPopup = function(popup) {
  this.popup = popup;
};

Adventure.prototype.root = function() {

  var self = this; // It's all about the context...

  Handlebars.registerHelper('nav', function(name) {

    // Crossroads is global - is this a good idea?
    // Have I got this right? Do I need to add a route for every name or
    // is {name} a parameter?
    crossroads.addRoute('/node/{name}', function(name) {
      navigate(name, self);
    });
    // Nasty duplication of URL pattern - not DRY
    return '#/node/' + name;
  });

  var root_options = [];

{'fraction_non_alphanumeric': 0.1976434815659445, 'fraction_numerical': 0.0032307107563664004, 'mean_word_length': 3.5965065502183404, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 41, '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': '7082914', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1767, 'n_words': 382}