Gmanium

Style under Substance

Now Playing on my TiVo

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Loading...</title>
<script type="text/javascript">
<![CDATA[
var tivo = new Array(5);
tivo[0]=[ "Living Room","192.168.0.111", 29.25 ];//[ "Location" , "Tivo's IP" , total gigabytes used to record shows ]
//tivo[1]=[ "Master Bedroom" , "192.168.0.101" , 29.25 ];
//tivo[2]=[ "Den" ,"192.168.0.101" , 69.25 ];
//tivo[3]=[ "Kitchen" , "192.168.0.101" , 109.25 ];
//tivo[4]=[ "Bathroom" , "192.168.0.101" , 0 ];
var mak=''; //your media access key
var totalGB = tivo[0][2]; 

var numExpDReqFilled = 0;
window.onload = function (evt) {
     if (tivo[1]){
        var f = document.createElement('form');
        f.setAttribute('name','frmSelTiVo');
        f.setAttribute('id','frmSelTiVo');
        var s = document.createElement('select');
        s.setAttribute('disabled',"disabled");
        s.setAttribute('name','selTiVos');
        s.setAttribute('id','selTiVos');
        s.onchange=getContent;
        var o = new Array(5);
        var oTN = new Array(5);
        for (i = 0; i < 5; i++) {
            if (tivo[i]){
                o[i] = document.createElement('option');
                o[i].setAttribute('value',tivo[i][1]);
                oTN[i] = document.createTextNode(tivo[i][0]);
                o[i].appendChild(oTN[i]);
                s.appendChild(o[i]);
            }
        }
        f.appendChild(s);
        document.body.appendChild(f);
    }
    getContent();
}
function getContent(){
    var tivo_ip = tivo[0][1];
    if (document.getElementById("selTiVos")){
        var tivo_list = document.getElementById("selTiVos");
        tivo_list.setAttribute('disabled','disabled');
        tivo_ip = tivo_list.options[tivo_list.selectedIndex].value;
        totalGB = tivo[tivo_list.selectedIndex][2];
    }
    document.title="Loading...";
    if (document.getElementById('content')){
        document.body.removeChild(document.getElementById('content'));
    }
    var contentDiv = document.createElement('div');
    contentDiv.setAttribute('id','content');
    document.body.appendChild(contentDiv);
    var xsltNS = 'http://www.w3.org/1999/XSL/Transform';
    var xsltSheet = document.getElementsByTagNameNS(xsltNS, 'stylesheet')[0];
    var xsltProcessor = new XSLTProcessor();
    var xmlDoc;
    xsltProcessor.importStylesheet(xsltSheet);
    var myXMLHTTPRequest = new XMLHttpRequest();
    netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
    //myXMLHTTPRequest.open("GET", '826nowrectransnontivo.xml', true,'tivo',mak);
    //myXMLHTTPRequest.open("GET", '826nowtransnontivo.xml', true,'tivo',mak);
//myXMLHTTPRequest.open("GET", '826nowrecnowtransnontivo.xml', true,'tivo',mak);
 //myXMLHTTPRequest.open("GET", '826nowrecnowtrans.xml', true,'tivo',mak);
 //myXMLHTTPRequest.open("GET", '826nowrec.xml', true,'tivo',mak);
    myXMLHTTPRequest.open("GET", 'https://'+tivo_ip+'/TiVoConnect?Command=QueryContainer&Container=%2FNowPlaying&Recurse=Yes', true,'tivo',mak);

    myXMLHTTPRequest.send(null);
    myXMLHTTPRequest.onreadystatechange=function() {
        if (myXMLHTTPRequest.readyState==4) {
            netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
            xmlDoc = myXMLHTTPRequest.responseXML;
            var fragment = xsltProcessor.transformToFragment(xmlDoc, document);
            document.getElementById('content').appendChild(fragment);
            convertDates();
            calcTimeLeft();
            if (document.getElementById("nRI")) getNowRecInfo(tivo_ip);
            var tblNP = document.getElementById('nowPlay');
            sortTable(3, 'nowPlay');
            sortTable(3, 'nowPlay');
            for (i = 0; i < tblNP.rows.length; i++) {
                getExpDate(tivo_ip, tblNP.rows[i].cells[2], tblNP.rows.length);
            }
            if (document.getElementById("selTiVos")){
                document.getElementById("selTiVos").removeAttribute('disabled');
            }
        }
    }
    
}
function getNowRecInfo(tivo_ip){
    var nRSpan = document.getElementById("nRI");
    var vd = nRSpan.childNodes[0].nodeValue;
    var myXMLHTTPRequest = new XMLHttpRequest();
    netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
    myXMLHTTPRequest.open("GET", vd, true,'tivo',mak);
    myXMLHTTPRequest.send(null);
    myXMLHTTPRequest.onreadystatechange=function() {
        if (myXMLHTTPRequest.readyState==4) {
            if (myXMLHTTPRequest.status!=200){
                getNowRecInfo(tivo_ip);
            } else {
                netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
                var responseText = myXMLHTTPRequest.responseText;
                var zuluTime = responseText.match( /<expirationTime>(.+)<\/expirationTime>/ );
                var y = zuluTime[1].substring(0,4);
                var mo = zuluTime[1].substring(5,7);
                var d = zuluTime[1].substring(8,10);
                var h = zuluTime[1].substring(11,13);
                var m = zuluTime[1].substring(14,16);
                var s = zuluTime[1].substring(17,19);
                var expDate = new Date(Date.UTC(y,mo-1,d,h,m,s));
                var weekday=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
                var d =weekday[expDate.getDay()]+' '+(expDate.getMonth()+1)+'/'+expDate.getDate();
                expDate = d+" "+getClockTime(expDate)
                var quality = responseText.match( /<recordingQuality.+>(.+)<\/recordingQuality>/);
                if (quality[1]=="GOOD") quality[1]="BASIC";
                var recDur = responseText.match( /<recordedDuration>(.+)<\/recordedDuration>/ );
                var dur = responseText.match( /<showing>.+<duration>(.+?)<\/duration>/ );
                nRSpan.childNodes[0].nodeValue="Quality: "+quality[1]+" | Partialness: "
                        +recDur[1].substring(2)+" of "+dur[1].substring(2)
                        +" | Will Expire: "+expDate+"}";
                nRSpan.className = '';
            }
        }
    }
}
function getExpDate(tivo_ip, node, timesToBeCalled){
    var showId = node.childNodes[0].childNodes[0].nodeValue;
    var myXMLHTTPRequest = new XMLHttpRequest();
    netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
    myXMLHTTPRequest.open("GET", 'https://'+tivo_ip+
               '/TiVoVideoDetails?id='+showId, true,'tivo',mak);
    myXMLHTTPRequest.send(null);
    myXMLHTTPRequest.onreadystatechange=function() {
        if (myXMLHTTPRequest.readyState==4) {
            if (myXMLHTTPRequest.status!=200){
                getExpDate(tivo_ip, node, timesToBeCalled);
            } else {
                numExpDReqFilled++;
                netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
                var responseText = myXMLHTTPRequest.responseText;
                var zuluTime = responseText.match( /<expirationTime>(.+)<\/expirationTime>/ )
                var spanNode = document.createElement("span");
                if (zuluTime[1]=='2038-01-19T00:00:00Z') {
                    var textNode=document.createTextNode('Never');
                    spanNode.appendChild(textNode);
                    node.appendChild(spanNode);
                    node.childNodes[0].childNodes[0].nodeValue=9999999999;
                } else{
                    var y = zuluTime[1].substring(0,4);
                    var mo = zuluTime[1].substring(5,7);
                    var d = zuluTime[1].substring(8,10);
                    var h = zuluTime[1].substring(11,13);
                    var m = zuluTime[1].substring(14,16);
                    var s = zuluTime[1].substring(17,19);
                    var expDate = new Date(Date.UTC(y,mo-1,d,h,m,s));
                    var weekday=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
                    var d =weekday[expDate.getDay()]+' '+(expDate.getMonth()+1)+'/'+expDate.getDate();
                    var textNode=document.createTextNode(d);
                    var di = document.createElement("div");
                    var tn = document.createTextNode(getClockTime(expDate));
                    di.appendChild(tn);
                    spanNode.appendChild(textNode);
                    spanNode.appendChild(di);
                    node.appendChild(spanNode);
                    node.childNodes[0].childNodes[0].nodeValue=(expDate.getTime()/1000);
                }
                if (numExpDReqFilled==timesToBeCalled){
                        numExpDReqFilled = 0
                        var where = " on my Tivo";
                        if (document.getElementById("selTiVos")){
                            var tivo_list = document.getElementById("selTiVos");
                            where = " in my "+tivo_list.options[tivo_list.selectedIndex].childNodes[0].nodeValue
                        }
                        document.title="Now Playing"+where;
                        if (document.getElementById('exp')) document.getElementById('exp').className = 'sort';
                }
            }
        }
    }
}

function convertDates(){
    var tblNP = document.getElementById('nowPlay');
    for (i = 0; i < tblNP.rows.length; i++) {
        var hexDate = tblNP.rows[i].cells[3].childNodes[1].nodeValue;
        var d=new Date((parseInt(hexDate, 16))*1000+2000);
        var weekday=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
        var newValue =weekday[d.getDay()]+' '+(d.getMonth()+1)+'/'+d.getDate();
        tblNP.rows[i].cells[3].childNodes[1].nodeValue = newValue;
        var di = document.createElement("div");
        var tn = document.createTextNode(getClockTime(d));
        di.appendChild(tn);
        tblNP.rows[i].cells[3].appendChild(di);
    }
    if (document.getElementById('suggest')) {
        var tblSu = document.getElementById('suggest');
        for (i = 0; i < tblSu.rows.length; i++) {
            var hexDate = tblSu.rows[i].cells[2].childNodes[1].nodeValue;
            var d=new Date((parseInt(hexDate, 16))*1000+2000);
            var weekday=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
            var newValue =weekday[d.getDay()]+' '+(d.getMonth()+1)+'/'+d.getDate();
            tblSu.rows[i].cells[2].childNodes[1].nodeValue = newValue;
            var di = document.createElement("div");
            var tn = document.createTextNode(getClockTime(d));
            di.appendChild(tn);
            tblSu.rows[i].cells[2].appendChild(di);
        }
    }
}
function getClockTime(d)
{
   var hour   = d.getHours();
   var minute = d.getMinutes();
   var ap = "A";
   if (hour > 11) { ap = "P";}
   if (hour > 12) { hour = hour - 12; }
   if (hour == 0) { hour = 12; }
   if (minute < 10) { minute = "0" + minute; }
   var timeString = hour + ':' + minute +ap;
   return timeString;
} 
function calcTimeLeft(){
    var used = document.body.getElementsByTagName('i')[0].childNodes[0].nodeValue;
    if (totalGB>used) {
        var leftGB = totalGB - used;
        var bestHoursLeft = leftGB * 1073741824/763712/3600;
        var bestHo = Math.floor(bestHoursLeft);
        var bestMin = Math.round((bestHoursLeft - bestHo)*60);
        if (bestMin==60){bestMin=0;bestHo+=1}
        var highHoursLeft = leftGB * 1073741824/475354/3600;
        var highHo = Math.floor(highHoursLeft);
        var highMin = Math.round((highHoursLeft - highHo)*60);
        if (highMin==60){highMin=0;highHo+=1}
        var medHoursLeft = leftGB * 1073741824/361759/3600;
        var medHo = Math.floor(medHoursLeft);
        var medMin = Math.round((medHoursLeft - medHo)*60);
        if (medMin==60){medMin=0;medHo+=1}
        var basHoursLeft = leftGB * 1073741824/213210/3600;
        var basHo = Math.floor(basHoursLeft);
        var basMin = Math.round((basHoursLeft - basHo)*60);
        if (basMin==60){basMin=0;basHo+=1}
        var h2 = document.createElement("h2");
        var tn = document.createTextNode('TimeLeft: ~ '
                    +bestHo+'hr '+bestMin+'min (@Best) || '
                    +highHo+'hr '+highMin+'min (@High) || '
                    +medHo+'hr '+medMin+'min (@Medium) || '
                    +basHo+'hr '+basMin+'min (@Basic)');
        h2.appendChild(tn);
        document.body.getElementsByTagName('h1')[0].appendChild(h2);
    }
}

function sortTable(col, tableBody) {
    var tblEl = document.getElementById(tableBody);
    
    if (tblEl.reverseSort == null) tblEl.reverseSort = new Array();
    if (col == tblEl.lastColumn) tblEl.reverseSort[col] = !tblEl.reverseSort[col];
    tblEl.lastColumn = col;
    
    var oldDsply = tblEl.style.display;
    tblEl.style.display = "none";

    var tmpEl, i, j, minVal, minIdx, testVal, cmp;
    for (i = 0; i < tblEl.rows.length - 1; i++) {
        minIdx = i;
        minVal = tblEl.rows[i].cells[col].childNodes[0].childNodes[0].nodeValue;
        for (j = i + 1; j < tblEl.rows.length; j++) {
            testVal = tblEl.rows[j].cells[col].childNodes[0].childNodes[0].nodeValue;
            cmp = compareValues(minVal, testVal);
            if (tblEl.reverseSort[col])
                cmp = -cmp;
            if (cmp > 0) {
                minIdx = j;
                minVal = testVal;
            }
        }
        if (minIdx > i) {
            tmpEl = tblEl.removeChild(tblEl.rows[minIdx]);
            tblEl.insertBefore(tmpEl, tblEl.rows[i]);
        }
    }
    tblEl.style.display = oldDsply;
}

function compareValues(v1, v2) {
    var f1, f2;
    if (v1.substring(0,4)=='The ') v1=v1.substring(4);
    if (v1.substring(0,2)=='A ') v1=v1.substring(2);
    if (v2.substring(0,4)=='The ') v2=v2.substring(4);
    if (v2.substring(0,2)=='A ') v2=v2.substring(2);
    if (v1.substring(0,2)=='0x'){
        f1 = parseInt(v1,16);
        f2 = parseInt(v2,16);
    } else {
        f1= parseInt(v1);
        f2=parseInt(v2);
    }
    if (!isNaN(f1) && !isNaN(f2)) {
        v1 = f1;
        v2 = f2;
    }
    
    if (v1 == v2) return 0;
    if (v1 > v2) return 1
    return -1;
}

function showNowRecordingDetails(vdUrl){
    var tivo_ip = tivo[0][1];
    if (document.getElementById("selTiVos")){
        var tivo_list = document.getElementById("selTiVos");
        tivo_ip = tivo_list.options[tivo_list.selectedIndex].value;
    }

    if (document.getElementById("nowRec").childNodes[0].nodeValue=="show"){
        document.getElementById("nowRec").childNodes[0].nodeValue="hide";
            var xsltProcessor = new XSLTProcessor();
            var xsltSheet = document.getElementsByTagNameNS('http://www.w3.org/1999/XSL/Transform', 'stylesheet')[1];
            xsltProcessor.importStylesheet(xsltSheet);
            var myXMLHTTPRequest = new XMLHttpRequest();
            netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
            myXMLHTTPRequest.open("GET", vdUrl, false,'tivo',mak);
            myXMLHTTPRequest.send(null);
            xmlDoc = myXMLHTTPRequest.responseXML;
            var fragment = xsltProcessor.transformToFragment(xmlDoc, document);
            var nr=document.getElementById("recDesc");
            nr.appendChild(fragment);
        
    } else {
        var nr=document.getElementById("recDesc");
        nr.removeChild(nr.lastChild);
        document.getElementById("nowRec").childNodes[0].nodeValue="show";
    }
}
function showDetails(showNum){
    var tivo_ip = tivo[0][1];
    if (document.getElementById("selTiVos")){
        var tivo_list = document.getElementById("selTiVos");
        tivo_ip = tivo_list.options[tivo_list.selectedIndex].value;
    }

    if (document.getElementById('SH'+showNum).childNodes[0].nodeValue=="show"){
        var xsltProcessor = new XSLTProcessor();
            var xsltSheet = document.getElementsByTagNameNS('http://www.w3.org/1999/XSL/Transform', 'stylesheet')[1];
            xsltProcessor.importStylesheet(xsltSheet);
            var myXMLHTTPRequest = new XMLHttpRequest();
            netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
            myXMLHTTPRequest.open("GET", 'https://'+tivo_ip+'/TiVoVideoDetails?id='+showNum, false,'tivo',mak);
            myXMLHTTPRequest.send(null);
            xmlDoc = myXMLHTTPRequest.responseXML;
            var fragment = xsltProcessor.transformToFragment(xmlDoc, document);
            var row=document.getElementById(showNum);
            row.childNodes[1].appendChild(fragment);
            document.getElementById('SH'+showNum).childNodes[0].nodeValue="hide";
            
    } else {
        var row=document.getElementById(showNum);
        row.childNodes[1].removeChild(row.childNodes[1].lastChild);
        document.getElementById('SH'+showNum).childNodes[0].nodeValue="show";
    }
}
function showSuggTable() {
    if (document.getElementById("suggShowHide").childNodes[0].nodeValue=="show"){
        document.getElementById("suggTable").style.display="block";
        document.getElementById("suggShowHide").childNodes[0].nodeValue="hide"
    } else {
        document.getElementById("suggTable").style.display="none";
        document.getElementById("suggShowHide").childNodes[0].nodeValue="show"
    }
}

]]>
</script>

