Skip to content

Instantly share code, notes, and snippets.

@mlcollard
Created April 30, 2018 14:00
Show Gist options
  • Save mlcollard/51ce0dc077684ffd1a29a5b401902886 to your computer and use it in GitHub Desktop.
Save mlcollard/51ce0dc077684ffd1a29a5b401902886 to your computer and use it in GitHub Desktop.
iOS: TVML: Loading page with loaded local document
var baseURL = "http://localhost:9001/"
function getDocument(url) {
var templateXHR = new XMLHttpRequest();
templateXHR.responseType = "document";
templateXHR.addEventListener("load", function() {pushDoc(templateXHR.responseXML);}, false);
templateXHR.open("GET", url, true);
templateXHR.send();
}
function pushDoc(document) {
navigationDocument.pushDocument(document);
}
function loadingDoc() {
var template = `
<document>
<loadingTemplate>
<activityIndicator><text>Loading</text></activityIndicator>
</loadingTemplate>
</document>
`;
var templateParser = new DOMParser();
var parsedTemplate = templateParser.parseFromString(template, "application/xml");
navigationDocument.pushDocument(parsedTemplate);
}
App.onLaunch = function(options) {
loadingDoc()
var templateURL = baseURL + "templates/HelloWorld.xml";
getDocument(templateURL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment