cwilso / WebMIDIAPIShim

Polyfill using the Jazz NPAPI MIDI plugin to implement the Web MIDI API on Mac and Windows.
380 stars 53 forks source link

Code cleanup #31

Closed jaycliff closed 11 years ago

jaycliff commented 11 years ago

turned a few function statements to function expressions, because the function names are already declared at the topmost var statement (komodo edit complains about redeclared functions). Changed 'opera' to just 'o', etc.

notator commented 11 years ago

There's a problem with this merge.

An exception is now thrown in my code because requestMIDIAccess is undefined when calling

navigator.requestMIDIAccess().then(onSuccessCallback, onErrorCallback);

I got round this by moving the lines

    //init: create plugin
    if(!window.navigator.requestMIDIAccess)
    {
        window.navigator.requestMIDIAccess = _requestMIDIAccess;
        if(!window.navigator.getMIDIAccess)
            window.navigator.getMIDIAccess = _getMIDIAccess;
    }

from line 21 down to the end of their block (where _requestMIDIAccess has been defined).

Strangely, _getMIDIAccess is declared but never defined...

best, James

cwilso commented 11 years ago

Fixed.

_getMIDIAccess was an old version of requestMIDIAccess that threw a warning. I got rid of it when I cleaned up, but forgot the hookup.

notator commented 11 years ago

You got rid of the hookup, but _getMIDIAccess is still declared (line 19).

cwilso commented 11 years ago

So I did. Thanks.