Completed JsonYatta. Added IwcConnector

This commit is contained in:
Kevin Jahns 2014-08-02 01:39:30 +02:00
parent b91135157e
commit 8169b17eb4
82 changed files with 5547 additions and 591 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
/node_modules/
.kateproject.d
.kateproject
.directory

View File

@ -72,16 +72,36 @@ module.exports = (grunt) ->
browserify:
dist:
files:
'dest/browser/Yatta.js': ['lib/index.coffee']
'dest/browser/Yatta_test.js': ['test/**/*.coffee']
'dest/browser/Connectors/IwcConnector.js': ['lib/Connectors/IwcConnector.coffee']
'dest/browser/Frameworks/JsonIwcYatta.js': ['./lib/Frameworks/JsonYatta.coffee', './lib/Connectors/IwcConnector.coffee']
options:
transform: ['coffeeify']
debug: true
bundleOptions: {debug: true}
debug: false
bundleOptions: {debug: false}
# Serve files via http-server
connect:
server:
options:
hostname: '*'
port: 1337
base: './dest/browser/'
keepalive: true
middleware: (connect, options, middlewares)->
middlewares.push (req, res, next)->
if res.header?
res.header('Access-Control-Allow-Origin', "*")
res.header('Access-Control-Allow-Credentials', true)
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')
res.header('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0')
return next()
return middlewares
# These plugins provide necessary tasks.
grunt.loadNpmTasks "grunt-browserify"
grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks 'grunt-contrib-connect'
grunt.loadNpmTasks "grunt-contrib-watch"
grunt.loadNpmTasks "grunt-simple-mocha"
grunt.loadNpmTasks "grunt-coffeelint"

View File

@ -0,0 +1,130 @@
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var createIwcConnector;
createIwcConnector = function(callback) {
var IwcConnector, duiClient, get_root_intent, init, iwcHandler, received_HB, root_element;
iwcHandler = {};
duiClient = new DUIClient();
duiClient.connect((function(_this) {
return function(intent) {
var _ref;
console.log("intent received iwc: " + (JSON.stringify(intent)));
console.log("" + (JSON.stringify(_this.iwcHandler)));
return (_ref = iwcHandler[intent.action]) != null ? _ref.map(function(f) {
return setTimeout(function() {
return f(intent);
}, 0);
}) : void 0;
};
})(this));
duiClient.initOK();
root_element = null;
received_HB = null;
IwcConnector = (function() {
function IwcConnector(engine, HB, execution_listener, yatta) {
var receive_, sendRootElement, send_;
this.engine = engine;
this.HB = HB;
this.execution_listener = execution_listener;
this.yatta = yatta;
this.duiClient = duiClient;
this.iwcHandler = iwcHandler;
send_ = (function(_this) {
return function(o) {
return _this.send(o);
};
})(this);
this.execution_listener.push(send_);
receive_ = (function(_this) {
return function(intent) {
var o;
o = intent.extras;
return _this.receive(o);
};
})(this);
this.iwcHandler["Yatta_new_operation"] = [receive_];
if (root_element != null) {
this.engine.applyOps(received_HB);
}
sendRootElement = (function(_this) {
return function() {
var json;
json = {
root_element: _this.yatta.getRootElement(),
HB: _this.yatta.getHistoryBuffer().toJson()
};
return _this.sendIwcIntent("Yatta_push_root_element", json);
};
})(this);
this.iwcHandler["Yatta_get_root_element"] = [sendRootElement];
}
IwcConnector.prototype.getRootElement = function() {
return root_element;
};
IwcConnector.prototype.send = function(o) {
if (o.uid.creator === this.HB.getUserId() && (typeof o.uid.op_number !== "string")) {
return this.sendIwcIntent("Yatta_new_operation", o);
}
};
IwcConnector.prototype.receive = function(o) {
if (o.uid.creator !== this.HB.getUserId()) {
return this.engine.applyOp(o);
}
};
IwcConnector.prototype.sendIwcIntent = function(action_name, content) {
var intent;
intent = {
action: action_name,
component: "",
data: "",
dataType: "",
extras: content
};
return this.duiClient.publishToUser(intent);
};
IwcConnector.prototype.sync = function() {
throw new Error("Can't use this a.t.m.");
};
return IwcConnector;
})();
get_root_intent = {
action: "Yatta_get_root_element",
component: "",
data: "",
dataType: "",
extras: {}
};
init = function() {
var is_initialized, receiveRootElement;
duiClient.publishToUser(get_root_intent);
is_initialized = false;
receiveRootElement = function(json) {
root_element = json != null ? json.extras.root_element : void 0;
received_HB = json != null ? json.extras.HB : void 0;
if (!is_initialized) {
is_initialized = true;
return callback(IwcConnector);
}
};
iwcHandler["Yatta_push_root_element"] = [receiveRootElement];
return setTimeout(receiveRootElement, 3000);
};
setTimeout(init, 10);
return void 0;
};
module.exports = createIwcConnector;
if (typeof window !== "undefined" && window !== null) {
window.createIwcConnector = createIwcConnector;
}
},{}]},{},[1]);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Video upload" description="Upload videos in Sevianno" author="Kevin Jahns, Chair of Computer Science 5, RWTH Aachen University, Germany" author_email="jahns@dbis.rwth-aachen.de" scrolling="true">
<Require feature="dynamic-height"/>
</ModulePrefs>
<Content type="html"><![CDATA[
<script type="application/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/lib/las/storage.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/lib/las/lasAjaxClient.js"></script>
<script src="../Widgets/libs/DUIClient.js"></script>
<script src="../Frameworks/JsonIwcYatta.js"></script>
<script>
function init(){
window.createIwcConnector(function(Connector){
console.log("initializing..");
yatta = new window.JsonYatta(1, Connector);
var dui = yatta.getConnector().duiClient
dui.getAppState()
console.log("initialized!");
})
}
$(document).ready(init)
</script>
<h1> awesomewidget </h1>
]]></Content>
</Module>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Video upload" description="Upload videos in Sevianno" author="Kevin Jahns, Chair of Computer Science 5, RWTH Aachen University, Germany" author_email="jahns@dbis.rwth-aachen.de" scrolling="true">
<Require feature="dynamic-height"/>
</ModulePrefs>
<Content type="html"><![CDATA[
<script type="application/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/lib/las/storage.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/lib/las/lasAjaxClient.js"></script>
<script src="../Widgets/libs/DUIClient.js"></script>
<script src="../Frameworks/JsonIwcYatta.js"></script>
<script>
function init(){
function f(){
console.log("beginning");
window.createIwcConnector(function(Connector){
console.log("initializing..");
yatta = new window.JsonYatta(2, Connector);
console.log("initialized!");
});
}
setTimeout(f, 1000)
}
$(document).ready(init)
</script>
<h1> awesomewidget </h1>
]]></Content>
</Module>

View File

@ -0,0 +1,241 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs
title="IWC Test Stub"
description="A widget for tracing and sending ROLE IWC intents. Recommended for developers of IWC-enabled widgets."
author="Dominik Renzel, Chair of Computer Science 5, RWTH Aachen University, Germany"
author_email="renzel@dbis.rwth-aachen.de"
height="500">
<Require feature="dynamic-height"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<style type="text/css">
* {
font-family: Verdana;
font-size: 8pt;
}
#accordion {
overflow: auto;
height: 310px;
}
#pubform, .entry {
border: 1pt solid black
width: 100%;
}
tr td.ui-state-default{
width: 20%;
}
tr td.input, tr td.ui-widget-content {
width: 80%;
}
#pub_form tr td input {
width: 100%;
}
#pub_form tr td textarea {
width: 100%;
}
</style>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"/>
<script type="application/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="application/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"</script>
<script src="http://open-app.googlecode.com/files/openapp.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/iwc.js"></script>
<script src="http://dbis.rwth-aachen.de/gadgets/iwc/lib/date.js"></script>
<script type="text/javascript">
var counter = 0;
var iwcClient = null;
function renderIntent(intent){
var result = "<table class='entry'>";
var sender = intent.sender;
var publisher = "me";
var source = sender;
if (sender.indexOf("?sender=") > -1){
var ts = sender.split("?sender=");
publisher = ts[0].split("/")[0];
source = ts[1];
} else {
publisher = "<b><i>me</i></b>";
source = sender;
}
result += "<tr><td class='ui-state-default'>Publisher</td><td class='ui-widget-content'>" + publisher + "</td></tr>";
result += "<tr><td class='ui-state-default'>Source</td><td class='ui-widget-content'>" + source + "</td></tr>";
var comp = intent.component;
if(comp === ""){
comp = "*";
}
result += "<tr><td class='ui-state-default'>Component</td><td class='ui-widget-content,value'>" + comp + "</td></tr>";
result += "<tr><td class='ui-state-default'>Action</td><td class='ui-widget-content'>" + intent.action + "</td></tr>";
result += "<tr><td class='ui-state-default'>Data</td><td class='ui-widget-content'>" + intent.data + "</td></tr>";
result += "<tr><td class='ui-state-default'>Datatype</td><td class='ui-widget-content'>" + intent.dataType + "</td></tr>";
result += "<tr><td class='ui-state-default'>Categories</td><td class='ui-widget-content'>" + intent.categories + "</td></tr>";
result += "<tr><td class='ui-state-default'>Flags</td><td class='ui-widget-content'>" + intent.flags + "</td></tr>";
result += "<tr><td class='ui-state-default'>Extras</td><td class='ui-widget-content'> " + JSON.stringify(intent.extras) + "</td></tr>";
result += "</table>";
return result;
}
function collectIntent(){
var action = $("#pub_action").val();
console.log("Action: " + action);
var sender = $("#pub_source").val();
if(!($("#pub_publisher").val() == 'me')){
sender = $("#pub_publisher").val() + "?sender=" + sender;
}
var categories = $("#pub_categories").val().split(",");
var flags = $("#pub_flags").val().split(",");
try{
var extras = $.parseJSON($("#pub_extras").val());
} catch(error) {
alert("Corrupt JSON specified for extras");
return;
}
var intent = {
"component": $("#pub_component").val(),
"sender": sender,
"data": $("#pub_data").val(),
"dataType":$("#pub_datatype").val(),
"action":$("#pub_action").val(),
"categories":categories,
"flags": flags,
"extras": extras
};
return intent;
}
function init(){
iwcClient = new iwc.Client();
var iwcCallback = function(intent) {
var date = new Date();
var format = "yyyy-MM-dd kk:mm:ss";
var dates = formatDate(date,format)+"."+date.getMilliseconds();
$('#accordion').prepend("<h3><a href='#'>#" + counter + " - " + intent.action + " (" + dates + ")</a></h3><div>" + renderIntent(intent) + "</div>").accordion('destroy').accordion();
counter += 1;
}
iwcClient.connect(iwcCallback);
}
$(function() {
$( "#accordion" ).accordion({
collapsible: true
});
$( "#clearb" ).button().click(function() {
counter = 0;
$( "#accordion" ).accordion('destroy').empty().accordion();
});
$( "#sendb" ).button().click(function() {
$("#sendintent").dialog('open');
});
$("#exint").dialog({
autoOpen: false,
heigth: 340,
width: 350,
modal: true
});
$("#sendintent").dialog({
autoOpen: false,
height: 340,
width: 350,
modal: true,
buttons: {
"Send": function() {
var intent = collectIntent();
console.log(intent);
if(iwc.util.validateIntent(intent)) {
iwcClient.publish(intent);
}
else {
alert("Intent not valid! ");
}
},
Export: function() {
var intent = collectIntent();
var istr = JSON.stringify(intent);
console.log(istr);
$("#intsnip").html(istr);
$("#exint").dialog("open");
},
Cancel: function() {
$(this).dialog('close');
}
},
close: function(){
//$(this).dialog('close');
}
});
gadgets.window.adjustHeight();
});
$(document).ready(init());
</script>
<button id="sendb">Send Intent</button> <button id="clearb">Clear List</button>
<h1>Received Intents</h1>
<div id="accordion">
</div>
<div id='sendintent' title='Send Intent'>
<table id='pub_form'>
<tr><td class='ui-state-default'>Publisher</td><td class='input'><input id='pub_publisher' type='text' value='me'/></td></tr>
<tr><td class='ui-state-default'>Source</td><td class='input'><input id='pub_source' type='text' value='http://widget.org/sender.xml'/></td></tr>
<tr><td class='ui-state-default'>Component</td><td class='input'><input id='pub_component' type='text'/></td></tr>
<tr><td class='ui-state-default'>Action</td><td class='input'><input id='pub_action' type='text' value='ACTION_UPDATE'/></td></tr>
<tr><td class='ui-state-default'>Data</td><td class='input'><input id='pub_data' type='text' value='http://example.org/some/data'/></td></tr>
<tr><td class='ui-state-default'>Data Type</td><td class='input'><input id='pub_datatype' type='text' value='text/plain'/></td></tr>
<tr><td class='ui-state-default'>Flags</td><td class='input'><input id='pub_flags' type='text' value='PUBLISH_GLOBAL'/></td></tr>
<tr><td class='ui-state-default'>Categories</td><td class='input'><input id='pub_categories' type='text' value='cat1,cat2'/></td></tr>
<!-- <tr><td class='ui-state-default'>Extras</td><td class='input'><input id='pub_extras' type='text' value='{"key":"value"}'/></td></tr> -->
<tr><td class='ui-state-default'>Extras</td><td class='input'><textarea id='pub_extras' value='{"key":"value"}'/></td></tr>
</table>
</div>
<div id="exint" title="Exported Intent JSON">
Copy the snippet below to your code to specify a respective intent message.
<p id="intsnip"></p>
</div>
</div>
]]>
</Content>
</Module>

View File