<style type="text/css">
    body { font-family: sans-serif }
    a.sh { cursor: pointer; color:#0000ff }
    a.search{ text-decoration:none;color:#000000}
    a.search:hover { color:#0000ff;text-decoration:underline}
    a.sort { cursor: pointer; color:#000000 }
    a.sort:hover { color:#790619}
    .sortBy {display:none}
    .cantSortYet { color:#ffffff }
    .nRDisplayHide {display:none }
    h1 { font-size: large }
    h2 { font-size: medium }
    tr { font-size: small }
    th { font-size: small; padding: 7px }
    td { font-size: small; padding: 7px }
</style>

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:t="http://www.tivo.com/developer/calypso-protocol-1.6/">
<xsl:output method="html"/>

<xsl:template match="/">
<xsl:for-each select="t:TiVoContainer/t:Item[t:Links/t:CustomIcon/t:Url='urn:tivo:image:in-progress-transfer']">
<span style="font-size:large;color:#3c9feb"><b>Now Transferring</b></span>

<b><xsl:value-of select="t:Details/t:Title"/>
<xsl:if test="t:Details/t:EpisodeTitle">: "<xsl:value-of select="t:Details/t:EpisodeTitle"/>"</xsl:if></b>

<xsl:value-of select="substring-before(t:Details/t:Description,'Copyright')"/>
<hr style ="background-color:#3c9feb"></hr>


</xsl:for-each>

<xsl:for-each select="t:TiVoContainer/t:Item[t:Details/t:InProgress and not(t:Links/t:CustomIcon/t:Url='urn:tivo:image:in-progress-transfer')]">
<xsl:variable name="vd" select="t:Links/t:TiVoVideoDetails/t:Url"/>
<span style="font-size:large;color:#fc0000"><b>Now Recording</b></span>

<b>
<xsl:value-of select="t:Details/t:SourceStation"/> Ch. 
<xsl:value-of select="substring-before(t:Details/t:SourceChannel,'-0')"/>
- 
<xsl:value-of select="t:Details/t:Title"/>
<xsl:if test="t:Details/t:EpisodeTitle">: "<xsl:value-of select="t:Details/t:EpisodeTitle"/>"</xsl:if>
</b>
 
<span style="font-family:courier">[<b>details:</b>
<a class='sh' onclick="showNowRecordingDetails('{$vd}')">
<xsl:attribute name="id">nowRec</xsl:attribute>show</a>]
</span>


<span style="font-size:small">
<b>
<xsl:choose>
<xsl:when test="../t:Item[last()]/t:Details/t:InProgress and not(../t:Item[last()]/t:Links/t:CustomIcon/t:Url='urn:tivo:image:in-progress-transfer')"> {Suggestion | </xsl:when>
<xsl:otherwise> { Planned | </xsl:otherwise>
</xsl:choose>
<span class="nRDisplayHide">
<xsl:attribute name="id">nRI</xsl:attribute>
<xsl:value-of select="$vd"/></span>
</b>
</span>


<span>
<xsl:attribute name="id">recDesc</xsl:attribute>
<xsl:value-of select="substring-before(t:Details/t:Description,'Copyright')"/></span>
<hr style ="background-color:#fc0000"></hr>
</xsl:for-each>

<h1>Now Playing - 
<xsl:value-of select="count(t:TiVoContainer/t:Item[not(t:Details/t:InProgress 
                             or t:Links/t:CustomIcon/t:Url=
                             'urn:tivo:image:suggestion-recording')])"/>
 Shows
<xsl:variable name="hr" select="floor(sum(//t:Duration[not(../t:InProgress 
                                or ../../t:Links/t:CustomIcon/t:Url=
                                'urn:tivo:image:suggestion-recording')])
                                div 3600000)"/>
<xsl:variable name="min" select="round(((sum(//t:Duration[not(../t:InProgress 
                                 or ../../t:Links/t:CustomIcon/t:Url=
                                 'urn:tivo:image:suggestion-recording')]) 
                                 div 3600000)-$hr)*6000 div 100)"/>
