js/playscreen.js
changeset 21 007254e97333
parent 20 8b0a464fb5ac
child 22 4e1e66b2fdf1
--- 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,