@ -0,0 +1,368 @@
//get the iwc.Client class def.
/*
iwc = iwc || {};
iwc.Client = iwc.Client || {};
/**
* Add a function to set the compnent name of the iwc.Client class.<br/>
* This component name is for filtering incoming intent at the iwc.Client. The intent can be further processed
* only when the intent.component attribute matches the component name of the iwc.Client or the intent.component is an empty string(pseudo broadcast).
* @param componentName The component name
*/
/*
iwc.Client.prototype.setComponentName = function(componentName){
this._componentName = componentName;
};
*/
DUIClient = function(){
//in role framework the parent div of the widget ifr is IDed as "widget-{widgetId}-body" sth. like this
var _widgetId = parent.document.getElementById(self.frameElement.id).parentNode.id.split("-")[1];
var that = this;
var _iwcClient = new iwc.Client(["*"]);
_iwcClient._componentName = "duiclient-"+_widgetId;
this.externalCallback = function(intent){};
/**
* The target function when the intent is for updating widget state request
*/
this._onUpdateState = function(intent){
var isForMigration = intent.extras.isForMigration;
if (isForMigration)
this.finishMigration(intent);
else
this.updateState(intent);
};
/**
* The target function when the intent is for getting the current widget state.<br/>
* The intent.extras object here is always a Json object.
*/
this._onGetWidgetState = function(intent){
var target = null;
var forMigration = false;
if (intent.extras.target != null){
target = intent.extras.target;
forMigration = true;
}
var states = this.getWidgetState(forMigration);
var resIntent = {};
if (forMigration)
resIntent = {
"action": "DUI_WS_MIG",
"categories": ["DUI"],
"component": "duimanager",
"data":"",
"dataType":"",
"extras":{"target": target, "widgetId": _widgetId, "widgetStates": states}
};
else
resIntent = {
"action": "DUI_WS",
"categories": ["DUI"],
"component": intent.sender,
"data":"",
"dataType":"",
"extras":{"widgetId": _widgetId, "widgetStates": states}
};
_iwcClient.publish(resIntent);
};
/**
* The target function when the intent is to inform a change in the scope of the application
*/
this._onAppStateChange = function(intent){
this.changeWithApp(intent);
};
/**
* The target function when the intent is to inform a migration of this widget is waiting to be taken place
*/
this._prepareMigration = function(intent){
console.log("do sth before the widget is removed");
this.prepareMigration();
};
this._logOff = function(intent){
var states = this.getWidgetState(false);
resIntent = {
"action": "DUI_WS_LOGOFF",
"categories": ["DUI"],
"component": "duimanager",
"data":"",
"dataType":"",
"extras":{"widgetId": _widgetId, "widgetStates": states}
};
_iwcClient.publish(resIntent);
};
/**
* The intent dispatcher and the callback function connected to the private field of iwc.Client.onIntent.<br/>
* This function is called once an intent is received by the iwc.Client and passed the first level filter of the iwc.Client.<br/>
* @param intent The incoming intent. Technically all intents will come, the filter of the iwc.Client class is weak...
*/
var _iwcCallback = function(intent){
that.externalCallback(intent);
//does not accept global intents(global intents are processed by normal iwc.Client, normal iwc.Proxy and DUI manager)
//does not accept intents that are not categorized as "DUI"
if ((typeof intent.flags != "undefined" && intent.flags.indexOf("PUBLISH_GLOBAL")!=-1)
|| typeof intent.categories == "undefined" || intent.categories.indexOf("DUI") == -1)
return;
//then does not accept intents for other widgets
//if the widget id is undefined here, this is an DUI intent from the DUI manager for all involved widget, e.g. application state changed
var action = intent.action;
if (typeof intent.extras.widgetId != "undefined" && intent.extras.widgetId == _widgetId){
if (action == "DUI_UPDATE_STATE"){
that._onUpdateState(intent);
return;
}
if (action == "DUI_GET_WS"){
that._onGetWidgetState(intent);
return;
}
if (action == "DUI_PRE_MIG"){
that._prepareMigration(intent);
return;
}
}else if (typeof intent.extras.widgetId == "undefined"){
if (action == "DUI_LOG_OFF"){
that._logOff(intent);
return;
}
if (action == "DUI_APP_CHANGE"){
that._onAppStateChange(intent);
return;
}
if (action == "DUI_REG_CLIENT"){
that.initOK();
return;
}
if (action == "DUI_AS"){
that.onAppState(intent.extras.appStates);
}
}
};
_iwcClient.connect(_iwcCallback);
//remember to bind(this) the function when override
/**
* The function is called when the dui manager wants the widget states.<br/>
* <strong>Notice</strong>: avoid putting complex data and data structure to the state value, the browser and Java JSON encoder and parser might cause inconsistent input and output.
* @param isForMigration A boolean. True if special state for migration is needed otherwise not.
* @returns an object containing the widget states, e.g. {"selectIndex":1, "phaseNum":2, "textinput":"iamatextvalueinatextinput"}
*/
this.getWidgetState = function(isForMigration){
console.log("the widget collects it is state and return, overwrite it");
var states = {};
return states;
};
/**
* The function is called when there detected a application state change at the dui manager and the manager informs the widget about the change.<br/>
* Override this function to apply changes to the widget according to the valuable application state changes.<br/>
* @param intent intent The infos are in intent.extras object e.g. intent.extras = {"oldStates":{}, "newStates":{"statename":value, "state2":value2}}. the property 'oldStates' can be null if the space has not set app state ever before.
*/
this.changeWithApp = function(intent){
//sample
var oldStates = intent.extras.oldStates;
var newStates = intent.extras.newStates;
console.log(oldStates);
console.log(newStates);
console.log("the widget may need to change something following the whole app");
};
/**
* The function is called right before a migration for this widget and the widget state is already saved to the server in previous migration phases.<br/>
* And it is the last chance to perform any moves before the widget is removed from current web page.<br/>
* Override this method to perform state update for each different widget.<br/>
* <strong>AND DO REMEMBER TO CALL {@link DUIClient#prepareMigDone} AT THE END OF THIS FUNCTION!</strong>
*/
this.prepareMigration = function(){
//e.g. ..... just a joke....
/*
if (confirm("you sure to sign out?..."))
parent.location = parent.location.protocol + "//" + parent.location.host + "/:authentication?return=&action=signout";
console.log("the migration is at hand, the widget may need to do sth special before it is removed from the role widget container e.g. disconnect from the lasServer etc.");
*/
this.prepareMigDone();
};
/**
* The function is called when the dui manager asks the widget to update its states.<br/>
* Compared to the function DUIClient.finishMigration(), this is a typical normal state update for active widget on presence.<br/>
* This method will be called as a callback for DUIClient#requireWidgetState(); or DUIClient#initOK() when it is not a migration.
* Override this method to perform state update for each different widget.
* @param intent The Intent object that contains infos of required widget states, the infos are in intent.extras.widgetStates e.g. {"state1":value1,"state2":value2}.
* The object might contain appStates as well if there is any application state, get it in intent.extras.appStates e.g. {"appstate1":value1,"appstate2":value2}.
*/
this.updateState = function(intent){
var states = {};
states = intent.extras.widgetStates;
var appStates = intent.extras.appStates;
console.log(states);
if (typeof appStates != "undefined")
console.log(appStates);
console.log("update the widget state, widget need to overwrite it");
};
/**
* The function is called to finish the Migration and update the widget state.<br/>
* Compared to the method DUIClient.updateState(), this method is a special widget state update for the widget that has just migrated.<br/>
* Override this method to perform finishing moves for each different widget.
* @param intent The Intent object that contains infos to complete the migration, the infos are in intent.extras.states e.g. {"state1":value1, "state2":value2}.
* The object might contain appStates as well if there is any application state, get it in intent.extras.appStates e.g. {"appstate1":value1,"appstate2":value2}.
*/
this.finishMigration = function(intent){
var states = {};
states = intent.extras.widgetStates;
var appStates = intent.extras.appStates;
console.log(states);
if (typeof appStates != "undefined")
console.log(appStates);
console.log("the migration is done, the widget may need to perform special inits before update the widget state e.g. login to the lasServer again.");
};
/**
* The function to signal the dui manager that the preparation for the migration is ready on this widget.<br/>
* This function should be called at the end of the overwritten function {@link DUIClient#prepareMigration}<br/>
* Do not override this method unless there is really an unstoppable reason.
*/
this.prepareMigDone = function(){
//prepared and send OK response to DUIMgr
var intent = {
"component": "duimanager",
"categories": ["DUI"],
"action": "DUI_PRE_MIG_OK",
"data": "",
"dataType": "",
"extras": {"widgetId": _widgetId}
};
_iwcClient.publish(intent);
};
/**
* The function to call the DUI manager to save the widget state on the server.<br/>
* Do not override this method unless there is really an unstoppable reason.
* @param states An array of widget state object {"stateName": stateValue}
*/
this.saveWidgetState = function(){
var states = this.getWidgetState(false);
var intent = {
"action": "DUI_SAVE_WS",
"categories": ["DUI"],
"component": "duimanager",// the overwritten dui manager from the iwc.Proxy should have the _componentName set to "duimanager"
"data":"",
"dataType":"",
"extras":{"widgetStates":states, "widgetId": _widgetId}
};
_iwcClient.publish(intent);
};
/**
* An open interface to send any intent
*/
this.sendIntent = function(intent){
//or to send the intent to "duimanager"
_iwcClient.publish(intent);
};
/**
* This function asks the framework for the states stored on the server.
* Do not override it.
*/
this.requireWidgetState = function(){
var intent = {
"action": "DUI_REQ_WS",
"categories": ["DUI"],
"component": "duimanager",// the overwritten dui manager from the iwc.Proxy should have the _componentName set to "duimanager"
"data":"",
"dataType":"",
"extras":{"widgetId": _widgetId}
};
_iwcClient.publish(intent);
};
/**
* Store the global app state
* @param states the app state to be stored e.g. {"state1":value1, "state2":value2}
*/
this.setAppState = function(states){
var intent = {
"action": "DUI_SET_AS",
"categories": ["DUI"],
"component": "duimanager",// the overwritten dui manager from the iwc.Proxy should have the _componentName set to "duimanager"
"data":"",
"dataType":"",
"extras":{"states": states}
};
_iwcClient.publish(intent);
};
/**
* Ask the dui manager for the app state.
*/
this.getAppState = function(){
var intent = {
"action": "DUI_GET_AS",
"categories": ["DUI"],
"component": "duimanager",// the overwritten dui manager from the iwc.Proxy should have the _componentName set to "duimanager"
"data":"",
"dataType":"",
};
_iwcClient.publish(intent);
};
/**
* Override this function to do something when the requested app state comes.
* @param appStates the json format of the app state:{"name1": value1, "name2": value2};
*/
this.onAppState = function(appStates){};
/**
* call this function to register the duiclient to duimanager after all things are OK
*/
this.initOK = function(){
var okIntent = {
"action": "DUI_CLIENT_OK",
"categories": ["DUI"],
"component": "duimanager",// the overwritten dui manager from the iwc.Proxy should have the _componentName set to "duimanager"
"data":"",
"dataType":"",
"extras":{"widgetId": _widgetId}
};
_iwcClient.publish(okIntent);
};
/**
* publish the intent in the domain of the user only
*/
this.publishToUser = function(intent){
var wrap = {
"action": "DUI_PUB_USER",
"categories": ["DUI"],
"component": "duimanager",
"data": JSON.stringify(intent),
"dataType": "application/json",
"extras": {}
};
_iwcClient.publish(intent);
_iwcClient.publish(wrap);
};
/**
* register the call back function of the widget to the DUI client.
*/
this.connect = function(callback){
this.externalCallback = callback;
};
};
// reminder to myself:.... the callback funcs injected into this DUIClient need to bind()

View File

@ -1 +0,0 @@
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({},{},[])

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,128 @@
var createIwcConnector;
createIwcConnector = function(callback) {
var IwcConnector, duiClient, get_root_intent, init, iwcHandler, received_HB, root_element;
iwcHandler = {};
duiClient = new DUIClient();
duiClient.connect((function(_this) {
return function(intent) {
var _ref;
console.log("intent received iwc: " + (JSON.stringify(intent)));
console.log("" + (JSON.stringify(_this.iwcHandler)));
return (_ref = iwcHandler[intent.action]) != null ? _ref.map(function(f) {
return setTimeout(function() {
return f(intent);
}, 0);
}) : void 0;
};
})(this));
duiClient.initOK();
root_element = null;
received_HB = null;
IwcConnector = (function() {
function IwcConnector(engine, HB, execution_listener, yatta) {
var receive_, sendRootElement, send_;
this.engine = engine;
this.HB = HB;
this.execution_listener = execution_listener;
this.yatta = yatta;
this.duiClient = duiClient;
this.iwcHandler = iwcHandler;
send_ = (function(_this) {
return function(o) {
return _this.send(o);
};
})(this);
this.execution_listener.push(send_);
receive_ = (function(_this) {
return function(intent) {
var o;
o = intent.extras;
return _this.receive(o);
};
})(this);
this.iwcHandler["Yatta_new_operation"] = [receive_];
if (root_element != null) {
this.engine.applyOps(received_HB);
}
sendRootElement = (function(_this) {
return function() {
var json;
json = {
root_element: _this.yatta.getRootElement(),
HB: _this.yatta.getHistoryBuffer().toJson()
};
return _this.sendIwcIntent("Yatta_push_root_element", json);
};
})(this);
this.iwcHandler["Yatta_get_root_element"] = [sendRootElement];
}
IwcConnector.prototype.getRootElement = function() {
return root_element;
};
IwcConnector.prototype.send = function(o) {
if (o.uid.creator === this.HB.getUserId() && (typeof o.uid.op_number !== "string")) {
return this.sendIwcIntent("Yatta_new_operation", o);
}
};
IwcConnector.prototype.receive = function(o) {
if (o.uid.creator !== this.HB.getUserId()) {
return this.engine.applyOp(o);
}
};
IwcConnector.prototype.sendIwcIntent = function(action_name, content) {
var intent;
intent = {
action: action_name,
component: "",
data: "",
dataType: "",
extras: content
};
return this.duiClient.publishToUser(intent);
};
IwcConnector.prototype.sync = function() {
throw new Error("Can't use this a.t.m.");
};
return IwcConnector;
})();
get_root_intent = {
action: "Yatta_get_root_element",
component: "",
data: "",
dataType: "",
extras: {}
};
init = function() {
var is_initialized, receiveRootElement;
duiClient.publishToUser(get_root_intent);
is_initialized = false;
receiveRootElement = function(json) {
root_element = json != null ? json.extras.root_element : void 0;
received_HB = json != null ? json.extras.HB : void 0;
if (!is_initialized) {
is_initialized = true;
return callback(IwcConnector);
}
};
iwcHandler["Yatta_push_root_element"] = [receiveRootElement];
return setTimeout(receiveRootElement, 3000);
};
setTimeout(init, 10);
return void 0;
};
module.exports = createIwcConnector;
if (typeof window !== "undefined" && window !== null) {
window.createIwcConnector = createIwcConnector;
}
//# sourceMappingURL=IwcConnector.js.map

View File

@ -0,0 +1,10 @@
{
"version": 3,
"file": "IwcConnector.js",
"sourceRoot": "../../../../lib/Connectors/",
"sources": [
"IwcConnector.coffee"
],
"names": [],
"mappings": "AACA,IAAA,kBAAA;;AAAA,kBAAA,GAAqB,SAAC,QAAD,GAAA;AACnB,MAAA,qFAAA;AAAA,EAAA,UAAA,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AAA;AACnB,MAAA,YAAA,kBAAe,IAAI,CAAE,MAAM,CAAC,qBAA5B,CAAA;AAAA,MACA,WAAA,kBAAc,IAAI,CAAE,MAAM,CAAC,WAD3B,CAAA;AAEA,MAAA,IAAG,CAAA,cAAH;AACE,QAAA,cAAA,GAAiB,IAAjB,CAAA;eACA,QAAA,CAAS,YAAT,EAFF;OAHmB;IAAA,CAHrB,CAAA;AAAA,IASA,UAAW,CAAA,yBAAA,CAAX,GAAwC,CAAC,kBAAD,CATxC,CAAA;WAUA,UAAA,CAAW,kBAAX,EAA+B,IAA/B,EAXK;EAAA,CAzEP,CAAA;AAAA,EAsFA,UAAA,CAAW,IAAX,EAAiB,EAAjB,CAtFA,CAAA;SAwFA,OAzFmB;AAAA,CAArB,CAAA;;AAAA,MA0FM,CAAC,OAAP,GAAiB,kBA1FjB,CAAA;;;EA2FA,MAAM,CAAE,kBAAR,GAA6B;CA3F7B"
}

View File

