-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.html
162 lines (133 loc) · 4.33 KB
/
index.html
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
---
layout: default
title: Are men talking too much?
---
<body>
<div class="alert alert-info alert-ga text-center" role="alert">
<a href="https://www.genderavenger.com/blog/are-men-talking-too-much" class="ga" target="_blank">
We're teaming up with GenderAvenger to measure #WhoTalks! Learn more »
</a>
<a class="icon-link" href="https://twitter.com/intent/tweet?text=I+just+watched+X.+men+talked+X%25+of+the+time!+%23WhoTalks" target="_blank">
<i class="fa fa-lg fa-twitter" aria-hidden="true"></i>
</a>
</div>
<div class="content">
<div class="row-fluid">
<div class="col-sm-8 col-sm-offset-2 center">
<br/>
<h3><span class="highlight"><i>check who's dominating the conversation</i></span></h3>
<br/>
<h1>who's talking?</h1>
<p id="ans"> </p>
<div class="row-fluid" id="button-div">
<div class="col-xs-6">
<a class="btn btn-lg btn-default" id="dude">a dude</a>
<p id="dude-display">00:00</p>
</div>
<div class="col-xs-6">
<a class="btn btn-lg btn-default" id="not-dude">not a dude</a>
<p id="not-dude-display">00:00</p>
</div>
</div>
<div class="clearfix"></div>
<br/><br/><br/><br/><br/><br/><br/><br/><br/>
<p class="small"><a class="muted-link" href="https://github.com/cathydeng/are-men-talking-too-much">made with ♡ by Cathy Deng</a></p>
</div>
</div>
</div>
</body>
<script type="text/javascript">
$(function() {
'use strict';
var dude = {
time: {
minutes: 0,
seconds: 0,
hours: 0
},
active: false
};
var not_dude = {
time: {
minutes: 0,
seconds: 0,
hours: 0
},
active: false
};
var dude_t;
var not_dude_t;
var $ans = $('#ans');
var $dude = $('#dude');
var $not_dude = $('#not-dude');
function num_pad(num) {
if (num < 10) {
return '0' + num;
} else {
return num;
}
}
function add(tally, display_sel) {
tally.seconds++;
if (tally.seconds >= 60) {
tally.minutes++;
tally.seconds = 0;
}
if (tally.minutes >= 60) {
tally.hours++;
tally.minutes = 0;
}
if (tally.hours !== 0) {
$(display_sel).html(num_pad(tally.hours) + ':' + num_pad(tally.minutes) + ':' + num_pad(tally.seconds));
} else {
$(display_sel).html(num_pad(tally.minutes) + ':' + num_pad(tally.seconds));
}
var d_tot = (dude.time.hours * 3600) + (dude.time.minutes * 60) + dude.time.seconds;
var l_tot = (not_dude.time.hours * 3600) + (not_dude.time.minutes * 60) + not_dude.time.seconds;
var pct = parseInt(d_tot / (d_tot + l_tot) * 100, 10);
$ans.html('<span id="pct">' + pct + '</span>% men');
}
$dude.click(function() {
$dude.toggleClass('pressed');
if (dude.active === true) {
dude.active = false;
clearInterval(dude_t);
} else {
dude.active = true;
if (not_dude.active === true) {
$not_dude.toggleClass('pressed');
not_dude.active = false;
clearInterval(not_dude_t);
}
dude_t = setInterval(function() {
add(dude.time, '#dude-display');
}, 1000);
}
});
$not_dude.click(function() {
$not_dude.toggleClass('pressed');
if (not_dude.active === true) {
not_dude.active = false;
clearInterval(not_dude_t);
} else {
not_dude.active = true;
if (dude.active === true) {
$dude.toggleClass('pressed');
dude.active = false;
clearInterval(dude_t);
}
not_dude_t = setInterval(function() {
add(not_dude.time, '#not-dude-display');
}, 1000);
}
});
$('body').keydown(function(e) {
if (e.keyCode === 37) { // left
$dude.trigger('click');
} else if (e.keyCode === 39) { //right
$not_dude.trigger('click');
}
});
});
</script>
</body>