<commit_before>/*
Google Summer of Code 2012: Automagic Music Maker

Primarily written by <NAME>
Strongly influenced by GSOC Mentor <NAME>
Using the Infusion framework and Flocking Library

The Automagic Music Maker is distributed under the terms the MIT or GPL2 Licenses. 
Choose the license that best suits your project. The text of the MIT and GPL 
licenses are at the root of the Piano directory. 

*/
/*global jQuery, fluid, document*/

var automm = automm || {};

(function ($) {
    "use strict";
    fluid.defaults("automm.eventBinder", {
        gradeNames: ["fluid.viewComponent", "autoInit"],
        preInitFunction: "automm.eventBinder.preInitFunction",
        postInitFunction: "automm.eventBinder.postInitFunction",

        model: {
            isShift: false
        },

        events: {
            afterUpdate: null,
            onNote: null,
            afterNote: null,
            afterPoly: null
        }

    });

    automm.eventBinder.preInitFunction = function (that) {
        that.bindEvents = function () {
            // Variables to keep track of currently pressed notes
            var lastClicked = {},
                isClicking = false;

            $(document).keydown(function (event) {
                if (event.shiftKey === true) {
                    that.model.isShift = true;
                }
            });
            $(document).keyup(function (event) {
                if (event.shiftKey === false && that.model.isShift) {
                    that.model.isShift = false;
                }
            });
            
            // Get an Array of all notes on canvas
            that.notes = that.container.find(".note");

            // Iterate through each note
            /*jslint unparam: true*/
            that.notes.each(function (i, note) {
                // Make sure the note element is set up properly
                note = $(note);
                // mousedown event binding
                note.mousedown(function () {
                    // For Keeping track
                    lastClicked = note;
                    isClicking = true;
                    that.events.onNote.fire(note);
                });
                // mousup event binding
                note.mouseup(function () {
                    isClicking = false;
                    that.events.afterNote.fire(note);
                    lastClicked = {};
                });
                // mouse hover event binding
                note.mouseover(function () {
                    if (isClicking) {
                        that.events.afterNote.fire(lastClicked);
                        that.events.onNote.fire(note);
                    }
                    lastClicked = note;
                });
            });
            /*jslint unparam: false*/
        };
    };

    automm.eventBinder.postInitFunction = function (that) {
        that.bindEvents();
        that.events.afterUpdate.addListener(that.bindEvents);
    };
}(jQuery));<commit_msg>Polyphony works<commit_after>/*
Google Summer of Code 2012: Automagic Music Maker

Primarily written by <NAME>
Strongly influenced by GSOC Mentor <NAME>
Using the Infusion framework and Flocking Library

The Automagic Music Maker is distributed under the terms the MIT or GPL2 Licenses. 
Choose the license that best suits your project. The text of the MIT and GPL 
licenses are at the root of the Piano directory. 

*/
/*global jQuery, fluid, document*/

var automm = automm || {};

(function ($) {
    "use strict";
    fluid.defaults("automm.eventBinder", {
        gradeNames: ["fluid.viewComponent", "autoInit"],
        preInitFunction: "automm.eventBinder.preInitFunction",
        postInitFunction: "automm.eventBinder.postInitFunction",

        model: {
            isShift: false
        },

        events: {
            afterUpdate: null,
            onNote: null,
            afterNote: null
        }

    });

    automm.eventBinder.preInitFunction = function (that) {
        that.init = function () {
            // Variables to keep track of currently pressed notes
            var lastClicked = {},
                isClicking = false;
            that.polyNotes = [];

            $(document).keydown(function (event) {
                if (event.shiftKey === true) {
                    that.model.isShift = true;
                }
            });
            $(document).keyup(function (event) {
                if (event.shiftKey === false && that.model.isShift) {
                    that.model.isShift = false;
                    that.afterShift();
                }
            });

            // Get an Array of all notes on canvas
            that.notes = that.container.find(".note");

            // Iterate through each note
            /*jslint unparam: true*/
            that.notes.each(function (i, note) {
                // Make sure the note element is set up properly
                note = $(note);
                // mousedown event binding
                note.mousedown(function () {
                    // For Keeping track
                    lastClicked = note;
                    isClicking = true;
                    that.events.onNote.fire(note);
                });
                // mousup event binding
                note.mouseup(function () {
                    isClicking = false;
                    if (!that.model.isShift) {
                        that.events.afterNote.fire(note);
                    }
                    lastClicked = {};
                });
                // mouse hover event binding
                note.mouseover(function () {
                    if (isClicking) {
                        if (!that.model.isShift) {
                            that.events.afterNote.fire(lastClicked);
                        }
                        that.events.onNote.fire(note);
                    }
                    lastClicked = note;
                });
            });
            /*jslint unparam: false*/
        };

        that.onNote = function (note) {
            if (that.model.isShift) {
                that.polyNotes[that.polyNotes.length] = note;
            }
        };

        that.afterShift = function () {
            /*jslint unparam: true*/
            fluid.each(that.polyNotes, function (note) {
                that.events.afterNote.fire(note);
            });
            /*jslint unparam: false*/
        };
    };

    automm.eventBinder.postInitFunction = function (that) {
        that.init();
        that.events.afterUpdate.addListener(that.bindEvents);
        that.events.onNote.addListener(that.onNote);
    };
}(jQuery));
{'fraction_non_alphanumeric': 0.10018077734257307, 'fraction_numerical': 0.0015064778547755348, 'mean_word_length': 1.3676890156918688, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '609198', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1624, 'n_words': 418}