diff --git a/core/index.html b/core/index.html index 9c7e7cfa..fac5c3ce 100644 --- a/core/index.html +++ b/core/index.html @@ -18,7 +18,7 @@ update available! refresh to update -
+
> diff --git a/core/terminal.js b/core/terminal.js index 044a582a..8514659d 100644 --- a/core/terminal.js +++ b/core/terminal.js @@ -110,7 +110,7 @@ Terminal.prototype.clear = function() { } Terminal.prototype.ping = function() { - this.dispatch({index: this._index - 1, lines: [{action: "ping"}]}); + this.dispatch({action: "ping"}); } Terminal.prototype.getOutput = function(haveIndex) { diff --git a/packages/cory/index/index.js b/packages/cory/index/index.js index 00efdb24..1e54a237 100644 --- a/packages/cory/index/index.js +++ b/packages/cory/index/index.js @@ -16,6 +16,7 @@ function index() { usersByApp["/~" + user.packageOwner + "/" + user.packageName].push(user.name); } + terminal.cork(); terminal.clear(); terminal.print("Available applications [active users]:"); packages.sort(function(x, y) { @@ -47,7 +48,8 @@ function index() { {href: "/~" + app.owner + "/" + app.name}, message); }); + terminal.uncork(); }); } -index(); +index(); \ No newline at end of file diff --git a/packages/cory/wiki/wiki.js b/packages/cory/wiki/wiki.js new file mode 100644 index 00000000..c4df8319 --- /dev/null +++ b/packages/cory/wiki/wiki.js @@ -0,0 +1,152 @@ +"use strict"; + +terminal.setEcho(false); + +core.register("onInput", function(input) { + if (input == "new page") { + editPage("new", ""); + } else if (input == "submit") { + submitNewPost().then(renderBlog); + } else if (input == "home") { + renderIndex(); + } else if (input.substring(0, 5) == "open:") { + var title = input.substring(5); + database.get(title).then(function(contents) { + editPage(title, contents); + }); + } else if (input.substring(0, 7) == "delete:") { + terminal.clear(); + var title = input.substring(7); + terminal.print("Are you sure you want to delete page '", title, "'?"); + terminal.print({command: "confirmDelete:" + title, value: "delete it"}); + terminal.print({command: "home", value: "cancel"}); + } else if (input.substring(0, 14) == "confirmDelete:") { + var title = input.substring(14); + database.remove(title).then(renderIndex); + } +}); + +function renderIndex() { + terminal.clear(); + terminal.print("Editor Test"); + if (core.user.credentials.permissions.authenticated) { + terminal.print({command: "new page"}); + } + + database.getAll().then(function(entries) { + for (var i = 0; i < entries.length; i++) { + if (core.user.credentials.permissions.authenticated) { + terminal.print( + "* ", + {style: "font-weight: bold", value: {command: "open:" + entries[i], value: entries[i]}}, + " (", + {command: "delete:" + entries[i], value: "x"}, + ")"); + } else { + terminal.print( + "* ", + {style: "font-weight: bold", value: {command: "open:" + entries[i], value: entries[i]}}); + } + } + }); +} + +var gPage = null; + +core.register("onWindowMessage", function(event) { + if (event.message.ready) { + terminal.postMessageToIframe("iframe", {title: gPage.title, contents: gPage.contents}); + } else if (event.message.index) { + renderIndex(); + } else { + database.set(event.message.title, event.message.contents).then(function() { + renderIndex(); + }); + } +}); + +function editPage(title, contents) { + gPage = {title: title, contents: contents}; + terminal.clear(); + terminal.print({iframe: ` + + + + + + + + + + + + +
+ +
+
+ + `, name: "iframe", style: "width: 100%; border: 0; height: 600px"}); +} + +renderIndex(); \ No newline at end of file diff --git a/packages/cory/xmpp/xmpp.js b/packages/cory/xmpp/xmpp.js index 248680e7..a4e990f7 100644 --- a/packages/cory/xmpp/xmpp.js +++ b/packages/cory/xmpp/xmpp.js @@ -665,7 +665,7 @@ XmlStanzaParser.prototype.parseNode = function(node) { // end xmpp.js -var gFocus = false; +var gFocus = true; var gUnread = 0; function updateTitle() { @@ -792,10 +792,12 @@ var gPresence = {}; function refreshUsers() { terminal.select("users"); + terminal.cork(); terminal.clear(); for (var i in gPresence) { terminal.print(i); } + terminal.uncork(); terminal.select("terminal"); } @@ -937,7 +939,7 @@ function connect(socket, userName, password) { } refreshUsers(); } else { - terminal.print(data); + terminal.print(JSON.stringify(data)); } }); } catch (error) {