I'm not all that far into learning javascript, but I am starting to see some patterns. I've been trying to get a button to appear in its own box in the BBLog drop down menu. It doesn't matter what it does; it just has to be there. I took a peak at some of the plugins that do this and tried to mimic it, but I must be missing something because it isn't appearing. Any help with it?
The only difference between them is the naming as far as I can see.
BrainFooLong
Administrator
translantions
kurtextrem
Also you should remove trailing kommas (,)
example: var array = [
'hi',
'123'
]
(instead of var array = [
'hi',
'123',
])
Post edited 1 x times, last by
GameFreakBoy
Topicstarter
GameFreakBoy
Fixed those things, but the inspect element tool in Chrome gave me this error:
Uncaught ReferenceError: BBlog is not defined dl.dropboxusercontent.com/s/m4aliq5v7wmegcy/test_plugin.js:5
Edit: I found it. the "L" in BBLog.handle was lowercase. It is working now. :D
Topicstarter
GameFreakBoy
Now I am actually trying to make a real plugin. There are some things that I can't seem to find the id to.
I have this snippet that should change the text of the quick match button in the multiplayer drop down menu to "Last Played Server." Any problems with it?
I hope you don't mind me asking these questions here.
Post edited 1 x times, last by
kurtextrem
kurtextrem
document.getElementById("btn btn-primary btn-block btn-large base-quickmatch-serverfilter-menu")
Your parameter is not an Id, it's a selector.
I recommend you to use $ (jQuery), so to say $("btn btn-primary btn-block btn-large base-quickmatch-serverfilter-menu")
Note: you can't use DOM specific functions on these objects.
You have to use $("btn btn-primary btn-block btn-large base-quickmatch-serverfilter-menu").text('Last played Server')
Take a look at the jQuery documentation:
Anyway, to learn jQuery, use this epic online school. It's very good and easy for beginners.
http://try.jquery.com/
kurtextrem
I guess yours is wrong to. I think this is what he meant: $(".btn.btn-primary.btn-block.btn-large.base-quickmatch-serverfilter-menu")
But that could select (possibly!) every button which these classes, so you should always look for something unique, Battlelog often does not have Ids, but other things, for example your button has some "data-X" attributes. "data-track='menudropdown.quickmatch'" looks unique, so we use it. $('.base-quickmatch-serverfilter-menu[data-track="menudropdown.quickmatch"]')