Documentation and cleanup
This commit is contained in:
@@ -10,7 +10,7 @@ Engine = require "../Engine"
|
||||
# * Integer
|
||||
# * Array
|
||||
#
|
||||
class JsonYatta
|
||||
class JsonFramework
|
||||
|
||||
#
|
||||
# @param {String} user_id Unique id of the peer.
|
||||
@@ -22,23 +22,16 @@ class JsonYatta
|
||||
@types = type_manager.types
|
||||
@engine = new Engine @HB, type_manager.parser
|
||||
@connector = new Connector @engine, @HB, type_manager.execution_listener, @
|
||||
|
||||
first_word = new @types.JsonType @HB.getReservedUniqueIdentifier()
|
||||
@HB.addOperation(first_word).execute()
|
||||
@root_element = first_word
|
||||
|
||||
#
|
||||
# @result JsonType
|
||||
# @return JsonType
|
||||
#
|
||||
getSharedObject: ()->
|
||||
@root_element
|
||||
|
||||
#
|
||||
# @see Engine
|
||||
#
|
||||
getEngine: ()->
|
||||
@engine
|
||||
|
||||
#
|
||||
# Get the initialized connector.
|
||||
#
|
||||
@@ -60,7 +53,7 @@ class JsonYatta
|
||||
#
|
||||
# Get the UserId from the HistoryBuffer object.
|
||||
# In most cases this will be the same as the user_id value with which
|
||||
# JsonYatta was initialized (Depending on the HistoryBuffer implementation).
|
||||
# JsonFramework was initialized (Depending on the HistoryBuffer implementation).
|
||||
#
|
||||
getUserId: ()->
|
||||
@HB.getUserId()
|
||||
@@ -77,16 +70,22 @@ class JsonYatta
|
||||
val : (name, content, mutable)->
|
||||
@root_element.val(name, content, mutable)
|
||||
|
||||
#
|
||||
# @see Operation.on
|
||||
#
|
||||
on: ()->
|
||||
@root_element.on arguments...
|
||||
|
||||
#
|
||||
# @see Operation.deleteListener
|
||||
#
|
||||
deleteListener: ()->
|
||||
@root_element.deleteListener arguments...
|
||||
|
||||
#
|
||||
# @see JsonType.value
|
||||
#
|
||||
Object.defineProperty JsonYatta.prototype, 'value',
|
||||
Object.defineProperty JsonFramework.prototype, 'value',
|
||||
get : -> @root_element.value
|
||||
set : (o)->
|
||||
if o.constructor is {}.constructor
|
||||
@@ -95,8 +94,8 @@ class JsonYatta
|
||||
else
|
||||
throw new Error "You must only set Object values!"
|
||||
|
||||
module.exports = JsonYatta
|
||||
module.exports = JsonFramework
|
||||
if window?
|
||||
if not window.Y?
|
||||
window.Y = {}
|
||||
window.Y.JsonYatta = JsonYatta
|
||||
window.Y.JsonFramework = JsonFramework
|
||||
@@ -6,7 +6,7 @@ Engine = require "../Engine"
|
||||
#
|
||||
# Framework for Text Datastructures.
|
||||
#
|
||||
class TextYatta
|
||||
class TextFramework
|
||||
|
||||
#
|
||||
# @param {String} user_id Uniqe user id that defines this peer.
|
||||
@@ -24,7 +24,7 @@ class TextYatta
|
||||
beginning.next_cl = end
|
||||
beginning.execute()
|
||||
end.execute()
|
||||
first_word = new @types.Word {creator: '_', op_number: '_'}, beginning, end
|
||||
first_word = new @types.WordType {creator: '_', op_number: '_'}, beginning, end
|
||||
@HB.addOperation(first_word).execute()
|
||||
|
||||
uid_r = { creator: '_', op_number: "RM" }
|
||||
@@ -37,17 +37,11 @@ class TextYatta
|
||||
|
||||
|
||||
#
|
||||
# @result Word
|
||||
# @return WordType
|
||||
#
|
||||
getSharedObject: ()->
|
||||
@root_element.val()
|
||||
|
||||
#
|
||||
# @see Engine
|
||||
#
|
||||
getEngine: ()->
|
||||
@engine
|
||||
|
||||
#
|
||||
# Get the initialized connector.
|
||||
#
|
||||
@@ -63,7 +57,7 @@ class TextYatta
|
||||
#
|
||||
# Get the UserId from the HistoryBuffer object.
|
||||
# In most cases this will be the same as the user_id value with which
|
||||
# JsonYatta was initialized (Depending on the HistoryBuffer implementation).
|
||||
# JsonFramework was initialized (Depending on the HistoryBuffer implementation).
|
||||
#
|
||||
getUserId: ()->
|
||||
@HB.getUserId()
|
||||
@@ -75,35 +69,38 @@ class TextYatta
|
||||
@getSharedObject().val()
|
||||
|
||||
#
|
||||
# @see Word.insertText
|
||||
# @see WordType.insertText
|
||||
#
|
||||
insertText: (pos, content)->
|
||||
@getSharedObject().insertText pos, content
|
||||
|
||||
#
|
||||
# @see Word.deleteText
|
||||
# @see WordType.deleteText
|
||||
#
|
||||
deleteText: (pos, length)->
|
||||
@getSharedObject().deleteText pos, length
|
||||
|
||||
#
|
||||
# @see Word.bind
|
||||
# @see WordType.bind
|
||||
#
|
||||
bind: (textarea)->
|
||||
@getSharedObject().bind textarea
|
||||
|
||||
#
|
||||
# @see Word.replaceText
|
||||
# @see WordType.replaceText
|
||||
#
|
||||
replaceText: (text)->
|
||||
@getSharedObject().replaceText text
|
||||
|
||||
#
|
||||
# @see Operation.on
|
||||
#
|
||||
on: ()->
|
||||
@root_element.on arguments...
|
||||
|
||||
|
||||
module.exports = TextYatta
|
||||
module.exports = TextFramework
|
||||
if window?
|
||||
if not window.Y?
|
||||
window.Y = {}
|
||||
window.Y.TextYatta = TextYatta
|
||||
window.Y.TextFramework = TextFramework
|
||||
Reference in New Issue
Block a user