<xsl:choose>
   <xsl:when test="$min = 60">(<xsl:value-of select="$hr+1"/>hr 0min using </xsl:when><xsl:otherwise>
   (<xsl:value-of select="$hr"/>hr <xsl:value-of select="$min"/>min using </xsl:otherwise>
 </xsl:choose>
<b><i>
<xsl:value-of select="round(sum(//t:SourceSize[not(../t:InProgress 
                                  or ../../t:Links/t:CustomIcon/t:Url=
                                  'urn:tivo:image:suggestion-recording')]) 
                                  div 1073741824 * 100) div 100"/>
</i></b><b>GB</b>)
</h1>

<table id='tab' style="width:100%;">
<thead>
<tr style="background-color:#E5E5C5;">
<th style="width:1%"><a class='sort' onclick="sortTable(0, 'nowPlay')">Source</a></th>
<th><a class='sort' onclick="sortTable(1, 'nowPlay')">Description</a></th>
<th style="width:6%"><a class='cantSortYet' onclick="sortTable(2, 'nowPlay')">
<xsl:attribute name="id">exp</xsl:attribute>Expires</a></th>
<th style="width:6%"><a class='sort' onclick="sortTable(3, 'nowPlay')">Acquired</a></th>
<th style="width:5%"><a class='sort' onclick="sortTable(4, 'nowPlay')">Size</a></th>
<th style="width:5%"><a class='sort' onclick="sortTable(5, 'nowPlay')">Quality</a></th>
</tr>
</thead>
<tbody>
<xsl:attribute name="id">nowPlay</xsl:attribute>
<xsl:for-each select="t:TiVoContainer/t:Item[not(t:Details/t:InProgress 
         or t:Links/t:CustomIcon/t:Url='urn:tivo:image:suggestion-recording')]">
