<commit_before>
var jq = null;
var KillKat = 
{
	init: 	function(){

        KillKat.loadStaticFiles();
        KillKat.initImgList();
	},
	listImgs: [],
	IMG_MIN_WIDTH : 100,
	IMG_MIN_HEIGHT : 100,
	KILL_TAG: 'killkat-shot',

    loadStaticFiles: function()
    {
        var stylesheet = document.createElement('link');
        stylesheet.href = 'https://rawgit.com/jorisgrouillet/killkat/master/css/killkat.css';
        stylesheet.rel = 'stylesheet';
        stylesheet.type = 'text/css';
        document.getElementsByTagName('head')[0].appendChild(stylesheet);
    },

	requirements: {
		'min-dimensions' : function(img){ return ((img.width * img.height) > (KillKat.IMG_MIN_WIDTH * KillKat.IMG_MIN_HEIGHT)); },
	},
	
	splatterStyle : { 
		'opacity': 1, 
		'background-color' : 'transparent',
		'background-repeat' : 'no-repeat', 
		'background-size' : '50%',
		'background-position': 'center center',
		'background-image' : "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYQAAAGQCAYAAACu+hdeAAAABmJLR0QAAAAAAAD5Q7t/AAAACW9GRnMAAAAWAAAAEwBuShbaAAAACXBIWXMAAAErAAABKwAhzE8tAAAyd3pUWHRSYXcgcHJvZmlsZSB0eXBlIGlwdGMAAHja7Z1bjuO60qXfOYozBPFODociKeAHGuhGz/+hv0X5lk5nZdbep4EqwK5yWpYlXoIRK1YEKcn8n//7v4//+V/T/Oc//3E55WJ8CS7UMLbg4nZ72e2718N5Qd/N2jlb890fueQt2eTTnmIObksuxZRT<KEY>)"
	 },
	 underSplatterStyle: {
	 	'opacity' : 0.25
	 },
	 splatterStyle_Off : { 
		'opacity': 1, 
		'background' : 'none'
	 },
	 underSplatterStyle_Off: {
	 	'opacity' : 1
	 },

	initImgList : function()
	{
		jq('img').each(
			function(idx, domImg){
				KillKat.filterImg(domImg);
				
			}
		);
	},

	filterImg : function(domImg)
	{
		if (KillKat.meetRequirements(domImg)){
			KillKat.addToListImgs(domImg);	
		}
	},

	meetRequirements : function(domImg)
	{	
		reqs = KillKat.requirements;
		var validateReqs = true;
		for (var rIdx in reqs){
			if (typeof(reqs[rIdx]) == 'function'){
				validateReqs &= reqs[rIdx].call(this, domImg);
			}
		}
		return (validateReqs===1);
	},
	
	addToListImgs: function(domImg)
	{
		jqImg = KillKat.overrideClickEvent(domImg);
		KillKat.listImgs.push(jqImg);
	},

	overrideClickEvent: function(domImg)
	{
		jqImg = jq(domImg);
		fct = KillKat.getClickEventFunction();
		jqImg.unbind('click').click(fct);
		return jqImg;
	},
	getClickEventFunction: function()
	{
		return function(e){
            e.preventDefault();
			KillKat.addOverlayToTarget(this);
			return false;
		};
	},
	addOverlayToTarget: function(domImg)
	{
		jqImg = jq(domImg);
		if (! KillKat.isKatKilled(jqImg)){
			jqImg.parent().addClass(KillKat.KILL_TAG);
		}
		else {
			jqImg.parent().removeClass(KillKat.KILL_TAG);	
		}
	},
	
	isKatKilled: function(jqImg)
	{
		return (jqImg.parent().hasClass(KillKat.KILL_TAG));
	},

	convertImgToBase64 : function(url, callback, outputFormat)
	{
	    var canvas = document.createElement('canvas'),
	    ctx = canvas.getContext('2d'),
	    img = new Image();
	    img.crossOrigin = 'Anonymous';
	    img.onload = function(){
	        canvas.height = img.height;
	        canvas.width = img.width;
	        ctx.drawImage(img,0,0);
	        var dataURL = canvas.toDataURL(outputFormat || 'image/png');
	        callback.call(this, dataURL);
	        canvas = null; 
	    };
	    img.src = url;
	}
};


