Closed argiepiano closed 1 month ago
@argiepiano I've made an attempt at refactoring the JS. I'm not so sure about using the window.Backdrop
namespace for part of it but it seems like it works.
Ha! I was working on this as well. Let me take a look.
Instead of using window.selectedToken
I suggest Backdrop.settings.tokenBrowserSelectedToken
I am using a different approach that encapsulates everything (variables etc) within a function, within Backdrop.behaviors.fastTokenBrowser
. This way you can still use var
, since those variables will not be global. I'm going to post my version of this.
I am not sure about the use of Backdrop.
to store all those variables. That will store them as properties of the global object Backdrop
, and in my opinion this is not safe and is unnecessary. Those variables (which hold the DOM templates) are only needed within the fast token browser function scope.
@herbdool I posted an alternative pr
Backdrop
to store the DOM template variables (unnecessary, sincevar
is limited to the scope of the anonymous function assigned to attach
, and are not needed outside this function.)window
to store global variables that are not needed as global. I would prefer not to use window
at all. Instead I'm using the the Backdrop.settings
object to store things, which was already in use in this JS file to store the textarea DOM element. Storing things that need to remain in memory in Backdrop.settings
is done in other core js files, like token.js
@argiepiano let's use yours. I hadn't put as much thought or time into refactoring. Yours is a better approach.
FTB javascript doesn't follow some of the standard Backdrop JS practices - for example it uses global
window
variables with no name spacing. I'll attempt to refactor the code to make it more in line with how other js files do it in Backdrop