Skip to content

Commit

Permalink
Minor tweaks to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
josephg committed Sep 17, 2011
1 parent 3361bbb commit f2e3d90
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 37 deletions.
13 changes: 8 additions & 5 deletions examples/ace/index.html
Expand Up @@ -43,13 +43,16 @@
});
};

window.onload = function() {
editor = ace.edit("editor");
window.onload = function() {
editor = ace.edit("editor");
editor.session.setUseWrapMode(true);

// For fun, we'll go into coffeescript syntax mode.
//var CoffeeScriptMode = require("ace/mode/coffee").Mode;
//editor.getSession().setMode(new CoffeeScriptMode());
var CoffeeScriptMode = require("ace/mode/coffee").Mode;
var session = editor.getSession();
session.setMode(new CoffeeScriptMode());
session.setTabSize(2);
session.setUseSoftTabs(true);

setDoc('ace');

Expand All @@ -67,7 +70,7 @@
} else {
namefield.attachEvent('oninput', fn);
}
};
};
</script>
</body>
</html>
Expand Down
31 changes: 0 additions & 31 deletions examples/file.js

This file was deleted.

36 changes: 36 additions & 0 deletions examples/sharefile.coffee
@@ -0,0 +1,36 @@
# This script watches for changes in a document and constantly resaves a file
# with the document's contents.

#client = require('share').client
client = require('../src').client
fs = require('fs')

argv = require('optimist')
.usage('Usage: $0 -d docname [--url URL] [-f filename]')
.default('d', 'hello')
.default('url', 'http://localhost:8000/sjs')
.argv

filename = argv.f || argv.d

console.log "Opening '#{argv.d}' at #{argv.url}. Saving to '#{filename}'"

timeout = null
doc = null

# Writes the snapshot data to the file not more than once per second.
write = ->
if (timeout == null)
timeout = setTimeout ->
console.log "Saved version " + doc.version
fs.writeFile filename, doc.snapshot
timeout = null
, 1000

client.open argv.d, 'text', argv.url, (d, error) ->
doc = d
console.log('Document ' + argv.d + ' open at version ' + doc.version)

write()
doc.on 'change', (op) ->
write()
1 change: 0 additions & 1 deletion test/types/index.coffee

This file was deleted.

0 comments on commit f2e3d90

Please sign in to comment.