diff --git a/demo/kitchen-sink/doclist.js b/demo/kitchen-sink/doclist.js
index b0198238..a4848d50 100644
--- a/demo/kitchen-sink/doclist.js
+++ b/demo/kitchen-sink/doclist.js
@@ -169,13 +169,44 @@ function loadDoc(name, callback) {
});
}
+function saveDoc(name, callback) {
+ var doc = fileCache[name] || name;
+ if (!doc || !doc.session)
+ return callback("Unknown document: " + name);
+
+ var path = doc.path;
+ var parts = path.split("/");
+ if (parts[0] == "docs")
+ path = "demo/kitchen-sink/" + path;
+ else if (parts[0] == "ace")
+ path = "lib/" + path;
+
+ upload(path, doc.session.getValue(), callback);
+}
+
+function upload(url, data, callback) {
+ url = net.qualifyURL(url);
+ if (!/https?:/.test(url))
+ return callback(new Error("Unsupported url scheme"));
+ var xhr = new XMLHttpRequest();
+ xhr.open("PUT", url, true);
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState === 4) {
+ callback(!/^2../.test(xhr.status));
+ }
+ };
+ xhr.send(data);
+};
+
+
module.exports = {
fileCache: fileCache,
docs: sort(prepareDocList(docs)),
ownSource: prepareDocList(ownSource),
hugeDocs: prepareDocList(hugeDocs),
initDoc: initDoc,
- loadDoc: loadDoc
+ loadDoc: loadDoc,
+ saveDoc: saveDoc,
};
module.exports.all = {
"Mode Examples": module.exports.docs,
diff --git a/demo/kitchen-sink/docs/abc.abc b/demo/kitchen-sink/docs/abc.abc
new file mode 100644
index 00000000..d8ac326e
--- /dev/null
+++ b/demo/kitchen-sink/docs/abc.abc
@@ -0,0 +1,171 @@
+%abc-2.1
+H:This file contains some example English tunes
+% note that the comments (like this one) are to highlight usages
+% and would not normally be included in such detail
+O:England % the origin of all tunes is England
+
+X:1 % tune no 1
+T:Dusty Miller, The % title
+T:Binny's Jig % an alternative title
+C:Trad. % traditional
+R:DH % double hornpipe
+M:3/4 % meter
+K:G % key
+B>cd BAG|FA Ac BA|B>cd BAG|DG GB AG:|
+Bdd gfg|aA Ac BA|Bdd gfa|gG GB AG:|
+BG G/2G/2G BG|FA Ac BA|BG G/2G/2G BG|DG GB AG:|
+W:Hey, the dusty miller, and his dusty coat;
+W:He will win a shilling, or he spend a groat.
+W:Dusty was the coat, dusty was the colour;
+W:Dusty was the kiss, that I got frae the miller.
+
+X:2
+T:Old Sir Simon the King
+C:Trad.
+S:Offord MSS % from Offord manuscript
+N:see also Playford % reference note
+M:9/8
+R:SJ % slip jig
+N:originally in C % transcription note
+K:G
+D|GFG GAG G2D|GFG GAG F2D|EFE EFE EFG|A2G F2E D2:|
+D|GAG GAB d2D|GAG GAB c2D|[1 EFE EFE EFG|[A2G] F2E D2:|\ % no line-break in score
+M:12/8 % change of meter
+[2 E2E EFE E2E EFG|\ % no line-break in score
+M:9/8 % change of meter
+A2G F2E D2|]
+
+X:3
+T:William and Nancy
+T:New Mown Hay
+T:Legacy, The
+C:Trad.
+O:England; Gloucs; Bledington % place of origin
+B:Sussex Tune Book % can be found in these books
+B:Mally's Cotswold Morris vol.1 2
+D:Morris On % can be heard on this record
+P:(AB)2(AC)2A % play the parts in this order
+M:6/8
+K:G
+[P:A] D|"G"G2G GBd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
+[P:B] d|"G"e2d B2d|"C"gfe "G"d2d| "G"e2d B2d|"C"gfe "D7"d2c|
+ "G"B2B Bcd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
+% changes of meter, using inline fields
+[T:Slows][M:4/4][L:1/4][P:C]"G"d2|"C"e2 "G"d2|B2 d2|"Em"gf "A7"e2|"D7"d2 "G"d2|\
+ "C"e2 "G"d2|[M:3/8][L:1/8] "G"B2 d |[M:6/8] "C"gfe "D7"d2c|
+ "G"B2B Bcd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
+
+X:4
+T:South Downs Jig
+R:jig
+S:Robert Harbron
+M:6/8
+L:1/8
+K:G
+|: d | dcA G3 | EFG AFE | DEF GAB | cde d2d |
+dcA G3 | EFG AFE | DEF GAB | cAF G2 :|
+B | Bcd e2c | d2B c2A | Bcd e2c | [M:9/8]d2B c2B A3 |
+[M:6/8]DGF E3 | cBA FED | DEF GAB |1 cAF G2 :|2 cAF G3 |]
+
+X:5
+T:Atholl Brose
+% in this example, which reproduces Highland Bagpipe gracing,
+% the large number of grace notes mean that it is more convenient to be specific about
+% score line-breaks (using the $ symbol), rather than using code line breaks to indicate them
+I:linebreak $
+K:D
+{gcd}c<{e}A {gAGAG}A2 {gef}e>A {gAGAG}Ad|
+{gcd}c<{e}A {gAGAG}A>e {ag}a>f {gef}e>d|
+{gcd}c<{e}A {gAGAG}A2 {gef}e>A {gAGAG}Ad|
+{g}c/d/e {g}G>{d}B {gf}gG {dc}d>B:|$
+{g}c
By default, the editor supports plain text mode. All other language modes are available as separate modules, loaded on demand like this:
-editor.getSession().setMode("ace/mode/javascript");
-
+ editor.getSession().setMode("ace/mode/javascript");