Browse files

Final polishing for JavaOne demo

  • Loading branch information...
1 parent 009e91b commit 5e8c20efd9d42e817b630bf754b507e20b95e605 Jeremy Grelle committed Sep 21, 2010
View
74 src/main/webapp/WEB-INF/layouts/html5-default.jspx
@@ -1,4 +1,4 @@
-<html xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tiles="http://tiles.apache.org/tags-tiles" xmlns:spring="http://www.springframework.org/tags" xmlns:util="urn:jsptagdir:/WEB-INF/tags/util">
+<html xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tiles="http://tiles.apache.org/tags-tiles" xmlns:spring="http://www.springframework.org/tags" xmlns:util="urn:jsptagdir:/WEB-INF/tags/util" manifest="cache.manifest">
<jsp:output doctype-root-element="HTML" doctype-system="about:legacy-compat" />
@@ -19,34 +19,25 @@
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.Form");
dojo.addOnLoad(function(){
- dojo.declare("Model", null, {
- data : null,
-
- constructor : function(url, callback) {
- var resultHandler = this.load;
- var onload = (!callback ? function(){} : callback);
- var deferred = dojo.xhrGet({
- url : url.match(/.*[^\?form]/)[0],
+
+ var controller = {
+ basePath : location.protocol + "//" + location.host + "/" + (location.pathname.search(/spring-html5/) > -1 ? "spring-html5/" : ""),
+ getModel : function(url) {
+ return dojo.xhrGet({
+ url : url.match(/.*[^\?form]/)[0],
+
preventCache : true,
-
+
handleAs : "json",
-
+
headers : {
"Content-Type": "application/json",
"Accept": "application/json"
}
});
- var that = this;
- deferred.addCallback(function(result){
- that.data = result;
- onload();
- });
- }
- });
-
- var controller = {
- basePath : location.protocol + "//" + location.host + "/" + (location.pathname.search(/spring-html5/) > -1 ? "spring-html5/" : ""),
+ },
+
getView : function(url) {
var view = { requiresModel : true };
var hasIdentifier = false;
@@ -75,35 +66,11 @@
view.template = template;
return dojo.isFunction(view.template) ? view : null;
},
+
renderView : function(view, url) {
- if (view.requiresModel) {
- var model = new Model(url, function(){
- var content = view.template.apply(window, [{model : model.data}]);
- dojo.html.set(main, content, {parseContent:true,
- onBegin: function(){
- var existing = dijit.byId("content");
- if (existing) {
- existing.destroyRecursive();
- }
- },
- onEnd: function(){
- this.inherited("onEnd", arguments);
- dojo.query("#content a").forEach(function(navItem) {
- dojo.connect(navItem, "onclick", function(e) {
- var main = dojo.byId("main");
- var view = controller.getView(navItem.href);
- if (view) {
- dojo.stopEvent(e);
- controller.renderView(view, navItem.href);
- }
- });
- });
- dijit.byId("content").toggle();
- }
- });
- });
- } else {
- var content = view.template.apply(window, [{}]);
+ var model = view.requiresModel ? controller.getModel(url) : null;
+ dojo.when(model, function(model){
+ var content = view.template.apply(window, [{model : model}]);
dojo.html.set(main, content, {parseContent:true,
onBegin: function(){
var existing = dijit.byId("content");
@@ -123,16 +90,18 @@
}
});
});
+
dijit.byId("content").toggle();
}
-
});
- }
+ });
+
if(location.href != url) {
- history.pushState({}, "", url);
+ history.pushState({}, "view", url);
}
}
};
+
dojo.query("a.menuItem").forEach(function(menuItem) {
dojo.connect(menuItem, "onclick", function(e) {
var main = dojo.byId("main");
@@ -143,6 +112,7 @@
}
});
});
+
dojo.connect(window, "onpopstate", function(e){
if(location.href.search(/html5-index/) > -1) {
location.reload();
View
6 src/main/webapp/activity/Activity.html
@@ -49,11 +49,11 @@
</STYLE>
</HEAD>
<BODY>
-<H1>activity</H1>
+<H1>Spring 3.0 SVN Commit Activity</H1>
<CANVAS id="glow" width="1000" height="500"></CANVAS>
-<P id="date">Sun 21 Sep 2008<BR>11:38 AM
+<P id="date">
</P>
-<P id="footer">Derived from an example created by <A
+<P id="footer">Derived from an <A href="">example</A> created by <A
href="http://www.mattryall.net/">Matt Ryall</A> with <A
href="http://ejohn.org/blog/processingjs/">Processing.js</A></P>
View
39 src/main/webapp/activity/activity.js
@@ -8,7 +8,7 @@ Array.prototype.remove = function(from, to) {
jQuery(function($) {
var el = document.getElementById("glow");
- var frameRate = 30;
+ var frameRate = 45;
//var speed = 5; // average # of messages per second
var width = el.width;
var height = el.height;
@@ -47,15 +47,15 @@ jQuery(function($) {
}
p.noStroke();
whiteText("overall activity", 20, fontSize * 1.5);
- whiteText("module", width - font.width("module") * fontSize
+ whiteText("author", width - font.width("author") * fontSize
* 1.5, bottom + height / 10 + fontSize * 1.2);
}
}
};
components.push(new Axes());
var Circle = function Circle(height, author) {
- var maxAge = 100;
+ var maxAge = 50;
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.".split("");
var x = 0;
for ( var i = 0; i < 3; i++)
@@ -124,51 +124,18 @@ jQuery(function($) {
return t;
}
- /*var Glow = function Glow(commits) {
- var mindate = commits[0].date.getTime();
- var maxdate = mindate + commits[commits.length - 1].date.getTime();
- var frames = commits.length * frameRate / speed;
- var datedelta = (maxdate - mindate) / frames;
- var frame = 0;
- return {
- update: function () {
- frame++;
- var d = mindate + frame * datedelta;
- var last = null;
- while (commits.length > 0 && commits[0].date.getTime() <= d) {
- var c = commits.shift();
- if (!last || last.module != c.module || last.date.getTime() != c.date.getTime()) {
- last = c;
- console.debug("Pushing circle for " + c.module + " at " + c.date.getTime());
- components.push(new Circle(components.length, c.module));
- }
- }
- if (frame % 5 == 0)
- $("#date").html(formatDate(new Date(d)) + "<br/>" + formatTime(new Date(d)));
- },
- draw: function () {
- p.background(0, 15);
- }
- };
- };*/
-
var Glow = function Glow() {
return {
update : function() {
var c = commits.shift();
if (c) {
- /*if (window.console) {
- console.debug("Pushing circle #"+c.order+" for " + c.module + " at "
- + c.date.getTime());
- }*/
components.push(new Circle(components.length, c.author));
$("#date").html(
formatDate(c.date) + "<br/>" + formatTime(c.date));
}
},
draw : function() {
p.background(0, 15);
- //p.background(0, 0, 0, 100);
}
};
};
View
4 src/main/webapp/activity/commitProcessor.js
@@ -11,6 +11,7 @@ function start(offline) {
var connectionFailed = false;
var messagesReceived = false;
if (!self.WebSocket || offline) {
+ postMessage("Reverting to cached data.js");
importScripts("data.js");
data.reverse();
for ( var i = 0; i < data.length; i++) {
@@ -48,9 +49,6 @@ function start(offline) {
}
socket.onclose = function(event) {
postMessage("Connection to "+messageChannelUrl+" was closed.");
- if (connectionFailed && !messagesReceived) {
- postMessage("Reverting to cached data.js");
- }
start(true);
}
}

0 comments on commit 5e8c20e

Please sign in to comment.