2016-04-06 16:22:30 +00:00
|
|
|
var G;
|
2016-05-12 01:03:50 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
2016-04-07 07:44:34 +00:00
|
|
|
var Dataspace = Syndicate.Dataspace;
|
2016-04-06 16:22:30 +00:00
|
|
|
var sub = Syndicate.sub;
|
|
|
|
var assert = Syndicate.assert;
|
|
|
|
var retract = Syndicate.retract;
|
|
|
|
var __ = Syndicate.__;
|
|
|
|
var _$ = Syndicate._$;
|
|
|
|
|
|
|
|
G = new Syndicate.Ground(function () {
|
|
|
|
console.log('starting ground boot');
|
|
|
|
|
2016-05-12 01:03:50 +00:00
|
|
|
Syndicate.UI.spawnUIDriver();
|
2016-04-06 16:22:30 +00:00
|
|
|
|
2016-04-07 07:44:34 +00:00
|
|
|
Dataspace.spawn({
|
2016-04-06 16:22:30 +00:00
|
|
|
boot: function () {
|
2016-05-12 01:03:50 +00:00
|
|
|
var ui = new Syndicate.UI.Anchor();
|
|
|
|
return assert(ui.html("#clicker-holder",
|
|
|
|
'<button><span style="font-style: italic">Click me!</span></button>'))
|
|
|
|
.andThen(sub(Syndicate.UI.globalEvent("button", "click", __)));
|
2016-04-06 16:22:30 +00:00
|
|
|
},
|
|
|
|
handleEvent: function (e) {
|
2016-05-12 01:03:50 +00:00
|
|
|
if (e.type === "message" && Syndicate.UI.globalEvent.isClassOf(e.message)) {
|
2016-04-07 07:44:34 +00:00
|
|
|
Dataspace.send("bump_count");
|
2016-04-06 16:22:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-04-07 07:44:34 +00:00
|
|
|
Dataspace.spawn({
|
2016-04-06 16:22:30 +00:00
|
|
|
counter: 0,
|
2016-05-12 01:03:50 +00:00
|
|
|
ui: new Syndicate.UI.Anchor(),
|
2016-04-06 16:22:30 +00:00
|
|
|
boot: function () {
|
|
|
|
this.updateState();
|
|
|
|
return sub("bump_count");
|
|
|
|
},
|
|
|
|
updateState: function () {
|
2016-05-12 01:03:50 +00:00
|
|
|
Dataspace.stateChange(retract(this.ui.htmlPattern)
|
|
|
|
.andThen(assert(this.ui.html(
|
|
|
|
"#counter-holder",
|
|
|
|
'<div><p>The current count is: '+this.counter+
|
|
|
|
'</p></div>'))));
|
2016-04-06 16:22:30 +00:00
|
|
|
},
|
|
|
|
handleEvent: function (e) {
|
|
|
|
if (e.type === "message" && e.message === "bump_count") {
|
|
|
|
this.counter++;
|
|
|
|
this.updateState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-05-10 04:44:02 +00:00
|
|
|
G.dataspace.setOnStateChange(function (mux, patch) {
|
2016-05-12 01:03:50 +00:00
|
|
|
document.getElementById('spy-holder').innerText = Syndicate.prettyTrie(mux.routingTable);
|
2016-05-10 04:44:02 +00:00
|
|
|
});
|
2016-04-06 16:22:30 +00:00
|
|
|
|
|
|
|
G.startStepping();
|
|
|
|
});
|