<commit_before>//
// Initialization
//
jQuery(function() {
  FragmentForm.init();
  Fragment.init();
  QuickEdit.init();
  
  // auto-complete
  jQuery("input[name=tags]").autocomplete(constants["autocomplete-url"], {
    minChars: 1,
    selectFirst: true,
    multiple: true,
    multipleSeparator: ', ',
    scrollHeight: 300
  });
  jQuery("input.single-tag").autocomplete(constants["autocomplete-url"], {
    minChars: 1,
    selectFirst: true,
    multiple: false,
    scrollHeight: 300
  });
});



//
// Fragment Form
//
var FragmentForm = {
	init: function() {
		jQuery('.content-type-switch input').click(FragmentForm.onContentTypeSwitch);
	  jQuery("textarea.fragment-content").markItUp(FragmentForm.markItUpSettings);
	  jQuery(".markItUp .markItUpButton9 a").attr("href", constants["wiki-help-href"])
	  	.click(FragmentForm.onWikiHelpClick);
	  jQuery("input[name=preview]").click(function () {
	    this.form.contentFieldHeight.value = jQuery(this.form.content).height();
	  });
	  jQuery(".fragment-form-panel input[name=register]").click(function () {
	    var panel = jQuery(this).closest(".fragment-form-panel");
	    panel.find(".fragment-form-toggle").putLoadingIcon("margin-left: 5px; vertical-align: middle;");
	    panel.find(".toggle-icon").attr("src", "images/twistie-up.gif");
	    panel.find(".fragment-form-div").hide();
	  });
	  
	  jQuery("input.fragment-as-tag").button({
      icons: {
      	primary: "ui-icon-piggydb-tag"
      },
      text: false
	  });
	},
		
  onToggleClick: function(panelName) {
		var formDiv = document.getElementById(panelName + "-div");
		var toggleIcon = document.getElementById(panelName + "-toggle-icon");
		if (formDiv.style.display == "none") {
		  toggleIcon.src = "images/twistie-down.gif";
		  formDiv.style.display = "block";
		} 
		else {
		  toggleIcon.src = "images/twistie-up.gif";
		  formDiv.style.display = "none";
		}
  },
  
  onContentTypeSwitch: function() {
    var formId = jQuery(this.form).attr("id");
    var newValue = this.value;
    var oldValue = this.form.contentType.value;
    if (newValue == oldValue) {
      return;
    }
    jQuery('#' + formId + ' .for-' + oldValue).hide();
    jQuery('#' + formId + ' .for-' + newValue).show();
    this.form.contentType.value = newValue;
  },
  
  wikiHelp: new Facebox("facebox-wiki-help"),
  
  onWikiHelpClick: function() {
  	FragmentForm.wikiHelp.show(this.href);
    return false;
  },
  
  markItUpSettings: {
    previewAutoRefresh: false,
    previewParserPath:  '', // path to your Wiki parser
    onShiftEnter:   {keepDefault:false, replaceWith:'\n\n'},
    markupSet: [
      {name: messages["editor-bold"], key: 'B', openWith: "'''", closeWith: "'''"}, 
      {name: messages["editor-italic"], key: 'I', openWith: "''", closeWith: "''"}, 
      {name: messages["editor-strike"], key: 'S', openWith: '__', closeWith: '__'}, 
      {separator: '---------------' },
      {name: messages["editor-bulleted-list"], openWith: '-'}, 
      {name: messages["editor-numeric-list"], openWith: '+'}, 
      {separator: '---------------' },
      {name: messages["editor-link"], key: "L", openWith: "[[![URL:!:http://]!] ", 
        closeWith: ']', placeHolder: messages["editor-link-label"] },
      {name: messages["editor-embed-another-fragment"], key: 'E',
        openWith: "fragment:[![" + messages["editor-fragment-id"] + "]!]:embed "},
      {separator: '---------------' },
      {name: messages["editor-quote"], openWith: '>', placeHolder: ''},
      {separator: '---------------' },
      {name: messages["help"]}
    ]
  }
};



