working state

pull/1/head
ansuz 9 years ago
parent 69e8f54e8f
commit 1a9e7299fc

@ -3,23 +3,40 @@ define([
'/code/rt_codemirror.js', '/code/rt_codemirror.js',
'/common/messages.js', '/common/messages.js',
'/common/crypto.js', '/common/crypto.js',
'/common/realtime-input.js',
'/common/TextPatcher.js',
'/bower_components/jquery/dist/jquery.min.js' '/bower_components/jquery/dist/jquery.min.js'
], function (Config, RTCode, Messages, Crypto) { ], function (Config, RTCode, Messages, Crypto, Realtime, TextPatcher) {
var $ = window.jQuery; var $ = window.jQuery;
var ifrw = $('#pad-iframe')[0].contentWindow; var ifrw = $('#pad-iframe')[0].contentWindow;
var module = {};
$(function () { $(function () {
$(window).on('hashchange', function() { var userName = Crypto.rand64(8);
window.location.reload();
}); var key;
if (window.location.href.indexOf('#') === -1) { var channel = '';
window.location.href = window.location.href + '#' + Crypto.genKey(); if (!/#/.test(window.location.href)) {
return; key = Crypto.genKey();
} else {
var hash = window.location.hash.slice(1);
channel = hash.slice(0, 32);
key = hash.slice(32);
} }
var config = {
userName: userName,
websocketURL: Config.websocketURL,
channel: channel,
cryptKey: key,
crypto: Crypto,
};
var andThen = function (CMeditor) { var andThen = function (CMeditor) {
var key = Crypto.parseKey(window.location.hash.substring(1)); var $pad = $('#pad-iframe');
var editor = CMeditor.fromTextArea($('#pad-iframe').contents().find('#editor1')[0], { var $textarea = $pad.contents().find('#editor1');
var editor = CMeditor.fromTextArea($textarea[0], {
lineNumbers: true, lineNumbers: true,
lineWrapping: true, lineWrapping: true,
autoCloseBrackets: true, autoCloseBrackets: true,
@ -35,18 +52,52 @@ define([
}); });
editor.setValue(Messages.codeInitialState); editor.setValue(Messages.codeInitialState);
var rtw = // TODO lock editor until chain is synced
RTCode.start(ifrw, // then unlock
Config.websocketURL, var setEditable = function () { };
Crypto.rand64(8),
key.channel, var initializing = true;
key.cryptKey);
editor.on('change', function() { var onInit = config.onInit = function (info) {
editor.save(); window.location.hash = info.channel + key;
rtw.onEvent(); var realtime = info.realtime;
module.patchText = TextPatcher.create({
realtime: realtime,
logging: true,
});
$(window).on('hashchange', function() {
window.location.reload();
}); });
}; };
var onReady = config.onReady = function (info) {
console.log("READY!");
initializing = false;
};
var onRemote = config.onRemote = function (info) {
if (initializing) { return; }
// check cursor
// apply changes to textarea
// replace cursor
};
var onLocal = config.onLocal = function () {
editor.save();
//rtw.onEvent();
};
var onAbort = config.onAbort = function (info) {
// TODO alert the user
// inform of network disconnect
};
var realtime = module.realtime = Realtime.start(config);
editor.on('change', onLocal);
};
var interval = 100; var interval = 100;
var first = function () { var first = function () {

@ -0,0 +1,50 @@
* hack
- good
* code
- this is actually a fair bit of work (maybe)
* canvas
- seems to work
- should have json-ot
* form
- doesn't work yet
- don't bother developing for websocket, move to netflux asap
* p
- using sockets, pad is the fixed version
- move things over and deprecate
* pad
- using netflux already, but might require some updates from /p/
* padrtc
- using netflux, but it's not really useful
* render
- idek man
* style
- works, using netflux
* text
- works
## Remaining
* code
- use netflux
* form
- use netflux
- get it working
- audit json-ot
* pad
- update /pad/ from /p/
- then delete p
* p
- see above
* padrtc
- idk
* render
- get it working
- use diffdom
- continue to use rainbow?
* style
- push initial styles into new documents
* text
- support tabs?

@ -8,7 +8,7 @@ define([
'/common/rainbow.js', '/common/rainbow.js',
'/bower_components/jquery/dist/jquery.min.js', '/bower_components/jquery/dist/jquery.min.js',
'/customize/pad.js' '/customize/pad.js'
], function (Config, Realtime, Messages, Crypto, Marked, Convert, Rainbow) { ], function (Config, Realtime, Crypto, Marked, Convert, Rainbow) {
var $ = window.jQuery; var $ = window.jQuery;
var Vdom = Convert.core.vdom, var Vdom = Convert.core.vdom,

Loading…
Cancel
Save