<xsl:variable name="showUrl" select="t:Links/t:TiVoVideoDetails/t:Url"/>
<xsl:variable name="showNum" select="substring-after($showUrl,'id=')"/>
<tr id="{$showNum}">

<td style="background-color:#fc0000;vertical-align:top;text-align:center;">
<xsl:choose>
<xsl:when test = "not(t:Details/t:SourceChannel)"><span class="sortBy">zzzz</span>PC:GREG</xsl:when>
<xsl:otherwise>
<span class="sortBy"><xsl:value-of select="t:Details/t:SourceStation"/></span>
<xsl:value-of select="t:Details/t:SourceStation"/>

<xsl:value-of select="substring-before(t:Details/t:SourceChannel,'-0')"/>
</xsl:otherwise>
</xsl:choose>
</td>

<td style="background-color:#F5F595;vertical-align:top;text-align:left;">
<span class="sortBy"><xsl:value-of select="t:Details/t:Title"/></span>
<xsl:if test="t:Details/t:SourceChannel">
<span style="float:right;font-family:courier">[<b>details:</b>
<a class='sh' id="SH{$showNum}" onclick="showDetails('{$showNum}')">show</a>]</span>
</xsl:if>
<xsl:choose>
   <xsl:when test="t:Links/t:CustomIcon/t:Url=
   'urn:tivo:image:save-until-i-delete-recording'">
