06. December 2012 19:45 Topicstarter
Hi there,
i got a little problem with my Plugin Source.
It replaces the COOP button on the home-page with a link to your server favourites.
Folowing works fine:
BBLog.handle("add.plugin", {
//plugin ID
id : "coop-to-favourites",
//plugin name
name : "COOP to Server-Favourites",
init : function(instance){
this.ChangeCOOPtoFAV();
},
domchange : function(instance){
this.ChangeCOOPtoFAV();
},
// main-function
ChangeCOOPtoFAV : function()
{
// replace COOP with FAV
$("#main-loggedin-header-puff-coop").attr("data-href", "/bf3/servers/favourites/");
$("#main-loggedin-header-puff-coop > .main-loggedin-header-puff-content > .wfont").html("favourites");
// hide COOP counter
$("#main-loggedin-header-puff-coop > .main-loggedin-header-puff-content > .main-loggedin-header-puff-play").hide();
}
});
When i now add the language specific code (see below) it doesn't work.
BBLog.handle("add.plugin", {
//plugin ID
id : "coop-to-favourites",
//plugin name
name : "COOP to Server-Favourites",
// language strings
translations : {
"en" : {
"lang.fav" : "favourites"
},
"de" : {
"lang.fav" : "favoriten"
}
},
init : function(instance){
this.ChangeCOOPtoFAV();
},
domchange : function(instance){
this.ChangeCOOPtoFAV();
},
// main-function
ChangeCOOPtoFAV : function()
{
// replace COOP with FAV
$("#main-loggedin-header-puff-coop").attr("data-href", "/bf3/servers/favourites/");
$("#main-loggedin-header-puff-coop > .main-loggedin-header-puff-content > .wfont").html("lang.fav");
// hide COOP counter
$("#main-loggedin-header-puff-coop > .main-loggedin-header-puff-content > .main-loggedin-header-puff-play").hide();
}
});
Plugins still works, but the button title is "lang.fav".
Can anyone tell me what i forgot?
Thanks in Advance!
GosuSan
06. December 2012 20:02 BrainFooLong
Administrator
...html(instance.t("lang.fav")); // hide COOP counter
06. December 2012 20:03 Post edited 1 x times, last by
BrainFooLong
Administrator
06. December 2012 20:03
BrainFooLong
Administrator
And also need to
instance.ChangeCOOPtoFAV(instance);
06. December 2012 20:20 Post edited 6 x times, last by
07. December 2012 13:39
Topicstarter
Thanks for your reply!
I am soory, i'm still new to JS developing i have another question.
I understand this:
...html(instance.t("lang.fav")); // hide COOP counter
But what does this?
instance.ChangeCOOPtoFAV(instance);
And where do i have to put it in the sourcecode?
Sry for my bad english, it's not my native language.
EDIT: This is the full code:
DELETED
GosuSan
06. December 2012 21:12 BrainFooLong
Administrator
You have to change this
init : function(instance){
this.ChangeCOOPtoFAV();
},
domchange : function(instance){
this.ChangeCOOPtoFAV();
},
to this
init : function(instance){
instance.ChangeCOOPtoFAV(instance);
},
domchange : function(instance){
instance.ChangeCOOPtoFAV(instance);
},
That you have "instance" available in your custom function.
06. December 2012 21:17 Post edited 1 x times, last by
06. December 2012 21:19
Topicstarter
Ah ok, thank you very much for the fast support.
I think i'll release the plugin tomorrow.
I first want to look into the code of some other plugins to learn more about this language
and the bblog plugin system.
Thanks again
GosuSan
EDIT: another question: is it hard to create a button in the bblog-menu to enable / disable this little plugin?
It is not really needed, but i wonder how to do this.
06. December 2012 21:21 BrainFooLong
Administrator
See the example plugin...
it describes all whats possible.
You can also add it to your plugin list to see what it is doing.
http://getbblog.com/plugins/example.js
06. December 2012 22:30 Topicstarter
Thanks, this helped me a lot!
You can close this thread if you want, at the moment all my questions are answered.
And many thanks to the whole bblog team, it's a great work you are doing here!
GosuSan