<commit_before>var statusa;

chrome.extension.sendRequest({msg: "getStatus"}, function(response) {
   if (response.status == 1) {
   		statusa = true;
   } else {
   		statusa = false;
   }
});

WIKI_URL_REGEX = /^((http|https):\/\/)?[a-z]+.wikipedia.org\/wiki\/[a-zA-Z0-9_()#%,.!-]+$/i
CLASS_MATCHER = /easy-wiki-popover/i

var extractLanguage = function(url) {
	return url.match(/\/[a-z]{2}/i)[0].replace("/", '');
}

var extractTitle = function(url) {
	return url.match(/wiki\/[a-zA-Z0-9_()#%,.!-]+$/i)[0].replace("wiki/", '');
}

var wikiFetch = function(url) {
	language = extractLanguage(url);
	title = extractTitle(url);

	fetchUrl = "http://" + language + '.wikipedia.org/w/api.php?' + 'action=query&prop=extracts&exchars=500&format=json&titles=' + title;

	$.ajax({
		url: fetchUrl,
		timeout: 30000,
	})
	.done(function(data) {
		var ewp_content = '';
		var ewp_title = "";
		$.each(data.query.pages, function(key) {
			ewp_content = data.query.pages[key].extract.replace(/(<([^>]+)>)/ig,"");
			ewp_title = data.query.pages[key].title;
		});
		var link = $(".ewp-active");
		link.attr("data-content", ewp_content);
		link.attr("data-title", ewp_title);
		link.attr("data-original-title", ewp_title);
		$(".popover-content").html(ewp_content);
		$(".popover-title").html(ewp_title);
	})
	.fail(function(data) {
		var ewp_content = "Drats! Error fetching the Wikipedia page.";
		var ewp_title = "Error";
		var link = $(".ewp-active");
		link.attr("data-content", ewp_content);
		link.attr("data-title", ewp_title);
		link.attr("data-original-title", ewp_title);
		$(".popover-content").html(ewp_content);
		$(".popover-title").html(ewp_title);
	});
}

$(document).ready(function() {
	
	var delay = 700, timer;

	$("a").on('mouseenter', function() {
		__this = this;

		popTitle = $(this).attr("title");
		if (statusa && !($(this).hasClass("easy-wiki-popover"))) {
			$(this).attr("title", "");
		}

		timer = setTimeout(function() {
			if (statusa && __this.href.match(WIKI_URL_REGEX)) {

				$(__this).addClass("ewp-active");

				if (!($(__this).hasClass("easy-wiki-popover"))) {
					$(__this).addClass("easy-wiki-popover");

					$(__this).popover({
						html: true,
						trigger: 'manual',
						title: popTitle,
						content: "Loading..."
					}).on("mouseenter", function() {
						var _this = this;
				        $(this).popover("show");
				        $(this).siblings(".popover").on("mouseleave", function () {
				            $(_this).popover('destroy');
				            $(_this).removeClass("ewp-active");
				        });
					}).on("mouseleave", function() {
						var _this = this;
				        setTimeout(function () {
				            if (!$(".popover:hover").length) {
				                $(_this).popover("destroy");
				                $(_this).removeClass("ewp-active");
				            }
				        }, 5);
					}).popover("show");<commit_msg>Use EasyWiki as title if not available.<commit_after>var statusa;

chrome.extension.sendRequest({msg: "getStatus"}, function(response) {
   if (response.status == 1) {
   		statusa = true;
   } else {
   		statusa = false;
   }
});

WIKI_URL_REGEX = /^((http|https):\/\/)?[a-z]+.wikipedia.org\/wiki\/[a-zA-Z0-9_()#%,.!-]+$/i
CLASS_MATCHER = /easy-wiki-popover/i

var extractLanguage = function(url) {
	return url.match(/\/[a-z]{2}/i)[0].replace("/", '');
}

var extractTitle = function(url) {
	return url.match(/wiki\/[a-zA-Z0-9_()#%,.!-]+$/i)[0].replace("wiki/", '');
}

var wikiFetch = function(url) {
	language = extractLanguage(url);
	title = extractTitle(url);

	fetchUrl = "http://" + language + '.wikipedia.org/w/api.php?' + 'action=query&prop=extracts&exchars=500&format=json&titles=' + title;

	$.ajax({
		url: fetchUrl,
		timeout: 30000,
	})
	.done(function(data) {
		var ewp_content = '';
		var ewp_title = "";
		$.each(data.query.pages, function(key) {
			ewp_content = data.query.pages[key].extract.replace(/(<([^>]+)>)/ig,"");
			ewp_title = data.query.pages[key].title;
		});
		var link = $(".ewp-active");
		link.attr("data-content", ewp_content);
		link.attr("data-title", ewp_title);
		link.attr("data-original-title", ewp_title);
		$(".popover-content").html(ewp_content);
		$(".popover-title").html(ewp_title);
	})
	.fail(function(data) {
		var ewp_content = "Drats! Error fetching the Wikipedia page.";
		var ewp_title = "Error";
		var link = $(".ewp-active");
		link.attr("data-content", ewp_content);
		link.attr("data-title", ewp_title);
		link.attr("data-original-title", ewp_title);
		$(".popover-content").html(ewp_content);
		$(".popover-title").html(ewp_title);
	});
}

$(document).ready(function() {
	
	var delay = 700, timer;

	$("a").on('mouseenter', function() {
		__this = this;

		popTitle = $(this).attr("title");
		if (statusa && !($(this).hasClass("easy-wiki-popover"))) {
			$(this).attr("title", "");
		}

		timer = setTimeout(function() {
			if (statusa && __this.href.match(WIKI_URL_REGEX)) {

				$(__this).addClass("ewp-active");

				if (!($(__this).hasClass("easy-wiki-popover"))) {
					$(__this).addClass("easy-wiki-popover");

					$(__this).popover({
						html: true,
						trigger: 'manual',
						title: popTitle || 'EasyWiki',
						content: "Loading..."
					}).on("mouseenter", function() {
						var _this = this;
				        $(this).popover("show");
				        $(this).siblings(".popover").on("mouseleave", function () {
				            $(_this).popover('destroy');
				            $(_this).removeClass("ewp-active");
				        });
					}).on("mouseleave", function() {
						var _this = this;
				        setTimeout(function () {
				            if (!$(".popover:hover").length) {
				                $(_this).popover("destroy");
				                $(_this).removeClass("ewp-active");
				            }
				        }, 5);
					}).popover("show");
{'fraction_non_alphanumeric': 0.22447213568708896, 'fraction_numerical': 0.006922810661128418, 'mean_word_length': 3.1396848137535818, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '312762', 'n_tokens_mistral': 2375, 'n_tokens_neox': 2049, 'n_words': 296}