diff -r 4d6f57d4571c -r 2169ca441eb3 integ/iri/js/iri-buzz.js --- a/integ/iri/js/iri-buzz.js Tue Apr 30 18:22:21 2013 +0200 +++ b/integ/iri/js/iri-buzz.js Thu May 02 14:52:38 2013 +0200 @@ -78,6 +78,7 @@ return a._timestamp > b._timestamp; }); $("#data-viz").html("").css("text-align","left"); + var lastShownToken = null; var barChartSettings = { width : vsWidth, height : vsHeight, @@ -140,12 +141,18 @@ return { category: opinion._column, datetime: opinion.datetime, + timestamp: opinion._timestamp, movie: opinion._movie, colorId: opinion._colorId, fillStyle: opinion._color, + avatar: (typeof opinion.actor.user.avatar === "undefined" ? "http://fr.web.img6.acsta.net/r_50_x/commons/emptymedia/AvatarAllocineMr.gif" : resizeAcPicture( opinion.actor.user.avatar, 50, "x" )), + username: opinion.actor.user.userName, + actiontype: opinion.action.type, + actionvalue: opinion.action.value, + content: ( opinion.action.type === "userreview" ? opinion.content.$ : (opinion.action.type === "wanttosee" ? "veut voir ce film." : "" ) ), size: 30, texture: { - src: "iri/img/star-icon.png" + src: "iri/img/logo-iri.png" }, strokeStyle: "rgba(255,255,255,.2)", t: Math.floor((opinion._timestamp - originalStart) * timeScale / config.refreshRate), @@ -155,13 +162,48 @@ height: config.tokenHeight / 2 }, callback:{ + mouseover: function(token) { + if (token !== lastShownToken) { + var h = "Il y a ", + deltaT = Date.now() - token.attr("timestamp"), + deltaH = Math.round(deltaT / HOURS); + if (deltaH) { + h += deltaH + " heure"; + if (deltaH > 1) { + h += "s"; + } + } else { + var deltaM = Math.round(deltaT / MINUTES); + h += deltaM + " minute"; + if (deltaM > 1) { + h += "s"; + } + } + commentDiv.find(".comment-content").removeClass("userreview wanttosee rate").addClass(token.attr("actiontype")); + commentDiv.find(".stars-rating").attr("className","stars-rating rate-"+token.attr("actionvalue")); + commentDiv.find(".review-content").text(token.attr("content")); + commentDiv.find(".date").text(h); + commentDiv.find(".avatar img").attr("src", token.attr("avatar")); + commentDiv.find(".username").text(token.attr("username")); + commentDiv.show(); + lastShownToken = token; + } + }, + mouseout: function(token) { + lastShownToken = null; + setTimeout(function() { + if (!lastShownToken) { + commentDiv.hide(); + } + }, 200); + }, suspension: function(token) { var currentT = config.refreshRate * token.attr("t"); deltaT = Date.now() - currentT; setTimeout(function() { token.flocculate(); barChart.strata.update(barChart); - }, 5000); + }, 8000); } } } @@ -254,16 +296,19 @@ function resizeAcPicture(pic, w, h) { var path = pic.path || pic.href || pic || ""; - if (/^https?:\/\//.test(path)) { + if (/^https?:\/\/[\w\d\.]+\.acsta\.net\//.test(path)) { path = path.replace(/^https?:\/\/[^\/]+/,''); } - return "http://fr.web.img" - + ( 1 + (acimgserv++ % acimgservcount)) - + ".acsta.net/r_" - + w - + "_" - + h - + path; + if (path[0] === "/") { + return "http://fr.web.img" + + ( 1 + (acimgserv++ % acimgservcount)) + + ".acsta.net/r_" + + w + + "_" + + h + + path; + } + return path; } $.getJSON( @@ -281,7 +326,16 @@ tzDelta = .5 * HOURS * Math.round((Date.parse(d.feed.updated) - loadTime) / (.5 * HOURS)); tzSuffix = d.feed.updated.replace(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,''); - movies = d.feed.movie.map(function(movie, i) { + movies = []; + for (var i = 0; i < d.feed.movie.length; i++) { + var movie = d.feed.movie[i]; + if (i % 2) { + movies.push(movie); + } else { + movies.splice(0,0,movie); + } + } + movies = movies.map(function(movie, i) { return { id: movie.code, column: i, @@ -312,6 +366,17 @@ $(".rejouer").click(function() { startViz(); return false; - }) + }); + + var commentDiv = $("#comment"); + + $("#data-viz").mousemove(_.throttle(function(e) { + commentDiv + .css({ + left: e.pageX, + top: e.pageY + }) + .attr("className", (e.pageX < $(window).width() / 2 ? "left" : "right")) + }, 50)); }); \ No newline at end of file