Uw opmerkingen

IR.AddListener(IR.EVENT_START,0,function()
{
   pXMLTV.request(function(resp) {
      try {
         if (resp.tv[0]  !== undefined) {
            IR.Log("TEMPERATURE is " + resp.tv.channel.url);
            for (j=0; j<pXMLTV.lngth(resp.tv.channel); j++) {
              IR.Log(resp.tv.channel[j]["display-name"]);
              IR.Log('------------------////----------------');
            }
            for (k=0; k<pXMLTV.lngth(resp.tv.programme); k++) {
              st=pXMLTV.ctime(resp.tv.programme[k]["@start"]);
              et=pXMLTV.ctime(resp.tv.programme[k]["@stop"]);
              IR.Log(resp.tv.programme[k]["title"] + " ["+st + 
              " - " + et + "]") ;
            }
            //IR.Log(typeof resp.main.temp)
            //IR.GetDevice("HDL-BUS Pro Network (UDP)").Set("HVAC:temp", resp.main.temp); //type conversion warring!
         } 
      } catch (e) {
         IR.Log("Something is wrong \n" + e); // error handler 
      } 
   });
});
var pXMLTV  = {};
pXMLTV.dev = IR.CreateDevice(IR.DEVICE_CUSTOM_HTTP_TCP, "pXMLTV_dev", 
{Host: "raspored.hrt.hr",
            Port: 80,
            SSL: false,
            ScriptMode: IR.DIRECT_AND_SCRIPT,
            SendCommandAttempts: 0,
            ConnectWaitTimeMax: 3000,
            ReceiveWaitTimeMax: 5000
});
pXMLTV.request = function(in_callback){
      pXMLTV.dev.Connect(); // Must be
        pXMLTV.dev.SendEx({
            Type: "GET",
            Url: "/format/xmltv.xml?mreza=2",
            /*Headers: {
            "Content-Type": "application/json"
            },*/
            cbReceiveText: function(text, code, headers) {
            
            if (code != 200) return; //parse other error codes!
                var resp = new XML(text);
            //BUG: new XML return always  null || Ticket ID: #11928
            pXMLTV.dev.Disconnect();            
            in_callback(resp);            
            },
        });
   }
   
pXMLTV.lngth= function(node) { //childNode does not have the length property || Ticket ID: #11929
   var i = 0;
   while (node[i] !== undefined) ++i;
   return i;
}
pXMLTV.ctime= function(tme) { //
   return tme.replace(
    /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)\s([+-])(\d{4})$/,
    '$2/$3/$1 $4:$5:$6' //bug with GMT/UTC ;
    );
}