<commit_before>
// SmoothScroll v0.9.1
// Licensed under the terms of the MIT license.
// <NAME> (c) 2010

/**
 * A module for middle mouse scrolling.
 */
(function(window){

// local settings
var img = document.createElement("div"); // img at the reference point
var scrolling = false; // guards one phase
var enabled   = false; // from settings
var framerate = 100;

// get global settings
chrome.extension
 .connect({ name: "smoothscroll"})
 .onMessage.addListener(function (settings) {
    enabled = (settings.middlemouse == "true");
 });   
 
/**
 * Initializes the image at the reference point.
 */
function init() {
    var url = chrome.extension.getURL("../img/cursor.png");
    var style = img.style;
    style.display    = "none";
    style.background = "url("+url+")";
    style.position   = "fixed";
    style.zIndex     = "1000";
    style.width      = "20px";
    style.height     = "20px";
    document.body.appendChild(img);
}

/**
 * Helper function for adding an event listener.
 */
function addEvent(type, fn) {
    window.addEventListener(type, fn, false);
}

/**
 * Helper function for removing an event listener.
 */
function removeEvent(type, fn) {
    window.removeEventListener(type, fn, false);  
}

/**
 * Shows the reference image, and binds event listeners for scrolling.
 * It also manages the animation.
 * @param {Object} event
 */
function mousedown(e) {

    var elem = document.elementFromPoint(e.clientX, e.clientY);
    var isLink;
    
    do {
        isLink = elem.nodeName.toLowerCase() === "a";
        if (isLink) break;
    } while (elem = elem.parentNode)

    // if it's not the middle button, or<commit_msg>fixed isLink in mousedown, sometimes elem resulted in null<commit_after>
// SmoothScroll v0.9.1
// Licensed under the terms of the MIT license.
// <NAME>ambosi (c) 2010

/**
 * A module for middle mouse scrolling.
 */
(function(window){

// local settings
var img = document.createElement("div"); // img at the reference point
var scrolling = false; // guards one phase
var enabled   = false; // from settings
var framerate = 100;

// get global settings
chrome.extension
 .connect({ name: "smoothscroll"})
 .onMessage.addListener(function (settings) {
    enabled = (settings.middlemouse == "true");
 });   
 
/**
 * Initializes the image at the reference point.
 */
function init() {
    var url = chrome.extension.getURL("../img/cursor.png");
    var style = img.style;
    style.display    = "none";
    style.background = "url("+url+")";
    style.position   = "fixed";
    style.zIndex     = "1000";
    style.width      = "20px";
    style.height     = "20px";
    document.body.appendChild(img);
}

/**
 * Helper function for adding an event listener.
 */
function addEvent(type, fn) {
    window.addEventListener(type, fn, false);
}

/**
 * Helper function for removing an event listener.
 */
function removeEvent(type, fn) {
    window.removeEventListener(type, fn, false);  
}

/**
 * Shows the reference image, and binds event listeners for scrolling.
 * It also manages the animation.
 * @param {Object} event
 */
function mousedown(e) {

    var isLink = false;
    var elem   = document.elementFromPoint(e.clientX, e.clientY);
    
    while (elem) {
        isLink = elem.nodeName.toLowerCase() === "a";
        if (isLink) break;
        elem = elem.parentNode;
    }

    // if it's not the middle button, or
{'fraction_non_alphanumeric': 0.13757396449704143, 'fraction_numerical': 0.010650887573964497, 'mean_word_length': 2.9823321554770317, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2440535', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1010, 'n_words': 316}