--- a/js/playscreen.js Wed Apr 10 15:39:28 2013 +0200
+++ b/js/playscreen.js Tue Apr 16 18:26:43 2013 +0200
@@ -78,18 +78,7 @@
var topicHash = document.location.hash || "#selectedtopics=5,15&visibletopics=5,10,15";
var pageParams = {};
-
- var syncVideo = true,
- syncTimer;
-
- function deSync() {
- syncVideo = false;
- clearTimeout(syncTimer);
- syncTimer = setTimeout(function() {
- syncVideo = true;
- },5000);
- }
-
+
topicHash
.replace(/^#/,'')
.split('&')
@@ -160,7 +149,6 @@
var chap = data.chapters[i];
if (chap.startTime > player.currentTime && topics.indexOf(chap.topic) !== -1) {
player.setCurrentTime(chap.startTime);
- throttledShowLocal();
return;
}
}
@@ -169,7 +157,6 @@
var chap = data.chapters[i];
if (topics.indexOf(chap.topic) !== -1) {
player.setCurrentTime(chap.startTime);
- throttledShowLocal();
return;
}
}
@@ -201,26 +188,38 @@
}
function showTopics(topiclist) {
+
+
var tbhtml = topiclist.reduce(function(mem, topic) {
var wordsToShow = topic.words.slice(0,4),
max = wordsToShow[0].weight,
min = Math.min(wordsToShow[wordsToShow.length - 1].weight, max - .01),
scale = 8 / (max - min);
+
+ function line(words) {
+ return '<ul class="topic-words">' + words.reduce(function(memwords, word) {
+ return memwords
+ + '<li style="font-size: '
+ + ( 8 + scale * (word.weight - min) )
+ + 'px;">'
+ + word.word
+ + '</li>';
+ },"") + '</ul>';
+ }
+
var li = '<li class="shadow-block topic" data-topic-id="'
+ topic.index
- + '" data-timestamp="999999"><ul class="topic-words">'
- + wordsToShow.reduce(function(memwords, word) {
- return memwords
- + '<li style="font-size: '
- + ( 8 + scale * (word.weight - min) )
- + 'px;">'
- + word.word
- + '</li>';
- },"")
- + '</ul></li>';
+ + '" data-timestamp="999999">'
+ + line(wordsToShow.filter(function( v, k ) {
+ return !(k % 2);
+ }))
+ + line(wordsToShow.filter(function( v, k ) {
+ return !!(k % 2);
+ }))
+ + '</li>';
return mem + li;
},'');
- var tb = $(".topics-block");
+ var tb = $(".topics-list");
tb.html(tbhtml);
tb.css("top",0);
@@ -692,7 +691,7 @@
ntw = tweetids.length,
topicweight = data.topics[j].weights[mmstruct.mmsoindex];
for (var k = 0; k < tweetids.length; k++) {
- var relevance = topicweight * (ntw - k) / ntw,
+ var relevance = topicweight + .5 * (ntw - k) / ntw,
tweetid = tweetids[k];
if (!requestedtweets[tweetid]) {
requestedtweets[tweetid] = {
@@ -846,7 +845,7 @@
var localy = (+t - localpos + localduration / 2) * localyscale;
localIndic.css("top", localy);
}
- if (syncVideo) {
+ if (timelock) {
localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, t));
throttledShowLocal();
}
@@ -871,7 +870,7 @@
return false;
});
- $(".topics-block").on("mouseenter", ".topic", function() {
+ $(".topics-list").on("mouseenter", ".topic", function() {
var el = $(this);
el.addClass("hover");
showTopicViz();
@@ -895,9 +894,12 @@
posX = e.gesture.center.pageX - _o.left,
posY = e.gesture.center.pageY - _o.top;
if (posX < 140) {
- deSync();
- localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, Math.floor(posY / yscale)));
- throttledShowLocal();
+ if (timelock) {
+ player.setCurrentTime(Math.max(0, Math.min(data.duration, Math.floor(posY / yscale))));
+ } else {
+ localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, Math.floor(posY / yscale)));
+ throttledShowLocal();
+ }
}
})
.on("dragstart", function(e) {
@@ -909,9 +911,12 @@
.on("drag", function(e) {
if (isDragging && e.gesture) {
var delta = Math.floor(e.gesture.deltaY / (scrollGlobal ? yscale : - localyscale));
- deSync();
- localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, startPos + delta));
- throttledShowLocal();
+ if (timelock) {
+ player.setCurrentTime(Math.max(0, Math.min(data.duration, startPos + delta)));
+ } else {
+ localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, startPos + delta));
+ throttledShowLocal();
+ }
}
})
.on("touch", function(e) {
@@ -968,8 +973,8 @@
var moveInterval;
- $(".left-arrow").data("direction", -3);
- $(".right-arrow").data("direction", 3);
+ $(".left-arrow").data("direction", 3);
+ $(".right-arrow").data("direction", -3);
$(".left-arrow,.right-arrow")
.on("mouseenter touchstart", function() {
@@ -977,13 +982,22 @@
var moveDirection = $(this).data("direction");
moveInterval = setInterval(function() {
var t = $(".topics-block");
- t.css("left", + moveDirection + parseFloat(t.css("left")));
+ var newcss = + moveDirection + parseFloat(t.css("left"));
+ if ((moveDirection > 0 && newcss > 30) || (moveDirection < 0 && newcss < (t.parent().width() - t.children().width() - 30))) {
+ clearInterval(moveInterval);
+ return;
+ }
+ t.css("left", newcss);
}, 20);
})
.on("mouseleave touchend", function() {
clearInterval(moveInterval);
});
+ $(".play-localtweets").on("click", "li", function() {
+ player.setCurrentTime(parseInt($(this).attr("data-timestamp")));
+ return false;
+ });
$(".play-localtweets").on("click", "li a", function() {
var userid = $(this).attr("data-user-id");
$.getJSON(
@@ -1022,6 +1036,18 @@
return false;
});
+ var timelock = true;
+
+ $(".lock-button").click(function() {
+ timelock = !timelock;
+ if (timelock) {
+ $(this).addClass("locked").attr("title", "Découpler la lecture et la visualisation");
+ } else {
+ $(this).removeClass("locked").attr("title", "Coupler la lecture et la visualisation");
+ }
+ return false;
+ });
+
checkOrGoNext();
}