Talk:Widget

From BC$ MobileTV Wiki
Jump to: navigation, search

Here's an example widget JSON config to keep track of which widgets a user has enabled and where they have positioned them

{
   "widgets": [
       {
           "widget": {
               "debug": "on",
               "window": {
                   "title": "Text",
                   "name": "widget-text",
                   "width": 320,
                   "height": 240,
                   "position": 1
               },
               "text": {
                   "data": "Welcome to your personalizable Widget portal!",
                   "size": 36,
                   "style": "bold",
                   "name": "message",
                   "hOffset": 250,
                   "vOffset": 100
               }
           },
          ... NEXT WIDGET ...
       }
   ]
}







Modify LOTTO widget with the following new YQL query:

select * from html where url="http://m.alc.ca/game.jsp;jsessionid=B10D73F421BEBCC216D5880B2EFD2C60?id=LOTTO649" and xpath='//strong[@class="num"]'

Use the ;jsessionid= (using a regex or URL query parser) string value from the body of the url element in the response, which looks as follows in XML:

<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
   yahoo:count="14" yahoo:created="2013-06-26T20:13:29Z" yahoo:lang="en-US">
   <diagnostics>
       <publiclyCallable>true</publiclyCallable>
       <cache execution-start-time="2" execution-stop-time="2" execution-time="0" method="GET" type="MEMCACHED">
         <![CDATA[ http://m.alc.ca/robots.txt ]]>
       </cache>
       <url execution-start-time="1" execution-stop-time="285" execution-time="284" proxy="DEFAULT">
         <![CDATA[ http://m.alc.ca/game.jsp;jsessionid=B10D73F421BEBCC216D5880B2EFD2C60?id=LOTTO649 ]]>
       </url>
       <user-time>296</user-time>
       <service-time>284</service-time>
       <build-version>37740</build-version>
   </diagnostics> 
   <results>
       <strong class="num">03</strong>
       <strong class="num">04</strong>
       <strong class="num">05</strong>
       <strong class="num">12</strong>
       <strong class="num">23</strong>
       <strong class="num">33</strong>
       <strong class="num">27</strong>
       <strong class="num">14</strong>
       <strong class="num">18</strong>
       <strong class="num">25</strong>
       <strong class="num">26</strong>
       <strong class="num">29</strong>
       <strong class="num">45</strong>
       <strong class="num">38</strong>
   </results>
</query>

-OR-

JSON:

{
"query": {
 "count": 14,
 "created": "2013-06-26T20:17:54Z",
 "lang": "en-US",
 "diagnostics": {
  "publiclyCallable": "true",
  "cache": {
   "execution-start-time": "66",
   "execution-stop-time": "66",
   "execution-time": "0",
   "method": "GET",
   "type": "MEMCACHED",
   "content": "http://m.alc.ca/robots.txt"
  },
  "url": {
   "execution-start-time": "0",
   "execution-stop-time": "351",
   "execution-time": "351",
   "proxy": "DEFAULT",
   "content": "http://m.alc.ca/game.jsp;jsessionid=B10D73F421BEBCC216D5880B2EFD2C60?id=LOTTO649"
  },
  "user-time": "364",
  "service-time": "351",
  "build-version": "37740"
 },
 "results": {
  "strong": [
   {
    "class": "num",
    "content": "03"
   },
   {
    "class": "num",
    "content": "04"
   },
   {
    "class": "num",
    "content": "05"
   },
   {
    "class": "num",
    "content": "12"
   },
   {
    "class": "num",
    "content": "23"
   },
   {
    "class": "num",
    "content": "33"
   },
   {
    "class": "num",
    "content": "27"
   },
   {
    "class": "num",
    "content": "14"
   },
   {
    "class": "num",
    "content": "18"
   },
   {
    "class": "num",
    "content": "25"
   },
   {
    "class": "num",
    "content": "26"
   },
   {
    "class": "num",
    "content": "29"
   },
   {
    "class": "num",
    "content": "45"
   },
   {
    "class": "num",
    "content": "38"
   }
  ]
 }
}
}