Created
April 30, 2018 14:00
-
-
Save mlcollard/51ce0dc077684ffd1a29a5b401902886 to your computer and use it in GitHub Desktop.
iOS: TVML: Loading page with loaded local document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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