Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

builder catching up

  • Loading branch information...
commit abcaebede5aa227cbe5ac2b37b06ea66b495ad7c 1 parent e08ff56
@WardCunningham authored
Showing with 45 additions and 9 deletions.
  1. +30 −9 client/client.js
  2. +15 −0 client/test/testclient.js
View
39 client/client.js
@@ -421,20 +421,24 @@ require.define("/lib/legacy.coffee", function (require, module, exports, __dirna
return string.replace(/\[\[([^\]]+)\]\]/gi, renderInternalLink).replace(/\[(http.*?) (.*?)\]/gi, "<a class=\"external\" target=\"_blank\" href=\"$1\">$2</a>");
};
addToJournal = wiki.addToJournal = function(journalElement, action) {
- var actionElement, pageElement, prev;
+ var actionElement, actionTitle, pageElement, prev;
pageElement = journalElement.parents('.page:first');
- actionElement = $("<a href=\"\#\" /> ").addClass("action").addClass(action.type).text(action.type[0]).attr('title', action.type).attr('data-id', action.id || "0").appendTo(journalElement);
+ if (action.type === 'edit') {
+ prev = journalElement.find(".edit[data-id=" + (action.id || 0) + "]");
+ }
+ actionTitle = action.type;
+ if (action.type === 'edit') actionTitle += "(" + prev.length + ")";
+ if (action.date != null) {
+ actionTitle += ": " + (util.formatDate(action.date));
+ }
+ actionElement = $("<a href=\"\#\" /> ").addClass("action").addClass(action.type).text(action.type[0]).attr('title', actionTitle).attr('data-id', action.id || "0").appendTo(journalElement);
if (action.type === 'fork') {
- actionElement.css("background-image", "url(//" + action.site + "/favicon.png)").attr("href", "//" + action.site + "/" + (pageElement.attr('id')) + ".html").data("site", action.site).data("slug", pageElement.attr('id'));
+ return actionElement.css("background-image", "url(//" + action.site + "/favicon.png)").attr("href", "//" + action.site + "/" + (pageElement.attr('id')) + ".html").data("site", action.site).data("slug", pageElement.attr('id'));
} else {
- actionElement.on('click', function() {
+ return actionElement.on('click', function() {
return wiki.dialog("" + action.type + " action", $('<pre/>').text(JSON.stringify(action, null, 2)));
});
}
- if (action.type === 'edit') {
- prev = journalElement.find(".edit[data-id=" + (action.id || 0) + "]");
- return actionElement.attr('title', "edit " + prev.length);
- }
};
useLocalStorage = wiki.useLocalStorage = function() {
wiki.log('useLocalStorage', $(".login").length > 0);
@@ -442,6 +446,7 @@ require.define("/lib/legacy.coffee", function (require, module, exports, __dirna
};
putAction = wiki.putAction = function(pageElement, action) {
var site;
+ action.date = (new Date()).getTime();
if ((site = pageElement.data('site')) != null) {
action.fork = site;
pageElement.find('h1 img').attr('src', '/favicon.png');
@@ -450,7 +455,8 @@ require.define("/lib/legacy.coffee", function (require, module, exports, __dirna
state.setUrl();
addToJournal(pageElement.find('.journal'), {
type: 'fork',
- site: site
+ site: site,
+ date: (new Date()).getTime()
});
}
if (useLocalStorage()) {
@@ -651,6 +657,21 @@ require.define("/lib/util.coffee", function (require, module, exports, __dirname
return "" + h + ":" + mi + " " + am + "<br>" + (d.getDate()) + " " + mo + " " + (d.getFullYear());
};
+ util.formatDate = function(msSinceEpoch) {
+ var am, d, day, h, mi, mo, sec, wk, yr;
+ d = new Date(msSinceEpoch);
+ wk = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][d.getDay()];
+ mo = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()];
+ day = d.getDate();
+ yr = d.getFullYear();
+ h = d.getHours();
+ am = h < 12 ? 'AM' : 'PM';
+ h = h === 0 ? 12 : h > 12 ? h - 12 : h;
+ mi = (d.getMinutes() < 10 ? "0" : "") + d.getMinutes();
+ sec = (d.getSeconds() < 10 ? "0" : "") + d.getSeconds();
+ return "" + wk + " " + mo + " " + day + " " + yr + " " + h + ":" + mi + ":" + sec + " " + am;
+ };
+
util.asSlug = function(name) {
return name.replace(/\s/g, '-').replace(/[^A-Za-z0-9-]/g, '').toLowerCase();
};
View
15 client/test/testclient.js
@@ -432,6 +432,21 @@ require.define("/lib/util.coffee", function (require, module, exports, __dirname
return "" + h + ":" + mi + " " + am + "<br>" + (d.getDate()) + " " + mo + " " + (d.getFullYear());
};
+ util.formatDate = function(msSinceEpoch) {
+ var am, d, day, h, mi, mo, sec, wk, yr;
+ d = new Date(msSinceEpoch);
+ wk = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][d.getDay()];
+ mo = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()];
+ day = d.getDate();
+ yr = d.getFullYear();
+ h = d.getHours();
+ am = h < 12 ? 'AM' : 'PM';
+ h = h === 0 ? 12 : h > 12 ? h - 12 : h;
+ mi = (d.getMinutes() < 10 ? "0" : "") + d.getMinutes();
+ sec = (d.getSeconds() < 10 ? "0" : "") + d.getSeconds();
+ return "" + wk + " " + mo + " " + day + " " + yr + " " + h + ":" + mi + ":" + sec + " " + am;
+ };
+
util.asSlug = function(name) {
return name.replace(/\s/g, '-').replace(/[^A-Za-z0-9-]/g, '').toLowerCase();
};
Please sign in to comment.
Something went wrong with that request. Please try again.