<commit_before>// -*- Mode: SCSS; tab-width: 8; indent-tabs-mode: true; c-basic-offset: 8 -*-

var Juvia;
if (!Juvia) {
	Juvia = {};
}

(function(Juvia) {
	var RawDeflate;
	<%= File.read("#{Rails.root}/app/assets/javascripts/jquery-1.7.1.min.js").html_safe %>
	<%= File.read("#{Rails.root}/app/assets/javascripts/jquery.delayed-observer.js").html_safe %>
	<%= File.read("#{Rails.root}/app/assets/javascripts/jquery.example.min.js").html_safe %>
	<%= File.read("#{Rails.root}/app/assets/javascripts/rawdeflate.js").html_safe %>
	<%= File.read("#{Rails.root}/app/assets/javascripts/base64.js").html_safe %>
	var $ = Juvia.$ = window.jQuery.noConflict(true);
	
	Juvia.reinstallBehavior = function() {
		var self = this;
		
		if (!$(document.body).hasClass('juvia-installed-behavior')) {
			$(document.body).addClass('juvia-installed-behavior');
			$(document.body).bind('mousedown touchdown', function(event) {
				if (!$(event.target).hasClass('.juvia-help-content')
				 && $(event.target).closest('.juvia-help-content').length == 0) {
					$('.juvia-help-content').hide();
				}
			});
		}
		
		$('.juvia-container:not(.juvia-installed-behavior)').each(function() {
			var $this = $(this);
			$this.addClass('juvia-installed-behavior');
			
			var addCommentForm = $('.juvia-add-comment-form', this);
			
			$('input[name=author_name]', addCommentForm).example('Your name (optional)',
				{ className: 'juvia-example-text' });
			$('input[name=author_email]', addCommentForm).example('Your email (optional)',
				{ className: 'juvia-example-text' });
			
			/* Our submit handler is called before jquery.example has cleared the
			 * example texts. We work around this by calling our actual
			 * submit handler a short while later.
			 */
			addCommentForm.bind('submit', function(event) {
				setTimeout(function() {
					self.submitComment(event);
				}, 1);
			});
			
			$('.juvia-help', this).bind('click', function() {
				var $this = $(this);
				var content = $this.parent().find('.juvia-help-content');
				var offset = $this.position();
				content.css({
					left: offset.left + 'px',
					top: (offset.top + $this.outerHeight() + 8) + 'px'
				});
				content.show();
			});

			var textarea = $('.juvia-textarea-field textarea', addCommentForm);
			textarea.delayedObserver(function() {
				self.previewComment(this);
			});
			
			var errorDiv = $('.juvia-form-actions .juvia-error', addCommentForm);
			addCommentForm.bind('reset', function() {
				errorDiv.hide();
				// Repopulate example texts in input fields.
				setTimeout(function() {
					$('input', addCommentForm).blur();
				}, 1);
			});
		});

		$('.juvia-reply-to-comment a:not(.juvia-installed-behavior)').each(function() {
			var $this = $(this);
			$this.addClass('juvia-installed-behavior');
			$this.bind('click', function() {
				var comment = $(this).closest('.juvia-comment');
				self.replyToComment(comment);
			});
		});
	}
	
	Juvia.findContainer = function(options) {
		return $('.juvia-container[data-site-key="' +
			options.site_key +
			'"][data-topic-key="' +
			options.topic_key +
			'"]');
	}
	
	Juvia.showFormError = function(container, message) {
		var div = $('.juvia-form-actions .juvia-error', container);
		if (message == undefined || message == null || message == '') {
			div.hide();
		} else {
			div.text(message).show();
		}
	}
	
	Juvia.loadScript = function(path, options) {
		var url = '<%= escape_javascript(request.protocol + request.host_with_port) %>';
		url += path;
		
		if (this.supportsCors) {
			url += '.json';
			$.post(url, options, function(response) {
				Juvia.handleResponse(response);
			}, 'json');
		} else {<commit_msg>Use protocol relative url to load javascript<commit_after>// -*- Mode: SCSS; tab-width: 8; indent-tabs-mode: true; c-basic-offset: 8 -*-

var Juvia;
if (!Juvia) {
	Juvia = {};
}

(function(Juvia) {
	var RawDeflate;
	<%= File.read("#{Rails.root}/app/assets/javascripts/jquery-1.7.1.min.js").html_safe %>
	<%= File.read("#{Rails.root}/app/assets/javascripts/jquery.delayed-observer.js").html_safe %>
	<%= File.read("#{Rails.root}/app/assets/javascripts/jquery.example.min.js").html_safe %>
	<%= File.read("#{Rails.root}/app/assets/javascripts/rawdeflate.js").html_safe %>
	<%= File.read("#{Rails.root}/app/assets/javascripts/base64.js").html_safe %>
	var $ = Juvia.$ = window.jQuery.noConflict(true);
	
	Juvia.reinstallBehavior = function() {
		var self = this;
		
		if (!$(document.body).hasClass('juvia-installed-behavior')) {
			$(document.body).addClass('juvia-installed-behavior');
			$(document.body).bind('mousedown touchdown', function(event) {
				if (!$(event.target).hasClass('.juvia-help-content')
				 && $(event.target).closest('.juvia-help-content').length == 0) {
					$('.juvia-help-content').hide();
				}
			});
		}
		
		$('.juvia-container:not(.juvia-installed-behavior)').each(function() {
			var $this = $(this);
			$this.addClass('juvia-installed-behavior');
			
			var addCommentForm = $('.juvia-add-comment-form', this);
			
			$('input[name=author_name]', addCommentForm).example('Your name (optional)',
				{ className: 'juvia-example-text' });
			$('input[name=author_email]', addCommentForm).example('Your email (optional)',
				{ className: 'juvia-example-text' });
			
			/* Our submit handler is called before jquery.example has cleared the
			 * example texts. We work around this by calling our actual
			 * submit handler a short while later.
			 */
			addCommentForm.bind('submit', function(event) {
				setTimeout(function() {
					self.submitComment(event);
				}, 1);
			});
			
			$('.juvia-help', this).bind('click', function() {
				var $this = $(this);
				var content = $this.parent().find('.juvia-help-content');
				var offset = $this.position();
				content.css({
					left: offset.left + 'px',
					top: (offset.top + $this.outerHeight() + 8) + 'px'
				});
				content.show();
			});

			var textarea = $('.juvia-textarea-field textarea', addCommentForm);
			textarea.delayedObserver(function() {
				self.previewComment(this);
			});
			
			var errorDiv = $('.juvia-form-actions .juvia-error', addCommentForm);
			addCommentForm.bind('reset', function() {
				errorDiv.hide();
				// Repopulate example texts in input fields.
				setTimeout(function() {
					$('input', addCommentForm).blur();
				}, 1);
			});
		});

		$('.juvia-reply-to-comment a:not(.juvia-installed-behavior)').each(function() {
			var $this = $(this);
			$this.addClass('juvia-installed-behavior');
			$this.bind('click', function() {
				var comment = $(this).closest('.juvia-comment');
				self.replyToComment(comment);
			});
		});
	}
	
	Juvia.findContainer = function(options) {
		return $('.juvia-container[data-site-key="' +
			options.site_key +
			'"][data-topic-key="' +
			options.topic_key +
			'"]');
	}
	
	Juvia.showFormError = function(container, message) {
		var div = $('.juvia-form-actions .juvia-error', container);
		if (message == undefined || message == null || message == '') {
			div.hide();
		} else {
			div.text(message).show();
		}
	}
	
	Juvia.loadScript = function(path, options) {
		var url = '<%= escape_javascript("//" + request.host_with_port) %>';
		url += path;
		
		if (this.supportsCors) {
			url += '.json';
			$.post(url, options, function(response) {
				Juvia.handleResponse(response);
			}, 'json');
		} else {
{'fraction_non_alphanumeric': 0.20109215017064846, 'fraction_numerical': 0.0030034129692832765, 'mean_word_length': 3.5959849435382685, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4300085', 'n_tokens_mistral': 2980, 'n_tokens_neox': 2423, 'n_words': 396}