<commit_before>
//Settting default to mouse
var eventMode = "mouse"

//Listing touch devices user agents
var UA_touchDevices = ["iPhone","iPod","iPad","Android"] ;

// trigger events 
var events = {
        touch : {
                start : "touchstart",
                move : "touchmove",
                end : "touchend",
                pageX : function(e){ return e.originalEvent.touches[0].pageX ;},
                pageY : function(e){ return e.originalEvent.touches[0].pageY ;}
        },
        mouse : {
                start : "mousedown",
                move : "mousemove",
                end : "mouseup",
                pageX : function(e){ return e.pageX ;},
                pageY : function(e){ return e.pageY ;}
        }
};

//Don't forget, only on dom ready !
var setEventMode = function (){
	for (var i = 0; i < UA_touchDevices.length; i++) {
		if(navigator.userAgent.indexOf(UA_touchDevices[i]) != -1) eventMode = "touch";
	};
}

$(function(){
	//Don't forget, only on dom ready !
	setEventMode();


	// Now events[eventMode].start will trigger the right event ;-)

	// Example for fun ;-)

	var $currentObject ;

	var mnmsColors = ["#d72e2e","#3978e0","#7ed85e","#feab1a","#b7dd43","#dd2b2b"]


	for (var i = 0; i < 24; i++) {
		$("<div class='ball'><strong>m</strong></div>")
		.css({
			"left": Math.round(Math.random()*500),
			"top": Math.round(Math.random()*200),
			"background-color" : mnmsColors[Math.round(Math.random()* (mnmsColors.length-1))]
		})
		.appendTo(".viewport") ;
	};

	var tempEvents = {
		"prevX" : 0 ,
		"prevY" : 0 ,
		"ballX" : 0 ,
		"ballY" : 0

	}


	var onMove = function(e){
		$currentObject.css({
			"left": 	tempEvents.ballX - ( tempEvents.prevX - events[eventMode].pageX(e)  ) , 
			"top":  	tempEvents.ballY - ( tempEvents.prevY - events[eventMode].pageY(e)  ) 
		}) ;

		e.preventDefault();
	}

	var onStart = function(e){
		$currentObject = $(this) ;
		tempEvents.prevX = events[eventMode].pageX(e) ;
		tempEvents.prevY = events[eventMode].pageY(e) ;
		tempEvents.ballX = $currentObject.position().left;
		tempEvents.ballY = $currentObject.position().top ;
		$currentObject.on(events[eventMode].move, onMove);

		//
		$(".ball").css({"z-index":1}) ;
		$currentObject.css({"z-index":10}) ;

	}

	var onEnd = function(e){
		
		$currentObject.off(events[eventMode].move, onMove);
	}


	$(".ball").on(events[eventMode].end, onEnd );
	$(".ball").on(events[eventMode].start, onStart);



})

<commit_msg>Add MS touch<commit_after>
//Settting default to mouse
var eventMode = "mouse"

//Listing touch devices user agents
var UA_touchDevices = ["iPhone","iPod","iPad","Android", "Windows Phone"];

// trigger events 
var events = {
       touch : {
                start : "touchstart",
                move : "touchmove",
                end : "touchend",
                pageX : function(e){ return e.originalEvent.touches[0].pageX ;},
                pageY : function(e){ return e.originalEvent.touches[0].pageY ;}
            },
            mouse : {
                start : "mousedown",
                move : "mousemove",
                end : "mouseup",
                pageX : function(e){ return e.pageX ;},
                pageY : function(e){ return e.pageY ;}
            },
            mstouch : {
                start : "touchstart",
                move : "touchmove",
                end : "touchend",
                pageX : function(e){ return e.targetTouches[0].pageX ;},
                pageY : function(e){ return e.targetTouches[0].pageY ;}
            },
            mstouchpointer : {
                start : "MSPointerDown",
                move : "MSPointerMove",
                end : "MSPointerUp",
                pageX : function(e){ return e.pageX || e.targetTouches[0].pageX ;},
                pageY : function(e){ return e.pageY || e.targetTouches[0].pageY ;}
            }
};

var setEventMode = function (){
	 for (var i = 0; i < UA_touchDevices.length; i++) {
        if (navigator.userAgent.indexOf(UA_touchDevices[i]) != -1)
        {
            eventMode = "touch";
            if (navigator.userAgent.indexOf(UA_touchDevices[3]) != -1)  isAndroid = true ;
        }

    };
    if (navigator.userAgent.indexOf("Windows Phone") != -1) {
        eventMode = "mstouch";
        if (window.navigator.msPointerEnabled) {
             eventMode = "mstouchpointer";
        }
    }
}

$(function(){
	//Don't forget, only on dom ready !
	setEventMode();


	// Now events[eventMode].start will trigger the right event ;-)

	// Example for fun ;-)

	var $currentObject ;

	var mnmsColors = ["#d72e2e","#3978e0","#7ed85e","#feab1a","#b7dd43","#dd2b2b"]


	for (var i = 0; i < 24; i++) {
		$("<div class='ball'><strong>m</strong></div>")
		.css({
			"left": Math.round(Math.random()*500),
			"top": Math.round(Math.random()*200),
			"background-color" : mnmsColors[Math.round(Math.random()* (mnmsColors.length-1))]
		})
		.appendTo(".viewport") ;
	};

	var tempEvents = {
		"prevX" : 0 ,
		"prevY" : 0 ,
		"ballX" : 0 ,
		"ballY" : 0

	}


	var onMove = function(e){
		$currentObject.css({
			"left": 	tempEvents.ballX - ( tempEvents.prevX - events[eventMode].pageX(e)  ) , 
			"top":  	tempEvents.ballY - ( tempEvents.prevY - events[eventMode].pageY(e)  ) 
		}) ;

		e.preventDefault();
	}

	var onStart = function(e){
		$currentObject = $(this) ;
		tempEvents.prevX = events[eventMode].pageX(e) ;
		tempEvents.prevY = events[eventMode].pageY(e) ;
		tempEvents.ballX = $currentObject.position().left;
		tempEvents.ballY = $currentObject.position().top ;
		
		$currentObject.on(events[eventMode].move, onMove);

		//
		$(".ball").css({"z-index":1}) ;
		$currentObject.css({"z-index":10}) ;

	}

	var onEnd = function(e){
		
		$currentObject.off(events[eventMode].move, onMove);
	}


	$("body").on(events[eventMode].end,".ball", onEnd );
	$("body").on(events[eventMode].start,".ball", onStart);



})


{'fraction_non_alphanumeric': 0.17737003058103976, 'fraction_numerical': 0.014101257220523276, 'mean_word_length': 2.4670200235571262, 'pattern_counts': {'":': 12, '<': 15, '<?xml version=': 0, '>': 11, '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': '3341122', 'n_tokens_mistral': 2216, 'n_tokens_neox': 2035, 'n_words': 366}