-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpresentation.js
125 lines (95 loc) · 3.27 KB
/
presentation.js
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
$(document).ready(function() {
/* initializing fathom */
var fathom = new Fathom('#presentation');
/* initializing timer */
$(".time").countdown(
{ since: new Date(), compact: true, format: "MS" }
);
var timerState = true;
$(".time").on( 'click', function() {
if ( timerState ) {
timerState = false;
$(this).countdown('pause');
$(this).fadeTo( 1000, 0.5 );
} else {
timerState = true;
$(this).countdown('resume');
$(this).fadeTo( 1000, 1.0 );
}
});
/* enumerating the slides and fitting the size */
var counter = 0;
var length = 0;
$(".title").each( function() {
++counter;
$(this).html( '<div class="enumerator">' + counter + "</div>" + $(this).html() );
/* the size of long titles is reduced */
length = $(this).text().split(" ").length;
if ( length > 5 ) {
var o = parseInt( $(this).css( "font-size" ) );
$(this).css( "font-size", ( o * 0.75 ) + "px" );
}
});
/* creating a variable offset */
var counter = 0;
var offset = 0.0;
$( ".slide" ).html( function() {
++counter;
if ( counter % 2 == 0 ) {
offset = Math.random() + 0.5;
$(this).css( "margin-top", offset + "em" );
}
});
/* fitting the font-size of the paragraphs agains the
length of their contents */
$( "p" ).each( function() {
var length = $(this).text().split(" ").length;
var size = 1.0;
if ( length <= 3 ) {
$(this).css( "font-size", 3.5 + "em" );
$(this).css( "padding-left", 2.5 + "em" );
} else if ( length <= 10 ) {
$(this).css( "font-size", 2.5 + "em" );
} else if ( length <= 30 ) {
$(this).css( "font-size", 1.8 + "em" );
} else if ( length <= 60 ) {
$(this).css( "font-size", 1.2 + "em" );
}
console.info( length + " " + size );
/* $(this).append( '<sup style="color: rgba( 0, 0, 0, 0.2 );">{' + length + '}</sup>' ); */
});
/* compute the mean length of each list item and
increase the font-size accordingly */
$( "ul" ).each( function() {
var length = 0;
var count = 0;
$(this).children().each( function() {
length += $(this).text().length;
count += 1
});
var mean = ( length / count ) ? count > 0 : 0;
if ( mean < 32 ) {
$(this).css( "font-size", 1.8 + "em" );
} else if ( mean < 72 ) {
$(this).css( "font-size", 1.5 + "em" );
} else if ( mean < 164 ) {
$(this).css( "font-size", 1.1 + "em" );
}
});
$( "ol" ).each( function() {
var length = 0;
var count = 0;
$(this).children().each( function() {
length += $(this).text().length;
count += 1
});
var mean = ( length / count ) ? count > 0 : 1000;
if ( mean < 32 ) {
$(this).css( "font-size", 1.8 + "em" );
} else if ( mean < 72 ) {
$(this).css( "font-size", 1.5 + "em" );
} else if ( mean < 164 ) {
$(this).css( "font-size", 1.1 + "em" );
}
});
});