Permalink
Browse files

Tabs -> 2 spaces

  • Loading branch information...
1 parent 5113f6d commit 21a43fc95bce7cb86476bf208bbb0777000a0012 @josephg committed Oct 20, 2011
Showing with 6,121 additions and 6,121 deletions.
  1. +38 −38 package.json
  2. +116 −116 src/client/ace.coffee
  3. +189 −189 src/client/connection.coffee
  4. +150 −150 src/client/doc.coffee
  5. +40 −40 src/client/index.coffee
  6. +30 −30 src/client/microevent.coffee
  7. +48 −48 src/client/textarea.coffee
  8. +3 −3 src/client/web-prelude.coffee
  9. +8 −8 src/server/db/index.coffee
  10. +80 −80 src/server/db/memory.coffee
  11. +142 −142 src/server/db/redis.coffee
  12. +55 −55 src/server/events.coffee
  13. +11 −11 src/server/index.coffee
  14. +256 −256 src/server/model.coffee
  15. +96 −96 src/server/rest.coffee
  16. +300 −300 src/server/socketio.coffee
  17. +15 −15 src/server/syncqueue.coffee
  18. +8 −8 src/types/count.coffee
  19. +47 −47 src/types/helpers.coffee
  20. +3 −3 src/types/index.coffee
  21. +386 −386 src/types/json.coffee
  22. +8 −8 src/types/simple.coffee
  23. +23 −23 src/types/text-api.coffee
  24. +36 −36 src/types/text-composable-api.coffee
  25. +201 −201 src/types/text-composable.coffee
  26. +68 −68 src/types/text-tp2-api.coffee
  27. +232 −232 src/types/text-tp2.coffee
  28. +122 −122 src/types/text.coffee
  29. +390 −390 test/auth.coffee
  30. +443 −443 test/client.coffee
  31. +171 −171 test/db.coffee
  32. +159 −159 test/events.coffee
  33. +34 −34 test/helpers/misc.coffee
  34. +145 −145 test/helpers/randomizer.coffee
  35. +7 −7 test/helpers/webclient.coffee
  36. +131 −131 test/integration.coffee
  37. +99 −99 test/microevent.coffee
  38. +203 −203 test/model.coffee
  39. +224 −224 test/rest.coffee
  40. +17 −17 test/server.coffee
  41. +359 −359 test/socketio.coffee
  42. +29 −29 test/syncqueue.coffee
  43. +17 −17 test/testhelpers.coffee
  44. +17 −17 test/testingtools.coffee
  45. +2 −2 test/types/count.coffee
  46. +506 −506 test/types/json.coffee
  47. +2 −2 test/types/randomWord.coffee
  48. +65 −65 test/types/text-api.coffee
  49. +65 −65 test/types/text-composable.coffee
  50. +127 −127 test/types/text-tp2.coffee
  51. +171 −171 test/types/text.coffee
  52. +7 −7 test/version.coffee
  53. +20 −20 tests.coffee
