forked from maboa/hyperaudiopad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindexlatest.htm
564 lines (393 loc) · 14.4 KB
/
indexlatest.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<!DOCTYPE html>
<!-- BEGIN html -->
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<!-- Based on an Orman Clark design (http://www.premiumpixels.com) -->
<!-- BEGIN head -->
<head>
<!-- Meta Tags -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- Title -->
<title>Hyperaudio An Introduction</title>
<!-- Stylesheets -->
<!--<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Droid+Serif:regular,italic,bold,bolditalic" type="text/css" />
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold" type="text/css" /> -->
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="circleplayer.css" type="text/css" media="screen" />
<!-- Magick -->
<!-- Move jQuery Local! -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.rotate.js"></script>
<script type="text/javascript" src="js/jquery.grab.js"></script>
<script type="text/javascript" src="js/jquery.jplayer.js"></script>
<script type="text/javascript" src="js/mod.csstransforms.min.js"></script>
<script type="text/javascript" src="js/popcorn.js"></script>
<script type="text/javascript" src="js/popcorn.transcript.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var cssTransforms = Modernizr.csstransforms;
var myPlayer = $("#jquery_jplayer_1");
// Utility
function getUrlVars() {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
// url links to audio
var endTime = getUrlVars()["e"];
if (getUrlVars()["e"] != null) {
endTime = parseInt(getUrlVars()["e"])/10;
}
myPlayer.jPlayer({
ready: function (event) {
if(event.jPlayer.html.used && event.jPlayer.html.audio.available) {
//initPopcorn('#' + $(this).data("jPlayer").internal.audio.id);
}
},
solution: "html, flash",
swfPath: "js",
supplied: "mp3,oga"
//errorAlerts: "true",
//warningAlerts: "true"
});
function checkStartParam() {
if (getUrlVars()["s"] != null) {
var s = parseInt(getUrlVars()["s"])/10;
if (lang == 'en') {
playerEn.jPlayer("play",s);
} else {
playerDa.jPlayer("play",s);
}
}
}
// These events are fired as play time increments
var playingWord = 1;
myPlayer.bind($.jPlayer.event.timeupdate, function(event) {
playTimeEn = event.jPlayer.status.currentPercentAbsolute;
currentTime = event.jPlayer.status.currentTime;
// Check for end param
if (endTime != null && endTime < currentTime) {
myPlayer.jPlayer("pause");
endTime = null;
}
});
// transcript links to audio
$('#transcript').delegate('span','click',function(){
var jumpTo = $(this).attr('m')/1000;
myPlayer.jPlayer("play",jumpTo);
return false;
});
function displayProgress(pc) {
var degs = pc * 3.6+"deg";
// 24 x 104px sprites
var spriteOffset = (Math.floor((Math.round(pc))*0.24)-1)*-104;
if (pc <= 50) {
if (cssTransforms) {
$('#circle-holder').removeClass('gt50');
$('#progress1').css({rotate: degs});
$('#progress1').removeClass('fallback');
}
else { // fall back
if (spriteOffset <= 0) {
$('#circle-holder').addClass('gt50');
$('#progress1').addClass('fallback');
$('#progress1').css('background-position', '0 '+spriteOffset+'px');
}
}
$('#progress2').hide();
}
else if (pc <= 100) {
$('#circle-holder').addClass('gt50');
if (cssTransforms) {
$('#progress1').css({rotate: '180deg'});
$('#progress2').css({rotate: degs});
$('#progress2').show();
}
else { // fall back
$('#progress1').css('background-position', '0 '+spriteOffset+'px');
}
}
}
function displayBuffered(pc) {
var degs = pc * 3.6+"deg";
if (pc <= 50) {
$('#buffer-holder').removeClass('gt50');
$('#buffer1').css({rotate: degs});
$('#buffer2').hide();
}
else if (pc <= 100) {
$('#buffer-holder').addClass('gt50');
$('#buffer1').css({rotate: '180deg'});
$('#buffer2').show();
$('#buffer2').css({rotate: degs});
}
}
// This event fired as play time increments
myPlayer.bind($.jPlayer.event.timeupdate, function(event) {
var pc = event.jPlayer.status.currentPercentAbsolute;
if (!dragging) {
displayProgress(pc);
}
});
// This event fired as buffered time increments
myPlayer.bind($.jPlayer.event.progress, function(event) {
var audio = $('#jquery_jplayer_1').data("jPlayer").htmlElement.audio;
var pc = 0;
// Fallback to event.jPlayer.status.seekPercent; if buffered not supported
if((typeof audio.buffered === "object") && (audio.buffered.length > 0)) {
pc = (audio.duration > 0) ? 100 * audio.buffered.end(audio.buffered.length-1) / audio.duration : 100;
displayBuffered(pc);
}
else {
pc = event.jPlayer.status.seekPercent;
}
// Old buffering doesn't take account of different timeranges when user skips forward
/*if ((audio.buffered != undefined) && (audio.buffered.length != 0))
{
pc = parseInt(((audio.buffered.end(0) / audio.duration) * 100), 10);
displayBuffered(pc);
} */
});
myPlayer.bind($.jPlayer.event.ended, function() {
if (cssTransforms) {
$('#circle-holder').removeClass('gt50');
$('#progress1').css({rotate: '0deg'}).show();
$('#progress2').css({rotate: '0deg'}).hide();
}
else {
$('#progress1').css('background-position', '0 104px');
}
});
var dragging = false; // Indicates if the progressbar is being 'dragged'.
var clickControl = $('.click-control');
function getArcPc(pageX, pageY) {
var self = clickControl,
offset = self.offset(),
x = pageX - offset.left - self.width()/2,
y = pageY - offset.top - self.height()/2,
a = Math.atan2(y,x);
if (a > -1*Math.PI && a < -0.5*Math.PI) {
a = 2*Math.PI+a;
}
// a is now value between -0.5PI and 1.5PI
// ready to be normalized and applied
var pc = (a + Math.PI/2) / 2*Math.PI * 10;
return pc;
}
clickControl.grab({
onstart: function(){
dragging = true;
}, onmove: function(event){
var pc = getArcPc(event.position.x, event.position.y);
myPlayer.jPlayer("playHead", pc).jPlayer("play");
displayProgress(pc);
}, onfinish: function(event){
dragging = false;
var pc = getArcPc(event.position.x, event.position.y);
myPlayer.jPlayer("playHead", pc).jPlayer("play");
}
});
/* hyperaudiopad stuff */
/* load in the file */
function initPopcorn(id) {
var p = Popcorn(id);
$("#transcript-content span").each(function(i) {
p.transcript({
time: $(this).attr("m") / 1000, // seconds
futureClass: "transcript-grey",
target: this
});
});
};
$('.transcript-file').live('click',function(){
var id = $(this).attr('href');
var file ='transcripts/'+id;
var audioogg = 'audio/'+id+'.ogg';
var audiomp3 = 'audio/'+id+'.mp3';
$('#script-title').text($(this).text());
$('#transcript-content').load(file, function() {
//load success!!!
initPopcorn('#' + myPlayer.data("jPlayer").internal.audio.id);
// load in the audio
myPlayer.jPlayer("setMedia", {
mp3: audiomp3,
oga: audioogg
});
});
return false;
});
// select text function
function getSelText()
{
var txt = '';
if (window.getSelection){
txt = window.getSelection();
}
else if (document.getSelection){
txt = document.getSelection();
}
else if (document.selection){
txt = document.selection.createRange().text;
}
return txt;
}
// Sets the excerpt
$('#transcript-content').mouseup(function(e){
var select = getSelText();
var tweetable = select+"";
var startSpan = select.anchorNode.nextSibling;
if (startSpan == null) {
startSpan = select.anchorNode.parentNode;
}
var endSpan = select.focusNode.nextSibling;
if (endSpan == null) {
endSpan = select.focusNode.parentNode.nextElementSibling;
if (endSpan == null) {
endSpan = select.focusNode.parentNode;
}
}
// Flip if end time is less than start time (ie the text was selected backwards)
var startTime = startSpan.getAttribute('m');
var endTime = endSpan.getAttribute('m');
var tempSpan = endSpan;
if (endTime < startTime) {
endSpan = startSpan;
startSpan = tempSpan;
}
console.log(startSpan);
console.log(endSpan);
var nextSpan = startSpan;
while(nextSpan != endSpan) {
//for (i=0; i<10; i++) {
nextSpan = getNextNode(nextSpan,true,endSpan);
$(nextSpan).appendTo('#target-content');
console.log(nextSpan);
}
//console.log(startSpan.nextElementSibling);
//console.log(getNextNode(startSpan,true,endSpan));
//var midspan = startSpan.nextSibling;
//console.log(startSpan.parentNode.nextElementSibling);
//console.log(endSpan);
/* console.log('hhhhh');
var nextSpan = startSpan;
while (nextSpan != endSpan) {
nextSpan = nextSpan.nextSibling;
console.log(nextSpan);
} */
});
var getNextNode = function(node, skipChildren, endNode){
//if there are child nodes and we didn't come from a child node
if (endNode == node) {
return null;
}
if (node.firstChild && !skipChildren) {
return node.firstChild;
}
if (!node.parentNode){
return null;
}
return node.nextElementSibling
|| getNextNode(node.parentNode, true, endNode);
//return node.nextSibling
//|| getNextNode(node.parentNode, true, endNode);
};
});
</script>
<!-- END Magick -->
<!-- END head -->
</head>
<!-- BEGIN body -->
<body class="single single-post postid-4004 gecko layout-2cr">
<div>
<ul>
<li><a class="transcript-file" href="nitotmozilla-m" >Tristan Nitot on Firefox</a></li>
<li><a class="transcript-file" href="" >Transcript 2</a></li>
<li><a class="transcript-file" href="" >Transcript 3</a></li>
</ul>
<a href="" id="test">test</a>
</div>
<!-- BEGIN #container -->
<div id="container">
<!-- BEGIN #header -->
<div id="header" class="clearfix">
<!-- BEGIN #upper-wrap -->
<div id="upper-wrap" class="clearfix">
<!-- <div id="logo">
What is Hyperaudio?
<p id="tagline">hypertext + audio (tightly coupled)</p>
</div> -->
<!--END #upper-wrap-->
</div>
<!--END #header-->
</div>
<!--BEGIN #content -->
<div id="content" class="clearfix">
<!--BEGIN #primary .hfeed-->
<div id="primary" class="hfeed">
<!--BEGIN .hentry -->
<div>
<!-- Player -->
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
<div id="jp_container_1" class="player">
<div id="buffer-holder" class="hold"> <!-- .gt50 only needed when buffer is > than 50% -->
<div id="buffer1" class="buffer">
</div>
<div id="buffer2" class="buffer fill" style="display:none"> <!-- this div, with extra .fill only needed when buffer is > than 50% -->
</div>
</div>
<div id="circle-holder" class="hold"> <!-- .gt50 only needed when progress is > than 50% -->
<div id="progress1" class="progress">
</div>
<div id="progress2" class="progress fill" style="display:none"> <!-- this div, with extra .fill only needed when progress is > than 50% -->
</div>
</div>
<div class="click-control"></div>
<ul class="jp-controls">
<li><a href="#" class="jp-play" tabindex="1">play</a></li>
<li><a href="#" class="jp-pause" style="display:none;" tabindex="1">pause</a></li>
</ul>
</div>
<!-- END Player -->
<!--<h2 class="entry-title">Hyperaudio Interview on Danish Radio's HardDisken Program</h2>-->
<h2 id="script-title" class="entry-title"></h2>
<!--BEGIN .clearfix -->
<div class="clearfix">
<!--BEGIN .entry-meta .entry-header-->
<!--<div class="entry-meta entry-header">
<span class="author">Interview with <a href="https://twitter.com/#!/nitot">Tristan Nitot</a></span>
<span class="author">By <a href="http://www.dr.dk/P1/harddisken/om_harddisken/20071204114844.htm">Anders Høgh Nissen</a></span>
<span class="published">On <strong>April 3, 2011</strong></span>
</div> <!--END .entry-meta entry-header -->
<!--BEGIN .entry-content -->
<div id="transcript" class="entry-content">
<!-- transcript goes here -->
<div id="transcript-content">
</div>
<!--END .entry-content -->
</div>
<!--END .clearfix -->
</div>
<!--END .hentry-->
</div>
</div>
<!-- pasteable part -->
<div id="target-content" contenteditable="true">
Paste here.
</div>
<!-- BEGIN #footer -->
<div id="footer" class="clearfix">
<!--<p>Demo by <a href="http://twitter.com/maboa"> @maboa</a></p>-->
<!-- END #footer -->
</div>
<!-- END #footer-container -->
</div>
<!-- Theme Hook -->
<!--END body-->
</body>
<!--END html-->
</html>