<span style="background-color:#32c864">
<b>
<xsl:value-of select="t:Details/t:Title"/>
<xsl:if test="t:Details/t:EpisodeTitle">: "<xsl:value-of select="t:Details/t:EpisodeTitle"/>"</xsl:if>
</b>
</span>
</xsl:when>
<xsl:otherwise>
      <span style="color:#000000">
<b>
<xsl:value-of select="t:Details/t:Title"/>
<xsl:if test="t:Details/t:EpisodeTitle">: "<xsl:value-of select="t:Details/t:EpisodeTitle"/>"</xsl:if>
</b>
</span>
   </xsl:otherwise>
</xsl:choose>



<xsl:value-of select="substring-before(t:Details/t:Description,'Copyright')"/>
</td>
<td>
<xsl:attribute name="style">
background-color:#32c864;vertical-align:top;text-align:center
</xsl:attribute>
<span class="sortBy"><xsl:value-of select="$showNum"/></span>
</td>
<td>
<xsl:attribute name="style">
background-color:#32c864;vertical-align:top;text-align:center
</xsl:attribute>
<span class="sortBy"><xsl:value-of select="t:Details/t:CaptureDate"/></span>
<xsl:value-of select="t:Details/t:CaptureDate"/>
</td>



<xsl:variable name="dur" select="(t:Details/t:Duration+2000) div 3600000"/>
<xsl:variable name="hr" select="floor($dur)"/>
<xsl:variable name="min" select="round((($dur)-($hr))*60)"/>

