Spaces:
Running
Running
Delete js/old-js.php
Browse files- js/old-js.php +0 -139
js/old-js.php
DELETED
@@ -1,139 +0,0 @@
|
|
1 |
-
|
2 |
-
/* --------------------------------------------------*/
|
3 |
-
/* ------------- MEDIA PLAYBACK ----------------- */
|
4 |
-
/* ---------------------https://web.archive.org/web/20220121094229/ */
|
5 |
-
/* https://childes.talkbank.org/browser/index.php?url=Eng-UK/MPI-EVA-Manchester/Eleanor/020006b.cha */
|
6 |
-
/*-----------------------------*/
|
7 |
-
$(function (){
|
8 |
-
|
9 |
-
// Add "timeupdate" listener to "#speakera".
|
10 |
-
var vid = document.getElementById("speakera");
|
11 |
-
vid.addEventListener("timeupdate", function(){
|
12 |
-
updatePosition(this.currentTime);
|
13 |
-
});
|
14 |
-
|
15 |
-
|
16 |
-
// Listen for user to pause video.
|
17 |
-
vid.addEventListener("pause", function(){
|
18 |
-
$( '.movControl' ).removeClass( 'playing' ); // Mark all bullets as not "playing".
|
19 |
-
$( '.movControl' ).html("▶"); // Change all bullets to "play".
|
20 |
-
});
|
21 |
-
|
22 |
-
|
23 |
-
// Listen for user to play video. ** i added this
|
24 |
-
vid.addEventListener("play", function(){
|
25 |
-
$( '.movControl' ).html("■"); // Change all bullets to "stop".
|
26 |
-
});
|
27 |
-
|
28 |
-
|
29 |
-
// Click on the little 'play' character at end of utterance line.
|
30 |
-
//$("body").on('click', ".movControl",
|
31 |
-
$("body").on('click', 'span[name=utterance]',
|
32 |
-
function(event) {
|
33 |
-
var vid = document.getElementById("speakera");
|
34 |
-
|
35 |
-
|
36 |
-
// If user clicked "stop" on a playing line, pause video, remove ".playing", change icon to "play".
|
37 |
-
// if($(this).children(".movControl").hasClass('playing')) {
|
38 |
-
if(!vid.paused) {
|
39 |
-
vid.pause();
|
40 |
-
}
|
41 |
-
|
42 |
-
else {
|
43 |
-
var newTime = $(this).attr("beg");
|
44 |
-
vid.currentTime = newTime / 1000;
|
45 |
-
|
46 |
-
vid.play();
|
47 |
-
|
48 |
-
var segmentDur = $(this).attr("end") - newTime
|
49 |
-
|
50 |
-
setTimeout(function(){
|
51 |
-
document.getElementById('speakera').pause();
|
52 |
-
}, segmentDur);
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
-
/*
|
58 |
-
// If video currently paused, and click on highlighted line, then play video.
|
59 |
-
if(( vid.paused ) && ($(this).children(".movControl").hasClass('playing'))) {
|
60 |
-
vid.play();
|
61 |
-
}
|
62 |
-
// Set media to clicked location and pause video
|
63 |
-
else {
|
64 |
-
var newTime = $(this).attr("beg");
|
65 |
-
vid.currentTime = newTime / 1000;
|
66 |
-
|
67 |
-
vid.pause();
|
68 |
-
}
|
69 |
-
*/
|
70 |
-
|
71 |
-
}
|
72 |
-
);
|
73 |
-
|
74 |
-
|
75 |
-
getIntervals();
|
76 |
-
});
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
// Create "intervals[]" from each <span name="utterance"> using its id/class to get the begin/end times.
|
81 |
-
// Needs to be called whenever a new chat file is loaded.
|
82 |
-
var intervals = [];
|
83 |
-
function getIntervals() {
|
84 |
-
$( 'span[name=utterance]' ).each(function( index ) {
|
85 |
-
//console.log( index + ", begin: " + $( this ).prop('beg') + ", end: " + $( this ).prop('end'));
|
86 |
-
intervals.push({"begin": $( this ).prop('beg'), "end": $( this ).prop('end')});
|
87 |
-
});
|
88 |
-
|
89 |
-
//console.log(intervals);
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
// Set $ref as not playing.
|
94 |
-
function notPlaying($ref) {
|
95 |
-
$ref.removeClass('uttPlaying');
|
96 |
-
$ref.children(".movControl").html("▶"); // Show "play" icon.
|
97 |
-
$ref.children(".movControl").removeClass("playing");
|
98 |
-
}
|
99 |
-
|
100 |
-
// Set $ref as playing.
|
101 |
-
function isPlaying($ref) {
|
102 |
-
$ref.addClass('uttPlaying');
|
103 |
-
$ref.children(".movControl").html("■"); // Show "stop" icon.
|
104 |
-
$ref.children(".movControl").addClass("playing");
|
105 |
-
}
|
106 |
-
|
107 |
-
|
108 |
-
// Returns true if $elem is beyond the current scrolled view.
|
109 |
-
function isScrolledOutOfView($elem) {
|
110 |
-
var $window = $(window);
|
111 |
-
|
112 |
-
var windowTop = $window.scrollTop();
|
113 |
-
var windowBottom = windowTop + $window.height();
|
114 |
-
|
115 |
-
var elemTop = $elem.offset().top;
|
116 |
-
var elemBottom = elemTop + $elem.height();
|
117 |
-
|
118 |
-
return ((elemBottom > windowBottom) || (elemTop < windowTop));
|
119 |
-
}
|
120 |
-
|
121 |
-
// Callback function for timeupdate event.
|
122 |
-
function updatePosition( currentTime ) {
|
123 |
-
var msTime = currentTime * 1000;
|
124 |
-
|
125 |
-
for ( c = 0; c < intervals.length; c++ ) {
|
126 |
-
if ((msTime >= intervals[c].begin) && (msTime < intervals[c].end)) {
|
127 |
-
notPlaying($( 'span[name=utterance]' )); // Mark everything as "not playing".
|
128 |
-
isPlaying($( '#' + intervals[c].begin )); // Mark line corresponding to currentTime as "playing".
|
129 |
-
|
130 |
-
// Auto-scroll if playing line is out of view.
|
131 |
-
if (isScrolledOutOfView($('.playing'))) {
|
132 |
-
$('html, body').animate({
|
133 |
-
scrollTop: ($(".playing").offset().top - ($(window).height() / 2))
|
134 |
-
}, 500);
|
135 |
-
}
|
136 |
-
}
|
137 |
-
//$( 'span[name=utterance]' ).removeClass('uttPlaying'); // No interval defined at currentTime.
|
138 |
-
}
|
139 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|