-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
209 lines (184 loc) · 6.77 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Petition Pinger</title>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js" integrity="sha256-ufGElb3TnOtzl5E4c/qQnZFGP+FYEZj5kbSEdJNrw0A=" crossorigin="anonymous"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"
integrity="sha256-chlNFSVx3TdcQ2Xlw7SvnbLAavAQLO0Y/LBiWX04viY=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.4.4/d3.min.js"
integrity="sha256-V28Aoqm/QLxBnkLyoarf0+wZtgxDAu7mJ9KcBYvTBnI=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/5.0.1/Rx.min.js"
integrity="sha256-TeWVfZ29ZE2tO8al/1wPR2TAOWZ1GRXbZ90H5p/dNMY=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"
integrity="sha256-8E6QUcFg1KTnpEU8TFGhpTGHw5fJqB9vCms3OhAYLqw=" crossorigin="anonymous"></script>
<style>
path.constituency {
transition: fill 3s ease;
}
#main {
display: -ms-flex;
display: -webkit-flex;
display: flex;
height: 600px;
}
#outlet {
min-width: 400px;
height: 600px;
width: 32%;
}
#outlet svg {
margin: auto;
display: block;
}
#votes {
min-width: 200px;
width: 67%;
height: 600px;
}
table {
border-collapse: collapse;
}
td, th {
border: 1px solid #999;
padding: 5px;
text-align: left;
}
.new-entry {
background-color: green;
}
.moving-up:after {
content: ' \2191 ';
color: green;
}
.moving-down:after {
content: ' \2193 ';
color: red;
}
.steady:after {
content: ' \2194 ';
}
.highlight {
transition: none !important;
fill: green !important;
background-color: rgba(0, 128, 0, 0.3);
}
.constituency-name {
cursor: pointer;
}
#flash {
color: red;
font-size: xx-large;
font-weight: bold;
}
#petition {
width: 350px;
}
input {
border: 1px solid grey;
padding-left: 5px;
}
</style>
</head>
<body>
<h1>Petition Pinger</h1>
<p>
Back in 2017 I was amazed at how quickly <a href="https://petition.parliament.uk/petitions/171928" target="_blank">this
petition</a> was being signed and noticed that the data is <a
href="https://petition.parliament.uk/petitions/171928.json" target="_blank">published as JSON</a> so decided to
see where the votes were coming from.
<br/> <a href="https://github.com/pauldambra/petition-pinger">(fork me on github)</a>
</p>
<div id="petition-chooser">
<h2><label for="petition">Choose a petition:</label></h2>
<input id="petition" list="popular-petitions" v-model="petitionUrl"/>
<datalist id="popular-petitions">
<option
v-for="petition in petitions"
:value="petition.url"
>
{{petition.description}}
</option>
</datalist>
</div>
<p id="now-tracking-outlet">
Currently tracking <a :href="humanUrl">{{name}}</a> with {{signatureCount}} signatures <a :href="humanUrl">go sign it if you haven't!</a>
<p>
</p>
<div id="flash"></div>
<div id="main">
<div id="outlet">
<svg></svg>
</div>
<div id="votes" style="max-width: 560px">
<h1>
Constituencies by Votes
</h1>
<div class="pagination" style="text-align: center">
<button style="float: left" @click="prevPage"> ← Previous</button>
<span>page {{currentPage}} of {{totalPages}}</span>
<button style="float: right" @click="nextPage">Next →</button>
</div>
<div>
<input v-model="constituencyFilter" placeholder="filter"
style="width: 98%;margin:1% 0;height: 2em;line-height: 2em"/>
</div>
<table width="100%">
<thead>
<th>Constituency</th>
<th>Votes</th>
</thead>
<tbody>
<tr
v-for="leader in leaderboardPage"
v-bind:key="leader.name"
:class="leader.isNewEntry && 'new-entry'"
v-on:mouseover.stop="mouseOver($event, leader)"
v-on:mouseleave.stop="mouseLeave($event, leader)"
>
<td class="constituency-name">
{{ leader.name }}
</td>
<td>
<span
:class="leader.movement"
:data-position="leader.position"
:data-last-position="leader.lastPosition"
>
{{ leader.signatureCount }}
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h2>How does it work</h2>
<p>
Choose a petition and the site starts checking it for new signatures. "pinging it". Constituencies flash yellow when at least one new signature is received from them. Once the leaderboard loads you can hover over constituencies to see where they are.
</p>
<h2>Sharing</h2>
<p>
You can share a pinger that starts on a particular URL by adding its json petition url to a query parameter called "petition"...
</p>
<p>
Or a pinger that starts pre-filtered to search for constituencies by adding the search string to a query parameter called "filter"...
</p><p>like this: <a
href="https://pauldambra.dev/petition-pinger/?filter=stockport&petition=https://petition.parliament.uk/archived/petitions/171928.json"
target="_blank">https://pauldambra.dev/petition-pinger/?filter=stockport&petition=https://petition.parliament.uk/archived/petitions/171928.json</a>
</p>
<script type="text/javascript">
window.petitionPinger = window.petitionPinger || {}
</script>
<script src="query-params.js" charset="utf-8"></script>
<script src="constituencies.js" charset="utf-8"></script>
<script src="uk.electionmap.d3.js" charset="utf-8"></script>
<script src="map.js" charset="utf-8"></script>
<script src="petition-chooser.js" charset="utf-8"></script>
<script src="pinger.js" charset="utf-8"></script>
<script src="flash-on-sign.js" charset="utf-8"></script>
<script src="leaderboard.js" charset="utf-8"></script>
<script src="update-now-tracking.js" charset="utf-8"></script>
</body>
</html>