<td style="background-color:#fe9900;vertical-align:top;text-align:center;">
<span class="sortBy"><xsl:value-of select="t:Details/t:SourceSize"/></span>
<xsl:choose>
   <xsl:when test="$min = 60">
   <xsl:value-of select="$hr+1"/>:00</xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$hr"/>:<xsl:if test="$min < 10">0</xsl:if><xsl:value-of select="$min"/>
   </xsl:otherwise>
 </xsl:choose>
 

 <xsl:variable name="download" select="t:Links/t:Content/t:Url"/>
 <a href='{$download}'>
<xsl:value-of select="round(t:Details/t:SourceSize div 1024 div 1024)"/></a> MB
</td>

<td style="background-color:#6565ca;vertical-align:top;text-align:center;">
<xsl:variable name="bs" select="t:Details/t:SourceSize div 
                                (t:Details/t:Duration div 1000)"/>
<xsl:variable name="qual">
<xsl:choose>
    <xsl:when test = "not(t:Details/t:SourceChannel)">Unknown</xsl:when>
   <xsl:when test="$bs > 600000">Best</xsl:when>
     <xsl:when test="$bs > 400000 and $bs < 600000">High</xsl:when>
   <xsl:when test="$bs > 300000 and $bs < 400000">Medium</xsl:when>
   <xsl:otherwise>Basic</xsl:otherwise>
 </xsl:choose>
</xsl:variable>
<span class="sortBy"><xsl:value-of select="$qual"/></span>
<b><xsl:value-of select="$qual"/></b>
</td>

</tr>
</xsl:for-each>
</tbody>
</table>


<xsl:variable name="numSugg" select="count(t:TiVoContainer/t:Item
        [t:Links/t:CustomIcon/t:Url='urn:tivo:image:suggestion-recording'])"/>
<xsl:if test="$numSugg > 0">
<hr></hr>
<b id="ts">TiVo Suggestions: </b>
<xsl:value-of select="$numSugg"/>
 Shows  
<span style="font-family:courier">[<a class='sh' onclick="showSuggTable()">
<xsl:attribute name="id">suggShowHide</xsl:attribute>show</a>]</span>

<table style="display:none;width:100%">
<xsl:attribute name="id">suggTable</xsl:attribute>
<thead>
<tr style="background-color:#E5E5C5;">
<th style="width:1%"><a class='sort' onclick="sortTable(0, 'suggest')">Source</a></th>
<th><a class='sort' onclick="sortTable(1, 'suggest')">Description</a></th>
<th style="width:6%"><a class='sort' onclick="sortTable(2, 'suggest')">Captured</a></th>
<th style="width:5%"><a class='sort' onclick="sortTable(3, 'suggest')">Size</a></th>
<th style="width:5%"><a class='sort' onclick="sortTable(4, 'suggest')">Quality</a></th>
</tr>
</thead>
<tbody>
<xsl:attribute name="id">suggest</xsl:attribute>
<xsl:variable name="numNowPlay" select="count(t:TiVoContainer/t:Item[not(t:Details/t:InProgress 
                             or t:Links/t:CustomIcon/t:Url=
                             'urn:tivo:image:suggestion-recording')])"/>
<xsl:for-each select="t:TiVoContainer/t:Item
        [t:Links/t:CustomIcon/t:Url='urn:tivo:image:suggestion-recording']">
<xsl:sort select="t:Details/t:Title"/>
<xsl:variable name="showUrl" select="t:Links/t:TiVoVideoDetails/t:Url"/>
<xsl:variable name="showNum" select="substring-after($showUrl,'id=')"/>
<tr id="{$showNum}">
<td style="width:1%;background-color:#fc0000;vertical-align:top;text-align:center;">
<span class="sortBy"><xsl:value-of select="t:Details/t:SourceStation"/></span>
<xsl:value-of select="t:Details/t:SourceStation"/>


<xsl:value-of select="substring-before(t:Details/t:SourceChannel,'-0')"/>
</td>

