I need someone good at javascript, because I’m facing a nice difficulty… :
I need someone good at javascript, because I’m facing a nice difficulty… :
For my TaskerTask API, I have the object TaskerTask which has a var. The TaskerTask constructor is like :
function TaskerTask() {
var intent = new TaskerIntent();
}
Now, I have functions like :
TaskerTask.prototype.addAction = {
setVariable: function(varName, value, options) {
//blabla
this.intent.addArg(/* blabla */);
},
flash: function(text, options) {
//blabla
this.intent.addArg(/* blabla */);
}
};
Which make me able to do this :
var task = new TaskerTask();
task.addAction.setVariable(“VarName”, value);
The problem is : in the setVariable function, this isn’t defined anymore… and I need it….
I’m not sure it’s very clear.. ask if needed !
]]>« Hey (Previous Post)
(Next Post) For the scrolling wallpaper issue this is how I am trying to select the wallpaper but till no luck with scrolling »
< ![CDATA[
JavaScript does not work as a class language, this is object oriented, hence this does not refer to the TaskerIntent object. There is no “instance” but only “objects”, with some kind of class simulation through the prototype mechanism. this does not implicitly link to the object, it only links to the owner of hte object. In this case this is the “addAction” object.
]]>
< ![CDATA[
In this case, how can I pass the this reference from addAction to setVariable, flash, etc…?
]]>
< ![CDATA[
I would suggest instead to not use the extra step “addAction”. I don’t think this is so useful.
]]>
< ![CDATA[
That’s a bit true, but it was a naming “convention” problem : I wanted to have the word “add” separated from task and the action to add…
How can I name it?
I wanted : task.addAction.setVariable(name, value, option)
And
task.manageDefault.setVariable(newOptions)
Any ideas?
]]>
< ![CDATA[
I regret the “add”, but I’ll do something like :
task.setVariable(“%Name”, value, {append: true});
And
task.overwriteDefaultOptionsFor(“setVariable”, {doMath: true});
I could maybe do task.addAction(“setVariable”, “Name”, value, {doMath: true});
But the addAction function will have variable number of args and would be giant ^^ and I don’t want it
]]>
< ![CDATA[
Nevermind, I’ve found!
Finally it’ll be :
task.addAction(“setVariable”, [“%VarName”, value, {doMath: true}]);
]]>