# HG changeset patch # User veltr # Date 1366648960 -7200 # Node ID 007254e973336d4890ac38205f609c4c7ded40eb # Parent 8b0a464fb5ac7caf00143ca6dceac0efa3e5760e improvements for better code reuse diff -r 8b0a464fb5ac -r 007254e97333 js/playscreen.js --- a/js/playscreen.js Wed Apr 17 17:10:43 2013 +0200 +++ b/js/playscreen.js Mon Apr 22 18:42:40 2013 +0200 @@ -1,8 +1,4 @@ -var topicPoubelle = 13; - -var adjust = 54; - -var deltaT = new Date("Wed, 02 May 2012 19:00:00 +0000") / 1000 + adjust; +var deltaT = tweetStartDate / 1000 + tweetTimeDelta; function secsToString(seconds) { var hours = Math.floor(seconds/3600), @@ -19,15 +15,35 @@ } function solrUrl(table, params) { - var u = "http://159.217.144.101:8050/sia-solr/" + table + "/select?" + $.param(params) + "&wt=json&json.wrf=?"; - console.log(u); + var u = solrUrlBase + table + "/select?" + $.param(params) + "&wt=json&json.wrf=?"; return u; } function showData() { + data.duration = data.segments[data.segments.length - 1].end; + data.chapters = []; + var nmmso = data.segments.length; + + data.topics.forEach(function(topic) { + topic.score = 0; + topic.weights = []; + for (var i = 0; i < nmmso; i++) { + topic.weights.push(0); + } + }); + + data.segments.forEach(function(mmso, i) { + mmso.topics.forEach(function(t) { + data.topics[t.topic].weights[i] = t.weight; + data.topics[t.topic].score += t.weight; + }); + }); + + var topicPoubelle = removeBiggestTopic ? _(data.topics.slice()).sortBy(function(t) { return -t.score; })[0].index : -1; + data.segments.forEach(function(segment, index) { var topics = segment.topics.filter(function(t) { return t.topic !== topicPoubelle; @@ -90,24 +106,7 @@ var ordertag = 0; $(".duration").text(secsToString(data.duration)); - - var nmmso = data.segments.length; - - data.topics.forEach(function(topic) { - topic.score = 0; - topic.weights = []; - for (var i = 0; i < nmmso; i++) { - topic.weights.push(0); - } - }); - - data.segments.forEach(function(mmso, i) { - mmso.topics.forEach(function(t) { - data.topics[t.topic].weights[i] = t.weight; - data.topics[t.topic].score += t.weight; - }); - }); - + var sortedTopics = data.topics.filter(function(t) { return pageParams.visibletopics.indexOf(t.index.toString()) !==-1 && t.index !== topicPoubelle; }); @@ -355,7 +354,7 @@ rgb = rgb.map(function(c) { return parseInt(c/opacity); }); - ctx.fillStyle = 'rgba(' + rgb.join(',') + ',' + opacity + ')'; + ctx.fillStyle = 'rgba(' + rgb.join(',') + ',' + (.25+.75*opacity) + ')'; ctx.fillRect(globL, yscale * mmso.start, globW, yscale * mmso.duration); if (isinlocal) { ctx.fillRect( localL, y, localW, h ); @@ -759,9 +758,7 @@ var _MAX_BATCH = 20; function getTweetIds() { - - console.log("getTweetIds"); - + var toload = []; _(tweetstructure).each(function(w) { @@ -786,8 +783,6 @@ function getTweetData() { - console.log("getTweetData"); - var toload = []; _(requestedtweets).each(function(v) { @@ -837,8 +832,6 @@ function getLocalTweets() { - console.log("getLocalTweets"); - var topics = Array.prototype.join.call($(".topic.selected").map(function(){return $(this).attr("data-topic-id")})).split(","); filteredSegments.forEach(function(mmso) { @@ -867,7 +860,7 @@ var localpos = 300, localduration = 600; - var player = new Player(); + var player = new Player(typeof tvCoords !== "undefined" ? tvCoords : null); player.duration = data.duration; @@ -978,13 +971,13 @@ var totalScroll = 0, zoomlevels = [ 1800, 900, 600, 300, 120, 60 ], currentlevel = 2; - $(".play-bottom") + $(".play-canvas") + .on("touchstart", function(_e) { + _e.preventDefault(); + }) .mousedown(function(_e) { _e.preventDefault(); }) - .on("touchstart", function(_e) { - _e.preventDefault(); - }) .mousewheel(function(_event, _scrolldelta) { totalScroll += _scrolldelta; if (Math.abs(totalScroll) >= 1) { @@ -1087,7 +1080,7 @@ checkOrGoNext(); } -var data = { duration: 10200, topics: [] }, +var data = { topics: [] }, colorset = ["#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#A65628", "#F781BF"]; $(function() { @@ -1225,10 +1218,7 @@ topics.sort(function(a,b) { return b.weight - a.weight; }); -/* topics = topics.filter(function(t) { - return t.topic !== topicPoubelle - }).slice(0,1); - topics[0].weight = 1; */ + return { id: mmso.MMSO_id, start: start, diff -r 8b0a464fb5ac -r 007254e97333 js/remote-player.js --- a/js/remote-player.js Wed Apr 17 17:10:43 2013 +0200 +++ b/js/remote-player.js Mon Apr 22 18:42:40 2013 +0200 @@ -1,14 +1,15 @@ -function Player() { +function Player(dimensions) { var events = {}, self = this, loaded = false, -// tvWindow, + tvWindow, destination = document.location.href.replace(/^(https?:\/\/[^\/]+).*$/,'$1'), timeAtLoad, timeDelta = 0, timeOut, - playAtLoad = false; + playAtLoad = false, + winDimensions = dimensions || { left: 0, top: 0, width: 640, height:360 }; this.currentTime = 0; this.duration = 0; @@ -65,10 +66,16 @@ } $(".tv").click(function() { - tvWindow = window.open("tv.html","TV","width=640,height=360,toolbar=0,location=0,status=0,titlebar=0"); + tvWindow = window.open("tv.html","TV", _(winDimensions).reduce(function(mem, v, k) { return mem + k + "=" + v + "," },"") + "toolbar=0,location=0,status=0,titlebar=0"); window.addEventListener("message",receiveMessage,false); }); + $(window).on("unload", function() { + if (typeof tvWindow !== "undefined" && tvWindow) { + tvWindow.close(); + } + }) + this.setCurrentTime = function(t) { if (loaded) { sendMessage("timeupdate:" + t); diff -r 8b0a464fb5ac -r 007254e97333 js/startscreen.js --- a/js/startscreen.js Wed Apr 17 17:10:43 2013 +0200 +++ b/js/startscreen.js Mon Apr 22 18:42:40 2013 +0200 @@ -1,7 +1,24 @@ -var topicPoubelle = 13; - function showData() { + + var nmmso = data.segments.length; + data.topics.forEach(function(topic) { + topic.score = 0; + topic.weights = []; + for (var i = 0; i < nmmso; i++) { + topic.weights.push(0); + } + }); + + data.segments.forEach(function(mmso, i) { + mmso.topics.forEach(function(t) { + data.topics[t.topic].weights[i] = t.weight; + data.topics[t.topic].score += t.weight; + }); + }); + + var topicPoubelle = removeBiggestTopic ? _(data.topics.slice()).sortBy(function(t) { return -t.score; })[0].index : -1; + data.topiclabels.forEach(function(v) { var words = _(v.words).map(function(v, k) { return { @@ -33,23 +50,6 @@ $(".duration").text(secsToString(data.duration)); - var nmmso = data.segments.length; - - data.topics.forEach(function(topic) { - topic.score = 0; - topic.weights = []; - for (var i = 0; i < nmmso; i++) { - topic.weights.push(0); - } - }); - - data.segments.forEach(function(mmso, i) { - mmso.topics.forEach(function(t) { - data.topics[t.topic].weights[i] = t.weight; - data.topics[t.topic].score += t.weight; - }); - mmso.tweet_rate = mmso.tweet_count / mmso.duration; - }); var sortedTopics = data.topics.filter(function(t) { return t.index !== topicPoubelle; @@ -160,6 +160,9 @@ source: allwords, change: function() { window.setTimeout(wordFilter,0); + }, + select: function() { + window.setTimeout(wordFilter,0); } }).on("keyup change paste", wordFilter); // */ @@ -345,7 +348,7 @@ } function solrUrl(table, params) { - return "http://159.217.144.101:8050/sia-solr/" + table + "/select?" + $.param(params) + "&wt=json&json.wrf=?"; + return solrUrlBase + table + "/select?" + $.param(params) + "&wt=json&json.wrf=?"; } function loadFromTopicsBean(method, propname, args, callback) { @@ -389,10 +392,6 @@ topics.sort(function(a,b) { return b.weight - a.weight; }); -/* topics = topics.filter(function(t) { - return t.topic !== topicPoubelle - }).slice(0,1); - topics[0].weight = 1; */ return { id: mmso.MMSO_id, start: start, diff -r 8b0a464fb5ac -r 007254e97333 playscreen-frame.html --- a/playscreen-frame.html Wed Apr 17 17:10:43 2013 +0200 +++ b/playscreen-frame.html Mon Apr 22 18:42:40 2013 +0200 @@ -57,7 +57,17 @@ Ouvrir la fenĂȘtre TV diff -r 8b0a464fb5ac -r 007254e97333 playscreen.html --- a/playscreen.html Wed Apr 17 17:10:43 2013 +0200 +++ b/playscreen.html Mon Apr 22 18:42:40 2013 +0200 @@ -54,7 +54,11 @@ diff -r 8b0a464fb5ac -r 007254e97333 startscreen-frame.html --- a/startscreen-frame.html Wed Apr 17 17:10:43 2013 +0200 +++ b/startscreen-frame.html Mon Apr 22 18:42:40 2013 +0200 @@ -10,7 +10,9 @@ diff -r 8b0a464fb5ac -r 007254e97333 startscreen.html --- a/startscreen.html Wed Apr 17 17:10:43 2013 +0200 +++ b/startscreen.html Mon Apr 22 18:42:40 2013 +0200 @@ -10,7 +10,9 @@