<td style="background-color:#F5F595;vertical-align:top;text-align:left;">
<span class="sortBy"><xsl:value-of select="t:Details/t:Title"/></span>
<xsl:variable name="vd" select="t:Links/t:TiVoVideoDetails/t:Url"/>
<span style="float:right;font-family:courier">[<b>details:</b>
<a class='sh' id="SH{$showNum}" onclick="showDetails('{$showNum}')">show</a>]</span>
<xsl:choose>
   <xsl:when test="t:Links/t:CustomIcon/t:Url=
   'urn:tivo:image:save-until-i-delete-recording'">
<span style="background-color:#00ff00">
<b><xsl:value-of select="t:Details/t:Title"/>
<xsl:if test="t:Details/t:EpisodeTitle">: "<xsl:value-of select="t:Details/t:EpisodeTitle"/>"</xsl:if>
</b>
</span>
</xsl:when>
<xsl:otherwise>
      <span style="color:#000000">
<b>
<xsl:value-of select="t:Details/t:Title"/>
<xsl:if test="t:Details/t:EpisodeTitle">: "<xsl:value-of select="t:Details/t:EpisodeTitle"/>"</xsl:if>
</b>
</span>
   </xsl:otherwise>
</xsl:choose>



<xsl:value-of select="substring-before(t:Details/t:Description,'Copyright')"/>
</td>

<td >
<xsl:attribute name="style">
width:5%;background-color:#32c864;vertical-align:top;text-align:center
</xsl:attribute>
<span class="sortBy"><xsl:value-of select="t:Details/t:CaptureDate"/></span>
<xsl:value-of select="t:Details/t:CaptureDate"/>
</td>


<xsl:variable name="dur" select="(t:Details/t:Duration+2000) div 3600000"/>
<xsl:variable name="hr" select="floor($dur)"/>
<xsl:variable name="min" select="round((($dur)-($hr))*60)"/>

<td style="width:5%;background-color:#fe9900;vertical-align:top;text-align:center;">
<span class="sortBy"><xsl:value-of select="t:Details/t:SourceSize"/></span>
<xsl:choose>
   <xsl:when test="$min = 60">
   1:00
   </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$hr"/>:<xsl:if test="$min < 10">0</xsl:if>
<xsl:value-of select="$min"/>
   </xsl:otherwise>
 </xsl:choose>
 

 <xsl:variable name="download" select="t:Links/t:Content/t:Url"/>
 <a href='{$download}'>
<xsl:value-of select="round(t:Details/t:SourceSize div 1024 div 1024)"/></a> MB
</td>

<td style="width:5%;background-color:#6565ca;vertical-align:top;text-align:center;">
<xsl:variable name="bs" select="t:Details/t:SourceSize div 
                                (t:Details/t:Duration div 1000)"/>
<xsl:variable name="qual">
<xsl:choose>
   <xsl:when test="$bs > 600000">Best</xsl:when>
     <xsl:when test="$bs > 400000 and $bs < 600000">High</xsl:when>
   <xsl:when test="$bs > 300000 and $bs < 400000">Medium</xsl:when>
   <xsl:otherwise>Basic</xsl:otherwise>
 </xsl:choose>
</xsl:variable>
<span class="sortBy"><xsl:value-of select="$qual"/></span>
<b><xsl:value-of select="$qual"/></b>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:if>

</xsl:template>
</xsl:stylesheet>

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:TvBusMarshalledStruct="http://tivo.com/developer/xml/idl/TvBusMarshalledStruct">
<xsl:output method="html"/>
<xsl:template match="/TvBusMarshalledStruct:TvBusEnvelope">
<xsl:variable name="oAD" select="showing/program/originalAirDate"/>
<xsl:variable name="expD" select="expirationTime"/>
<xsl:variable name="bkMk" select="vBookmark/element/time"/>
<table style="background-color:#FFFF7E;border-top: 2px solid #000000;border-left: 2px solid #000000;width:100%;">
<tr>

<td style="padding: 2px;width:200px;vertical-align: top;text-align:left">
Watched so far: <xsl:choose>
<xsl:when test="vBookmark/element">
<b>
<xsl:variable name="wsf" select="translate(substring-after
        (substring-before($bkMk,'M'),'PT'),'H','h')"/>
<xsl:choose>
   <xsl:when test="$wsf"><xsl:value-of select="$wsf"/></xsl:when>
   <xsl:otherwise><1</xsl:otherwise>
 </xsl:choose>min</b>
</xsl:when>
<xsl:otherwise>(None)</xsl:otherwise>
</xsl:choose>


<xsl:if test="showing/program/originalAirDate">
Original Air Date: <b>
<xsl:value-of select="translate(concat(substring($oAD,6,5),'-',substring($oAD,1,4)),'-','/')"/>
</b>
</xsl:if>


<xsl:if test="showing/program/episodeNumber">
Episode Number: 
<xsl:value-of select="showing/program/episodeNumber"/>


</xsl:if>
</td>

