<commit_before>// jquery.tileviewer.js
// Copyright 2010 <NAME>
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
// 	http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Chris Barr's No Select Plugin
// http://chris-barr.com/entry/disable_text_selection_with_jquery/
$(function(){
	$.extend($.fn.disableTextSelect = function() {
		return this.each(function(){
			if($.browser.mozilla){//Firefox
				$(this).css('MozUserSelect','none');
			}else if($.browser.msie){//IE
				$(this).bind('selectstart',function(){return false;});
			}else{//Opera, etc.
				$(this).mousedown(function(){return false;});
			}
		});
	});
});

// Tile Viewer Plugin follows.
jQuery.fn.tileviewer = function(options) {
	var thisDiv = $(this);
	thisDiv.disableTextSelect();
	var settings = $.extend({
		zoomwidth:23,
		zoomheight:100,
		width:thisDiv.width(),
		height:thisDiv.height()
		},options);
	if (!(settings['imagedir'])) {
		alert('ERROR: no image directory!');
		return;
	}
	$.getJSON(settings['imagedir']+'/settings.json', function(data) {
		settings = $.extend(settings,data)
		// global indexes
		var ROW=0; var COL=1;
		
		// set up canvas elements
		var canvas = $('<canvas width="'+settings['width']+'" height="'+settings['height']+'" style="position:absolute; top:0; left:0;"></canvas>');
		var zoomincanvas = $('<canvas width="'+settings['zoomwidth']+'" height="'+settings['zoomwidth']+'" style="position:absolute; top:0; left:0; cursor:pointer;"></canvas>');
		var zoomcanvas = $('<canvas width="'+settings['zoomwidth']+'" height="'+settings['zoomheight']+'" style="position:absolute; top:'+settings['zoomwidth']+'; left:0;"></canvas>');
		var zoomoutcanvas = $('<canvas width="'+settings['zoomwidth']+'" height="'+settings['zoomwidth']+'" style="position:absolute; top:'+(settings['zoomwidth']+settings['zoomheight'])+'; left:0; cursor:pointer"></canvas>')
		thisDiv.append(canvas).append(zoomincanvas).append(zoomcanvas).append(zoomoutcanvas);
		
		// get contexts
		var ctx = canvas.get(0).getContext('2d'); 
		var zictx = zoomincanvas.get(0).getContext('2d'); 
		var zctx = zoomcanvas.get(0).getContext('2d'); 
		var zoctx = zoomoutcanvas.get(0).getContext('2d');
		
		// current level
		cl = settings['levels'] - 1
		
		// various coordinates
		ox = settings['width']/2 - settings['cols_in_level'][cl]*settings['tile_size']/2;
		oy = settings['height']/2 - settings['rows_in_level'][cl]*settings['tile_size']/2;
		var startx, starty; var dragging = false;
		
		// blank image
		blank='data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
		
		// all images
		var images = new Array(settings['levels']); var filenames = new Array(settings['levels']); var loaded = new Array(settings['levels']);
		for (var l=0; l<settings['levels']; l++) {
			var tiles = settings['tiles_in_level'][l];
			images[l] = new Array(tiles); filenames[l] = new Array(tiles); loaded[l] = new Array(tiles);
			for (var i=0; i<tiles; i++) {
				images[l][i] = new Image(); images[l][i].src=blank; images[l][i].level = l; images[l][i].index = i;<commit_msg>add units to top offsets so it works<commit_after>// jquery.tileviewer.js
// Copyright 2010 <NAME>
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
// 	http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// <NAME>'s No Select Plugin
// http://chris-barr.com/entry/disable_text_selection_with_jquery/
$(function(){
	$.extend($.fn.disableTextSelect = function() {
		return this.each(function(){
			if($.browser.mozilla){//Firefox
				$(this).css('MozUserSelect','none');
			}else if($.browser.msie){//IE
				$(this).bind('selectstart',function(){return false;});
			}else{//Opera, etc.
				$(this).mousedown(function(){return false;});
			}
		});
	});
});

// Tile Viewer Plugin follows.
jQuery.fn.tileviewer = function(options) {
	var thisDiv = $(this);
	thisDiv.disableTextSelect();
	var settings = $.extend({
		zoomwidth:23,
		zoomheight:100,
		width:thisDiv.width(),
		height:thisDiv.height()
		},options);
	if (!(settings['imagedir'])) {
		alert('ERROR: no image directory!');
		return;
	}
	$.getJSON(settings['imagedir']+'/settings.json', function(data) {
		settings = $.extend(settings,data)
		// global indexes
		var ROW=0; var COL=1;
		
		// set up canvas elements
		var canvas = $('<canvas width="'+settings['width']+'" height="'+settings['height']+'" style="position:absolute; top:0; left:0;"></canvas>');
		var zoomincanvas = $('<canvas width="'+settings['zoomwidth']+'" height="'+settings['zoomwidth']+'" style="position:absolute; top:0; left:0; cursor:pointer;"></canvas>');
		var zoomcanvas = $('<canvas width="'+settings['zoomwidth']+'" height="'+settings['zoomheight']+'" style="position:absolute; top:'+settings['zoomwidth']+'px; left:0;"></canvas>');
		var zoomoutcanvas = $('<canvas width="'+settings['zoomwidth']+'" height="'+settings['zoomwidth']+'" style="position:absolute; top:'+(settings['zoomwidth']+settings['zoomheight'])+'px; left:0; cursor:pointer"></canvas>')
		thisDiv.append(canvas).append(zoomincanvas).append(zoomcanvas).append(zoomoutcanvas);
		
		// get contexts
		var ctx = canvas.get(0).getContext('2d'); 
		var zictx = zoomincanvas.get(0).getContext('2d'); 
		var zctx = zoomcanvas.get(0).getContext('2d'); 
		var zoctx = zoomoutcanvas.get(0).getContext('2d');
		
		// current level
		cl = settings['levels'] - 1
		
		// various coordinates
		ox = settings['width']/2 - settings['cols_in_level'][cl]*settings['tile_size']/2;
		oy = settings['height']/2 - settings['rows_in_level'][cl]*settings['tile_size']/2;
		var startx, starty; var dragging = false;
		
		// blank image
		blank='data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
		
		// all images
		var images = new Array(settings['levels']); var filenames = new Array(settings['levels']); var loaded = new Array(settings['levels']);
		for (var l=0; l<settings['levels']; l++) {
			var tiles = settings['tiles_in_level'][l];
			images[l] = new Array(tiles); filenames[l] = new Array(tiles); loaded[l] = new Array(tiles);
			for (var i=0; i<tiles; i++) {
				images[l][i] = new Image(); images[l][i].src=blank; images[l][i].level = l; images[l][i].index = i;
{'fraction_non_alphanumeric': 0.19214963865665297, 'fraction_numerical': 0.011336261867649142, 'mean_word_length': 4.956118143459916, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '497255', 'n_tokens_mistral': 2467, 'n_tokens_neox': 2267, 'n_words': 521}