Labs/Ubiquity/Writing A Search Command: Difference between revisions

Line 211: Line 211:
</pre>
</pre>


=== Using functions in the parser ===
=== Parsing XML / Using functions in the parser ===
<pre>
<pre>
CmdUtils.makeSearchCommand({
CmdUtils.makeSearchCommand({
Line 220: Line 220:
     container: "simpleforecast > forecastday",
     container: "simpleforecast > forecastday",
     title: "pretty",
     title: "pretty",
     body: "conditions",
     body: function() $("<div>").append(
      $("conditions", this), "<br/>",
      $("<b>", {
        text: $("low > celsius", this).text() + "\u2103",
        style: "color:#66f",
      }),
      " \uFF5E ",
      $("<b>", {
        text: $("high > celsius", this).text() + "\u2103",
        style: "color:#f66",
      })),
     thumbnail: function() $("<img>", {
     thumbnail: function() $("<img>", {
       src: ("http://icons-pe.wxug.com/i/c/a/" +
       src: "http://icons-pe.wxug.com/i/c/a/" + $("icon", this).text() + ".gif",
            this.find("icon").text() + ".gif"),
     }),
     }),
   },
   },
73

edits