<td style="padding: 2px;vertical-align: top">
<xsl:if test="showing/program/vProgramGenre">
Genre: 
<xsl:for-each select="showing/program/vProgramGenre/element">
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>


</xsl:if>
<xsl:if test="showing/program/movieYear">
Year: 
<xsl:value-of select="showing/program/movieYear"/>


</xsl:if>
<xsl:if test="showing/program/mpaaRating">
Rated: 
<xsl:value-of select="showing/program/mpaaRating"/>
</xsl:if>
</td>
</tr>

<xsl:if test="showing/program/vActor/element">
<tr><td colspan="2" style="padding: 2px">
<u>Actors</u>: 
<xsl:for-each select="showing/program/vActor/element">
<xsl:variable name="fname" select="substring-after(.,'|')"/>
<xsl:variable name="lname" select="substring-before(.,'|')"/>
<xsl:variable name="nam">
<xsl:value-of select="concat($fname,' ',$lname)"/>
</xsl:variable>
<a class='search' href="http://www.imdb.com/Find?for={$fname}%20{$lname}&select=People">
<xsl:value-of select="$nam"/></a>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>
</td></tr>
</xsl:if>

<xsl:if test="showing/program/vGuestStar/element">
<tr><td colspan="2" style="padding: 2px">
<u>Guest Stars</u>: 
<xsl:for-each select="showing/program/vGuestStar/element">
<xsl:variable name="fname" select="substring-after(.,'|')"/>
<xsl:variable name="lname" select="substring-before(.,'|')"/>
<xsl:variable name="nam">
<xsl:value-of select="concat($fname,' ',$lname)"/>
</xsl:variable>
<a class='search' href="http://www.imdb.com/Find?for={$fname}%20{$lname}&select=People">
<xsl:value-of select="$nam"/></a>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>
</td></tr>
</xsl:if>

<xsl:if test="showing/program/vHost/element">
<tr><td colspan="2" style="padding: 2px">
<u>Host</u>: 
<xsl:for-each select="showing/program/vHost/element">
<xsl:variable name="fname" select="substring-after(.,'|')"/>
<xsl:variable name="lname" select="substring-before(.,'|')"/>
<xsl:variable name="nam">
<xsl:value-of select="concat($fname,' ',$lname)"/>
</xsl:variable>
<a class='search' href="http://www.imdb.com/Find?for={$fname}%20{$lname}&select=People">
<xsl:value-of select="$nam"/></a>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>
</td></tr>
</xsl:if>

<xsl:if test="showing/program/vDirector/element">
<tr><td colspan="2" style="padding: 2px">
<u>Directed by</u>: 
<xsl:for-each select="showing/program/vDirector/element">
<xsl:variable name="fname" select="substring-after(.,'|')"/>
<xsl:variable name="lname" select="substring-before(.,'|')"/>
<xsl:variable name="nam">
<xsl:value-of select="concat($fname,' ',$lname)"/>
</xsl:variable>
<a class='search' href="http://www.imdb.com/Find?for={$fname}%20{$lname}&select=People">
<xsl:value-of select="$nam"/></a>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>
</td></tr>
</xsl:if>

<xsl:if test="showing/program/vWriter/element">
<tr><td colspan="2" style="padding: 2px">
<u>Written by</u>: 
<xsl:for-each select="showing/program/vWriter/element">
<xsl:variable name="fname" select="substring-after(.,'|')"/>
<xsl:variable name="lname" select="substring-before(.,'|')"/>
<xsl:variable name="nam">
<xsl:value-of select="concat($fname,' ',$lname)"/>
</xsl:variable>
<a class='search' href="http://www.imdb.com/Find?for={$fname}%20{$lname}&select=People">
<xsl:value-of select="$nam"/></a>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>
</td></tr>
</xsl:if>

<xsl:if test="showing/program/vExecProducer/element">
<tr><td colspan="2" style="padding: 2px">
<u>Exec. Produced by</u>: 
<xsl:for-each select="showing/program/vExecProducer/element">
<xsl:variable name="fname" select="substring-after(.,'|')"/>
<xsl:variable name="lname" select="substring-before(.,'|')"/>
<xsl:variable name="nam">
<xsl:value-of select="concat($fname,' ',$lname)"/>
</xsl:variable>
<a class='search' href="http://www.imdb.com/Find?for={$fname}%20{$lname}&select=People">
<xsl:value-of select="$nam"/></a>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>
</td></tr>
</xsl:if>

</table>
</xsl:template>
</xsl:stylesheet>


</head>
<body>
</body>
</html>

April Fools + DST

Comments

jffaroonie Tuesday, December 4, 2007 5:35:06 AM

I am getting the following error.

XML Parsing Error: not well-formed
Location: file:///C:/Documents%20and%20Settings/Jeff/My%20Documents/nowplaying.xhtml
Line Number 567, Column 55: <xsl:value-of select="$hr"/>:<xsl:if test="$min < 10">0</xsl:if><xsl:value-of select="$min"/>
------------------------------------------------------^

Please let me know what I did incorrectly.

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.

February 2012
S M T W T F S
January 2012March 2012
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29