View
@@ -1,40 +1,40 @@
{
- "name": "share",
- "version": "0.5.0",
- "description": "A database for concurrent document editing",
- "keywords": ["operational transformation", "ot", "concurrent", "collaborative", "database", "server"],
- "homepage": "",
- "author": "Joseph Gentle <josephg@gmail.com>",
- "main": "index.js",
- "bin": {
- "sharejs": "bin/sharejs",
- "sharejs-exampleserver": "bin/exampleserver"
- },
- "dependencies": {
- "socket.io": "~0.8",
- "socket.io-client": "~0.8",
- "connect": ">= 1.1.1 < 2.0.0",
- "optimist": ">= 0.2.4",
- "uglify-js": "~1",
- "request": ">= 2.1.1",
- "underscore": ">= 1.1.7",
- "coffee-script": "> 1.1.0",
- "hat": "*"
- },
- "devDependencies": {
- "nodeunit": "~0.5.0"
- },
- "engine": "node >= 0.4.4",
- "scripts": {
- "build": "cake build",
- "test": "nodeunit tests.coffee"
- },
- "licenses": [{
- "type": "BSD",
- "url": "http://www.freebsd.org/copyright/freebsd-license.html"
- }],
- "repository": {
- "type": "git",
- "url": "http://github.com/josephg/sharejs.git"
- }
+ "name": "share",
+ "version": "0.5.0",
+ "description": "A database for concurrent document editing",
+ "keywords": ["operational transformation", "ot", "concurrent", "collaborative", "database", "server"],
+ "homepage": "",
+ "author": "Joseph Gentle <josephg@gmail.com>",
+ "main": "index.js",
+ "bin": {
+ "sharejs": "bin/sharejs",
+ "sharejs-exampleserver": "bin/exampleserver"
+ },
+ "dependencies": {
+ "socket.io": "~0.8",
+ "socket.io-client": "~0.8",
+ "connect": ">= 1.1.1 < 2.0.0",
+ "optimist": ">= 0.2.4",
+ "uglify-js": "~1",
+ "request": ">= 2.1.1",
+ "underscore": ">= 1.1.7",
+ "coffee-script": "> 1.1.0",
+ "hat": "*"
+ },
+ "devDependencies": {
+ "nodeunit": "~0.5.0"
+ },
+ "engine": "node >= 0.4.4",
+ "scripts": {
+ "build": "cake build",
+ "test": "nodeunit tests.coffee"
+ },
+ "licenses": [{
+ "type": "BSD",
+ "url": "http://www.freebsd.org/copyright/freebsd-license.html"
+ }],
+ "repository": {
+ "type": "git",
+ "url": "http://github.com/josephg/sharejs.git"
+ }
}
View
@@ -4,125 +4,125 @@ Range = require("ace/range").Range
# Convert an ace delta into an op understood by share.js
applyToShareJS = (editorDoc, delta, doc) ->
- # Get the start position of the range, in no. of characters
- getStartOffsetPosition = (range) ->
- # This is quite inefficient - getLines makes a copy of the entire
- # lines array in the document. It would be nice if we could just
- # access them directly.
- lines = editorDoc.getLines 0, range.start.row
-
- offset = 0
-
- for line, i in lines
- offset += if i < range.start.row
- line.length
- else
- range.start.column
-
- # Add the row number to include newlines.
- offset + range.start.row
-
- pos = getStartOffsetPosition(delta.range)
-
- switch delta.action
- when 'insertText' then doc.insert delta.text, pos
- when 'removeText' then doc.del delta.text.length, pos
-
- when 'insertLines'
- text = delta.lines.join('\n') + '\n'
- doc.insert text, pos
-
- when 'removeLines'
- text = delta.lines.join('\n') + '\n'
- doc.del text.length, pos
-
- else throw new Error "unknown action: #{delta.action}"
-
- return
+ # Get the start position of the range, in no. of characters
+ getStartOffsetPosition = (range) ->
+ # This is quite inefficient - getLines makes a copy of the entire
+ # lines array in the document. It would be nice if we could just
+ # access them directly.
+ lines = editorDoc.getLines 0, range.start.row
+
+ offset = 0
+
+ for line, i in lines
+ offset += if i < range.start.row
+ line.length
+ else
+ range.start.column
+
+ # Add the row number to include newlines.
+ offset + range.start.row
+
+ pos = getStartOffsetPosition(delta.range)
+
+ switch delta.action
+ when 'insertText' then doc.insert delta.text, pos
+ when 'removeText' then doc.del delta.text.length, pos
+
+ when 'insertLines'
+ text = delta.lines.join('\n') + '\n'
+ doc.insert text, pos
+
+ when 'removeLines'
+ text = delta.lines.join('\n') + '\n'
+ doc.del text.length, pos
+
+ else throw new Error "unknown action: #{delta.action}"
+
+ return
# Attach an ace editor to the document. The editor's contents are replaced
# with the document's contents unless keepEditorContents is true. (In which case the document's
# contents are nuked and replaced with the editor's).
window.sharejs.Doc::attach_ace = (editor, keepEditorContents) ->
- throw new Error 'Only text documents can be attached to ace' unless @provides['text']
-
- doc = this
- editorDoc = editor.getSession().getDocument()
- editorDoc.setNewLineMode 'unix'
-
- check = ->
- window.setTimeout ->
- editorText = editorDoc.getValue()
- otText = doc.getText()
-
- if editorText != otText
- console.error "Text does not match!"
- console.error "editor: #{editorText}"
- console.error "ot: #{otText}"
- # Should probably also replace the editor text with the doc snapshot.
- , 0
-
- if keepEditorContents
- doc.del doc.getText().length, 0
- doc.insert editorDoc.getValue(), 0
- else
- editorDoc.setValue doc.getText()
-
- check()
-
- # When we apply ops from sharejs, ace emits edit events. We need to ignore those
- # to prevent an infinite typing loop.
- suppress = false
-
- # Listen for edits in ace
- editorListener = (change) ->
- return if suppress
- applyToShareJS editorDoc, change.data, doc
-
- check()
-
- editorDoc.on 'change', editorListener
-
- # Listen for remote ops on the sharejs document
- docListener = (op) ->
- suppress = true
- applyToDoc editorDoc, op
- suppress = false
-
- check()
-
-
- # Horribly inefficient.
- offsetToPos = (offset) ->
- # Again, very inefficient.
- lines = editorDoc.getAllLines()
-
- row = 0
- for line, row in lines
- break if offset <= line.length
-
- # +1 for the newline.
- offset -= lines[row].length + 1
-
- row:row, column:offset
-
- doc.on 'insert', (text, pos) ->
- suppress = true
- editorDoc.insert offsetToPos(pos), text
- suppress = false
- check()
-
- doc.on 'delete', (text, pos) ->
- suppress = true
- range = Range.fromPoints offsetToPos(pos), offsetToPos(pos + text.length)
- editorDoc.remove range
- suppress = false
- check()
-
- doc.detach_ace = ->
- doc.removeListener 'remoteop', docListener
- editorDoc.removeListener 'change', editorListener
- delete doc.detach_ace
-
- return
+ throw new Error 'Only text documents can be attached to ace' unless @provides['text']
+
+ doc = this
+ editorDoc = editor.getSession().getDocument()
+ editorDoc.setNewLineMode 'unix'
+
+ check = ->
+ window.setTimeout ->
+ editorText = editorDoc.getValue()
+ otText = doc.getText()
+
+ if editorText != otText
+ console.error "Text does not match!"
+ console.error "editor: #{editorText}"
+ console.error "ot: #{otText}"
+ # Should probably also replace the editor text with the doc snapshot.
+ , 0
+
+ if keepEditorContents
+ doc.del doc.getText().length, 0
+ doc.insert editorDoc.getValue(), 0
+ else
+ editorDoc.setValue doc.getText()
+
+ check()
+
+ # When we apply ops from sharejs, ace emits edit events. We need to ignore those
+ # to prevent an infinite typing loop.
+ suppress = false
+
+ # Listen for edits in ace
+ editorListener = (change) ->
+ return if suppress
+ applyToShareJS editorDoc, change.data, doc
+
+ check()
+
+ editorDoc.on 'change', editorListener
+
+ # Listen for remote ops on the sharejs document
+ docListener = (op) ->
+ suppress = true
+ applyToDoc editorDoc, op
+ suppress = false
+
+ check()
+
+
+ # Horribly inefficient.
+ offsetToPos = (offset) ->
+ # Again, very inefficient.
+ lines = editorDoc.getAllLines()
+
+ row = 0
+ for line, row in lines
+ break if offset <= line.length
+
+ # +1 for the newline.
+ offset -= lines[row].length + 1
+
+ row:row, column:offset
+
+ doc.on 'insert', (text, pos) ->
+ suppress = true
+ editorDoc.insert offsetToPos(pos), text
+ suppress = false
+ check()
+
+ doc.on 'delete', (text, pos) ->
+ suppress = true
+ range = Range.fromPoints offsetToPos(pos), offsetToPos(pos + text.length)
+ editorDoc.remove range
+ suppress = false
+ check()
+
+ doc.detach_ace = ->
+ doc.removeListener 'remoteop', docListener
+ editorDoc.removeListener 'change', editorListener
+ delete doc.detach_ace
+
+ return
Oops, something went wrong. Retry.

0 comments on commit 21a43fc

Please sign in to comment.