158 ); |
147 ); |
159 for (var i = 0; i < data.chapters.length; i++) { |
148 for (var i = 0; i < data.chapters.length; i++) { |
160 var chap = data.chapters[i]; |
149 var chap = data.chapters[i]; |
161 if (chap.startTime > player.currentTime && topics.indexOf(chap.topic) !== -1) { |
150 if (chap.startTime > player.currentTime && topics.indexOf(chap.topic) !== -1) { |
162 player.setCurrentTime(chap.startTime); |
151 player.setCurrentTime(chap.startTime); |
163 throttledShowLocal(); |
|
164 return; |
152 return; |
165 } |
153 } |
166 } |
154 } |
167 /* If next not found, loop around ! */ |
155 /* If next not found, loop around ! */ |
168 for (var i = 0; i < data.chapters.length; i++) { |
156 for (var i = 0; i < data.chapters.length; i++) { |
169 var chap = data.chapters[i]; |
157 var chap = data.chapters[i]; |
170 if (topics.indexOf(chap.topic) !== -1) { |
158 if (topics.indexOf(chap.topic) !== -1) { |
171 player.setCurrentTime(chap.startTime); |
159 player.setCurrentTime(chap.startTime); |
172 throttledShowLocal(); |
|
173 return; |
160 return; |
174 } |
161 } |
175 } |
162 } |
176 } |
163 } |
177 |
164 |
199 } |
186 } |
200 } |
187 } |
201 } |
188 } |
202 |
189 |
203 function showTopics(topiclist) { |
190 function showTopics(topiclist) { |
|
191 |
|
192 |
204 var tbhtml = topiclist.reduce(function(mem, topic) { |
193 var tbhtml = topiclist.reduce(function(mem, topic) { |
205 var wordsToShow = topic.words.slice(0,4), |
194 var wordsToShow = topic.words.slice(0,4), |
206 max = wordsToShow[0].weight, |
195 max = wordsToShow[0].weight, |
207 min = Math.min(wordsToShow[wordsToShow.length - 1].weight, max - .01), |
196 min = Math.min(wordsToShow[wordsToShow.length - 1].weight, max - .01), |
208 scale = 8 / (max - min); |
197 scale = 8 / (max - min); |
|
198 |
|
199 function line(words) { |
|
200 return '<ul class="topic-words">' + words.reduce(function(memwords, word) { |
|
201 return memwords |
|
202 + '<li style="font-size: ' |
|
203 + ( 8 + scale * (word.weight - min) ) |
|
204 + 'px;">' |
|
205 + word.word |
|
206 + '</li>'; |
|
207 },"") + '</ul>'; |
|
208 } |
|
209 |
209 var li = '<li class="shadow-block topic" data-topic-id="' |
210 var li = '<li class="shadow-block topic" data-topic-id="' |
210 + topic.index |
211 + topic.index |
211 + '" data-timestamp="999999"><ul class="topic-words">' |
212 + '" data-timestamp="999999">' |
212 + wordsToShow.reduce(function(memwords, word) { |
213 + line(wordsToShow.filter(function( v, k ) { |
213 return memwords |
214 return !(k % 2); |
214 + '<li style="font-size: ' |
215 })) |
215 + ( 8 + scale * (word.weight - min) ) |
216 + line(wordsToShow.filter(function( v, k ) { |
216 + 'px;">' |
217 return !!(k % 2); |
217 + word.word |
218 })) |
218 + '</li>'; |
219 + '</li>'; |
219 },"") |
|
220 + '</ul></li>'; |
|
221 return mem + li; |
220 return mem + li; |
222 },''); |
221 },''); |
223 var tb = $(".topics-block"); |
222 var tb = $(".topics-list"); |
224 tb.html(tbhtml); |
223 tb.html(tbhtml); |
225 tb.css("top",0); |
224 tb.css("top",0); |
226 |
225 |
227 showTopicViz(); |
226 showTopicViz(); |
228 } |
227 } |
690 for (var j = 0; j < res.length; j++) { |
689 for (var j = 0; j < res.length; j++) { |
691 var tweetids = res[j], |
690 var tweetids = res[j], |
692 ntw = tweetids.length, |
691 ntw = tweetids.length, |
693 topicweight = data.topics[j].weights[mmstruct.mmsoindex]; |
692 topicweight = data.topics[j].weights[mmstruct.mmsoindex]; |
694 for (var k = 0; k < tweetids.length; k++) { |
693 for (var k = 0; k < tweetids.length; k++) { |
695 var relevance = topicweight * (ntw - k) / ntw, |
694 var relevance = topicweight + .5 * (ntw - k) / ntw, |
696 tweetid = tweetids[k]; |
695 tweetid = tweetids[k]; |
697 if (!requestedtweets[tweetid]) { |
696 if (!requestedtweets[tweetid]) { |
698 requestedtweets[tweetid] = { |
697 requestedtweets[tweetid] = { |
699 id: tweetid, |
698 id: tweetid, |
700 status: 0, |
699 status: 0, |
844 globalIndic.css("top", yscale * t); |
843 globalIndic.css("top", yscale * t); |
845 if (localyscale) { |
844 if (localyscale) { |
846 var localy = (+t - localpos + localduration / 2) * localyscale; |
845 var localy = (+t - localpos + localduration / 2) * localyscale; |
847 localIndic.css("top", localy); |
846 localIndic.css("top", localy); |
848 } |
847 } |
849 if (syncVideo) { |
848 if (timelock) { |
850 localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, t)); |
849 localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, t)); |
851 throttledShowLocal(); |
850 throttledShowLocal(); |
852 } |
851 } |
853 }); |
852 }); |
854 |
853 |
869 $(".prev-button").click(function() { |
868 $(".prev-button").click(function() { |
870 goToPrev(); |
869 goToPrev(); |
871 return false; |
870 return false; |
872 }); |
871 }); |
873 |
872 |
874 $(".topics-block").on("mouseenter", ".topic", function() { |
873 $(".topics-list").on("mouseenter", ".topic", function() { |
875 var el = $(this); |
874 var el = $(this); |
876 el.addClass("hover"); |
875 el.addClass("hover"); |
877 showTopicViz(); |
876 showTopicViz(); |
878 }).on("mouseleave", ".topic", function() { |
877 }).on("mouseleave", ".topic", function() { |
879 $(this).removeClass("hover"); |
878 $(this).removeClass("hover"); |
893 h.on("tap", function(e) { |
892 h.on("tap", function(e) { |
894 var _o = $(this).offset(), |
893 var _o = $(this).offset(), |
895 posX = e.gesture.center.pageX - _o.left, |
894 posX = e.gesture.center.pageX - _o.left, |
896 posY = e.gesture.center.pageY - _o.top; |
895 posY = e.gesture.center.pageY - _o.top; |
897 if (posX < 140) { |
896 if (posX < 140) { |
898 deSync(); |
897 if (timelock) { |
899 localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, Math.floor(posY / yscale))); |
898 player.setCurrentTime(Math.max(0, Math.min(data.duration, Math.floor(posY / yscale)))); |
900 throttledShowLocal(); |
899 } else { |
|
900 localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, Math.floor(posY / yscale))); |
|
901 throttledShowLocal(); |
|
902 } |
901 } |
903 } |
902 }) |
904 }) |
903 .on("dragstart", function(e) { |
905 .on("dragstart", function(e) { |
904 startPos = localpos; |
906 startPos = localpos; |
905 var x = e.gesture.center.pageX - $(this).offset().left; |
907 var x = e.gesture.center.pageX - $(this).offset().left; |
907 scrollGlobal = (x < 140); |
909 scrollGlobal = (x < 140); |
908 }) |
910 }) |
909 .on("drag", function(e) { |
911 .on("drag", function(e) { |
910 if (isDragging && e.gesture) { |
912 if (isDragging && e.gesture) { |
911 var delta = Math.floor(e.gesture.deltaY / (scrollGlobal ? yscale : - localyscale)); |
913 var delta = Math.floor(e.gesture.deltaY / (scrollGlobal ? yscale : - localyscale)); |
912 deSync(); |
914 if (timelock) { |
913 localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, startPos + delta)); |
915 player.setCurrentTime(Math.max(0, Math.min(data.duration, startPos + delta))); |
914 throttledShowLocal(); |
916 } else { |
|
917 localpos = Math.max(localduration / 2, Math.min(data.duration - localduration / 2, startPos + delta)); |
|
918 throttledShowLocal(); |
|
919 } |
915 } |
920 } |
916 }) |
921 }) |
917 .on("touch", function(e) { |
922 .on("touch", function(e) { |
918 startLevel = currentlevel; |
923 startLevel = currentlevel; |
919 }) |
924 }) |
966 $(".keyword-search a").removeClass("placeholder").text(pageParams.keywords.join(", ")); |
971 $(".keyword-search a").removeClass("placeholder").text(pageParams.keywords.join(", ")); |
967 } |
972 } |
968 |
973 |
969 var moveInterval; |
974 var moveInterval; |
970 |
975 |
971 $(".left-arrow").data("direction", -3); |
976 $(".left-arrow").data("direction", 3); |
972 $(".right-arrow").data("direction", 3); |
977 $(".right-arrow").data("direction", -3); |
973 |
978 |
974 $(".left-arrow,.right-arrow") |
979 $(".left-arrow,.right-arrow") |
975 .on("mouseenter touchstart", function() { |
980 .on("mouseenter touchstart", function() { |
976 clearInterval(moveInterval); |
981 clearInterval(moveInterval); |
977 var moveDirection = $(this).data("direction"); |
982 var moveDirection = $(this).data("direction"); |
978 moveInterval = setInterval(function() { |
983 moveInterval = setInterval(function() { |
979 var t = $(".topics-block"); |
984 var t = $(".topics-block"); |
980 t.css("left", + moveDirection + parseFloat(t.css("left"))); |
985 var newcss = + moveDirection + parseFloat(t.css("left")); |
|
986 if ((moveDirection > 0 && newcss > 30) || (moveDirection < 0 && newcss < (t.parent().width() - t.children().width() - 30))) { |
|
987 clearInterval(moveInterval); |
|
988 return; |
|
989 } |
|
990 t.css("left", newcss); |
981 }, 20); |
991 }, 20); |
982 }) |
992 }) |
983 .on("mouseleave touchend", function() { |
993 .on("mouseleave touchend", function() { |
984 clearInterval(moveInterval); |
994 clearInterval(moveInterval); |
985 }); |
995 }); |
986 |
996 |
|
997 $(".play-localtweets").on("click", "li", function() { |
|
998 player.setCurrentTime(parseInt($(this).attr("data-timestamp"))); |
|
999 return false; |
|
1000 }); |
987 $(".play-localtweets").on("click", "li a", function() { |
1001 $(".play-localtweets").on("click", "li a", function() { |
988 var userid = $(this).attr("data-user-id"); |
1002 var userid = $(this).attr("data-user-id"); |
989 $.getJSON( |
1003 $.getJSON( |
990 solrUrl( |
1004 solrUrl( |
991 "twitter", |
1005 "twitter", |
1018 $(".user-tweets-list").html(html); |
1032 $(".user-tweets-list").html(html); |
1019 $(".user-name").text(tweets[0].from_user_name); |
1033 $(".user-name").text(tweets[0].from_user_name); |
1020 } |
1034 } |
1021 ); |
1035 ); |
1022 return false; |
1036 return false; |
|
1037 }); |
|
1038 |
|
1039 var timelock = true; |
|
1040 |
|
1041 $(".lock-button").click(function() { |
|
1042 timelock = !timelock; |
|
1043 if (timelock) { |
|
1044 $(this).addClass("locked").attr("title", "Découpler la lecture et la visualisation"); |
|
1045 } else { |
|
1046 $(this).removeClass("locked").attr("title", "Coupler la lecture et la visualisation"); |
|
1047 } |
|
1048 return false; |
1023 }); |
1049 }); |
1024 |
1050 |
1025 checkOrGoNext(); |
1051 checkOrGoNext(); |
1026 } |
1052 } |
1027 |
1053 |