+
The field below behaves like a REPL, with the realtime object created by this page exposed as the value x
+
Open your browser's console to see the output.
+
+
+
+
+
diff --git a/www/json/main.js b/www/json/main.js
new file mode 100644
index 000000000..2e51631fc
--- /dev/null
+++ b/www/json/main.js
@@ -0,0 +1,79 @@
+define([
+ '/api/config?cb=' + Math.random().toString(16).substring(2),
+ '/bower_components/chainpad-listmap/chainpad-listmap.js',
+ '/bower_components/chainpad-crypto/crypto.js',
+ '/common/cryptpad-common.js',
+ '/bower_components/jquery/dist/jquery.min.js',
+ //'/customize/pad.js'
+], function (Config, RtListMap, Crypto, Common) {
+ var $ = window.jQuery;
+
+ var secret = Common.getSecrets();
+
+ var config = {
+ websocketURL: Config.websocketURL,
+ channel: secret.channel,
+ cryptKey: secret.key,
+ data: {},
+ crypto: Crypto
+ };
+
+ var module = window.APP = {};
+
+ var $repl = $('[name="repl"]');
+
+ var setEditable = module.setEditable = function (bool) {
+ [$repl].forEach(function ($el) {
+ $el.attr('disabled', !bool);
+ });
+ };
+
+ var initializing = true;
+
+ setEditable(false);
+
+ var rt = module.rt = RtListMap.create(config);
+ rt.proxy.on('create', function (info) {
+ console.log("initializing...");
+ window.location.hash = info.channel + secret.key;
+ }).on('ready', function (info) {
+ console.log("...your realtime object is ready");
+
+ 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('remove', [], function (o, p, root) {
+ console.log("Removal of value [%s] at path [%s]", o, p.join(','));
+ })
+ .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;
+ })
+ // on(event, cb)
+ .on('disconnect', function (info) {
+ setEditable(false);
+ window.alert("Network connection lost");
+ });
+
+ // set up user interface hooks
+ $repl.on('keyup', function (e) {
+ if (e.which === 13 /* enter keycode */) {
+ var value = $repl.val();
+
+ if (!value.trim()) { return; }
+
+ console.log("evaluating `%s`", value);
+ var x = rt.proxy;
+
+ console.log('> ', eval(value)); // jshint ignore:line
+ console.log();
+ $repl.val('');
+ }
+ });
+
+ setEditable(true);
+ });
+});
diff --git a/www/pad/main.js b/www/pad/main.js
index b257fc82f..a66053386 100644
--- a/www/pad/main.js
+++ b/www/pad/main.js
@@ -2,13 +2,13 @@ require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/J
define([
'/api/config?cb=' + Math.random().toString(16).substring(2),
'/common/messages.js',
- '/common/crypto.js',
- '/common/realtime-input.js',
+ '/bower_components/chainpad-crypto/crypto.js',
+ '/bower_components/chainpad-netflux/chainpad-netflux.js',
'/bower_components/hyperjson/hyperjson.amd.js',
'/common/hyperscript.js',
'/common/toolbar.js',
'/common/cursor.js',
- '/common/json-ot.js',
+ '/bower_components/chainpad-json-validator/json-ot.js',
'/common/TypingTests.js',
'json.sortify',
'/bower_components/textpatcher/TextPatcher.amd.js',
@@ -50,7 +50,9 @@ define([
// return !(el.tagName === 'SPAN' && el.contentEditable === 'false');
var filter = (el.tagName === 'SPAN' &&
el.getAttribute('contentEditable') === 'false' &&
- /position:absolute;border-top:1px dashed/.test(el.getAttribute('style')));
+ /dashed/.test(el.getAttribute('style')) &&
+ /(rgb\(255|red)/.test(el.getAttribute('style')));
+ ///magicline/.test(el.getAttribute('style')));
if (filter) {
console.log("[hyperjson.serializer] prevented an element" +
"from being serialized:", el);
@@ -214,8 +216,7 @@ define([
var myID; // My server ID
var setMyID = function(info) {
- myID = info.myID || null;
- myUserName = myID;
+ myID = info.myID || null;
};
var createChangeName = function(id, $container) {
@@ -295,7 +296,7 @@ define([
addToUserList(userData);
hjson.pop();
}
- }
+ };
var onRemote = realtimeOptions.onRemote = function (info) {
if (initializing) { return; }
diff --git a/www/render/main.js b/www/render/main.js
index 451728ad0..d6b03eea8 100644
--- a/www/render/main.js
+++ b/www/render/main.js
@@ -1,7 +1,7 @@
define([
'/api/config?cb=' + Math.random().toString(16).substring(2),
- '/common/realtime-input.js',
- '/common/crypto.js',
+ '/bower_components/chainpad-netflux/chainpad-netflux.js',
+ '/bower_components/chainpad-crypto/crypto.js',
'/bower_components/marked/marked.min.js',
'/common/convert.js',
'/common/rainbow.js',
diff --git a/www/style/main.js b/www/style/main.js
index 218cc1cd8..d68a6c8c6 100644
--- a/www/style/main.js
+++ b/www/style/main.js
@@ -1,7 +1,7 @@
define([
'/api/config?cb=' + Math.random().toString(16).substring(2),
- '/common/realtime-input.js',
- '/common/crypto.js',
+ '/bower_components/chainpad-netflux/chainpad-netflux.js',
+ '/bower_components/chainpad-crypto/crypto.js',
'/bower_components/textpatcher/TextPatcher.amd.js',
'/bower_components/jquery/dist/jquery.min.js',
'/customize/pad.js'
diff --git a/www/text/main.js b/www/text/main.js
index e3c23af9e..077e997b4 100644
--- a/www/text/main.js
+++ b/www/text/main.js
@@ -1,7 +1,7 @@
define([
'/api/config?cb=' + Math.random().toString(16).substring(2),
- '/common/realtime-input.js',
- '/common/crypto.js',
+ '/bower_components/chainpad-netflux/chainpad-netflux.js',
+ '/bower_components/chainpad-crypto/crypto.js',
'/bower_components/textpatcher/TextPatcher.amd.js',
'/bower_components/jquery/dist/jquery.min.js',
'/customize/pad.js'