Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor tweaks to examples

  • Loading branch information...
commit f2e3d9052c6fafe3244d15491e48e15a8db9ed8e 1 parent 3361bbb
@josephg josephg authored
View
13 examples/ace/index.html
@@ -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
31 examples/file.js
@@ -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
36 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()
View
1  test/types/index.coffee
@@ -1 +0,0 @@
-require './text'
Please sign in to comment.
Something went wrong with that request. Please try again.