<commit_msg>push pour bookmarklet<commit_after>
var jq = null;
var KillKat = 
{
	init: 	function(){

        KillKat.loadStaticFiles();
        KillKat.initImgList();
	},
    sound: null,
    domImgs : [],
    listImgs : [],
	IMG_MIN_WIDTH : 100,
	IMG_MIN_HEIGHT : 100,
	KILL_TAG: 'killkat-shot',
    OVERLAY_TAG: 'killkat-overlay',

    loadStaticFiles: function()
    {
        var stylesheet = document.createElement('link');
        stylesheet.href = 'https://rawgit.com/jorisgrouillet/killkat/master/css/killkat.css';
        stylesheet.rel = 'stylesheet';
        stylesheet.type = 'text/css';
        document.getElementsByTagName('head')[0].appendChild(stylesheet);
    },

	requirements: {
		'min-dimensions' : function(img){ return ((img.width * img.height) > (KillKat.IMG_MIN_WIDTH * KillKat.IMG_MIN_HEIGHT)); }
	},

	initImgList : function()
	{
        KillKat.domImgs = jq('img');
        KillKat.domImgs.each(
			function(idx, domImg){
				KillKat.filterImg(domImg);

			}
		);
	},

	filterImg : function(domImg)
	{
		if (KillKat.meetRequirements(domImg)){
			KillKat.addToListImgs(domImg);	
		}
	},

	meetRequirements : function(domImg)
	{	
		var reqs = KillKat.requirements || [];
		var validateReqs = true;
		for (var rIdx in reqs){
			if (typeof(reqs[rIdx]) == 'function'){
				validateReqs &= reqs[rIdx].call(this, domImg);
			}
		}
		return (validateReqs===1);
	},
	
	addToListImgs: function(domImg)
	{
		jqImg = KillKat.overrideClickEvent(domImg);
		KillKat.listImgs.push(jqImg);
	},

	overrideClickEvent: function(domImg)
	{
		var jqImg = jq(domImg);
		var fct = KillKat.getClickEventFunction();
		jqImg.unbind('click').click(fct);
		return jqImg;
	},
	getClickEventFunction: function()
	{
		return function(e){
            e.preventDefault();
			KillKat.handleTarget(this);
			return false;
		};
	},
	handleTarget: function(domImg)
	{
		var jqImg = jq(domImg);
        KillKat.setOverlay(jqImg);

        /*
		if (! KillKat.isKatKilled(jqImg)){
			jqImg.closest('div').addClass(KillKat.KILL_TAG);
            KillKat.setOverlay(jqImg);

		}
		else {
			jqImg.closest('div').removeClass(KillKat.KILL_TAG);
		}
		*/
	},
    setOverlay: function(jqImg)
    {
        var imgContainer = jqImg.closest('div');
        //imgContainer.css('z-index', 99);
        var imgIndex = (KillKat.getImgIndex(jqImg)).toString();
        var domOverlay = jq('#killkat-tag-'+imgIndex);

        if (! domOverlay.length)
        {
            domOverlay = jq('<div class="'+KillKat.OVERLAY_TAG+'" id="killkat-tag-'+KillKat.getImgIndex(jqImg)+'"></div>')
                            .css({  'width' : imgContainer.innerWidth(),
                                    'height' : imgContainer.innerHeight(),
                                    'top' : imgContainer.offset().top,
                                    'left' : imgContainer.offset().left,
                                    'z-index': 1
                                })
                            .appendTo(jq('body'));

            KillKat.playSound();
            return;
        }

        if (domOverlay.is(':visible')){
            domOverlay.fadeOut(1000);
        }
        else{
            domOverlay.show();
            KillKat.playSound();
        }
    },
	
	isKatKilled: function(jqImg)
	{
		return (jqImg.parent().hasClass(KillKat.KILL_TAG));
	},

    getImgIndex : function(jqImg)
    {
        return KillKat.domImgs.index(jqImg);
    },
    playSound : function()
    {
        if (! jq('#killkat-sound').length){
            KillKat.setSoundPlayer();
        }
        KillKat.sound.play();
    },
    setSoundPlayer: function()
    {
        if (! jq('#killkat-sound').length)
        {
            var sound = jq('<audio id="killkat-sound" preload="auto" autoplay>'+
                '<source src="https://rawgit.com/jorisgrouillet/killkat/master/audio/splatter-sound.mp3" type="audio/mp3" />'+
                            //'<source src="http://www.freesfx.co.uk/rx2/mp3s/2/1871_1272479313.mp3" type="audio/mp3" />'+
                            'Votre navigateur n\'est pas compatible'+
                            '</audio>');

            jq('body').append(sound);
            KillKat.sound = sound.get(0);
        }
    }
	/*convertImgToBase64 : function(url, callback, outputFormat)
	{
	    var canvas = document.createElement('canvas'),
	    ctx = canvas.getContext('2d'),
	    img = new Image();
	    img.crossOrigin = 'Anonymous';
	    img.onload = function(){
	        canvas.height = img.height;
	        canvas.width = img.width;
	        ctx.drawImage(img,0,0);
	        var dataURL = canvas.toDataURL(outputFormat || 'image/png');
	        callback.call(this, dataURL);
	        canvas = null; 
	    };
	    img.src = url;
	}*/
};



{'fraction_non_alphanumeric': 0.14966670859011444, 'fraction_numerical': 0.013080115708715884, 'mean_word_length': 2.6477064220183486, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 12, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3972193', 'n_tokens_mistral': 3149, 'n_tokens_neox': 2801, 'n_words': 382}