I have this issue with this Javascript event listener. On click, it replaces an overlay, showing information depending on the details. (admin, player)
I want it to work in another way, whereas if you hold down shift, it copies the span textContent and does not replace the overlay. I've tried several ways for this to work, though none have done it as I want it to.
The issue seems to be with the seemingly unnecessary round function brackets at the end. }());
Why are they there in the first place, and why does the replaceOverlay function stop working when they are removed?
Their code:
span.on("click", function() {
var player = players[i];
return function() {
Class.replaceOverlay(Class.AdminPlayerLookupOverlay, {
admin: admin,
player: player
})
}
}());
What I would expect would work, but doesn't. (event is undefined. Replaces overlay no matter if shiftkey is down):
span.on("click", function(event) {
var player = players[i];
if (typeof event !== "undefined" && event.shiftKey == true) {
Class.copyText(event, span, playerName)
}
return function() {
Class.replaceOverlay(Class.AdminPlayerLookupOverlay, {
admin: admin,
player: player
})
}
}());
How could I get this working?
Thanks in advance :)