-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathedit.html
247 lines (225 loc) · 10.3 KB
/
edit.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta content="initial-scale=1, shrink-to-fit=no, width=device-width" name="viewport">
<!-- CSS -->
<link href="dist/css/main.css" rel="stylesheet">
<style>
</style>
</head>
<body>
<header>
<div class="collapse bg-primary-light" id="navbarHeader">
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-7 py-4">
<h4 class="">About</h4>
<p class="">
</p>
</div>
<div class="col-sm-4 offset-md-1 py-4">
<h4 class="">Contact</h4>
<ul class="list-unstyled">
<li><a href="https://twitter.com/eucampaign" class="">Follow on Twitter</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="navbar navbar-dark bg-primary box-shadow">
<div class="container d-flex justify-content-between">
<a href="#" class="navbar-brand d-flex align-items-center">
<svg><use href="#logo" /></svg>MEP Watch
</a>
<span class="date">YYYY-mm-DD</span>
<span class="report">A8-XXXX/20YY</span>
<a href="/vote.html" class="edit btn btn-light">View</a>
<a href="" class="app btn btn-light" >Generate the app</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
<svg class="icon"><use href="#menu" /></svg>
</button>
</div>
</div>
</header>
<main role="main">
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">Edit the presentation of a vote</h1>
<p>
</p>
</div>
</section>
<form>
<div class="py-5">
<div class="container-fluid">
<div class="row">
<div class="col-6">
<div class="form-group">
<label>report</label>
<input class="form-control" placeholder="Report" name="report" id="report">
</div>
<div class="form-group">
<label>Name</label>
<input class="form-control" placeholder="Enter Name of the vote" name="name" id="name">
<small id="emailHelp" class="form-text text-muted">Try to write it as a question: what the MEPs needed to vote for or against?</small>
</div>
<div class="form-group">
<label>Why is this important?</label>
<textarea class="form-control" rows="4" id="desc" name="desc"></textarea>
</div>
<div class="form-group">
<label>What was your vote recommendation?</label>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="goal" id="goal-for" value="for">
<label class="form-check-label">For</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="goal" id="goal-against" value="against">
<label class="form-check-label">Against</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="goal" id="goal-abstention" value="abstention" disabled>
<label class="form-check-label">Abstention</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
<div class="col-6">
<div class="form-group">
<label>Messages</label>
</div>
<div id="messages">
</div>
</div>
</div>
</div>
</div>
</form>
</main>
<footer class="text-muted">
<div class="container">
<p class="float-right">
<a href="#">Back to top</a>
</p>
</div>
</footer>
<div class="modal fade" role="modal" id="save">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Save disabled</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p class="alert alert-info">You don't have the permission to save directly, please use the email button</p>
<textarea class="form-control" rows="10"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a href="#" type="button" class="btn btn-primary mail-button">Submit for moderation</a>
</div>
</div>
</div>
</div>
<script src="dist/js/main.js"></script>
<script src="dist/js/dcbundle.js"></script>
<script src="src/js/vote.js"></script>
<script>
var voteid= Number(urlParam("v") || 93602);
var resultscolor= null;
var percentagecolor=null;
download(voteid,draw);
function draw(){
function subject (position) {
var tpl={
"for":"Thanks for supporting {vote}",
"against":"Your opposition to {vote}",
"abstention":"Your lack of vote on {vote}",
"no show":"Your lack of vote on {vote}",
"excused":"I hope you will be voting next time",
"attended":"Your lack of vote on {vote}"
};
return tpl[position] ? tpl[position] : "";
};
d3.selectAll(".rapporteur").html(config.rapporteur);
d3.selectAll(".date").html(dateFormat(config.date));
d3.selectAll(".report").html(config.report);
d3.select(".navbar .app").attr("href","presentation/demo.html?v="+config.id);
d3.select(".navbar .edit").attr("href","vote.html?v="+config.id);
Object.keys(config).forEach(function(k){
d3.selectAll("#"+k).datum(config[k]).each(function(d){
this.value = d });
});
//d3.select('#goal-'+config.goal).attr("checked",true);
$('#goal-'+config.goal).prop("checked",true);
d3.select("#messages")
.selectAll("div.form-group")
.data(results)
.enter()
.append("div").attr("class","row")
.each(function(d){
var div =d3.select(this)
.each(function(d){
var div =d3.select(this);
div
.append("div").attr("class","col-3")
.append("h4").html(function(d){ return config[d] ? d + "<br>("+config[d]+" MEPs)" : d});
div
.append("div").attr("class","col-9")
.append("div").attr("class","form-group")
.each(function(d){
var div =d3.select(this);
div.append("label").text("Twitter template");
div.append("input").attr("class","form-control").attr("id",function(d){return "twitter['"+d+"']"})
.attr("name",function(d){return "tweets-"+d})
.attr("value", function(d){return config.tweets && config.tweets[d] ? config.tweets[d] : ""});
div.append("label").text("email subject");
div.append("input").attr("class","form-control")
.attr("name",function(d){return "subject-"+ d})
.attr("value", function(d){return config.subject && config.subject[d] ? config.subject[d] : subject(d)})
.attr("id",function(d){return "subject['"+ d +"']"});
div.append("label").text("email body");
div.append("textarea").attr("class","form-control")
.attr("name",function(d){return "body-"+ d})
.attr("id",function(d){return "body['"+ d +"']"})
.each(function(d){ this.value= config.body && config.body[d] ? config.body[d] : ""})
});
});
});
$("form").submit(function( event ) {
var d={};
// var d=config;
$.map($(this).serializeArray(), function (n){
var key = n.name.split("-");
if (key.length == 1) {
d[n.name] = n.value;
return;
};
if (!d[key[0]])
d[key[0]] = {};
d[key[0]][key[1]] = n.value;
});
$("#save .modal-body textarea").text(JSON.stringify(d,null,2));
var mail= "mailto:[email protected]";
mail += "?subject=new text for vote "+ config.id;
mail += "&body=" + encodeURIComponent(JSON.stringify(d,null,2));
$("#save .mail-button").attr("href",mail);
$('#save').modal()
console.log(d);
event.preventDefault();
});
};
</script>
<svg class="d-none">
<symbol id="menu" viewBox="0 0 24 24">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
</symbol>
<symbol id="logo" viewBox="0 0 24 24"><path d="M6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-3 .5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm15 5.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM14 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-3.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm-11 10c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm7 7c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-17c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 5.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm8 .5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3 8.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM14 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm-4-12c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0 8.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-4.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-4c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"/></symbol>
</svg>
</body>
</html>