geekbozu / NintendoWiSpy

A live input-viewer for GameCube/N64 controllers over wifi or usb serial. Used for showing/recording inputs during livestreams/gameplay recording sessions.
MIT License
4 stars 2 forks source link

Make sure all JavaScript variables are declared. #8

Closed Eeems closed 6 years ago

geekbozu commented 6 years ago

Could you check this again. I think its much better

Eeems commented 6 years ago

Why do you have a ton of lines that only contain ;?

Eeems commented 6 years ago

I would also suggest merging var statements eg:

var i = 0,
    j = 1;
geekbozu commented 6 years ago

If that is in ReconectingSockets.js thats a third party library I'm importing for some future functionality reasons instead of including as a dependency. It also means I would rather not edit it if I don't have to :D

Eeems commented 6 years ago

I would suggest moving all of your code inside a closure and only adding things to the global scope you explicitly want there. ie:

(function(){
    // Your code here
   window.globalValue = internalValue;
})();
geekbozu commented 6 years ago

Do i need to call this or just wrap my whole file in that essentially?

Eeems commented 6 years ago

Just wrap your whole file. It's self calling. It's basically doing this: (exp)()

geekbozu commented 6 years ago

Done :D not sure if im keeping reconnecting sockets in the long run so i wont worry about that to much, As for everything else its all in window.onload now. As it was supposed to be.