Skip to content

Instantly share code, notes, and snippets.

@geetfun
Created September 13, 2015 02:25
Show Gist options
  • Save geetfun/a407a59c28643dcd6938 to your computer and use it in GitHub Desktop.
Save geetfun/a407a59c28643dcd6938 to your computer and use it in GitHub Desktop.
var count = 1;
var showHelloWorld = function(count) {
var resource = Template.call(this, count);
var parser = new DOMParser();
var doc = parser.parseFromString(resource, "application/xml");
doc.addEventListener("select", function() {
count += 1;
var oldDoc = doc;
var newDoc = showHelloWorld(count)
navigationDocument.replaceDocument(newDoc, oldDoc);
});
return doc;
};
App.onLaunch = function(options) {
evaluateScripts([`http://localhost:9001/templates/hello_world.xml.js`],
function(success) {
var doc = showHelloWorld(count)
navigationDocument.pushDocument(doc);
}
);
};
var Template = function(count) { return `<?xml version="1.0" encoding="UTF-8" ?>
<document>
<alertTemplate>
<title>Hello World Example</title>
<description>This is the Hello World ${count} description</description>
<button>
<text>Hit Me!</text>
</button>
<text>Hint: Try pressing the button</text>
</alertTemplate>
</document>`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment