begin implementing xml support

This commit is contained in:
Kevin Jahns 2014-09-26 10:48:21 +02:00
parent b750d95b98
commit 977e4d2a7c
30 changed files with 157 additions and 51 deletions

View File

@ -74,7 +74,8 @@
HistoryBuffer.prototype.getReservedUniqueIdentifier = function() { HistoryBuffer.prototype.getReservedUniqueIdentifier = function() {
return { return {
creator: '_', creator: '_',
op_number: "_" + (this.reserved_identifier_counter++) op_number: "_" + (this.reserved_identifier_counter++),
doSync: false
}; };
}; };

File diff suppressed because one or more lines are too long

View File

@ -231,24 +231,11 @@
</li> </li>
</ul> </ul>
</ul> </ul>
<ul>
<li class='letter'>x</li>
<ul>
<li>
<a href='file/lib/Types/XmlTypes.coffee.html'>
XmlTypes.coffee
</a>
<small>
(lib&#47;Types)
</small>
</li>
</ul>
</ul>
</div> </div>
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -302,7 +302,7 @@ data from the received intent.</p>
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -335,7 +335,7 @@ JsonFramework was initialized (Depending on the HistoryBuffer implementation).</
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -466,7 +466,7 @@ if (x.type === &quot;JsonType&quot;) {
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -139,7 +139,7 @@ console.log(w.newProperty == &quot;Awesome&quot;) # true!</code></pre>
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -222,7 +222,7 @@ on how to do that with urls.</p>
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -356,7 +356,7 @@ JsonFramework was initialized (Depending on the HistoryBuffer implementation).</
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -415,7 +415,7 @@ yatta.bind(textbox);</code></pre>
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -38,7 +38,7 @@
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -70,7 +70,7 @@ But I would become really motivated if you gave me some feedback :) (<a href="ht
<ul> <ul>
<li>XML support</li> <li>XML support</li>
</ul> </ul>
<h2 id="support">Support</h2><p>Please report any issues to the <a href="https://github.com/DadaMonad/Yatta/issues">Github issue page</a>!</p><h2 id="license">License</h2><p>Yatta! is licensed under the <a href="./LICENSE.txt">MIT License</a>.</p><a href="&#x6d;&#97;&#x69;&#108;&#116;&#x6f;&#58;&#x6b;&#x65;&#118;&#x69;&#110;&#46;&#106;&#x61;&#104;&#110;&#x73;&#64;&#114;&#119;&#116;&#x68;&#45;&#x61;&#97;&#x63;&#x68;&#x65;&#x6e;&#46;&#x64;&#x65;">&#x6b;&#x65;&#118;&#x69;&#110;&#46;&#106;&#x61;&#104;&#110;&#x73;&#64;&#114;&#119;&#116;&#x68;&#45;&#x61;&#97;&#x63;&#x68;&#x65;&#x6e;&#46;&#x64;&#x65;</a> <h2 id="support">Support</h2><p>Please report any issues to the <a href="https://github.com/DadaMonad/Yatta/issues">Github issue page</a>!</p><h2 id="license">License</h2><p>Yatta! is licensed under the <a href="./LICENSE.txt">MIT License</a>.</p><a href="&#x6d;&#x61;&#105;&#x6c;&#x74;&#x6f;&#x3a;&#x6b;&#101;&#x76;&#105;&#x6e;&#x2e;&#x6a;&#97;&#x68;&#x6e;&#115;&#64;&#x72;&#119;&#x74;&#x68;&#45;&#97;&#x61;&#99;&#x68;&#x65;&#x6e;&#x2e;&#x64;&#x65;">&#x6b;&#101;&#x76;&#105;&#x6e;&#x2e;&#x6a;&#97;&#x68;&#x6e;&#115;&#64;&#x72;&#119;&#x74;&#x68;&#45;&#97;&#x61;&#99;&#x68;&#x65;&#x6e;&#x2e;&#x64;&#x65;</a>
@ -79,7 +79,7 @@ But I would become really motivated if you gave me some feedback :) (<a href="ht
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -100,7 +100,7 @@
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -158,7 +158,7 @@
</div> </div>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -39,7 +39,7 @@
</table> </table>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -48,7 +48,7 @@
</dl> </dl>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -60,7 +60,7 @@
</dl> </dl>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -60,7 +60,7 @@
</dl> </dl>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -48,7 +48,7 @@
</dl> </dl>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -39,7 +39,7 @@
</table> </table>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -39,7 +39,7 @@
</table> </table>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -39,7 +39,7 @@
</table> </table>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -39,7 +39,7 @@
</table> </table>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -37,7 +37,7 @@
</table> </table>
</div> </div>
<div id='footer'> <div id='footer'>
September 17, 14 18:11:46 by September 23, 14 12:59:35 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'> <a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo Codo
</a> </a>

View File

@ -145,14 +145,6 @@
lib&#47;Types lib&#47;Types
</small> </small>
</li> </li>
<li>
<a href='file/lib/Types/XmlTypes.coffee.html' target='main'>
XmlTypes.coffee
</a>
<small class='namespace'>
lib&#47;Types
</small>
</li>
</ul> </ul>
<li> <li>

File diff suppressed because one or more lines are too long

View File

@ -69,6 +69,7 @@ class HistoryBuffer
{ {
creator : '_' creator : '_'
op_number : "_#{@reserved_identifier_counter++}" op_number : "_#{@reserved_identifier_counter++}"
doSync: false
} }
# #

View File

@ -26,13 +26,14 @@ module.exports = (HB)->
@is_deleted = false @is_deleted = false
@doSync = true @doSync = true
@garbage_collected = false @garbage_collected = false
if uid? if not uid?
@doSync = not isNaN(parseInt(uid.op_number))
else
uid = HB.getNextOperationIdentifier() uid = HB.getNextOperationIdentifier()
if not uid.doSync?
uid.doSync = not isNaN(parseInt(uid.op_number))
{ {
'creator': @creator 'creator': @creator
'op_number' : @op_number 'op_number' : @op_number
'doSync' : @doSync
} = uid } = uid
type: "Insert" type: "Insert"

View File

@ -341,7 +341,6 @@ module.exports = (HB)->
if @content? if @content?
@content.applyDelete() @content.applyDelete()
@content.dontSync() @content.dontSync()
@beforeDelete = @content # TODO!!!!!!!!!!
@content = null @content = null
super super

View File

@ -0,0 +1,125 @@
json_types_uninitialized = require "./JsonTypes"
module.exports = (HB)->
json_types = json_types_uninitialized HB
types = json_types.types
parser = json_types.parser
#
# Manages XML types
#
class XmlType extends types.Insert
constructor: (uid, @tagname, attributes, elements, prev_cl, next_cl, origin)->
super uid, prev_cl, next_cl, origin
if attributes? and elements?
@saveOperation 'attributes', attributes
@saveOperation 'elements', elements
else if (not attributes?) and (not elements?)
@attributes = new types.JsonType()
HB.addOperation(@attributes).execute()
@elements = new types.WordType()
HB.addOperation(@elements).execute()
else
throw new Error "Either define attribute and elements both, or none of them"
#
# Identifies this class.
# Use it in order to check whether this is an xml-type or something else.
#
type: "XmlType"
applyDelete: ()->
@attributes.applyDelete()
@elements.applyDelete()
super()
cleanup: ()->
super()
val: ()->
if document?
if arguments.length is 0
if not @xml?
@xml = document.createElement @tagname
attr = @attributes.val()
for attr_name, value of attr
a = document.createAttribute attr_name
a.value = value
@xml.setAttributeNode a
e = @elements.beginning.next_cl
while e.type isnt "Delimiter"
if not e.isDeleted()
@xml.appendChild e.val()
e.next_cl
@xml
else if arguments.length is 1
else
throw new Error "Can only parse one parameter"
#
# If possible set the replace manager in the content.
# @see WordType.setReplaceManager
#
execute: ()->
super
###
if not @validateSavedOperations()
return false
else
return true
###
#
# Get the parent of this JsonType.
# @return {XmlType}
#
getParent: ()->
@parent
#
# @private
#
# Convert all relevant information of this operation to the json-format.
# This result can be send to other clients.
#
_encode: ()->
json =
{
'type' : @type
'attributes' : @attributes.getUid()
'elements' : @elements.getUid()
'tagname' : @tagname
'uid' : @getUid()
'uid' : @getUid()
'prev': @prev_cl.getUid()
'next': @next_cl.getUid()
}
if @origin isnt @prev_cl
json["origin"] = @origin.getUid()
json
parser['XmlType'] = (json)->
{
'uid' : uid
'attributes' : attributes
'elements' : elements
'tagname' : tagname
'prev': prev
'next': next
'origin' : origin
} = json
new XmlType uid, tagname, attributes, elements, prev, next, origin
types['XmlType'] = XmlType
json_types