0

Terms of Service from a remote location

Hi, Im new to Connect TV and have little experience with JavaScript. Im currently following the instructions on

http://developer.yahoo.com/connectedtv/faq/#tos

to create a terms of service just like the one specified on the above page, and Im trying to change the source of the XML file to a remote XML file on a server instead of the local one stored under the Contents directory. If anyone could point me on the right direction.


I think the source should be changed in the following function, but don't really know how. What would I have to add or change to have access to the remote XML file?

CODE
updateView: function() {
var tos = XMLDOM.parseFile("TOS.xml");
this.controls.content.setText(tos.documentElement.firstChild.nodeValue);
}


Thanks

by
2 Replies
  • QUOTE (Julio @ Jul 1 2010, 08:14 AM) <{POST_SNAPBACK}>
    Hi, Im new to Connect TV and have little experience with JavaScript. Im currently following the instructions on

    http://developer.yahoo.com/connectedtv/faq/#tos

    to create a terms of service just like the one specified on the above page, and Im trying to change the source of the XML file to a remote XML file on a server instead of the local one stored under the Contents directory. If anyone could point me on the right direction.


    I think the source should be changed in the following function, but don't really know how. What would I have to add or change to have access to the remote XML file?

    CODE
    updateView: function() {
    var tos = XMLDOM.parseFile("TOS.xml");
    this.controls.content.setText(tos.documentElement.firstChild.nodeValue);
    }


    Thanks

    Hi Julio,
    You could fetch it using the XMLHttpRequest object, just like you would in the browser:

    CODE
    var xhr = new XMLHttpRequest();
    xhr.open("GET", "http://www.example.com/TOS.xml", true);
    xhr.onreadystatechange = function () {
    //...snipped for brevity;
    var xml = xhr.responseXML();
    };
    xhr.send();


    Hope that helps.
    - Ben
    0
  • Thanks Ben

    I trying to access the response namely the content of the xml file that was requested so that I can display it in the side. I used different things but nothing work. Im modifying the code provided on the FAQ (link is available on my first post) to access the xml file from a remote location instead of local.
    Here is the code for the entire js file

    CODE
    var TosView = new KONtx.Class({
    title: 'TosView',
    Extends: KONtx.system.SidebarView,
    config: {
    tos_key: 'tos',
    },
    createView: function() {
    this.controls.buttonHeight = KONtx.utility.scale(35);
    this.controls.agree = new KONtx.control.TextButton({
    guid: 'agree-button',
    label: 'I agree',
    styles: {
    width:this.width/2,
    height: this.controls.buttonHeight,
    vOffset: this.height-this.controls.buttonHeight
    },
    events: {
    onSelect: function(event) {
    currentAppData.set(this.getView().config.tos_key, "you have seen the tos");
    KONtx.application.loadView('view-Main', {});
    }
    }
    }).appendTo(this);
    this.controls.disagree = new KONtx.control.TextButton({
    guid: 'agree-button',
    label: 'I do not agree',
    styles: {
    width:this.width/2,
    hOffset: this.width/2,
    height: this.controls.buttonHeight,
    vOffset: this.height-this.controls.buttonHeight
    },
    events: {
    onSelect: function(event) {
    KONtx.HostEventManager.send('exitToDock');
    }
    }
    }).appendTo(this);
    this.controls.pageIndicator = new KONtx.control.PageIndicator({
    guid: 'pager',
    styles: {
    width: this.width,
    height: this.controls.buttonHeight,
    vOffset: this.controls.agree.outerHeight-this.controls.agree.height -this.controls.buttonHeight,
    }
    }).appendTo(this);
    this.controls.content = new KONtx.element.TextGrid({
    guid: 'tos',
    styles: {
    fontFamily: '"Helvetica Neue Regular"',
    fontSize: 12,
    color: '#FFFFFF',
    padding: 5,
    wrap: true,
    width: this.width,
    height: this.height-this.controls.agree.height-this.controls.pageIndicator.height,
    }
    }).appendTo(this).attachAccessories(this.controls.pageIndicator);
    },


    updateView: function() {

    var xhr = new XMLHttpRequest();
    xhr.open("GET", "http://tracktag.info/TOS.xml", true);
    xhr.onreadystatechange = function () {

    if (xhr.status == 200)
    var tosfile = xhr.responseXML.toXML();
    };
    xhr.send();


    var tos = XMLDOM.parseFile(tosfile);
    this.controls.content.setText(tos.documentElement.firstChild.nodeValue);
    }
    });


    Thanks
    0

Recent Posts

in Getting Started / Beginners - Yahoo! TV Widgets