//
// Fragment 
//
function Fragment(node) {
	this.node = jQuery(node);
	this.root = this.node.closest("table.fragment");
}
Fragment.init = function() {
	jQuery("table.fragment").live('mouseenter', function() {
    jQuery(this).find(".fragment-tools").eq(0).show();
  });
  jQuery("table.fragment").live('mouseleave', function() {
    jQuery(this).find(".fragment-tools").eq(0).hide();
  });
  jQuery("a.img-link").live("click", Fragment.onImageClick);
  makeFragmentsDroppable("table.fragment", null);
  makeSelectedFragmentsDroppable();
  makeRelationsDraggable("");
};
Fragment.findInTheSameFragmentNode = function(node, selector) {
	return jQuery(node).closest("table.fragment-node").find(selector);
};
Fragment.highlight = function(id, baseNode) {
  var selector = ".fragment-header-" + id;
  var color = "#ff9900";
  if (baseNode == null)
  	jQuery(selector).fadingHighlight(color);
  else
  	jQuery(baseNode).find(selector).fadingHighlight(color);
};
Fragment.onShowHiddenTags = function(button) {
  jQuery(button).siblings(".hidden-tags").show();
  jQuery(button).hide();
};
Fragment.imageViewer = new Facebox("facebox-image-viewer");
Fragment.onImageClick = function() {
	Fragment.imageViewer.showImage(this.href);
  return false;
};
Fragment.syncTitles = function(id, title, headline) {
	var selector = ".fragment-header-" + id + " span.title";
	jQuery(selector).html(headline);
	jQuery("table.fragment-full th.header-cell:first " + selector).html(title);
};
Fragment.prototype = {
	id: function() {
		return this.root.find("span.fragment-id:first").text();
	},
	
	header: function() {
		return this.root.find("div.fragment-header:first");
	},
	
	mainTitleSpan: function() {
		return this.header().find("span.title");
	},<commit_msg>Fixed Fragment.syncTitles<commit_after>//
// Initialization
//
jQuery(function() {
  FragmentForm.init();
  Fragment.init();
  QuickEdit.init();
  
  // auto-complete
  jQuery("input[name=tags]").autocomplete(constants["autocomplete-url"], {
    minChars: 1,
    selectFirst: true,
    multiple: true,
    multipleSeparator: ', ',
    scrollHeight: 300
  });
  jQuery("input.single-tag").autocomplete(constants["autocomplete-url"], {
    minChars: 1,
    selectFirst: true,
    multiple: false,
    scrollHeight: 300
  });
});



//
// Fragment Form
//
var FragmentForm = {
	init: function() {
		jQuery('.content-type-switch input').click(FragmentForm.onContentTypeSwitch);
	  jQuery("textarea.fragment-content").markItUp(FragmentForm.markItUpSettings);
	  jQuery(".markItUp .markItUpButton9 a").attr("href", constants["wiki-help-href"])
	  	.click(FragmentForm.onWikiHelpClick);
	  jQuery("input[name=preview]").click(function () {
	    this.form.contentFieldHeight.value = jQuery(this.form.content).height();
	  });
	  jQuery(".fragment-form-panel input[name=register]").click(function () {
	    var panel = jQuery(this).closest(".fragment-form-panel");
	    panel.find(".fragment-form-toggle").putLoadingIcon("margin-left: 5px; vertical-align: middle;");
	    panel.find(".toggle-icon").attr("src", "images/twistie-up.gif");
	    panel.find(".fragment-form-div").hide();
	  });
	  
	  jQuery("input.fragment-as-tag").button({
      icons: {
      	primary: "ui-icon-piggydb-tag"
      },
      text: false
	  });
	},
		
  onToggleClick: function(panelName) {
		var formDiv = document.getElementById(panelName + "-div");
		var toggleIcon = document.getElementById(panelName + "-toggle-icon");
		if (formDiv.style.display == "none") {
		  toggleIcon.src = "images/twistie-down.gif";
		  formDiv.style.display = "block";
		} 
		else {
		  toggleIcon.src = "images/twistie-up.gif";
		  formDiv.style.display = "none";
		}
  },
  
  onContentTypeSwitch: function() {
    var formId = jQuery(this.form).attr("id");
    var newValue = this.value;
    var oldValue = this.form.contentType.value;
    if (newValue == oldValue) {
      return;
    }
    jQuery('#' + formId + ' .for-' + oldValue).hide();
    jQuery('#' + formId + ' .for-' + newValue).show();
    this.form.contentType.value = newValue;
  },
  
  wikiHelp: new Facebox("facebox-wiki-help"),
  
  onWikiHelpClick: function() {
  	FragmentForm.wikiHelp.show(this.href);
    return false;
  },
  
  markItUpSettings: {
    previewAutoRefresh: false,
    previewParserPath:  '', // path to your Wiki parser
    onShiftEnter:   {keepDefault:false, replaceWith:'\n\n'},
    markupSet: [
      {name: messages["editor-bold"], key: 'B', openWith: "'''", closeWith: "'''"}, 
      {name: messages["editor-italic"], key: 'I', openWith: "''", closeWith: "''"}, 
      {name: messages["editor-strike"], key: 'S', openWith: '__', closeWith: '__'}, 
      {separator: '---------------' },
      {name: messages["editor-bulleted-list"], openWith: '-'}, 
      {name: messages["editor-numeric-list"], openWith: '+'}, 
      {separator: '---------------' },
      {name: messages["editor-link"], key: "L", openWith: "[[![URL:!:http://]!] ", 
        closeWith: ']', placeHolder: messages["editor-link-label"] },
      {name: messages["editor-embed-another-fragment"], key: 'E',
        openWith: "fragment:[![" + messages["editor-fragment-id"] + "]!]:embed "},
      {separator: '---------------' },
      {name: messages["editor-quote"], openWith: '>', placeHolder: ''},
      {separator: '---------------' },
      {name: messages["help"]}
    ]
  }
};



//
// Fragment 
//
function Fragment(node) {
	this.node = jQuery(node);
	this.root = this.node.closest("table.fragment");
}
Fragment.init = function() {
	jQuery("table.fragment").live('mouseenter', function() {
    jQuery(this).find(".fragment-tools").eq(0).show();
  });
  jQuery("table.fragment").live('mouseleave', function() {
    jQuery(this).find(".fragment-tools").eq(0).hide();
  });
  jQuery("a.img-link").live("click", Fragment.onImageClick);
  makeFragmentsDroppable("table.fragment", null);
  makeSelectedFragmentsDroppable();
  makeRelationsDraggable("");
};
Fragment.findInTheSameFragmentNode = function(node, selector) {
	return jQuery(node).closest("table.fragment-node").find(selector);
};
Fragment.highlight = function(id, baseNode) {
  var selector = ".fragment-header-" + id;
  var color = "#ff9900";
  if (baseNode == null)
  	jQuery(selector).fadingHighlight(color);
  else
  	jQuery(baseNode).find(selector).fadingHighlight(color);
};
Fragment.onShowHiddenTags = function(button) {
  jQuery(button).siblings(".hidden-tags").show();
  jQuery(button).hide();
};
Fragment.imageViewer = new Facebox("facebox-image-viewer");
Fragment.onImageClick = function() {
	Fragment.imageViewer.showImage(this.href);
  return false;
};
Fragment.syncTitles = function(id, title, headline) {
	var selector = ".fragment-header-" + id + " span.title";
	jQuery(selector).html(headline);
	jQuery("table.fragment-full > tbody > tr > th.header-cell " + selector).html(title);
};
Fragment.prototype = {
	id: function() {
		return this.root.find("span.fragment-id:first").text();
	},
	
	header: function() {
		return this.root.find("div.fragment-header:first");
	},
	
	mainTitleSpan: function() {
		return this.header().find("span.title");
	},
{'fraction_non_alphanumeric': 0.20326423412437858, 'fraction_numerical': 0.0030015945971297252, 'mean_word_length': 3.7093639575971733, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '3951493', 'n_tokens_mistral': 3584, 'n_tokens_neox': 3408, 'n_words': 523}