On Thu, Jan 22, 2009 at 12:42 PM, [email protected] <[email protected]>wrote:
>
> Hello
> Im making a command for my tv-use
> The command takes two arguments: Program category + start-time (using
> from as a modifier between)
> f.eks
> "tv movies from 17"
> The problem is that the site uses id-numbers for the various program-
> categories. 1 = children-programs, 12 = movies etc. So I tried to
> substitute the searchterms with numbers in my if/ else construction
>
> The question: Can someone help me to sort out the if - else
> construction so that it works (I know its not right...) For the moment
> it responds only to the if statement
>
Ahh! - took me a little while too, the problem is that your are testing
weather an assignment returns true (which it does, in this case)
To test for comparison, you must use ==, not just =
Moreover, I'd recommend using the switch statement, instead of a giant if
else...
switch (keywords.text) {
case "movies":
strKeyWords = 12;
break;
case "sports":
strKeyWords = 4;
break;
etc...
}
>
> Here is the code
>
> CmdUtils.CreateCommand({
> name: "tv",
> icon: "http://www.myspace.com/favicon.ico",
> preview: "(Category) from (time) <br> <p> Categories: <br> <p> all
> <br> children <br> science <br> movies <br> sports",
> description: "Searches dagbladet.no for tv-program",
> takes: {"keywords": noun_arb_text},
> modifiers: {"from": noun_arb_text},
>
> execute: function( keywords, modifiers ) {
>
> var strKeyWords = keywords.text;
> var strFrom = modifiers.from.text;
>
> if (keywords.text = "movies") {
> strKeyWords = 12;
> }
> else if (keywords.text = "sports") {
> strKeyWords = 4;
> }
> else if (keywords.text = "children") {
> strKeyWords = 1;
> }
> else if (keywords.text = "science") {
> strKeyWords = 2;
> }
> else if (keywords.text = "all") {
> strKeyWords = 0;
> }
> /* Put together our search URL */
>
> var strURL = "http://fredag.dagbladet.no/tv/index.html?kategori_id=" +
> strKeyWords +
> "&dag=0&fra_tid=" +
> strFrom +
> "&til_tid=5";
>
> /* "fra" = from, "dag" = day, "til" = to, "tid" = time */
>
> /* Open the URL in a new window or tab */
> Utils.openUrlInBrowser( strURL );
> }
> });
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ubiquity-firefox" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ubiquity-firefox?hl=en
-~----------~----~----~----~------~----~------~--~---