enable emulator support

This commit is contained in:
Keegan
2016-02-10 15:43:19 -08:00
parent 2142c68c01
commit 9412908636
4 changed files with 77 additions and 34 deletions
-14
View File
@@ -5,21 +5,7 @@ module.exports = function() {
/** @type {ClayConfig} */
var Clay = window.Clay = this;
Clay.on(Clay.EVENTS.BEFORE_BUILD, function() {
// register components here
this.registerComponent(require('pebble-clay-components').heading);
this.registerComponent(require('pebble-clay-components').text);
this.registerComponent(require('pebble-clay-components').footer);
this.registerComponent(require('pebble-clay-components').input);
this.registerComponent(require('pebble-clay-components').color);
this.registerComponent(require('pebble-clay-components').select);
this.registerComponent(require('pebble-clay-components').toggle);
this.registerComponent(require('pebble-clay-components').submit);
});
Clay.on(Clay.EVENTS.AFTER_BUILD, function() {
console.debug('KEEGAN: AFTER_BUILD', this);
Clay.getItemByAppKey('cool_stuff').on('change', function() {
if (this.get()) {
Clay.getItemByAppKey('background').enable();
+30
View File
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Config Page Emulator</title>
</head>
<script>
function getQueryParam(variable, defaultValue) {
var query = location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (pair[0] === variable) {
return decodeURIComponent(pair[1]);
}
}
return defaultValue || null;
}
var returnTo = getQueryParam('return_to');
var data = decodeURIComponent(location.hash.substring(1));
if (data) {
data = window.atob(data).replace('$$RETURN_TO$$', returnTo);
window.location.href = 'data:text/html;base64,' + encodeURIComponent(window.btoa(data));
}
</script>
<body>
</body>
</html>