Commit b20954d6 authored by Michael Murtaugh's avatar Michael Murtaugh

renames

parent a60f90b1
all: dist/app.js
all: dist/etherpad.js
dist/app.js: src/*.js
dist/etherpad.js: src/*.js
node_modules/.bin/rollup -c
......@@ -11,6 +11,23 @@
</style>
</head>
<body>
<script src="dist/app.js"></script>
<a id="use" href="test.etherpad.json">test</a>
<a href="constantcodeofconduct2.etherpad.json">constantcodeofconduct2</a>
<script src="dist/etherpad.js"></script>
<script>
async function init () {
var link = document.getElementById("use"),
pad = await etherpad.Etherpad.load(link.href, link.textContent),
div = document.createElement("div");
console.log("pad", pad);
document.body.appendChild(div);
pad.animate(change => {
div.innerHTML = change.curline;
}, 100);
}
document.addEventListener("DOMContentLoaded", init);
</script>
</body>
</html>
\ No newline at end of file
(function () {
var etherpad = (function (exports) {
'use strict';
// Z:9kj>1|8=al=o4*1a|1+1$
......@@ -47,12 +47,32 @@
return ret;
}
class Pad {
class Etherpad {
constructor (padname) {
this.padname = padname;
this.text = "\n";
this.changesets = null;
}
static async load (filename, padname) {
console.log("loading json...");
let resp = await fetch(filename),
data = await resp.json(),
pad_data = data[`pad:${padname}`];
var pad = new Etherpad(padname);
pad.parse_json(data);
return pad;
}
async animate (callback, steptime) {
var curtext = "\n";
for (var i=0; i<=this.last_rev; i++) {
let change = this.perform_changeset_curline(curtext, this.changesets[i]);
callback(change);
curtext = change.text;
// console.log(curtext);
await wait(steptime||100);
}
//console.log("CHECK", (curtext == pad_data.atext.text))
}
parse_json (data) {
let pad_data = data[`pad:${this.padname}`],
last_rev = pad_data.head;
......@@ -143,28 +163,9 @@
setTimeout(resolve, time);
})
}
async function init (filename, padname) {
console.log("loading json...");
let resp = await fetch(filename),
data = await resp.json(),
pad_data = data[`pad:${padname}`];
var pad = new Pad(padname);
pad.parse_json(data);
var curtext = "\n";
var div = document.createElement("div");
document.body.appendChild(div);
for (var i=0; i<=pad.last_rev; i++) {
let change = pad.perform_changeset_curline(curtext, pad.changesets[i]);
// console.log(curtext);
curtext = change.text;
div.innerHTML = change.curline;
await wait(100);
}
console.log("CHECK", (curtext == pad_data.atext.text));
}
document.addEventListener("DOMContentLoaded", e => {
init("constantcodeofconduct2.etherpad.json", "constantcodeofconduct2");
// init("test.etherpad.json", "test");
});
}());
exports.Etherpad = Etherpad;
return exports;
}({}));
......@@ -6,9 +6,9 @@ import resolve from 'rollup-plugin-node-resolve';
export default [{
input: 'src/app.js',
output: {
file: 'dist/app.js',
file: 'dist/etherpad.js',
format: 'iife',
name: 'app'
name: 'etherpad'
},
plugins: [
resolve(),
......
......@@ -44,12 +44,32 @@ function changeset_parse (c) {
return ret;
}
class Pad {
export class Etherpad {
constructor (padname) {
this.padname = padname;
this.text = "\n";
this.changesets = null;
}
static async load (filename, padname) {
console.log("loading json...");
let resp = await fetch(filename),
data = await resp.json(),
pad_data = data[`pad:${padname}`];
var pad = new Etherpad(padname);
pad.parse_json(data);
return pad;
}
async animate (callback, steptime) {
var curtext = "\n";
for (var i=0; i<=this.last_rev; i++) {
let change = this.perform_changeset_curline(curtext, this.changesets[i]);
callback(change);
curtext = change.text;
// console.log(curtext);
await wait(steptime||100);
}
//console.log("CHECK", (curtext == pad_data.atext.text))
}
parse_json (data) {
let pad_data = data[`pad:${this.padname}`],
last_rev = pad_data.head;
......@@ -146,26 +166,3 @@ async function wait (time) {
setTimeout(resolve, time);
})
}
async function init (filename, padname) {
console.log("loading json...");
let resp = await fetch(filename),
data = await resp.json(),
pad_data = data[`pad:${padname}`];
var pad = new Pad(padname);
pad.parse_json(data);
var curtext = "\n";
var div = document.createElement("div");
document.body.appendChild(div);
for (var i=0; i<=pad.last_rev; i++) {
let change = pad.perform_changeset_curline(curtext, pad.changesets[i]);
// console.log(curtext);
curtext = change.text;
div.innerHTML = change.curline;
await wait(100);
}
console.log("CHECK", (curtext == pad_data.atext.text))
}
document.addEventListener("DOMContentLoaded", e => {
init("constantcodeofconduct2.etherpad.json", "constantcodeofconduct2");
// init("test.etherpad.json", "test");
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment