diff --git a/packages/cory/libirc/libirc.js b/packages/cory/libirc/libirc.js index e079318c..7a7d11bb 100644 --- a/packages/cory/libirc/libirc.js +++ b/packages/cory/libirc/libirc.js @@ -98,6 +98,12 @@ class IrcService { let person = prefix.split('!')[0]; let conversation = parts[1]; this._service.notifyPresenceChanged(conversation, person, "unavailable"); + } else if (parts[0] == "QUIT") { + let person = prefix.split('!')[0]; + let conversations = this._service.getConversations(); + for (let i in conversations) { + this._service.notifyPresenceChanged(conversations[i], person, "unavailable"); + } } else if (parts[0] == "353") { // RPL_NAMREPLY if (!this._nameReplies[parts[3]]) { this._nameReplies[parts[3]] = []; diff --git a/packages/cory/sharedwiki/sharedwiki.js b/packages/cory/sharedwiki/sharedwiki.js new file mode 100644 index 00000000..910892a6 --- /dev/null +++ b/packages/cory/sharedwiki/sharedwiki.js @@ -0,0 +1,186 @@ +"use strict"; + +//! {"require": ["ui"]} + +terminal.setEcho(false); +terminal.setTitle("Live Markdeep Editor"); + +let gEditEvent = null; + +function back() { + terminal.split([{name: "terminal"}]); + if (gEditEvent) { + gEditEvent.back(); + } +} + +core.register("onWindowMessage", function(event) { + if (event.message.ready) { + core.broadcast({title: gEditEvent.name, sync: true}); + terminal.postMessageToIframe("iframe", {title: gEditEvent.name, contents: gEditEvent.value}); + } else if (event.message.index) { + back(); + } else if (event.message.cursor) { + core.broadcast({title: gEditEvent.name, user: core.user.index, cursor: event.message.cursor}); + } else if (event.message.change) { + core.broadcast({title: gEditEvent.name, user: core.user.index, change: event.message.change}); + } else if (event.message.sync) { + core.broadcast({title: event.message.title, user: core.user.index, contents: event.message.contents}); + } else { + gEditEvent.save(event.message.title, event.message.contents).then(function() { + return core.broadcast({title: gEditEvent.name, contents: event.message.contents, sync: true}); + }).then(back); + } +}); + +core.register("onMessage", function(sender, message) { + if (!gEditEvent || message.title == gEditEvent.name) { + terminal.postMessageToIframe("iframe", message); + } +}); + +core.register("onSessionEnd", function(process) { + terminal.postMessageToIframe("iframe", {user: process.index, cursor: {}}); +}); + +function editPage(event) { + gEditEvent = event; + terminal.split([{name: "terminal", type: "vertical"}]); + terminal.clear(); + terminal.print({iframe: ` +
+ + + + + + + + + +