Permalink
Browse files

Minor tweaks to examples

  • Loading branch information...
1 parent 3361bbb commit f2e3d9052c6fafe3244d15491e48e15a8db9ed8e @josephg josephg committed Sep 17, 2011
Showing with 44 additions and 37 deletions.
  1. +8 −5 examples/ace/index.html
  2. +0 −31 examples/file.js
  3. +36 −0 examples/sharefile.coffee
  4. +0 −1 test/types/index.coffee
View
@@ -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');
@@ -67,7 +70,7 @@
} else {
namefield.attachEvent('oninput', fn);
}
- };
+ };
</script>
</body>
</html>
View
@@ -1,31 +0,0 @@
-// This script watches for changes in the 'hello' document and constantly resaves a file
-// with the document's contents.
-
-var client = require('../lib/client');
-var fs = require('fs');
-
-var filename = 'out.html'
-
-var timeout = null;
-var doc = null;
-
-// Writes the snapshot data to the file not more than once per second.
-var write = function() {
- if (timeout == null) {
- timeout = setTimeout(function() {
- console.log("Saved version " + doc.version + " as " + filename);
- fs.writeFile(filename, doc.snapshot);
- timeout = null;
- }, 1000);
- }
-}
-
-client.open('hello', 'text', 'http://localhost:8000/sjs', function(d, error) {
- doc = d;
- console.log('Document open at version ' + doc.version);
-
- write();
- doc.on('change', function(op) {
- write();
- });
-});
View
@@ -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()
View
@@ -1 +0,0 @@
-require './text'

0 comments on commit f2e3d90

Please sign in to comment.