|
|
|
@ -26,45 +26,50 @@ define([
|
|
|
|
|
|
|
|
|
|
var initializing = true;
|
|
|
|
|
|
|
|
|
|
// TODO replace with `proxy.on('init'` ?
|
|
|
|
|
// or just remove?
|
|
|
|
|
var onInit = config.onInit = function (info) {
|
|
|
|
|
console.log("initializing!");
|
|
|
|
|
window.location.hash = info.channel + secret.key;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// TODO replace with `proxy.on('ready'` ?
|
|
|
|
|
var onReady = config.onReady = function (info) {
|
|
|
|
|
setEditable(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
setEditable(false);
|
|
|
|
|
|
|
|
|
|
// TODO replace with `proxy.on('disconnect'` ?
|
|
|
|
|
var onAbort = config.onAbort = function (info) {
|
|
|
|
|
setEditable(false);
|
|
|
|
|
window.alert("Network connection lost");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var rt = module.rt = RtListMap.create(config);
|
|
|
|
|
rt.proxy.on('create', function (info) {
|
|
|
|
|
console.log("initializing!");
|
|
|
|
|
window.location.hash = info.channel + secret.key;
|
|
|
|
|
console.log(info);
|
|
|
|
|
}).on('ready', function (info) {
|
|
|
|
|
console.log("ready");
|
|
|
|
|
|
|
|
|
|
console.log(info);
|
|
|
|
|
|
|
|
|
|
rt.proxy
|
|
|
|
|
// on(event, path, cb)
|
|
|
|
|
.on('change', [], function (o, n, p) {
|
|
|
|
|
console.log("root change event firing for path [%s]: %s => %s", p.join(','), o, n);
|
|
|
|
|
}).on('change', ['a', 'b', 'c'], function (o, n, p) {
|
|
|
|
|
console.log("Deeper change event at [%s]: %s => %s", p.join(','), o, n);
|
|
|
|
|
console.log("preventing propogation...");
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rt.proxy.on('disconnect', function (info) {
|
|
|
|
|
setEditable(false);
|
|
|
|
|
console.log(info);
|
|
|
|
|
window.alert("Network connection lost");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// set up user interface hooks
|
|
|
|
|
$repl.on('keyup', function (e) {
|
|
|
|
|
if (e.which === 13) {
|
|
|
|
|
var value = $repl.val();
|
|
|
|
|
// set up user interface hooks
|
|
|
|
|
$repl.on('keyup', function (e) {
|
|
|
|
|
if (e.which === 13) {
|
|
|
|
|
var value = $repl.val();
|
|
|
|
|
|
|
|
|
|
if (!value.trim()) { return; }
|
|
|
|
|
if (!value.trim()) { return; }
|
|
|
|
|
|
|
|
|
|
console.log("evaluating `%s`", value);
|
|
|
|
|
var x = rt.proxy;
|
|
|
|
|
console.log("evaluating `%s`", value);
|
|
|
|
|
var x = rt.proxy;
|
|
|
|
|
|
|
|
|
|
console.log('> ', eval(value)); // jshint ignore:line
|
|
|
|
|
console.log();
|
|
|
|
|
$repl.val('');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
console.log('> ', eval(value)); // jshint ignore:line
|
|
|
|
|
console.log();
|
|
|
|
|
$repl.val('');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// debugging TODO remove
|
|
|
|
|
//rt.proxy.on('change', 'u', (o, n) => console.log("'u' changed!", o,n));
|
|
|
|
|
//rt.proxy.on('change', ['u', 2], (o, n) => (console.log("'u[2]' changed!", o, n), true));
|
|
|
|
|
setEditable(true);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|