@ -16,10 +16,6 @@ module.exports = function(user_list) {
};
})(this);
this.execution_listener.push(send_);
if (!((user_list != null ? user_list.length : void 0) === 0)) {
this.engine.applyOps(user_list[0].getHistoryBuffer().toJson());
}
this.unexecuted = {};
this.applied_operations = [];
appliedOperationsListener = (function(_this) {
return function(o) {
@ -27,6 +23,10 @@ module.exports = function(user_list) {
};
})(this);
this.execution_listener.push(appliedOperationsListener);
if (!((user_list != null ? user_list.length : void 0) === 0)) {
this.engine.applyOps(user_list[0].getHistoryBuffer().toJson());
}
this.unexecuted = {};
}
TestConnector.prototype.getOpsInExecutionOrder = function() {
@ -35,17 +35,17 @@ module.exports = function(user_list) {
TestConnector.prototype.getRootElement = function() {
if (user_list.length > 0) {
return user_list[0].getRootElement();
return user_list[0].getRootElement().getUid();
}
};
TestConnector.prototype.send = function(o) {
var user, _i, _len, _results;
if (o.creator === this.HB.getUserId()) {
if ((o.uid.creator === this.HB.getUserId()) && (typeof o.uid.op_number !== "string")) {
_results = [];
for (_i = 0, _len = user_list.length; _i < _len; _i++) {
user = user_list[_i];
if (!user.getUserId() === this.HB.getUserId()) {
if (user.getUserId() !== this.HB.getUserId()) {
_results.push(user.getConnector().receive(o));
} else {
_results.push(void 0);
@ -75,8 +75,10 @@ module.exports = function(user_list) {
};
TestConnector.prototype.flushAll = function() {
var ops;
for (ops in this.unexecuted) {
var n, ops, _ref;
_ref = this.unexecuted;
for (n in _ref) {
ops = _ref[n];
this.engine.applyOps(ops);
}
return this.unexecuted = {};

View File

@ -6,5 +6,5 @@
"TestConnector.coffee"
],
"names": [],
"mappings": "AACA,IAAA,CAAA;;AAAA,CAAA,GAAI,OAAA,CAAQ,YAAR,CAAJ,CAAA;;AAAA,MAEM,CAAC,OAAP,GAAiB,SAAC,SAAD,GAAA;AACf,MAAA,aAAA;SAAM;AACS,IAAA,uBAAE,MAAF,EAAW,EAAX,EAAgB,kBAAhB,GAAA;AACX,UAAA,gCAAA;AAAA,MADY,IAAC,CAAA,SAAA,MACb,CAAA;AAAA,MADqB,IAAC,CAAA,KAAA,EACtB,CAAA;AAAA,MAD0B,IAAC,CAAA,qBAAA,kBAC3B,CAAA;AAAA,MAAA,KAAA,GAAQ,CAAA,SAAA,KAAA,GAAA;eAAA,SAAC,CAAD,GAAA;iBACN,KAAC,CAAA,IAAD,CAAM,CAAN,EADM;QAAA,EAAA;MAAA,CAAA,CAAA,CAAA,IAAA,CAAR,CAAA;AAAA,MAEA,IAAC,CAAA,kBAAkB,CAAC,IAApB,CAAyB,KAAzB,CAFA,CAAA;AAIA,MAAA,IAAG,CAAA,sBAAK,SAAS,CAAE,gBAAX,KAAqB,CAAtB,CAAP;AACE,QAAA,IAAC,CAAA,MAAM,CAAC,QAAR,CAAiB,SAAU,CAAA,CAAA,CAAE,CAAC,gBAAb,CAAA,CAA+B,CAAC,MAAhC,CAAA,CAAjB,CAAA,CADF;OAJA;AAAA,MAOA,IAAC,CAAA,UAAD,GAAc,EAPd,CAAA;AAAA,MAQA,IAAC,CAAA,kBAAD,GAAsB,EARtB,CAAA;AAAA,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A,EAAE,CAAC,SAAJ,CAAA,CAAzB;0BACE,IAAI,CAAC,YAAL,CAAA,CAAmB,CAAC,OAApB,CAA4B,CAA5B,GADF;WAAA,MAAA;kCAAA;WADF;AAAA;wBADF;OADI;IAAA,CArBN,CAAA;;AAAA,4BA2BA,OAAA,GAAS,SAAC,CAAD,GAAA;AACP,UAAA,YAAA;;uBAA0B;OAA1B;aACA,IAAC,CAAA,UAAW,CAAA,CAAC,CAAC,OAAF,CAAU,CAAC,IAAvB,CAA4B,CAA5B,EAFO;IAAA,CA3BT,CAAA;;AAAA,4BA+BA,QAAA,GAAU,SAAC,IAAD,GAAA;AACR,UAAA,IAAA;AAAA,MAAA,kDAAoB,CAAE,gBAAnB,GAA4B,CAA/B;eACE,IAAC,CAAA,MAAM,CAAC,OAAR,CAAgB,IAAC,CAAA,UAAW,CAAA,IAAA,CAAK,CAAC,KAAlB,CAAA,CAAhB,EADF;OADQ;IAAA,CA/BV,CAAA;;AAAA,4BAmCA,cAAA,GAAgB,SAAA,GAAA;aACd,IAAC,CAAA,QAAD,CAAW,CAAC,CAAC,MAAF,CAAS,CAAT,EAAa,SAAS,CAAC,MAAV,GAAiB,CAA9B,CAAX,EADc;IAAA,CAnChB,CAAA;;AAAA,4BAsCA,QAAA,GAAU,SAAA,GAAA;AACR,UAAA,YAAA;AAAA;AAAA,WAAA,SAAA;sBAAA;AACE,QAAA,IAAC,CAAA,MAAM,CAAC,QAAR,CAAiB,GAAjB,CAAA,CADF;AAAA,OAAA;aAEA,IAAC,CAAA,UAAD,GAAc,GAHN;IAAA,CAtCV,CAAA;;AAAA,4BA0CA,IAAA,GAAM,SAAA,GAAA;AACJ,YAAU,IAAA,KAAA,CAAM,uBAAN,CAAV,CADI;IAAA,CA1CN,CAAA;;yBAAA;;OAFa;AAAA,CAFjB,CAAA"
}

View File

@ -1,6 +1,4 @@
var Engine, _;
_ = require("underscore");
var Engine;
Engine = (function() {
function Engine(HB, parser) {
@ -19,32 +17,57 @@ Engine = (function() {
}
};
Engine.prototype.applyOps = function(ops) {
var o, _i, _len, _results;
Engine.prototype.applyOps = function(ops_json) {
var o, ops, _i, _j, _k, _len, _len1, _len2;
ops = [];
for (_i = 0, _len = ops_json.length; _i < _len; _i++) {
o = ops_json[_i];
ops.push(this.parseOperation(o));
}
for (_j = 0, _len1 = ops.length; _j < _len1; _j++) {
o = ops[_j];
this.HB.addOperation(o);
}
for (_k = 0, _len2 = ops.length; _k < _len2; _k++) {
o = ops[_k];
if (!o.execute()) {
this.unprocessed_ops.push(o);
}
}
return this.cleanUp();
};
Engine.prototype.cleanUp = function() {
var old_length, op, unprocessed, _i, _len, _ref, _results;
_results = [];
for (_i = 0, _len = ops.length; _i < _len; _i++) {
o = ops[_i];
_results.push(this.applyOp(o));
while (true) {
old_length = this.unprocessed_ops.length;
unprocessed = [];
_ref = this.unprocessed_ops;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
op = _ref[_i];
if (!op.execute()) {
unprocessed.push(op);
}
}
this.unprocessed_ops = unprocessed;
if (this.unprocessed_ops.length === old_length) {
break;
} else {
_results.push(void 0);
}
}
return _results;
};
Engine.prototype.applyOp = function(op_json) {
var o, op, unprocessed, _i, _len, _ref;
o = this.parseOperation(o_json);
var o;
o = this.parseOperation(op_json);
this.HB.addOperation(o);
if (!o.execute()) {
this.unprocessed_ops.push(o);
}
unprocessed = [];
_ref = this.unprocessed_ops;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
op = _ref[_i];
if (!op.execute()) {
unprocessed.push(op);
}
}
return this.unprocessed_ops = unprocessed;
return this.cleanUp();
};
return Engine;

View File

@ -6,5 +6,5 @@
"Engine.coffee"
],
"names": [],
"mappings": "AAAA,IAAA,SAAA;;AAAA,CAAA,GAAI,OAAA,CAAQ,YAAR,CAAJ,CAAA;;AAAA;AAGe,EAAA,gBAAE,EAAF,EAAO,MAAP,GAAA;AACX,IADY,IAAC,CAAA,KAAA,EACb,CAAA;AAAA,IADiB,IAAC,CAAA,SAAA,MACl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,GAAA;AACP,QAAA,qDAAA;AAAA;WAAM,IAAN,GAAA;AACE,MAAA,UAAA,GAAa,IAAC,CAAA,eAAe,CAAC,MAA9B,CAAA;AAAA,MACA,WAAA,GAAc,EADd,CAAA;AAEA;AAAA,WAAA,2CAAA;sBAAA;AACE,QAAA,IAAG,CAAA,EAAM,CAAC,OAAH,CAAA,CAAP;AACE,UAAA,WAAW,CAAC,IAAZ,CAAiB,EAAjB,CAAA,CADF;SADF;AAAA,OAFA;AAAA,MAKA,IAAC,CAAA,eAAD,GAAmB,WALnB,CAAA;AAMA,MAAA,IAAG,IAAC,CAAA,eAAe,CAAC,MAAjB,KAA2B,UAA9B;AACE,cADF;OAAA,MAAA;8BAAA;OAPF;IAAA,CAAA;oBADO;EAAA,CAtBT,CAAA;;AAAA,mBAiCA,OAAA,GAAS,SAAC,OAAD,GAAA;AAEP,QAAA,CAAA;AAAA,IAAA,CAAA,GAAI,IAAC,CAAA,cAAD,CAAgB,OAAhB,CAAJ,CAAA;AAAA,IACA,IAAC,CAAA,EAAE,CAAC,YAAJ,CAAiB,CAAjB,CADA,CAAA;AAEA,IAAA,IAAG,CAAA,CAAK,CAAC,OAAF,CAAA,CAAP;AACE,MAAA,IAAC,CAAA,eAAe,CAAC,IAAjB,CAAsB,CAAtB,CAAA,CADF;KAFA;WAIA,IAAC,CAAA,OAAD,CAAA,EANO;EAAA,CAjCT,CAAA;;gBAAA;;IADF,CAAA;;AAAA,MA6CM,CAAC,OAAP,GAAiB,MA7CjB,CAAA"
}

View File

@ -0,0 +1,61 @@
var Engine, HistoryBuffer, JsonYatta, json_types_uninitialized;
json_types_uninitialized = require("../Types/JsonTypes.coffee");
HistoryBuffer = require("../HistoryBuffer.coffee");
Engine = require("../Engine.coffee");
JsonYatta = (function() {
function JsonYatta(user_id, Connector) {
var first_word, json_types, root_elem;
this.HB = new HistoryBuffer(user_id);
json_types = json_types_uninitialized(this.HB);
this.engine = new Engine(this.HB, json_types.parser);
this.connector = new Connector(this.engine, this.HB, json_types.execution_listener, this);
root_elem = this.connector.getRootElement();
if (root_elem == null) {
first_word = new json_types.types.JsonType(this.HB.getNextOperationIdentifier());
this.HB.addOperation(first_word);
first_word.execute();
this.root_element = first_word;
} else {
this.root_element = this.HB.getOperation(root_elem);
}
}
JsonYatta.prototype.getRootElement = function() {
return this.root_element;
};
JsonYatta.prototype.getEngine = function() {
return this.engine;
};
JsonYatta.prototype.getConnector = function() {
return this.connector;
};
JsonYatta.prototype.getHistoryBuffer = function() {
return this.HB;
};
JsonYatta.prototype.getUserId = function() {
return this.HB.getUserId();
};
JsonYatta.prototype.val = function(name, content) {
return this.root_element.val(name, content);
};
return JsonYatta;
})();
if (typeof window !== "undefined" && window !== null) {
window.JsonYatta = JsonYatta;
}
module.exports = JsonYatta;
//# sourceMappingURL=JsonYatta.js.map

View File

@ -0,0 +1,10 @@
{
"version": 3,
"file": "JsonYatta.js",
"sourceRoot": "../../../../lib/Frameworks/",
"sources": [
"JsonYatta.coffee"
],
"names": [],
"mappings": "AACA,IAAA,0DAAA;;AAAA,wBAAA,GAA2B,OAAA,CAAQ,2BAAR,CAA3B,CAAA;;AAAA,aACA,GAAgB,OAAA,CAAQ,yBAAR,CADhB,CAAA;;AAAA,MAEA,GAAS,OAAA,CAAQ,kBAAR,CAFT,CAAA;;AAAA;AAKe,EAAA,mBAAC,OAAD,EAAU,SAAV,GAAA;AACX,QAAA,iCAAA;AAAA,IAAA,IAAC,CAAA,EAAD,GAAU,IAAA,aAAA,CAAc,OAAd,CAAV,CAAA;AAAA,IACA,UAAA,GAAa,wBAAA,CAAyB,IAAC,CAAA,EAA1B,CADb,CAAA;AAAA,IAEA,IAAC,CAAA,MAAD,GAAc,IAAA,MAAA,CAAO,IAAC,CAAA,EAAR,EAAY,UAAU,CAAC,MAAvB,CAFd,CAAA;AAAA,IAGA,IAAC,CAAA,SAAD,GAAiB,IAAA,SAAA,CAAU,IAAC,CAAA,MAAX,EAAmB,IAAC,CAAA,EAApB,EAAwB,U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AiB,SAtCjB,CAAA"
}

View File

@ -8,17 +8,19 @@ Engine = require("../Engine.coffee");
TextYatta = (function() {
function TextYatta(user_id, Connector) {
var first_word, text_types;
var first_word, root_elem, text_types;
this.HB = new HistoryBuffer(user_id);
text_types = text_types_uninitialized(this.HB);
this.engine = new Engine(this.HB, text_types.parser);
this.connector = new Connector(this.engine, this.HB, text_types.execution_listener);
this.root_element = this.connector.getRootElement();
if (this.root_element == null) {
root_elem = this.connector.getRootElement();
if (root_elem == null) {
first_word = new text_types.types.Word(this.HB.getNextOperationIdentifier());
this.HB.addOperation(first_word);
first_word.execute();
this.root_element = this.HB.addOperation(new text_types.types.ReplaceManager(first_word, this.HB.getNextOperationIdentifier())).execute();
} else {
this.root_element = this.HB.getOperation(root_elem);
}
}

View File

@ -6,5 +6,5 @@
"TextYatta.coffee"
],
"names": [],
"mappings": "AACA,IAAA,0DAAA;;AAAA,wBAAA,GAA2B,OAAA,CAAQ,2BAAR,CAA3B,CAAA;;AAAA,aACA,GAAgB,OAAA,CAAQ,yBAAR,CADhB,CAAA;;AAAA,MAEA,GAAS,OAAA,CAAQ,kBAAR,CAFT,CAAA;;AAAA;AAKe,EAAA,mBAAC,OAAD,EAAU,SAAV,GAAA;AACX,QAAA,sBAAA;AAAA,IAAA,IAAC,CAAA,EAAD,GAAU,IAAA,aAAA,CAAc,OAAd,CAAV,CAAA;AAAA,IACA,UAAA,GAAa,wBAAA,CAAyB,IAAC,CAAA,EAA1B,CADb,CAAA;AAAA,IAEA,IAAC,CAAA,MAAD,GAAc,IAAA,MAAA,CAAO,IAAC,CAAA,EAAR,EAAY,UAAU,CAAC,MAAvB,CAFd,CAAA;AAAA,IAGA,IAAC,CAAA,SAAD,GAAiB,IAAA,SAAA,CAAU,IAAC,CAAA,MAAX,EAAmB,IAAC,CAAA,EAApB,EAAwB,UAAU,CAAC,kBAAnC,CAHjB,CAAA;AAAA,IAIA,IAAC,CAAA,YAAD,GAAgB,IAAC,CAAA,SAAS,CAAC,cA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AAA,CAhCZ,CAAA;;AAAA,sBAmCA,UAAA,GAAY,SAAC,GAAD,EAAM,MAAN,GAAA;WACV,IAAC,CAAA,YAAY,CAAC,GAAd,CAAA,CAAmB,CAAC,UAApB,CAA+B,GAA/B,EAAoC,MAApC,EADU;EAAA,CAnCZ,CAAA;;AAAA,sBAsCA,WAAA,GAAa,SAAC,IAAD,GAAA;WACX,IAAC,CAAA,YAAY,CAAC,GAAd,CAAA,CAAmB,CAAC,WAApB,CAAgC,IAAhC,EADW;EAAA,CAtCb,CAAA;;mBAAA;;IALF,CAAA;;AAAA,MA+CM,CAAC,OAAP,GAAiB,SA/CjB,CAAA"
}

View File

@ -1,6 +1,4 @@
var HistoryBuffer, _;
_ = require("underscore");
var HistoryBuffer;
HistoryBuffer = (function() {
function HistoryBuffer(user_id) {
@ -15,17 +13,27 @@ HistoryBuffer = (function() {
};
HistoryBuffer.prototype.getOperationCounter = function() {
return _.clone(this.operation_counter);
var ctn, res, user, _ref;
res = {};
_ref = this.operation_counter;
for (user in _ref) {
ctn = _ref[user];
res[user] = ctn;
}
return res;
};
HistoryBuffer.prototype.toJson = function() {
var json, o, user, _i, _len, _ref;
var json, o, o_number, u_name, user, _ref;
json = [];
_ref = this.buffer;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
user = _ref[_i];
for (o in user) {
json.push(o.toJson());
for (u_name in _ref) {
user = _ref[u_name];
for (o_number in user) {
o = user[o_number];
if (!isNaN(parseInt(o_number))) {
json.push(o.toJson());
}
}
}
return json;
@ -51,6 +59,8 @@ HistoryBuffer = (function() {
var _ref;
if (uid instanceof Object) {
return (_ref = this.buffer[uid.creator]) != null ? _ref[uid.op_number] : void 0;
} else if (uid == null) {
} else {
throw new Error("This type of uid is not defined!");
}

View File

@ -6,5 +6,5 @@
"HistoryBuffer.coffee"
],
"names": [],
"mappings": "AAAA,IAAA,gBAAA;;AAAA,CAAA,GAAI,OAAA,CAAQ,YAAR,CAAJ,CAAA;;AAAA;AAee,EAAA,uB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YAAU,IAAA,KAAA,CAAM,kCAAN,CAAV,CAFG;KAHO;EAAA,CAvCd,CAAA;;AAAA,0BAgDA,YAAA,GAAc,SAAC,CAAD,GAAA;AACZ,IAAA,IAAO,8BAAP;AACE,MAAA,IAAC,CAAA,MAAO,CAAA,CAAC,CAAC,OAAF,CAAR,GAAqB,EAArB,CADF;KAAA;AAEA,IAAA,IAAO,yCAAP;AACE,MAAA,IAAC,CAAA,iBAAkB,CAAA,CAAC,CAAC,OAAF,CAAnB,GAAgC,CAAhC,CADF;KAFA;AAMA,IAAA,IAAG,2CAAH;AACE,YAAU,IAAA,KAAA,CAAM,oCAAN,CAAV,CADF;KANA;AAAA,IAQA,IAAC,CAAA,MAAO,CAAA,CAAC,CAAC,OAAF,CAAW,CAAA,CAAC,CAAC,SAAF,CAAnB,GAAkC,CARlC,CAAA;AASA,IAAA,IAAG,MAAA,CAAA,CAAQ,CAAC,SAAT,KAAsB,QAAtB,IAAmC,CAAC,CAAC,OAAF,KAAe,IAAC,CAAA,SAAD,CAAA,CAArD;AACE,MAAA,IAAC,CAAA,iBAAkB,CAAA,CAAC,CAAC,OAAF,CAAnB,EAAA,CADF;KATA;WAWA,EAZY;EAAA,CAhDd,CAAA;;uBAAA;;IARF,CAAA;;AAAA,MAsEM,CAAC,OAAP,GAAiB,aAtEjB,CAAA"
}

View File

@ -19,6 +19,7 @@ module.exports = function(HB) {
Operation.prototype.execute = function() {
var l, _i, _len;
this.is_executed = true;
for (_i = 0, _len = execution_listener.length; _i < _len; _i++) {
l = execution_listener[_i];
l(this.toJson());
@ -48,7 +49,7 @@ module.exports = function(HB) {
if (op) {
this[name] = op;
} else {
uninstantiated[name] = op;
uninstantiated[name] = op_uid;
success = false;
}
}
@ -94,7 +95,7 @@ module.exports = function(HB) {
parser['Delete'] = function(_arg) {
var deletes_uid, uid;
uid = _arg['uid'], deletes_uid = _arg['deletes'];
return new D(uid, deletes_uid);
return new Delete(uid, deletes_uid);
};
Insert = (function(_super) {
__extends(Insert, _super);
@ -131,6 +132,9 @@ module.exports = function(HB) {
break;
}
d++;
if (this === this.prev_cl) {
throw new Error("this should not happen ;) ");
}
o = o.prev_cl;
}
return d;
@ -159,11 +163,14 @@ module.exports = function(HB) {
};
Insert.prototype.execute = function() {
var distance_to_origin, i, o;
var distance_to_origin, i, o, _ref, _ref1;
if (this.is_executed != null) {
return this;
}
if (!this.validateSavedOperations()) {
return false;
} else {
if ((this.prev_cl != null) && (this.next_cl != null)) {
if (((_ref = this.prev_cl) != null ? _ref.validateSavedOperations() : void 0) && ((_ref1 = this.next_cl) != null ? _ref1.validateSavedOperations() : void 0) && this.prev_cl.next_cl !== this) {
distance_to_origin = 0;
o = this.prev_cl.next_cl;
i = 0;
@ -228,21 +235,25 @@ module.exports = function(HB) {
};
Delimiter.prototype.execute = function() {
var a, l, _i, _len;
a = this.validateSavedOperations();
for (_i = 0, _len = execution_listener.length; _i < _len; _i++) {
l = execution_listener[_i];
l(this.toJson());
var l, _i, _len;
if (this.validateSavedOperations()) {
for (_i = 0, _len = execution_listener.length; _i < _len; _i++) {
l = execution_listener[_i];
l(this.toJson());
}
return this;
} else {
return false;
}
return a;
};
Delimiter.prototype.toJson = function() {
var _ref, _ref1;
return {
'type': "Delimiter",
'uid': this.getUid(),
'prev': this.prev_cl.getUid(),
'next': this.next_cl.getUid()
'prev': (_ref = this.prev_cl) != null ? _ref.getUid() : void 0,
'next': (_ref1 = this.next_cl) != null ? _ref1.getUid() : void 0
};
};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,67 @@
var text_types_uninitialized,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
text_types_uninitialized = require("./TextTypes.coffee");
module.exports = function(HB) {
var JsonType, parser, text_types, types;
text_types = text_types_uninitialized(HB);
types = text_types.types;
parser = text_types.parser;
JsonType = (function(_super) {
__extends(JsonType, _super);
function JsonType(uid, initial_value) {
var name, o;
JsonType.__super__.constructor.call(this, uid);
if (initial_value != null) {
if (typeof initial_value !== "object") {
throw new Error("The initial value of JsonTypes must be of type Object! (current type: " + (typeof initial_value) + ")");
}
for (name in initial_value) {
o = initial_value[name];
this.val(name, o);
}
}
}
JsonType.prototype.val = function(name, content) {
var json, word;
if ((name != null) && (content != null)) {
if (typeof content === 'string') {
word = HB.addOperation(new types.Word(HB.getNextOperationIdentifier(), content)).execute();
JsonType.__super__.val.call(this, name, word);
return content;
} else if (typeof content === 'object') {
json = HB.addOperation(JsonType(HB.getNextOperationIdentifier(), content)).execute();
JsonType.__super__.val.call(this, name, json);
return content;
} else {
throw new Error("You must not set " + (typeof content) + "-types in collaborative Json-objects!");
}
} else {
return JsonType.__super__.val.call(this, name, content);
}
};
JsonType.prototype.toJson = function() {
return {
'type': "JsonType",
'uid': this.getUid()
};
};
return JsonType;
})(types.MapManager);
parser['JsonType'] = function(json) {
var uid;
uid = json['uid'];
return new JsonType(uid);
};
types['JsonType'] = JsonType;
return text_types;
};
//# sourceMappingURL=JsonTypes.js.map

View File

@ -0,0 +1,10 @@
{
"version": 3,
"file": "JsonTypes.js",
"sourceRoot": "../../../../lib/Types/",
"sources": [
"JsonTypes.coffee"
],
"names": [],
"mappings": "AAAA,IAAA,wBAAA;EAAA;iSAAA;;AAAA,wBAAA,GAA2B,OAAA,CAAQ,oBAAR,CAA3B,CAAA;;AAAA,MAEM,CAAC,OAAP,GAAiB,SAAC,EAAD,GAAA;AACf,MAAA,mCAAA;AAAA,EAAA,UAAA,GAAa,wBAAA,CAAyB,EAAzB,CAAb,CAAA;AAAA,EACA,KAAA,GAAQ,UAAU,CAAC,KADnB,CAAA;AAAA,EAEA,MAAA,GAAS,UAAU,CAAC,MAFpB,CAAA;AAAA,EAIM;AACJ,+BAAA,CAAA;;AAAa,IAAA,kBAAC,GAAD,EAAM,aAAN,GAAA;AACX,UAAA,OAA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A,QACE,MAAA,EAAS,UADX;AAAA,QAEE,KAAA,EAAQ,IAAC,CAAA,MAAD,CAAA,CAFV;QADM;IAAA,CAvBR,CAAA;;oBAAA;;KADqB,KAAK,CAAC,WAJ7B,CAAA;AAAA,EAkCA,MAAO,CAAA,UAAA,CAAP,GAAqB,SAAC,IAAD,GAAA;AACnB,QAAA,GAAA;AAAA,IACU,MACN,KADF,MADF,CAAA;WAGI,IAAA,QAAA,CAAS,GAAT,EAJe;EAAA,CAlCrB,CAAA;AAAA,EAyCA,KAAM,CAAA,UAAA,CAAN,GAAoB,QAzCpB,CAAA;SA2CA,WA5Ce;AAAA,CAFjB,CAAA"
}

View File

@ -1,41 +1,105 @@
var basic_types_uninitialized, _,
var basic_types_uninitialized,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
_ = require("underscore");
basic_types_uninitialized = require("./BasicTypes.coffee");
module.exports = function(HB) {
var ListManager, MapManager, ReplaceManager, Replaceable, basic_types, parser, types;
var AddName, ListManager, MapManager, ReplaceManager, Replaceable, basic_types, parser, types;
basic_types = basic_types_uninitialized(HB);
types = basic_types.types;
parser = basic_types.parser;
MapManager = (function() {
function MapManager() {
MapManager = (function(_super) {
__extends(MapManager, _super);
function MapManager(uid) {
this.map = {};
MapManager.__super__.constructor.call(this, uid);
}
MapManager.prototype.set = function(name, content) {
if (this.map[name] == null) {
return this.map[name] = new Replaceable(HB, this.map[name].replace(content));
MapManager.prototype.val = function(name, content) {
var o, result, _ref, _ref1;
if (content != null) {
if (this.map[name] == null) {
HB.addOperation(new AddName(HB.getNextOperationIdentifier(), this, name)).execute();
}
return this.map[name].replace(content);
} else if (name != null) {
return (_ref = this.map[name]) != null ? _ref.val() : void 0;
} else {
result = {};
_ref1 = this.map;
for (name in _ref1) {
o = _ref1[name];
result[name] = o.val();
}
return result;
}
};
return MapManager;
})();
})(types.Operation);
AddName = (function(_super) {
__extends(AddName, _super);
function AddName(uid, map_manager, name) {
this.name = name;
this.saveOperation('map_manager', map_manager);
AddName.__super__.constructor.call(this, uid);
}
AddName.prototype.execute = function() {
var beg, end, uid_beg, uid_end, uid_r;
if (!this.validateSavedOperations()) {
return false;
} else {
uid_r = this.map_manager.getUid();
uid_r.op_number = "_" + uid_r.op_number + "_RM_" + this.name;
if (HB.getOperation(uid_r) == null) {
uid_beg = this.map_manager.getUid();
uid_beg.op_number = "_" + uid_beg.op_number + "_RM_" + this.name + "_beginning";
uid_end = this.map_manager.getUid();
uid_end.op_number = "_" + uid_end.op_number + "_RM_" + this.name + "_end";
beg = HB.addOperation(new types.Delimiter(uid_beg, void 0, uid_end));
end = HB.addOperation(new types.Delimiter(uid_end, beg, void 0)).execute();
beg.execute();
this.map_manager.map[this.name] = HB.addOperation(new ReplaceManager(void 0, uid_r, beg, end)).execute();
}
return AddName.__super__.execute.apply(this, arguments);
}
};
AddName.prototype.toJson = function() {
return {
'type': "AddName",
'uid': this.getUid(),
'map_manager': this.map_manager.getUid(),
'name': this.name
};
};
return AddName;
})(types.Operation);
parser['AddName'] = function(json) {
var map_manager, name, uid;
map_manager = json['map_manager'], uid = json['uid'], name = json['name'];
return new AddName(uid, map_manager, name);
};
ListManager = (function(_super) {
__extends(ListManager, _super);
function ListManager(uid, beginning, end, prev, next, origin) {
if ((beginning != null) && (end != null)) {
saveOperation("beginning", beginning);
saveOperation("end", end);
this.saveOperation('beginning', beginning);
this.saveOperation('end', end);
} else {
this.beginning = HB.addOperation(new types.Delimiter(HB.getNextOperationIdentifier(), void 0, void 0));
this.end = HB.addOperation(new types.Delimiter(HB.getNextOperationIdentifier(), this.beginning, void 0));
this.beginning.next_cl = this.end;
this.beginning.execute();
this.end.execute();
}
ListManager.__super__.constructor.call(this, uid, prev, next, origin);
}
@ -113,8 +177,8 @@ module.exports = function(HB) {
json = {
'type': "ReplaceManager",
'uid': this.getUid(),
'beginning': this.beginning,
'end': this.end
'beginning': this.beginning.getUid(),
'end': this.end.getUid()
};
if ((this.prev_cl != null) && (this.next_cl != null)) {
json['prev'] = this.prev_cl.getUid();
@ -140,8 +204,8 @@ module.exports = function(HB) {
function Replaceable(content, parent, uid, prev, next, origin) {
this.saveOperation('content', content);
this.saveOperation('parent', parent);
if (!((prev != null) && (next != null))) {
throw new Error("You must define prev, and next for Replaceable-types!");
if (!((prev != null) && (next != null) && (content != null))) {
throw new Error("You must define content, prev, and next for Replaceable-types!");
}
Replaceable.__super__.constructor.call(this, uid, prev, next, origin);
}
@ -156,11 +220,15 @@ module.exports = function(HB) {
Replaceable.prototype.execute = function() {
var _base;
Replaceable.__super__.execute.apply(this, arguments);
if (typeof (_base = this.content).setReplaceManager === "function") {
_base.setReplaceManager(this.parent);
if (!this.validateSavedOperations()) {
return false;
} else {
if (typeof (_base = this.content).setReplaceManager === "function") {
_base.setReplaceManager(this.parent);
}
Replaceable.__super__.execute.apply(this, arguments);
return this;
}
return this;
};
Replaceable.prototype.toJson = function() {
@ -168,7 +236,7 @@ module.exports = function(HB) {
json = {
'type': "Replaceable",
'content': this.content.getUid(),
'ReplaceManager': this.parent,
'ReplaceManager': this.parent.getUid(),
'prev': this.prev_cl.getUid(),
'next': this.next_cl.getUid(),
'uid': this.getUid()

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,7 @@
var structured_types_uninitialized, _,
var structured_types_uninitialized,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
_ = require("underscore");
structured_types_uninitialized = require("./StructuredTypes.coffee");
module.exports = function(HB) {
@ -75,8 +73,11 @@ module.exports = function(HB) {
Word = (function(_super) {
__extends(Word, _super);
function Word(uid, prev, next, origin) {
Word.__super__.constructor.call(this, uid, prev, next, origin);
function Word(uid, initial_content, beginning, end, prev, next, origin) {
Word.__super__.constructor.call(this, uid, beginning, end, prev, next, origin);
if (initial_content != null) {
this.insertText(0, initial_content);
}
}
Word.prototype.insertText = function(position, content) {
@ -147,9 +148,10 @@ module.exports = function(HB) {
Word.prototype.toJson = function() {
var json;
json = {
'type': "TextInsert",
'content': this.content,
'uid': this.getUid()
'type': "Word",
'uid': this.getUid(),
'beginning': this.beginning.getUid(),
'end': this.end.getUid()
};
if (this.prev_cl != null) {
json['prev'] = this.prev_cl.getUid();
@ -167,9 +169,9 @@ module.exports = function(HB) {
})(types.ListManager);
parser['Word'] = function(json) {
var content, next, origin, prev, uid;
content = json['content'], uid = json['uid'], prev = json['prev'], next = json['next'], origin = json['origin'];
return new Word(uid, prev, next, origin);
var beginning, end, next, origin, prev, uid;
uid = json['uid'], beginning = json['beginning'], end = json['end'], prev = json['prev'], next = json['next'], origin = json['origin'];
return new Word(uid, void 0, beginning, end, prev, next, origin);
};
types['TextInsert'] = TextInsert;
types['TextDelete'] = TextDelete;

View File

@ -6,5 +6,5 @@
"TextTypes.coffee"
],
"names": [],
"mappings": "AAAA,IAAA,iCAAA;EAAA;iSAAA;;AAAA,CAAA,GAAI,OAAA,CAAQ,YAAR,CAAJ,CAAA;;AAAA,8BACA,GAAiC,OAAA,CAAQ,0BAAR,CADjC,CAAA;;AAAA,MAGM,CAAC,OAAP,GAAiB,SAAC,EAAD,GAAA;AACf,MAAA,6DAAA;AAAA,EAAA,gBAAA,GAAmB,8BAAA,CAA+B,EAA/B,CAAnB,CAAA;AAAA,EACA,KAAA,GAAQ,gBAAgB,CAAC,KADzB,CAAA;AAAA,EAEA,MAAA,GAAS,gBAAgB,CAAC,MAF1B,CAAA;AAAA,EAQM;AAAN,iCAAA,CAAA;;;;KAAA;;sBAAA;;KAAyB,KAAK,CAAC,OAR/B,CAAA;AAAA,EASA,MAAO,CAAA,YAAA,CAAP,GAAuB,MAAO,CAAA,QAAA,CAT9B,CAAA;AAAA,EAc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AAa,IAAC,CAAA,MAAD,KAAa,IAAC,CAAA,OAA9B;AACE,QAAA,IAAK,CAAA,QAAA,CAAL,GAAiB,IAAC,CAAA,MAAM,CAAC,MAAR,CAAA,CAAjB,CADF;OAVA;aAYA,KAbM;IAAA,CA7CR,CAAA;;gBAAA;;KADiB,KAAK,CAAC,YAlEzB,CAAA;AAAA,EA+HA,MAAO,CAAA,MAAA,CAAP,GAAiB,SAAC,IAAD,GAAA;AACf,QAAA,uCAAA;AAAA,IACU,WAAR,MADF,EAEgB,iBAAd,YAFF,EAGU,WAAR,MAHF,EAIU,YAAR,OAJF,EAKU,YAAR,OALF,EAMa,cAAX,SANF,CAAA;WAQI,IAAA,IAAA,CAAK,GAAL,EAAU,MAAV,EAAqB,SAArB,EAAgC,GAAhC,EAAqC,IAArC,EAA2C,IAA3C,EAAiD,MAAjD,EATW;EAAA,CA/HjB,CAAA;AAAA,EA0IA,KAAM,CAAA,YAAA,CAAN,GAAsB,UA1ItB,CAAA;AAAA,EA2IA,KAAM,CAAA,YAAA,CAAN,GAAsB,UA3ItB,CAAA;AAAA,EA4IA,KAAM,CAAA,MAAA,CAAN,GAAgB,IA5IhB,CAAA;SA8IA,iBA/Ie;AAAA,CAFjB,CAAA"
}

View File

@ -1,5 +1,3 @@
var _;
_ = require("underscore");
//# sourceMappingURL=XmlTypes.js.map

View File

@ -6,5 +6,5 @@
"XmlTypes.coffee"
],
"names": [],
"mappings": "AAAA,IAAA,CAAA;;AAAA,CAAA,GAAI,OAAA,CAAQ,YAAR,CAAJ,CAAA"
"mappings": "AAiJkB"
}

View File

@ -0,0 +1,173 @@
(function() {
var Connector_uninitialized, Yatta, chai, expect, should, sinon, sinonChai, _;
chai = require('chai');
expect = chai.expect;
should = chai.should();
sinon = require('sinon');
sinonChai = require('sinon-chai');
_ = require("underscore");
chai.use(sinonChai);
Yatta = require("../lib/Frameworks/JsonYatta.coffee");
Connector_uninitialized = require("../lib/Connectors/TestConnector.coffee");
describe("JsonYatta", function() {
beforeEach(function(done) {
var i, _i, _ref;
this.last_user = 10;
this.users = [];
this.Connector = Connector_uninitialized(this.users);
for (i = _i = 0, _ref = this.last_user + 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
this.users.push(new Yatta(i, this.Connector));
}
return done();
});
return it("can handle many engines, many operations, concurrently (random)", function() {
var Connector, applyRandomOp, doSomething, doSomething_amount, found_error, generateDeleteOp, generateInsertOp, generateRandomOp, generateReplaceOp, i, j, number_of_created_operations, number_of_engines, number_of_test_cases_multiplier, ops, ops_per_msek, printOpsInExecutionOrder, repeat_this, time_now, times, u, user, user_number, users, _i, _j, _k, _l, _len, _m, _ref, _results;
number_of_test_cases_multiplier = 1;
repeat_this = 1 * number_of_test_cases_multiplier;
doSomething_amount = 200 * number_of_test_cases_multiplier;
number_of_engines = 12 + number_of_test_cases_multiplier - 1;
this.time = 0;
this.ops = 0;
users = [];
generateInsertOp = function(user_num) {
var chars, length, nextchar, pos, text;
chars = "1234567890";
pos = _.random(0, users[user_num].val('name').length - 1);
length = 1;
nextchar = chars[_.random(0, chars.length - 1)];
text = "";
_(length).times(function() {
return text += nextchar;
});
users[user_num].val('name').insertText(pos, text);
return null;
};
generateReplaceOp = function(user_num) {
var chars, length, nextchar, text;
chars = "abcdefghijklmnopqrstuvwxyz";
length = _.random(0, 10);
nextchar = chars[_.random(0, chars.length - 1)];
text = "";
_(length).times(function() {
return text += nextchar;
});
return users[user_num].val('name').replaceText(text);
};
generateDeleteOp = function(user_num) {
var length, ops1, pos;
if (users[user_num].val('name').val().length > 0) {
pos = _.random(0, users[user_num].val('name').val().length - 1);
length = 1;
ops1 = users[user_num].val('name').deleteText(pos, length);
}
return void 0;
};
generateRandomOp = function(user_num) {
var i, op, op_gen;
op_gen = [generateDeleteOp, generateInsertOp, generateReplaceOp];
i = _.random(op_gen.length - 1);
return op = op_gen[i](user_num);
};
applyRandomOp = function(user_num) {
var user;
user = users[user_num];
return user.getConnector().flushOneRandom();
};
doSomething = (function() {
return function() {
var choice, choices, user_num;
user_num = _.random(number_of_engines - 1);
choices = [applyRandomOp, generateRandomOp];
choice = _.random(choices.length - 1);
return choices[choice](user_num);
};
})();
console.log("");
_results = [];
for (times = _i = 1; 1 <= repeat_this ? _i <= repeat_this : _i >= repeat_this; times = 1 <= repeat_this ? ++_i : --_i) {
users = [];
Connector = Connector_uninitialized(users);
users.push(new Yatta(0, Connector));
users[0].val('name', "initial");
for (i = _j = 1; 1 <= number_of_engines ? _j < number_of_engines : _j > number_of_engines; i = 1 <= number_of_engines ? ++_j : --_j) {
users.push(new Yatta(i, Connector));
}
found_error = false;
time_now = (new Date).getTime();
for (i = _k = 1; 1 <= doSomething_amount ? _k <= doSomething_amount : _k >= doSomething_amount; i = 1 <= doSomething_amount ? ++_k : --_k) {
doSomething();
}
for (user_number = _l = 0, _len = users.length; _l < _len; user_number = ++_l) {
user = users[user_number];
user.getConnector().flushAll();
}
this.time += (new Date()).getTime() - time_now;
number_of_created_operations = 0;
for (i = _m = 0, _ref = users.length; 0 <= _ref ? _m < _ref : _m > _ref; i = 0 <= _ref ? ++_m : --_m) {
number_of_created_operations += users[i].getConnector().getOpsInExecutionOrder().length;
}
this.ops += number_of_created_operations * users.length;
ops_per_msek = Math.floor(this.ops / this.time);
console.log(("" + times + "/" + repeat_this + ": Every collaborator (" + users.length + ") applied " + number_of_created_operations + " ops in a different order.") + (" Over all we consumed " + this.ops + " operations in " + (this.time / 1000) + " seconds (" + ops_per_msek + " ops/msek)."));
console.log(users[0].val('name').val());
_results.push((function() {
var _len1, _n, _o, _ref1, _results1;
_results1 = [];
for (i = _n = 0, _ref1 = users.length - 1; 0 <= _ref1 ? _n < _ref1 : _n > _ref1; i = 0 <= _ref1 ? ++_n : --_n) {
if (users[i].val('name').val() !== users[i + 1].val('name').val()) {
printOpsInExecutionOrder = function(otnumber, otherotnumber) {
var j, o, ops, s, _len1, _len2, _o, _p;
ops = users[otnumber].getConnector().getOpsInExecutionOrder();
for (_o = 0, _len1 = ops.length; _o < _len1; _o++) {
s = ops[_o];
console.log(JSON.stringify(s));
}
console.log("");
s = "ops = [";
for (j = _p = 0, _len2 = ops.length; _p < _len2; j = ++_p) {
o = ops[j];
if (j !== 0) {
s += ", ";
}
s += "op" + j;
}
s += "]";
console.log(s);
console.log("@users[@last_user].ot.applyOps ops");
console.log("expect(@users[@last_user].ot.val('name')).to.equal(\"" + (users[otherotnumber].val('name')) + "\")");
return ops;
};
console.log("");
console.log("Found an OT Puzzle!");
console.log("OT states:");
for (j = _o = 0, _len1 = users.length; _o < _len1; j = ++_o) {
u = users[j];
console.log(("OT" + j + ": ") + u.val('name'));
}
console.log("\nOT execution order (" + i + "," + (i + 1) + "):");
printOpsInExecutionOrder(i, i + 1);
console.log("");
ops = printOpsInExecutionOrder(i + 1, i);
_results1.push(console.log(""));
} else {
_results1.push(void 0);
}
}
return _results1;
})());
}
return _results;
});
});
}).call(this);

View File

@ -30,15 +30,16 @@
}
return done();
});
it("handles inserts correctly", function() {});
return it("can handle many engines, many operations, concurrently (random)", function() {
var Connector, applyRandomOp, doSomething, doSomething_amount, found_error, generateDeleteOp, generateInsertOp, generateRandomOp, generateReplaceOp, i, j, maximum_ops_per_engine, number_of_created_operations, number_of_engines, number_of_test_cases_multiplier, ops, ops_per_msek, printOpsInExecutionOrder, repeat_this, time_now, times, u, user, user_number, users, _i, _j, _k, _l, _len, _m, _ref, _results;
var Connector, applyRandomOp, doSomething, doSomething_amount, found_error, found_inconsistency, generateDeleteOp, generateInsertOp, generateRandomOp, generateReplaceOp, i, j, number_of_created_operations, number_of_engines, number_of_test_cases_multiplier, ops, ops_per_msek, printOpsInExecutionOrder, repeat_this, time_now, times, u, user, user_number, users, _i, _j, _k, _l, _len, _len1, _m, _n, _o, _ref, _ref1, _results;
number_of_test_cases_multiplier = 1;
repeat_this = 1000 * number_of_test_cases_multiplier;
doSomething_amount = 1000 * number_of_test_cases_multiplier;
number_of_engines = 300 + number_of_test_cases_multiplier - 1;
maximum_ops_per_engine = 20 * number_of_test_cases_multiplier;
repeat_this = 1 * number_of_test_cases_multiplier;
doSomething_amount = 500 * number_of_test_cases_multiplier;
number_of_engines = 12 + number_of_test_cases_multiplier - 1;
this.time = 0;
this.ops = 0;
users = [];
generateInsertOp = function(user_num) {
var chars, length, nextchar, pos, text;
chars = "1234567890";
@ -97,7 +98,7 @@
for (times = _i = 1; 1 <= repeat_this ? _i <= repeat_this : _i >= repeat_this; times = 1 <= repeat_this ? ++_i : --_i) {
users = [];
Connector = Connector_uninitialized(users);
for (i = _j = 0; 0 <= number_of_engines ? _j < number_of_engines : _j > number_of_engines; i = 0 <= number_of_engines ? ++_j : --_j) {
for (i = _j = 0; 0 <= number_of_engines ? _j <= number_of_engines : _j >= number_of_engines; i = 0 <= number_of_engines ? ++_j : --_j) {
users.push(new Yatta(i, Connector));
}
found_error = false;
@ -110,12 +111,6 @@
user.getConnector().flushAll();
}
this.time += (new Date()).getTime() - time_now;
/*catch error
found_error = true
console.log "Just found some error!!! :-)"
console.log error
*/
number_of_created_operations = 0;
for (i = _m = 0, _ref = users.length; 0 <= _ref ? _m < _ref : _m > _ref; i = 0 <= _ref ? ++_m : --_m) {
number_of_created_operations += users[i].getConnector().getOpsInExecutionOrder().length;
@ -124,51 +119,51 @@
ops_per_msek = Math.floor(this.ops / this.time);
console.log(("" + times + "/" + repeat_this + ": Every collaborator (" + users.length + ") applied " + number_of_created_operations + " ops in a different order.") + (" Over all we consumed " + this.ops + " operations in " + (this.time / 1000) + " seconds (" + ops_per_msek + " ops/msek)."));
console.log(users[0].val());
_results.push((function() {
var _len1, _n, _o, _ref1, _results1;
_results1 = [];
for (i = _n = 0, _ref1 = users.length - 1; 0 <= _ref1 ? _n < _ref1 : _n > _ref1; i = 0 <= _ref1 ? ++_n : --_n) {
if (users[i].val() !== users[i + 1].val()) {
printOpsInExecutionOrder = function(otnumber, otherotnumber) {
var j, o, ops, s, _len1, _len2, _o, _p;
ops = users[otnumber].getConnector().getOpsInExecutionOrder();
for (_o = 0, _len1 = ops.length; _o < _len1; _o++) {
s = ops[_o];
console.log(JSON.stringify(s));
}
console.log("");
s = "ops = [";
for (j = _p = 0, _len2 = ops.length; _p < _len2; j = ++_p) {
o = ops[j];
if (j !== 0) {
s += ", ";
}
s += "op" + j;
}
s += "]";
console.log(s);
console.log("@users[@last_user].ot.applyOps ops");
console.log("expect(@users[@last_user].ot.val()).to.equal(\"" + (users[otherotnumber].val()) + "\")");
return ops;
};
console.log("");
console.log("Found an OT Puzzle!");
console.log("OT states:");
for (j = _o = 0, _len1 = users.length; _o < _len1; j = ++_o) {
u = users[j];
console.log(("OT" + j + ": ") + u.val());
found_inconsistency = false;
for (i = _n = 0, _ref1 = users.length - 1; 0 <= _ref1 ? _n < _ref1 : _n > _ref1; i = 0 <= _ref1 ? ++_n : --_n) {
if (users[i].val() !== users[i + 1].val()) {
found_inconsistency = true;
printOpsInExecutionOrder = function(otnumber, otherotnumber) {
var j, o, ops, s, _len1, _len2, _o, _p;
ops = users[otnumber].getConnector().getOpsInExecutionOrder();
for (j = _o = 0, _len1 = ops.length; _o < _len1; j = ++_o) {
s = ops[j];
console.log("op" + j + " = " + (JSON.stringify(s)));
}
console.log("\nOT execution order (" + i + "," + (i + 1) + "):");
printOpsInExecutionOrder(i, i + 1);
console.log("");
ops = printOpsInExecutionOrder(i + 1, i);
_results1.push(console.log(""));
} else {
_results1.push(void 0);
s = "ops = [";
for (j = _p = 0, _len2 = ops.length; _p < _len2; j = ++_p) {
o = ops[j];
if (j !== 0) {
s += ", ";
}
s += "op" + j;
}
s += "]";
console.log(s);
console.log("@users[@last_user].ot.applyOps ops");
console.log("expect(@users[@last_user].val()).to.equal(\"" + (users[otherotnumber].val()) + "\")");
return ops;
};
console.log("");
console.log("Found an OT Puzzle!");
console.log("OT states:");
for (j = _o = 0, _len1 = users.length; _o < _len1; j = ++_o) {
u = users[j];
console.log(("OT" + j + ": ") + u.val());
}
console.log("\nOT execution order (" + i + "," + (i + 1) + "):");
printOpsInExecutionOrder(i, i + 1);
console.log("");
ops = printOpsInExecutionOrder(i + 1, i);
console.log("");
}
return _results1;
})());
}
if (found_inconsistency) {
throw new Error("dtrn");
} else {
_results.push(void 0);
}
}
return _results;
});

View File

@ -32,6 +32,16 @@
</ul>
<h2>Class Listing A-Z</h2>
<div class='index'>
<ul>
<li class='letter'>a</li>
<ul>
<li>
<a href='class/AddName.html'>
AddName
</a>
</li>
</ul>
</ul>
<ul>
<li class='letter'>e</li>
<ul>
@ -52,6 +62,31 @@
</li>
</ul>
</ul>
<ul>
<li class='letter'>i</li>
<ul>
<li>
<a href='class/IwcConnector.html'>
IwcConnector
</a>
</li>
</ul>
</ul>
<ul>
<li class='letter'>j</li>
<ul>
<li>
<a href='class/JsonYatta.html'>
JsonYatta
</a>
</li>
<li>
<a href='class/JsonType.html'>
JsonType
</a>
</li>
</ul>
</ul>
<ul>
<li class='letter'>l</li>
<ul>
@ -174,6 +209,40 @@
</li>
</ul>
</ul>
<ul>
<li class='letter'>i</li>
<ul>
<li>
<a href='file/lib/Connectors/IwcConnector.coffee.html'>
IwcConnector.coffee
</a>
<small>
(lib&#47;Connectors)
</small>
</li>
</ul>
</ul>
<ul>
<li class='letter'>j</li>
<ul>
<li>
<a href='file/lib/Frameworks/JsonYatta.coffee.html'>
JsonYatta.coffee
</a>
<small>
(lib&#47;Frameworks)
</small>
</li>
<li>
<a href='file/lib/Types/JsonTypes.coffee.html'>
JsonTypes.coffee
</a>
<small>
(lib&#47;Types)
</small>
</li>
</ul>
</ul>
<ul>
<li class='letter'>s</li>
<ul>
@ -233,7 +302,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

173
doc/class/AddName.html Normal file
View File

@ -0,0 +1,173 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Yatta! Documentation</title>
<script src='../javascript/application.js'></script>
<script src='../javascript/search.js'></script>
<link rel='stylesheet' href='../stylesheets/application.css' type='text/css'>
</head>
<body>
<div id='base' data-path='../'></div>
<div id='header'>
<div id='menu'>
<a href='../extra/README.md.html' title='Yatta!'>
Yatta!
</a>
&raquo;
<a href='../alphabetical_index.html' title='Index'>
Index
</a>
&raquo;
<span class='title'>AddName</span>
</div>
</div>
<div id='content'>
<h1>
Class:
AddName
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>lib&#47;Types&#47;StructuredTypes.coffee</td>
</tr>
<tr>
<td>Inherits:</td>
<td>
types.Operation
</td>
</tr>
</table>
<h2>Instance Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#execute-dynamic'>
#
(void)
<b>execute</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#toJson-dynamic'>
#
(void)
<b>toJson</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
</ul>
<h2>Constructor Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='constructor-dynamic'>
#
(void)
<b>constructor</b><span>(uid, map_manager, name)</span>
<br>
</p>
</div>
</div>
<h2>Instance Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='execute-dynamic'>
#
(void)
<b>execute</b><span>()</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='toJson-dynamic'>
#
(void)
<b>toJson</b><span>()</span>
<br>
</p>
</div>
</div>
</div>
<div id='footer'>
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>
2.0.9
&#10034;
Press H to see the keyboard shortcuts
&#10034;
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
&#10034;
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
Control the navigation frame:
</p>
<ul>
<li>
<span>L</span>
Toggle list view
</li>
<li>
<span>C</span>
Show class list
</li>
<li>
<span>I</span>
Show mixin list
</li>
<li>
<span>F</span>
Show file list
</li>
<li>
<span>M</span>
Show method list
</li>
<li>
<span>E</span>
Show extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
</div>
</body>
</html>

View File

@ -51,13 +51,24 @@
<a href='#applyOps-dynamic'>
#
(void)
<b>applyOps</b><span>(ops)</span>
<b>applyOps</b><span>(ops_json)</span>
</a>
</span>
<span class='desc'>
TODO:
</span>
</li>
<li>
<span class='signature'>
<a href='#cleanUp-dynamic'>
#
(void)
<b>cleanUp</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#applyOp-dynamic'>
@ -97,7 +108,7 @@
<p class='signature' id='applyOps-dynamic'>
#
(void)
<b>applyOps</b><span>(ops)</span>
<b>applyOps</b><span>(ops_json)</span>
<br>
</p>
<div class='docstring'>
@ -105,6 +116,15 @@
</div>
<div class='tags'>
</div>
</div>
<div class='method_details'>
<p class='signature' id='cleanUp-dynamic'>
#
(void)
<b>cleanUp</b><span>()</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='applyOp-dynamic'>
@ -118,7 +138,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -265,7 +265,7 @@ other operations (it wont be executable)</p>
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

227
doc/class/IwcConnector.html Normal file
View File

@ -0,0 +1,227 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Yatta! Documentation</title>
<script src='../javascript/application.js'></script>
<script src='../javascript/search.js'></script>
<link rel='stylesheet' href='../stylesheets/application.css' type='text/css'>
</head>
<body>
<div id='base' data-path='../'></div>
<div id='header'>
<div id='menu'>
<a href='../extra/README.md.html' title='Yatta!'>
Yatta!
</a>
&raquo;
<a href='../alphabetical_index.html' title='Index'>
Index
</a>
&raquo;
<span class='title'>IwcConnector</span>
</div>
</div>
<div id='content'>
<h1>
Class:
IwcConnector
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>lib&#47;Connectors&#47;IwcConnector.coffee</td>
</tr>
</table>
<h2>Instance Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#getRootElement-dynamic'>
#
(void)
<b>getRootElement</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#send-dynamic'>
#
(void)
<b>send</b><span>(o)</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#receive-dynamic'>
#
(void)
<b>receive</b><span>(o)</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#sendIwcIntent-dynamic'>
#
(void)
<b>sendIwcIntent</b><span>(action_name, content)</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#sync-dynamic'>
#
(void)
<b>sync</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
</ul>
<h2>Constructor Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='constructor-dynamic'>
#
(void)
<b>constructor</b><span>(engine, HB, execution_listener, yatta)</span>
<br>
</p>
</div>
</div>
<h2>Instance Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='getRootElement-dynamic'>
#
(void)
<b>getRootElement</b><span>()</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='send-dynamic'>
#
(void)
<b>send</b><span>(o)</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='receive-dynamic'>
#
(void)
<b>receive</b><span>(o)</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='sendIwcIntent-dynamic'>
#
(void)
<b>sendIwcIntent</b><span>(action_name, content)</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='sync-dynamic'>
#
(void)
<b>sync</b><span>()</span>
<br>
</p>
</div>
</div>
</div>
<div id='footer'>
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>
2.0.9
&#10034;
Press H to see the keyboard shortcuts
&#10034;
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
&#10034;
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
Control the navigation frame:
</p>
<ul>
<li>
<span>L</span>
Toggle list view
</li>
<li>
<span>C</span>
Show class list
</li>
<li>
<span>I</span>
Show mixin list
</li>
<li>
<span>F</span>
Show file list
</li>
<li>
<span>M</span>
Show method list
</li>
<li>
<span>E</span>
Show extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
</div>
</body>
</html>

173
doc/class/JsonType.html Normal file
View File

@ -0,0 +1,173 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Yatta! Documentation</title>
<script src='../javascript/application.js'></script>
<script src='../javascript/search.js'></script>
<link rel='stylesheet' href='../stylesheets/application.css' type='text/css'>
</head>
<body>
<div id='base' data-path='../'></div>
<div id='header'>
<div id='menu'>
<a href='../extra/README.md.html' title='Yatta!'>
Yatta!
</a>
&raquo;
<a href='../alphabetical_index.html' title='Index'>
Index
</a>
&raquo;
<span class='title'>JsonType</span>
</div>
</div>
<div id='content'>
<h1>
Class:
JsonType
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>lib&#47;Types&#47;JsonTypes.coffee</td>
</tr>
<tr>
<td>Inherits:</td>
<td>
types.MapManager
</td>
</tr>
</table>
<h2>Instance Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#val-dynamic'>
#
(void)
<b>val</b><span>(name, content)</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#toJson-dynamic'>
#
(void)
<b>toJson</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
</ul>
<h2>Constructor Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='constructor-dynamic'>
#
(void)
<b>constructor</b><span>(uid, initial_value)</span>
<br>
</p>
</div>
</div>
<h2>Instance Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='val-dynamic'>
#
(void)
<b>val</b><span>(name, content)</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='toJson-dynamic'>
#
(void)
<b>toJson</b><span>()</span>
<br>
</p>
</div>
</div>
</div>
<div id='footer'>
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>
2.0.9
&#10034;
Press H to see the keyboard shortcuts
&#10034;
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
&#10034;
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
Control the navigation frame:
</p>
<ul>
<li>
<span>L</span>
Toggle list view
</li>
<li>
<span>C</span>
Show class list
</li>
<li>
<span>I</span>
Show mixin list
</li>
<li>
<span>F</span>
Show file list
</li>
<li>
<span>M</span>
Show method list
</li>
<li>
<span>E</span>
Show extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
</div>
</body>
</html>

247
doc/class/JsonYatta.html Normal file
View File

@ -0,0 +1,247 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Yatta! Documentation</title>
<script src='../javascript/application.js'></script>
<script src='../javascript/search.js'></script>
<link rel='stylesheet' href='../stylesheets/application.css' type='text/css'>
</head>
<body>
<div id='base' data-path='../'></div>
<div id='header'>
<div id='menu'>
<a href='../extra/README.md.html' title='Yatta!'>
Yatta!
</a>
&raquo;
<a href='../alphabetical_index.html' title='Index'>
Index
</a>
&raquo;
<span class='title'>JsonYatta</span>
</div>
</div>
<div id='content'>
<h1>
Class:
JsonYatta
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>lib&#47;Frameworks&#47;JsonYatta.coffee</td>
</tr>
</table>
<h2>Instance Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#getRootElement-dynamic'>
#
(void)
<b>getRootElement</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#getEngine-dynamic'>
#
(void)
<b>getEngine</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#getConnector-dynamic'>
#
(void)
<b>getConnector</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#getHistoryBuffer-dynamic'>
#
(void)
<b>getHistoryBuffer</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#getUserId-dynamic'>
#
(void)
<b>getUserId</b><span>()</span>
</a>
</span>
<span class='desc'>
</span>
</li>
<li>
<span class='signature'>
<a href='#val-dynamic'>
#
(void)
<b>val</b><span>(name, content)</span>
</a>
</span>
<span class='desc'>
</span>
</li>
</ul>
<h2>Constructor Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='constructor-dynamic'>
#
(void)
<b>constructor</b><span>(user_id, Connector)</span>
<br>
</p>
</div>
</div>
<h2>Instance Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='getRootElement-dynamic'>
#
(void)
<b>getRootElement</b><span>()</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='getEngine-dynamic'>
#
(void)
<b>getEngine</b><span>()</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='getConnector-dynamic'>
#
(void)
<b>getConnector</b><span>()</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='getHistoryBuffer-dynamic'>
#
(void)
<b>getHistoryBuffer</b><span>()</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='getUserId-dynamic'>
#
(void)
<b>getUserId</b><span>()</span>
<br>
</p>
</div>
<div class='method_details'>
<p class='signature' id='val-dynamic'>
#
(void)
<b>val</b><span>(name, content)</span>
<br>
</p>
</div>
</div>
</div>
<div id='footer'>
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>
2.0.9
&#10034;
Press H to see the keyboard shortcuts
&#10034;
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
&#10034;
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
Control the navigation frame:
</p>
<ul>
<li>
<span>L</span>
Toggle list view
</li>
<li>
<span>C</span>
Show class list
</li>
<li>
<span>I</span>
Show mixin list
</li>
<li>
<span>F</span>
Show file list
</li>
<li>
<span>M</span>
Show method list
</li>
<li>
<span>E</span>
Show extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
</div>
</body>
</html>

View File

@ -165,7 +165,7 @@ Doesn&#39;t return left-right delimiter.</p>
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -32,15 +32,21 @@
<td>Defined in:</td>
<td>lib&#47;Types&#47;StructuredTypes.coffee</td>
</tr>
<tr>
<td>Inherits:</td>
<td>
types.Operation
</td>
</tr>
</table>
<h2>Instance Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#set-dynamic'>
<a href='#val-dynamic'>
#
(void)
<b>set</b><span>(name, content)</span>
<b>val</b><span>(name, content)</span>
</a>
</span>
<span class='desc'>
@ -53,7 +59,7 @@
<p class='signature' id='constructor-dynamic'>
#
(void)
<b>constructor</b><span>()</span>
<b>constructor</b><span>(uid)</span>
<br>
</p>
@ -62,10 +68,10 @@
<h2>Instance Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='set-dynamic'>
<p class='signature' id='val-dynamic'>
#
(void)
<b>set</b><span>(name, content)</span>
<b>val</b><span>(name, content)</span>
<br>
</p>
@ -73,7 +79,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -41,7 +41,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -132,7 +132,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -59,7 +59,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -213,7 +213,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -53,7 +53,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -149,7 +149,7 @@ This result can be send to other clients.</p>
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -233,7 +233,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -116,7 +116,7 @@
<p class='signature' id='constructor-dynamic'>
#
(void)
<b>constructor</b><span>(uid, prev, next, origin)</span>
<b>constructor</b><span>(uid, initial_content, beginning, end, prev, next, origin)</span>
<br>
</p>
@ -189,7 +189,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -29,6 +29,14 @@
<input type='text'>
</div>
<ul>
<li>
<a href='class/IwcConnector.html' target='main'>
IwcConnector
</a>
<small class='namespace'>
</small>
</li>
<li>
<a href='class/TestConnector.html' target='main'>
TestConnector
@ -45,6 +53,14 @@
</small>
</li>
<li>
<a href='class/JsonYatta.html' target='main'>
JsonYatta
</a>
<small class='namespace'>
</small>
</li>
<li>
<a href='class/TextYatta.html' target='main'>
TextYatta
@ -69,10 +85,38 @@
</small>
</li>
<li>
<a href='class/JsonType.html' target='main'>
JsonType
</a>
<small class='parent'>
<
types.MapManager
</small>
<small class='namespace'>
</small>
</li>
<li>
<a href='class/MapManager.html' target='main'>
MapManager
</a>
<small class='parent'>
<
types.Operation
</small>
<small class='namespace'>
</small>
</li>
<li>
<a href='class/AddName.html' target='main'>
AddName
</a>
<small class='parent'>
<
types.Operation
</small>
<small class='namespace'>
</small>

View File

@ -38,7 +38,7 @@
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -34,11 +34,11 @@
</p>
</nav>
<div id='filecontents'>
<h1 id="yatta-">Yatta!</h1><p>A Collaboration Framework that is not based on the Operational Transformation. </p>
<h1 id="yatta-">Yatta!</h1><p>A Collaboration Framework for arbitrary data structures that is <em>not</em> based on the Operational Transformation.</p>
</div>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -0,0 +1,158 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Yatta! Documentation</title>
<script src='../../../javascript/application.js'></script>
<script src='../../../javascript/search.js'></script>
<link rel='stylesheet' href='../../../stylesheets/application.css' type='text/css'>
</head>
<body>
<div id='base' data-path='../../../'></div>
<div id='header'>
<div id='menu'>
<a href='../../../extra/README.md.html' title='Yatta!'>
Yatta!
</a>
&raquo;
<a href='../../../alphabetical_index.html' title='Index'>
Index
</a>
&raquo;
<span class='title'>lib</span>
&raquo;
<span class='title'>Connectors</span>
&raquo;
<span class='title'>IwcConnector.coffee</span>
</div>
</div>
<div id='content'>
<h1>
File:
IwcConnector.coffee
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>lib&#47;Connectors</td>
</tr>
</table>
<h2>Variables Summary</h2>
<dl class='constants'>
<dt id='module.exports-variable'>
module.exports
=
</dt>
<dd>
<pre><code class='coffeescript'>createIwcConnector</code></pre>
</dd>
<dt id='window.createIwcConnector-variable'>
window.createIwcConnector
=
</dt>
<dd>
<pre><code class='coffeescript'>createIwcConnector</code></pre>
</dd>
</dl>
<h2>Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#createIwcConnector-'>
~
(void)
<b>createIwcConnector</b><span>(callback)</span>
</a>
</span>
<span class='desc'>
</span>
</li>
</ul>
<h2>Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='createIwcConnector-'>
~
(void)
<b>createIwcConnector</b><span>(callback)</span>
<br>
</p>
</div>
</div>
</div>
<div id='footer'>
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>
2.0.9
&#10034;
Press H to see the keyboard shortcuts
&#10034;
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
&#10034;
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
Control the navigation frame:
</p>
<ul>
<li>
<span>L</span>
Toggle list view
</li>
<li>
<span>C</span>
Show class list
</li>
<li>
<span>I</span>
Show mixin list
</li>
<li>
<span>F</span>
Show file list
</li>
<li>
<span>M</span>
Show method list
</li>
<li>
<span>E</span>
Show extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
</div>
</body>
</html>

View File

@ -39,7 +39,7 @@
</table>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -58,7 +58,7 @@
</dl>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -0,0 +1,142 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Yatta! Documentation</title>
<script src='../../../javascript/application.js'></script>
<script src='../../../javascript/search.js'></script>
<link rel='stylesheet' href='../../../stylesheets/application.css' type='text/css'>
</head>
<body>
<div id='base' data-path='../../../'></div>
<div id='header'>
<div id='menu'>
<a href='../../../extra/README.md.html' title='Yatta!'>
Yatta!
</a>
&raquo;
<a href='../../../alphabetical_index.html' title='Index'>
Index
</a>
&raquo;
<span class='title'>lib</span>
&raquo;
<span class='title'>Frameworks</span>
&raquo;
<span class='title'>JsonYatta.coffee</span>
</div>
</div>
<div id='content'>
<h1>
File:
JsonYatta.coffee
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>lib&#47;Frameworks</td>
</tr>
<tr>
<td>
Classes:
</td>
<td>
<a href='../../../class/JsonYatta.html'>
JsonYatta
</a>
</td>
</tr>
</table>
<h2>Variables Summary</h2>
<dl class='constants'>
<dt id='window.JsonYatta-variable'>
window.JsonYatta
=
</dt>
<dd>
<pre><code class='coffeescript'>JsonYatta</code></pre>
</dd>
<dt id='module.exports-variable'>
module.exports
=
</dt>
<dd>
<pre><code class='coffeescript'>JsonYatta</code></pre>
</dd>
</dl>
</div>
<div id='footer'>
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>
2.0.9
&#10034;
Press H to see the keyboard shortcuts
&#10034;
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
&#10034;
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
Control the navigation frame:
</p>
<ul>
<li>
<span>L</span>
Toggle list view
</li>
<li>
<span>C</span>
Show class list
</li>
<li>
<span>I</span>
Show mixin list
</li>
<li>
<span>F</span>
Show file list
</li>
<li>
<span>M</span>
Show method list
</li>
<li>
<span>E</span>
Show extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
</div>
</body>
</html>

View File

@ -60,7 +60,7 @@
</dl>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -58,7 +58,7 @@
</dl>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -39,7 +39,7 @@
</table>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -0,0 +1,113 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Yatta! Documentation</title>
<script src='../../../javascript/application.js'></script>
<script src='../../../javascript/search.js'></script>
<link rel='stylesheet' href='../../../stylesheets/application.css' type='text/css'>
</head>
<body>
<div id='base' data-path='../../../'></div>
<div id='header'>
<div id='menu'>
<a href='../../../extra/README.md.html' title='Yatta!'>
Yatta!
</a>
&raquo;
<a href='../../../alphabetical_index.html' title='Index'>
Index
</a>
&raquo;
<span class='title'>lib</span>
&raquo;
<span class='title'>Types</span>
&raquo;
<span class='title'>JsonTypes.coffee</span>
</div>
</div>
<div id='content'>
<h1>
File:
JsonTypes.coffee
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>lib&#47;Types</td>
</tr>
</table>
</div>
<div id='footer'>
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>
2.0.9
&#10034;
Press H to see the keyboard shortcuts
&#10034;
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
&#10034;
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
Control the navigation frame:
</p>
<ul>
<li>
<span>L</span>
Toggle list view
</li>
<li>
<span>C</span>
Show class list
</li>
<li>
<span>I</span>
Show mixin list
</li>
<li>
<span>F</span>
Show file list
</li>
<li>
<span>M</span>
Show method list
</li>
<li>
<span>E</span>
Show extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
</div>
</body>
</html>

View File

@ -39,7 +39,7 @@
</table>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -39,7 +39,7 @@
</table>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -39,7 +39,7 @@
</table>
</div>
<div id='footer'>
July 29, 14 20:52:59 by
August 02, 14 01:38:26 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -41,6 +41,14 @@
</span>
</li>
<ul>
<li>
<a href='file/lib/Connectors/IwcConnector.coffee.html' target='main'>
IwcConnector.coffee
</a>
<small class='namespace'>
lib&#47;Connectors
</small>
</li>
<li>
<a href='file/lib/Connectors/TestConnector.coffee.html' target='main'>
TestConnector.coffee
@ -65,6 +73,14 @@
</span>
</li>
<ul>
<li>
<a href='file/lib/Frameworks/JsonYatta.coffee.html' target='main'>
JsonYatta.coffee
</a>
<small class='namespace'>
lib&#47;Frameworks
</small>
</li>
<li>
<a href='file/lib/Frameworks/TextYatta.coffee.html' target='main'>
TextYatta.coffee
@ -97,6 +113,14 @@
lib&#47;Types
</small>
</li>
<li>
<a href='file/lib/Types/JsonTypes.coffee.html' target='main'>
JsonTypes.coffee
</a>
<small class='namespace'>
lib&#47;Types
</small>
</li>
<li>
<a href='file/lib/Types/StructuredTypes.coffee.html' target='main'>
StructuredTypes.coffee

File diff suppressed because one or more lines are too long

View File

@ -54,53 +54,21 @@
</small>
</li>
<li>
<a href='class/HistoryBuffer.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(HistoryBuffer)
</small>
</li>
<li>
<a href='class/Replaceable.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(Replaceable)
</small>
</li>
<li>
<a href='class/ReplaceManager.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(ReplaceManager)
</small>
</li>
<li>
<a href='class/ListManager.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(ListManager)
</small>
</li>
<li>
<a href='class/MapManager.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(MapManager)
</small>
</li>
<li>
<a href='class/Engine.html#constructor-dynamic' target='main' title='constructor'>
#constructor
<a href='class/Engine.html#cleanUp-dynamic' target='main' title='cleanUp'>
#cleanUp
</a>
<small>
(Engine)
</small>
</li>
<li>
<a href='class/TextYatta.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(TextYatta)
</small>
</li>
<li>
<a href='class/TestConnector.html#constructor-dynamic' target='main' title='constructor'>
#constructor
@ -109,6 +77,22 @@
(TestConnector)
</small>
</li>
<li>
<a href='class/JsonType.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(JsonType)
</small>
</li>
<li>
<a href='class/ListManager.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(ListManager)
</small>
</li>
<li>
<a href='class/Word.html#constructor-dynamic' target='main' title='constructor'>
#constructor
@ -117,6 +101,30 @@
(Word)
</small>
</li>
<li>
<a href='class/HistoryBuffer.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(HistoryBuffer)
</small>
</li>
<li>
<a href='class/IwcConnector.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(IwcConnector)
</small>
</li>
<li>
<a href='class/Replaceable.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(Replaceable)
</small>
</li>
<li>
<a href='class/TextInsert.html#constructor-dynamic' target='main' title='constructor'>
#constructor
@ -126,11 +134,51 @@
</small>
</li>
<li>
<a href='class/TextYatta.html#constructor-dynamic' target='main' title='constructor'>
<a href='class/JsonYatta.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(TextYatta)
(JsonYatta)
</small>
</li>
<li>
<a href='class/Engine.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(Engine)
</small>
</li>
<li>
<a href='class/AddName.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(AddName)
</small>
</li>
<li>
<a href='class/MapManager.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(MapManager)
</small>
</li>
<li>
<a href='class/ReplaceManager.html#constructor-dynamic' target='main' title='constructor'>
#constructor
</a>
<small>
(ReplaceManager)
</small>
</li>
<li>
<a href='file/lib/Connectors/IwcConnector.coffee.html#createIwcConnector-' target='main' title='createIwcConnector'>
~createIwcConnector
</a>
<small>
(lib&#47;Connectors&#47;IwcConnector.coffee)
</small>
</li>
<li>
@ -149,6 +197,14 @@
(TextYatta)
</small>
</li>
<li>
<a href='class/AddName.html#execute-dynamic' target='main' title='execute'>
#execute
</a>
<small>
(AddName)
</small>
</li>
<li>
<a href='class/TestConnector.html#flushAll-dynamic' target='main' title='flushAll'>
#flushAll
@ -181,6 +237,14 @@
(TextYatta)
</small>
</li>
<li>
<a href='class/JsonYatta.html#getConnector-dynamic' target='main' title='getConnector'>
#getConnector
</a>
<small>
(JsonYatta)
</small>
</li>
<li>
<a href='class/TextYatta.html#getEngine-dynamic' target='main' title='getEngine'>
#getEngine
@ -189,6 +253,14 @@
(TextYatta)
</small>
</li>
<li>
<a href='class/JsonYatta.html#getEngine-dynamic' target='main' title='getEngine'>
#getEngine
</a>
<small>
(JsonYatta)
</small>
</li>
<li>
<a href='class/ListManager.html#getFirstOperation-dynamic' target='main' title='getFirstOperation'>
#getFirstOperation
@ -205,6 +277,14 @@
(TextYatta)
</small>
</li>
<li>
<a href='class/JsonYatta.html#getHistoryBuffer-dynamic' target='main' title='getHistoryBuffer'>
#getHistoryBuffer
</a>
<small>
(JsonYatta)
</small>
</li>
<li>
<a href='class/ListManager.html#getLastOperation-dynamic' target='main' title='getLastOperation'>
#getLastOperation
@ -261,6 +341,22 @@
(TestConnector)
</small>
</li>
<li>
<a href='class/JsonYatta.html#getRootElement-dynamic' target='main' title='getRootElement'>
#getRootElement
</a>
<small>
(JsonYatta)
</small>
</li>
<li>
<a href='class/IwcConnector.html#getRootElement-dynamic' target='main' title='getRootElement'>
#getRootElement
</a>
<small>
(IwcConnector)
</small>
</li>
<li>
<a href='class/TestConnector.html#getRootElement-dynamic' target='main' title='getRootElement'>
#getRootElement
@ -294,11 +390,11 @@
</small>
</li>
<li>
<a href='class/TextYatta.html#insertText-dynamic' target='main' title='insertText'>
#insertText
<a href='class/JsonYatta.html#getUserId-dynamic' target='main' title='getUserId'>
#getUserId
</a>
<small>
(TextYatta)
(JsonYatta)
</small>
</li>
<li>
@ -309,6 +405,14 @@
(Word)
</small>
</li>
<li>
<a href='class/TextYatta.html#insertText-dynamic' target='main' title='insertText'>
#insertText
</a>
<small>
(TextYatta)
</small>
</li>
<li>
<a href='class/Engine.html#parseOperation-dynamic' target='main' title='parseOperation'>
#parseOperation
@ -317,6 +421,14 @@
(Engine)
</small>
</li>
<li>
<a href='class/IwcConnector.html#receive-dynamic' target='main' title='receive'>
#receive
</a>
<small>
(IwcConnector)
</small>
</li>
<li>
<a href='class/TestConnector.html#receive-dynamic' target='main' title='receive'>
#receive
@ -333,6 +445,14 @@
(ReplaceManager)
</small>
</li>
<li>
<a href='class/TextYatta.html#replaceText-dynamic' target='main' title='replaceText'>
#replaceText
</a>
<small>
(TextYatta)
</small>
</li>
<li>
<a href='class/Word.html#replaceText-dynamic' target='main' title='replaceText'>
#replaceText
@ -342,11 +462,11 @@
</small>
</li>
<li>
<a href='class/TextYatta.html#replaceText-dynamic' target='main' title='replaceText'>
#replaceText
<a href='class/IwcConnector.html#send-dynamic' target='main' title='send'>
#send
</a>
<small>
(TextYatta)
(IwcConnector)
</small>
</li>
<li>
@ -358,11 +478,11 @@
</small>
</li>
<li>
<a href='class/MapManager.html#set-dynamic' target='main' title='set'>
#set
<a href='class/IwcConnector.html#sendIwcIntent-dynamic' target='main' title='sendIwcIntent'>
#sendIwcIntent
</a>
<small>
(MapManager)
(IwcConnector)
</small>
</li>
<li>
@ -381,6 +501,14 @@
(TestConnector)
</small>
</li>
<li>
<a href='class/IwcConnector.html#sync-dynamic' target='main' title='sync'>
#sync
</a>
<small>
(IwcConnector)
</small>
</li>
<li>
<a href='class/ListManager.html#toArray-dynamic' target='main' title='toArray'>
#toArray
@ -389,6 +517,38 @@
(ListManager)
</small>
</li>
<li>
<a href='class/ReplaceManager.html#toJson-dynamic' target='main' title='toJson'>
#toJson
</a>
<small>
(ReplaceManager)
</small>
</li>
<li>
<a href='class/AddName.html#toJson-dynamic' target='main' title='toJson'>
#toJson
</a>
<small>
(AddName)
</small>
</li>
<li>
<a href='class/HistoryBuffer.html#toJson-dynamic' target='main' title='toJson'>
#toJson
</a>
<small>
(HistoryBuffer)
</small>
</li>
<li>
<a href='class/JsonType.html#toJson-dynamic' target='main' title='toJson'>
#toJson
</a>
<small>
(JsonType)
</small>
</li>
<li>
<a href='class/TextInsert.html#toJson-dynamic' target='main' title='toJson'>
#toJson
@ -405,22 +565,6 @@
(Word)
</small>
</li>
<li>
<a href='class/ReplaceManager.html#toJson-dynamic' target='main' title='toJson'>
#toJson
</a>
<small>
(ReplaceManager)
</small>
</li>
<li>
<a href='class/HistoryBuffer.html#toJson-dynamic' target='main' title='toJson'>
#toJson
</a>
<small>
(HistoryBuffer)
</small>
</li>
<li>
<a href='class/TextInsert.html#val-dynamic' target='main' title='val'>
#val
@ -429,6 +573,30 @@
(TextInsert)
</small>
</li>
<li>
<a href='class/MapManager.html#val-dynamic' target='main' title='val'>
#val
</a>
<small>
(MapManager)
</small>
</li>
<li>
<a href='class/JsonYatta.html#val-dynamic' target='main' title='val'>
#val
</a>
<small>
(JsonYatta)
</small>
</li>
<li>
<a href='class/TextYatta.html#val-dynamic' target='main' title='val'>
#val
</a>
<small>
(TextYatta)
</small>
</li>
<li>
<a href='class/ReplaceManager.html#val-dynamic' target='main' title='val'>
#val
@ -446,11 +614,11 @@
</small>
</li>
<li>
<a href='class/TextYatta.html#val-dynamic' target='main' title='val'>
<a href='class/JsonType.html#val-dynamic' target='main' title='val'>
#val
</a>
<small>
(TextYatta)
(JsonType)
</small>
</li>
</ul>

View File

@ -0,0 +1,94 @@
createIwcConnector = (callback)->
iwcHandler = {}
duiClient = new DUIClient()
#@duiClient = new iwc.Client()
duiClient.connect (intent)=>
console.log "intent received iwc: #{JSON.stringify(intent)}"
console.log "#{JSON.stringify(@iwcHandler)}"
iwcHandler[intent.action]?.map (f)->
setTimeout ()->
f intent
, 0
duiClient.initOK()
root_element = null
received_HB = null
class IwcConnector
constructor: (@engine, @HB, @execution_listener, @yatta)->
@duiClient = duiClient
@iwcHandler = iwcHandler
send_ = (o)=>
@send o
@execution_listener.push send_
receive_ = (intent)=>
o = intent.extras
@receive o
@iwcHandler["Yatta_new_operation"] = [receive_]
if root_element?
@engine.applyOps received_HB
sendRootElement = ()=>
json = {
root_element : @yatta.getRootElement()
HB : @yatta.getHistoryBuffer().toJson()
}
@sendIwcIntent "Yatta_push_root_element", json
@iwcHandler["Yatta_get_root_element"] = [sendRootElement]
getRootElement: ()->
root_element
send: (o)->
if o.uid.creator is @HB.getUserId() and (typeof o.uid.op_number isnt "string")
@sendIwcIntent "Yatta_new_operation", o
receive: (o)->
if o.uid.creator isnt @HB.getUserId()
@engine.applyOp o
sendIwcIntent: (action_name, content)->
intent =
action: action_name
component: ""
data: ""
dataType: ""
extras: content
@duiClient.publishToUser(intent)
sync: ()->
throw new Error "Can't use this a.t.m."
get_root_intent =
action: "Yatta_get_root_element"
component: ""
data: ""
dataType: ""
extras: {}
init = ()->
duiClient.publishToUser(get_root_intent)
is_initialized = false
receiveRootElement = (json)->
root_element = json?.extras.root_element
received_HB = json?.extras.HB
if not is_initialized
is_initialized = true
callback IwcConnector
iwcHandler["Yatta_push_root_element"] = [receiveRootElement]
setTimeout receiveRootElement, 3000
setTimeout init, 10
undefined
module.exports = createIwcConnector
window?.createIwcConnector = createIwcConnector

View File

@ -8,27 +8,26 @@ module.exports = (user_list)->
@send o
@execution_listener.push send_
@applied_operations = []
appliedOperationsListener = (o)=>
@applied_operations.push o
@execution_listener.push appliedOperationsListener
if not (user_list?.length is 0)
@engine.applyOps user_list[0].getHistoryBuffer().toJson()
@unexecuted = {}
@applied_operations = []
appliedOperationsListener = (o)=>
@applied_operations.push o
@execution_listener.push appliedOperationsListener
getOpsInExecutionOrder: ()->
@applied_operations
getRootElement: ()->
if user_list.length > 0
user_list[0].getRootElement()
user_list[0].getRootElement().getUid()
send: (o)->
if o.creator is @HB.getUserId()
if (o.uid.creator is @HB.getUserId()) and (typeof o.uid.op_number isnt "string")
for user in user_list
if not user.getUserId() is @HB.getUserId()
if user.getUserId() isnt @HB.getUserId()
user.getConnector().receive(o)
receive: (o)->
@ -43,9 +42,8 @@ module.exports = (user_list)->
@flushOne (_.random 0, (user_list.length-1))
flushAll: ()->
for ops of @unexecuted
for n,ops of @unexecuted
@engine.applyOps ops
@unexecuted = {}
sync: ()->
throw new Error "Can't use this a.t.m."

View File

@ -1,4 +1,3 @@
_ = require "underscore"
class Engine
constructor: (@HB, @parser)->
@ -12,21 +11,37 @@ class Engine
throw new Error "You forgot to specify a parser for type #{json.type}. The message is #{JSON.stringify json}."
# TODO:
applyOps: (ops)->
applyOps: (ops_json)->
ops = []
for o in ops_json
ops.push @parseOperation o
for o in ops
@applyOp o
@HB.addOperation o
for o in ops
if not o.execute()
@unprocessed_ops.push o
@cleanUp()
cleanUp: ()->
while true
old_length = @unprocessed_ops.length
unprocessed = []
for op in @unprocessed_ops
if not op.execute()
unprocessed.push op
@unprocessed_ops = unprocessed
if @unprocessed_ops.length is old_length
break
applyOp: (op_json)->
# $parse_and_execute will return false if $o_json was parsed and executed, otherwise the parsed operadion
o = @parseOperation o_json
o = @parseOperation op_json
@HB.addOperation o
if not o.execute()
@unprocessed_ops.push o
unprocessed = []
for op in @unprocessed_ops
if not op.execute()
unprocessed.push op
@unprocessed_ops = unprocessed
@cleanUp()
module.exports = Engine

View File

@ -0,0 +1,40 @@
json_types_uninitialized = require "../Types/JsonTypes.coffee"
HistoryBuffer = require "../HistoryBuffer.coffee"
Engine = require "../Engine.coffee"
class JsonYatta
constructor: (user_id, Connector)->
@HB = new HistoryBuffer user_id
json_types = json_types_uninitialized @HB
@engine = new Engine @HB, json_types.parser
@connector = new Connector @engine, @HB, json_types.execution_listener, @
root_elem = @connector.getRootElement()
if not root_elem?
first_word = new json_types.types.JsonType @HB.getNextOperationIdentifier()
@HB.addOperation(first_word)
first_word.execute()
@root_element = first_word
else
@root_element = @HB.getOperation(root_elem)
getRootElement: ()->
@root_element
getEngine: ()->
@engine
getConnector: ()->
@connector
getHistoryBuffer: ()->
@HB
getUserId: ()->
@HB.getUserId()
val: (name, content)->
@root_element.val(name, content)
window?.JsonYatta = JsonYatta
module.exports = JsonYatta

View File

@ -9,12 +9,14 @@ class TextYatta
text_types = text_types_uninitialized @HB
@engine = new Engine @HB, text_types.parser
@connector = new Connector @engine, @HB, text_types.execution_listener
@root_element = @connector.getRootElement()
if not @root_element?
root_elem = @connector.getRootElement()
if not root_elem?
first_word = new text_types.types.Word @HB.getNextOperationIdentifier()
@HB.addOperation(first_word)
first_word.execute()
@root_element = @HB.addOperation(new text_types.types.ReplaceManager first_word, @HB.getNextOperationIdentifier()).execute()
else
@root_element = @HB.getOperation(root_elem)
getRootElement: ()->
@root_element

View File

@ -1,4 +1,3 @@
_ = require "underscore"
#
# An object that holds all applied operations.
@ -22,13 +21,17 @@ class HistoryBuffer
@user_id
getOperationCounter: ()->
_.clone @operation_counter
res = {}
for user,ctn of @operation_counter
res[user] = ctn
res
toJson: ()->
json = []
for user in @buffer
for o of user
json.push o.toJson()
for u_name,user of @buffer
for o_number,o of user
if not isNaN(parseInt(o_number))
json.push o.toJson()
json
# Get the number of operations that were created by a user.
@ -51,6 +54,7 @@ class HistoryBuffer
getOperation: (uid)->
if uid instanceof Object
@buffer[uid.creator]?[uid.op_number]
else if not uid?
else
throw new Error "This type of uid is not defined!"
@ -70,6 +74,4 @@ class HistoryBuffer
@operation_counter[o.creator]++
o
module.exports = HistoryBuffer

View File

@ -16,6 +16,7 @@ module.exports = (HB)->
{ 'creator': @creator, 'op_number': @op_number }
execute: ()->
@is_executed = true
for l in execution_listener
l @toJson()
@
@ -62,7 +63,7 @@ module.exports = (HB)->
if op
@[name] = op
else
uninstantiated[name] = op
uninstantiated[name] = op_uid
success = false
delete @unchecked
if not success
@ -102,7 +103,7 @@ module.exports = (HB)->
# Define how to parse $Delete operations.
#
parser['Delete'] = ({'uid' : uid, 'deletes': deletes_uid})->
new D uid, deletes_uid
new Delete uid, deletes_uid
#
# A simple insert-type operation.
@ -114,7 +115,6 @@ module.exports = (HB)->
# - The complete-list (abbrev. cl) maintains all operations
#
class Insert extends Operation
# @param {Value} content The value of the insert operation. E.g. for strings content is a char.
# @param {Object} creator A unique user identifier
# @param {Integer} op_number This Number was assigned via getNextOperationIdentifier().
# @param {Operation} prev_cl The predecessor of this operation in the complete-list (cl)
@ -150,6 +150,9 @@ module.exports = (HB)->
if @origin is o
break
d++
#TODO: delete this
if @ is @prev_cl
throw new Error "this should not happen ;) "
o = o.prev_cl
d
@ -175,10 +178,12 @@ module.exports = (HB)->
# Include this operation in the associative lists.
#
execute: ()->
if @is_executed?
return @
if not @validateSavedOperations()
return false
else
if @prev_cl? and @next_cl?
if @prev_cl?.validateSavedOperations() and @next_cl?.validateSavedOperations() and @prev_cl.next_cl isnt @
distance_to_origin = 0
o = @prev_cl.next_cl
i = 0
@ -247,17 +252,19 @@ module.exports = (HB)->
0
execute: ()->
a = @validateSavedOperations()
for l in execution_listener
l @toJson()
a
if @validateSavedOperations()
for l in execution_listener
l @toJson()
@
else
false
toJson: ()->
{
'type' : "Delimiter"
'uid' : @getUid()
'prev' : @prev_cl.getUid()
'next' : @next_cl.getUid()
'prev' : @prev_cl?.getUid()
'next' : @next_cl?.getUid()
}
parser['Delimiter'] = (json)->

View File

@ -0,0 +1,49 @@
text_types_uninitialized = require "./TextTypes.coffee"
module.exports = (HB)->
text_types = text_types_uninitialized HB
types = text_types.types
parser = text_types.parser
class JsonType extends types.MapManager
constructor: (uid, initial_value)->
super uid
if initial_value?
if typeof initial_value isnt "object"
throw new Error "The initial value of JsonTypes must be of type Object! (current type: #{typeof initial_value})"
for name,o of initial_value
@val name, o
val: (name, content)->
if name? and content?
if typeof content is 'string'
word = HB.addOperation(new types.Word HB.getNextOperationIdentifier(), content).execute()
super name, word
content
else if typeof content is 'object'
json = HB.addOperation(JsonType HB.getNextOperationIdentifier(), content).execute()
super name, json
content
else
throw new Error "You must not set #{typeof content}-types in collaborative Json-objects!"
else
super name, content
toJson: ()->
{
'type' : "JsonType"
'uid' : @getUid()
}
parser['JsonType'] = (json)->
{
'uid' : uid
} = json
new JsonType uid
types['JsonType'] = JsonType
text_types

View File

@ -1,4 +1,3 @@
_ = require "underscore"
basic_types_uninitialized = require "./BasicTypes.coffee"
module.exports = (HB)->
@ -6,24 +5,75 @@ module.exports = (HB)->
types = basic_types.types
parser = basic_types.parser
class MapManager
constructor: ()->
class MapManager extends types.Operation
constructor: (uid)->
@map = {}
super uid
set: (name, content)->
if not @map[name]?
@map[name] = new Replaceable HB,
val: (name, content)->
if content?
if not @map[name]?
HB.addOperation(new AddName HB.getNextOperationIdentifier(), @, name).execute()
@map[name].replace content
else if name?
@map[name]?.val()
else
result = {}
for name,o of @map
result[name] = o.val()
result
class AddName extends types.Operation
constructor: (uid, map_manager, @name)->
@saveOperation 'map_manager', map_manager
super uid
execute: ()->
if not @validateSavedOperations()
return false
else
uid_r = @map_manager.getUid()
uid_r.op_number = "_#{uid_r.op_number}_RM_#{@name}"
if not HB.getOperation(uid_r)?
uid_beg = @map_manager.getUid()
uid_beg.op_number = "_#{uid_beg.op_number}_RM_#{@name}_beginning"
uid_end = @map_manager.getUid()
uid_end.op_number = "_#{uid_end.op_number}_RM_#{@name}_end"
beg = HB.addOperation(new types.Delimiter uid_beg, undefined, uid_end)
end = HB.addOperation(new types.Delimiter uid_end, beg, undefined).execute()
beg.execute()
@map_manager.map[@name] = HB.addOperation(new ReplaceManager undefined, uid_r, beg, end).execute()
super
toJson: ()->
{
'type' : "AddName"
'uid' : @getUid()
'map_manager' : @map_manager.getUid()
'name' : @name
}
parser['AddName'] = (json)->
{
'map_manager' : map_manager
'uid' : uid
'name' : name
} = json
new AddName uid, map_manager, name
class ListManager extends types.Insert
constructor: (uid, beginning, end, prev, next, origin)->
if beginning? and end?
saveOperation "beginning", beginning
saveOperation "end", end
@saveOperation 'beginning', beginning
@saveOperation 'end', end
else
@beginning = HB.addOperation new types.Delimiter HB.getNextOperationIdentifier(), undefined, undefined
@end = HB.addOperation new types.Delimiter HB.getNextOperationIdentifier(), @beginning, undefined
@beginning.next_cl = @end
@beginning.execute()
@end.execute()
super uid, prev, next, origin
# Get the element previous to the delemiter at the end
@ -83,8 +133,8 @@ module.exports = (HB)->
{
'type': "ReplaceManager"
'uid' : @getUid()
'beginning' : @beginning
'end' : @end
'beginning' : @beginning.getUid()
'end' : @end.getUid()
}
if @prev_cl? and @next_cl?
json['prev'] = @prev_cl.getUid()
@ -113,8 +163,8 @@ module.exports = (HB)->
constructor: (content, parent, uid, prev, next, origin)->
@saveOperation 'content', content
@saveOperation 'parent', parent
if not (prev? and next?)
throw new Error "You must define prev, and next for Replaceable-types!"
if not (prev? and next? and content?)
throw new Error "You must define content, prev, and next for Replaceable-types!"
super uid, prev, next, origin
#
@ -126,9 +176,12 @@ module.exports = (HB)->
@parent.replace content
execute: ()->
super
@content.setReplaceManager?(@parent)
@
if not @validateSavedOperations()
return false
else
@content.setReplaceManager?(@parent)
super
@
#
# Convert all relevant information of this operation to the json-format.
@ -139,7 +192,7 @@ module.exports = (HB)->
{
'type': "Replaceable"
'content': @content.getUid()
'ReplaceManager' : @parent
'ReplaceManager' : @parent.getUid()
'prev': @prev_cl.getUid()
'next': @next_cl.getUid()
'uid' : @getUid()

View File

@ -1,4 +1,3 @@
_ = require "underscore"
structured_types_uninitialized = require "./StructuredTypes.coffee"
module.exports = (HB)->
@ -69,8 +68,10 @@ module.exports = (HB)->
new TextInsert content, uid, prev, next, origin
class Word extends types.ListManager
constructor: (uid, prev, next, origin)->
super uid, prev, next, origin
constructor: (uid, initial_content, beginning, end, prev, next, origin)->
super uid, beginning, end, prev, next, origin
if initial_content?
@insertText 0, initial_content
# inserts a
insertText: (position, content)->
@ -114,9 +115,10 @@ module.exports = (HB)->
toJson: ()->
json = {
'type': "TextInsert"
'content': @content
'type': "Word"
'uid' : @getUid()
'beginning' : @beginning.getUid()
'end' : @end.getUid()
}
if @prev_cl?
json['prev'] = @prev_cl.getUid()
@ -128,13 +130,14 @@ module.exports = (HB)->
parser['Word'] = (json)->
{
'content' : content
'uid' : uid
'beginning' : beginning
'end' : end
'prev': prev
'next': next
'origin' : origin
} = json
new Word uid, prev, next, origin
new Word uid, undefined, beginning, end, prev, next, origin
types['TextInsert'] = TextInsert
types['TextDelete'] = TextDelete

View File

@ -1 +0,0 @@
_ = require "underscore"

View File

@ -1,31 +1,30 @@
{
"name": "JACK",
"version": "0.0.0",
"description": "Just Another Collaboration frameworK",
"name": "Yatta",
"version": "0.0.1",
"description": "",
"main": "lib/index.js",
"scripts": {
"test": "grunt test"
},
"repository": {
"type": "git",
"url": "https://github.com/DadaMonad/JACK"
"url": "https://github.com/DadaMonad/Yatta"
},
"keywords": [
"OT",
"Complex",
"Data",
"Structures",
"Complex Data Structures",
"XML",
"collaboration"
],
"author": "Kevin Jahns",
"license": "GPLv3",
"license": "LGPL",
"bugs": {
"url": "https://github.com/DadaMonad/JACK/issues"
"url": "https://github.com/DadaMonad/Yatta/issues"
},
"homepage": "https://github.com/DadaMonad/JACK",
"homepage": "https://github.com/DadaMonad/Yatta",
"dependencies": {
"underscore": "^1.6.0"
"underscore": "^1.6.0",
"grunt-contrib-connect": "~0.8.0"
},
"devDependencies": {
"grunt-contrib-coffee": "^0.10.1",

144
test/JsonYatta_test.coffee Normal file
View File

@ -0,0 +1,144 @@
chai = require('chai')
expect = chai.expect
should = chai.should()
sinon = require('sinon')
sinonChai = require('sinon-chai')
_ = require "underscore"
chai.use(sinonChai)
Yatta = require "../lib/Frameworks/JsonYatta.coffee"
Connector_uninitialized = require "../lib/Connectors/TestConnector.coffee"
describe "JsonYatta", ->
beforeEach (done)->
@last_user = 10
@users = []
@Connector = Connector_uninitialized @users
for i in [0..(@last_user+1)]
@users.push(new Yatta i, @Connector)
done()
it "can handle many engines, many operations, concurrently (random)", ->
number_of_test_cases_multiplier = 1
repeat_this = 1 * number_of_test_cases_multiplier
doSomething_amount = 200 * number_of_test_cases_multiplier
number_of_engines = 12 + number_of_test_cases_multiplier - 1
#maximum_ops_per_engine = 20 * number_of_test_cases_multiplier
@time = 0
@ops = 0
users = []
generateInsertOp = (user_num)->
chars = "1234567890"
pos = _.random 0, (users[user_num].val('name').length-1)
length = 1 #_.random 0, 10
nextchar = chars[(_.random 0, (chars.length-1))]
text = ""
_(length).times ()-> text += nextchar
users[user_num].val('name').insertText pos, text
null
generateReplaceOp = (user_num)->
chars = "abcdefghijklmnopqrstuvwxyz"
length = _.random 0, 10
nextchar = chars[(_.random 0, (chars.length-1))]
text = ""
_(length).times ()-> text += nextchar
users[user_num].val('name').replaceText text
generateDeleteOp = (user_num)->
if users[user_num].val('name').val().length > 0
pos = _.random 0, (users[user_num].val('name').val().length-1)
length = 1 # _.random 0, ot.val('name').length - pos
ops1 = users[user_num].val('name').deleteText pos, length
undefined
generateRandomOp = (user_num)->
op_gen = [generateDeleteOp, generateInsertOp, generateReplaceOp]
i = _.random (op_gen.length - 1)
op = op_gen[i](user_num)
applyRandomOp = (user_num)->
user = users[user_num]
user.getConnector().flushOneRandom()
doSomething = do ()->
()->
user_num = _.random (number_of_engines-1)
choices = [applyRandomOp, generateRandomOp]
#if (users[user_num].buffer[user_num].length < maximum_ops_per_engine)
# choices = choices.concat generateRandomOp
choice = _.random (choices.length-1)
choices[choice](user_num)
console.log ""
for times in [1..repeat_this]
#console.log "repeated_this x #{times} times"
users = []
Connector = Connector_uninitialized users
users.push(new Yatta 0, Connector)
users[0].val('name',"initial")
for i in [1...number_of_engines]
users.push(new Yatta i, Connector)
found_error = false
#try
time_now = (new Date).getTime()
for i in [1..doSomething_amount]
doSomething()
for user,user_number in users
user.getConnector().flushAll()
@time += (new Date()).getTime() - time_now
number_of_created_operations = 0
for i in [0...(users.length)]
number_of_created_operations += users[i].getConnector().getOpsInExecutionOrder().length
@ops += number_of_created_operations*users.length
ops_per_msek = Math.floor(@ops/@time)
console.log "#{times}/#{repeat_this}: Every collaborator (#{users.length}) applied #{number_of_created_operations} ops in a different order." + " Over all we consumed #{@ops} operations in #{@time/1000} seconds (#{ops_per_msek} ops/msek)."
console.log users[0].val('name').val()
for i in [0...(users.length-1)]
if ((users[i].val('name').val() isnt users[i+1].val('name').val()) )# and (number_of_created_operations <= 6 or true)) or found_error
printOpsInExecutionOrder = (otnumber, otherotnumber)->
ops = users[otnumber].getConnector().getOpsInExecutionOrder()
for s in ops
console.log JSON.stringify s
console.log ""
s = "ops = ["
for o,j in ops
if j isnt 0
s += ", "
s += "op#{j}"
s += "]"
console.log s
console.log "@users[@last_user].ot.applyOps ops"
console.log "expect(@users[@last_user].ot.val('name')).to.equal(\"#{users[otherotnumber].val('name')}\")"
ops
console.log ""
console.log "Found an OT Puzzle!"
console.log "OT states:"
for u,j in users
console.log "OT#{j}: "+u.val('name')
console.log "\nOT execution order (#{i},#{i+1}):"
printOpsInExecutionOrder i, i+1
console.log ""
ops = printOpsInExecutionOrder i+1, i
console.log ""

View File

@ -19,15 +19,19 @@ describe "TextYatta", ->
@users.push(new Yatta i, @Connector)
done()
it "handles inserts correctly", ->
it "can handle many engines, many operations, concurrently (random)", ->
number_of_test_cases_multiplier = 1
repeat_this = 1000 * number_of_test_cases_multiplier
doSomething_amount = 1000 * number_of_test_cases_multiplier
number_of_engines = 300 + number_of_test_cases_multiplier - 1
maximum_ops_per_engine = 20 * number_of_test_cases_multiplier
repeat_this = 1 * number_of_test_cases_multiplier
doSomething_amount = 500 * number_of_test_cases_multiplier
number_of_engines = 12 + number_of_test_cases_multiplier - 1
#maximum_ops_per_engine = 20 * number_of_test_cases_multiplier
@time = 0
@ops = 0
users = []
generateInsertOp = (user_num)->
chars = "1234567890"
@ -85,8 +89,8 @@ describe "TextYatta", ->
#console.log "repeated_this x #{times} times"
users = []
Connector = Connector_uninitialized users
for i in [0...number_of_engines]
users.push(new Yatta i, Connector)
for i in [0..number_of_engines]
users.push(new Yatta i, Connector)
found_error = false
@ -100,11 +104,6 @@ describe "TextYatta", ->
@time += (new Date()).getTime() - time_now
###catch error
found_error = true
console.log "Just found some error!!! :-)"
console.log error
###
number_of_created_operations = 0
for i in [0...(users.length)]
number_of_created_operations += users[i].getConnector().getOpsInExecutionOrder().length
@ -114,13 +113,14 @@ describe "TextYatta", ->
console.log "#{times}/#{repeat_this}: Every collaborator (#{users.length}) applied #{number_of_created_operations} ops in a different order." + " Over all we consumed #{@ops} operations in #{@time/1000} seconds (#{ops_per_msek} ops/msek)."
console.log users[0].val()
found_inconsistency = false
for i in [0...(users.length-1)]
if ((users[i].val() isnt users[i+1].val()) )# and (number_of_created_operations <= 6 or true)) or found_error
found_inconsistency =true
printOpsInExecutionOrder = (otnumber, otherotnumber)->
ops = users[otnumber].getConnector().getOpsInExecutionOrder()
for s in ops
console.log JSON.stringify s
for s,j in ops
console.log "op#{j} = #{JSON.stringify s}"
console.log ""
s = "ops = ["
for o,j in ops
@ -130,7 +130,7 @@ describe "TextYatta", ->
s += "]"
console.log s
console.log "@users[@last_user].ot.applyOps ops"
console.log "expect(@users[@last_user].ot.val()).to.equal(\"#{users[otherotnumber].val()}\")"
console.log "expect(@users[@last_user].val()).to.equal(\"#{users[otherotnumber].val()}\")"
ops
console.log ""
console.log "Found an OT Puzzle!"
@ -143,6 +143,8 @@ describe "TextYatta", ->
ops = printOpsInExecutionOrder i+1, i
console.log ""
if found_inconsistency
throw new Error "dtrn"
# expect(users[i].ot.val()).to.equal(users[i+1].ot.val())