<commit_before>// viewpage.js

(function($){

$(document).ready(handle);
$(document).bind("DOMNodeInserted", handle);

function select(node, selector) {
	return $(node).find(selector).andSelf().filter(selector);
}

function handle(event) {
	select(event.target, "a.view,a.diverted,a[data-diverted]").each(function() {
		var href = window.calli.viewpage(this.href, $(this).attr("data-query"));
		var link = $(this);
		if (this.href != href) {
			$(this).mousedown(function() {
				if (!link.attr("resource")) {
					link.attr("resource", link.attr("href"));
				}
				this.href = href;
			});
			link.addClass("view");
		} else {
			link.removeClass("view");
		}
		link.removeAttr("data-diverted");
		link.removeClass("diverted");
	});
	if (select(event.target, "a.diverted").length || select(event.target, "a[data-diverted]").length) {
		setTimeout(function(){ throw 'Use class="view" instead'; }, 0);
	}
}

if (!window.calli) {
	window.calli = {};
}

window.calli.viewpage = function(uri) {
	var url = uri;
	if (url.indexOf(':') < 0) {
	    if (document.baseURIObject && document.baseURIObject.resolve) {
	        url = document.baseURIObject.resolve(url);
	    } else {
	        var a = document.createElement('a');
	        a.setAttribute('href', url);
	        if (a.href) {
	            url = a.href;
	        }
	    }
	}
    var prefix = location.protocol + '//' + location.host + '/';
	if (url.indexOf(prefix) == 0) {
		url = url.substring(prefix.length - 1);
	}
	return prefix + 'callimachus/go?q=' + encodeURIComponent(url).replace(/%2F/g, '/');
}

window.calli.diverted = function(uri, query) {
	var url = uri;
    var prefix = location.protocol + '//' + location.host + '/';
	if (url.indexOf(prefix) != 0 && url.indexOf(':') > 0 || url.indexOf('?') > 0 || url.indexOf('#') > 0) {
		if (url.indexOf(':') < 0) {
		    if (document.baseURIObject && document.baseURIObject.resolve) {
		        url = document.baseURIObject.resolve(url);
		    } else {
		        var a = document.createElement('a');
		        a.setAttribute('href', url);
		        if (a.href) {
		            url = a.href;
		        }
		    }<commit_msg>Don't encode colon in goto URL<commit_after>// viewpage.js

(function($){

$(document).ready(handle);
$(document).bind("DOMNodeInserted", handle);

function select(node, selector) {
	return $(node).find(selector).andSelf().filter(selector);
}

function handle(event) {
	select(event.target, "a.view,a.diverted,a[data-diverted]").each(function() {
		var href = window.calli.viewpage(this.href, $(this).attr("data-query"));
		var link = $(this);
		if (this.href != href) {
			$(this).mousedown(function() {
				if (!link.attr("resource")) {
					link.attr("resource", link.attr("href"));
				}
				this.href = href;
			});
			link.addClass("view");
		} else {
			link.removeClass("view");
		}
		link.removeAttr("data-diverted");
		link.removeClass("diverted");
	});
	if (select(event.target, "a.diverted").length || select(event.target, "a[data-diverted]").length) {
		setTimeout(function(){ throw 'Use class="view" instead'; }, 0);
	}
}

if (!window.calli) {
	window.calli = {};
}

window.calli.viewpage = function(uri) {
	var url = uri;
	if (url.indexOf(':') < 0) {
	    if (document.baseURIObject && document.baseURIObject.resolve) {
	        url = document.baseURIObject.resolve(url);
	    } else {
	        var a = document.createElement('a');
	        a.setAttribute('href', url);
	        if (a.href) {
	            url = a.href;
	        }
	    }
	}
    var prefix = location.protocol + '//' + location.host + '/';
	if (url.indexOf(prefix) == 0) {
		url = url.substring(prefix.length - 1);
	}
	return prefix + 'callimachus/go?q=' + encodeURIComponent(url).replace(/%2F/g, '/').replace(/%3A/g, ':');
}

window.calli.diverted = function(uri, query) {
	var url = uri;
    var prefix = location.protocol + '//' + location.host + '/';
	if (url.indexOf(prefix) != 0 && url.indexOf(':') > 0 || url.indexOf('?') > 0 || url.indexOf('#') > 0) {
		if (url.indexOf(':') < 0) {
		    if (document.baseURIObject && document.baseURIObject.resolve) {
		        url = document.baseURIObject.resolve(url);
		    } else {
		        var a = document.createElement('a');
		        a.setAttribute('href', url);
		        if (a.href) {
		            url = a.href;
		        }
		    }
{'fraction_non_alphanumeric': 0.20190964136003725, 'fraction_numerical': 0.004890544946436889, 'mean_word_length': 3.036654135338346, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2636012', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1459, 'n_words': 256}