Help Understanding This - Better Battlelog Forums #109893

Sitemap
Post edited 1 x times, last by
Topicstarter
Here is a test plugin I have been playing with:
https://www.dropbox.com/s/m4aliq5v7wmegcy/test_plugin.js


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?

Usable link:
https://dl.dropboxusercontent.com/s/m4aliq5v7wmegcy/test_plugin.js
Post edited 1 x times, last by
When you compare it with that example plugin
http://getbblog.com/plugins/example.js
than you will see what's the error. Have a eye on the "configKeys" and "id" parameter.
Topicstarter
I got the test plugin to look like mine. It still works, but for some reason mine isn't showing up.
Example plugin:
https://dl.dropboxusercontent.com/s/5fj16dxox18qdir/testing.js

Mine:
https://dl.dropboxusercontent.com/s/m4aliq5v7wmegcy/test_plugin.js

The only difference between them is the naming as far as I can see.
translantions
Also you should remove trailing kommas (,)
example:
var array = [
'hi',
'123'
]


(instead of var array = [
'hi',
'123',
]
)
Post edited 1 x times, last by
Topicstarter
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
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?

https://dl.dropboxusercontent.com/s/h5uli1hg34fue3o/quick_match_to_last_server.js


I hope you don't mind me asking these questions here.
Post edited 1 x times, last by
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:
http://jquery.com
Post edited 2 x times, last by
kurtextrem wrote:
$("btn btn-primary btn-block btn-large base-quickmatch-serverfilter-menu")


Is wrong because of missing points to select elements with that class name and missing "," to search for multiple classes.

$(".btn, .btn-primary, .btn-block, .btn-large, .base-quickmatch-serverfilter-menu")

Is correct.


Anyway, to learn jQuery, use this epic online school. It's very good and easy for beginners.
http://try.jquery.com/
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"]')