Prevent Events Plugin

Just a test case for a plugin I would like to use.

by dwaddell

HTML

<div>
    <button id="First" class="PreventEvents">First</button>
    <button id="Second" class="PreventEvents">Second</button>
    <br /><br />
    <textarea id="ThisTextarea"></textarea>
</div>

JavaScript

$('#First').on('click.testme', function() {
    alert("hello");
});

$('#First').on('click', function() {
    alert("bye");
});

$('#Second').on('click', function() {
    alert("test");
});


$.fn.preventEvents = function(oOptions) {

    return this.each(function() {
        var target, oEvents, sEventType, bBlockEvent, asSelector, asNamespace, afnHandlers, nHowManyEventsWithEventType, nIndex, sNamespace, $target;

        target = this;
        $target = $(target);
        oEvents = $._data(target, 'events');

        if (!oEvents) {
            // There are no handlers to save.
            return;
        }

        function fnCanThisEventFire(event) {
            console.log('prevent events');
            console.log(arguments);

            if (true) {
                event.stopImmediatePropagation();
                return false;
            }
            else {
                // All is good turn self off              
                $('*').off('.OSCPreventEvent');
            }
        }

        for (sEventType in oEvents) {
            bBlockEvent = true;

            if ((typeof oOptions === 'object') && ($.isArray(oOptions.asBlockEvents))) {
                // ACW 8/31/11 #28955 Changed to use jQuery's inArray
                bBlockEvent = ($.inArray(sEventType, oOptions.asBlockEvents) >= 0);
            }

            // Only unbind the events we want to block
            if (bBlockEvent) {

                // Let's create arrays for the handlers and selectors
                asSelector = [];
                asNamespace = [];
                afnHandlers = [];

                // How many events do with have with the current event type?
                nHowManyEventsWithEventType = oEvents[sEventType].length;

                // Fill the arrays with the the event information that we care about
                for (nIndex = 0; nIndex < nHowManyEventsWithEventType; nIndex++) {
                    asSelector[asSelector.length] =...