-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
238 lines (197 loc) · 7.81 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
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
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dom-to-image/2.6.0/dom-to-image.min.js"
integrity="sha256-c9vxcXyAG4paArQG3xk6DjyW/9aHxai2ef9RpMWO44A=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.min.js"></script>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.js"></script>
<style>
#main-container {
width: 100%;
margin-top: 30px;
display: flex;
flex-direction: row;
padding-left: 50px;
padding-right: 50px;
align-items: center;
justify-content: space-evenly;
}
#poster-container {
width: 540px;
height: 700px;
background:white;
border: 1px solid black;
box-shadow: 3px 8px 10px rgb(167, 167, 167);
padding: 40px;
}
#downloadPDF {
margin: auto;
margin-top: 30px;
margin-bottom: 10px;
box-shadow: 1px 3px 3px rgb(167, 167, 167);
}
#form {
width: 350px;
padding: 20px;
padding-left: 20px;
margin-right: 50px;
}
select {
padding: 10px;
width: 150px;
height: 30px;
background-color: white;
box-shadow: 1px 3px 3px rgb(167, 167, 167);
}
.pic {
position: relative;
}
.person {
top: 200px;
width: 21%;
height: 45%;
background-size: contain;
background-repeat: no-repeat;
}
#person-right {
left: 56%;
}
#person-left {
left: 0%;
}
h1 {
top: 5%;
position: relative;
}
h3 {
color: gray;
position: relative;
top: 5%;
}
img {
background: rgb(0,0,0,0);
}
#poster-wrapper {
margin:auto;
width: 540px;
height: 700px;
}
#object {
top: -20px;
height: auto;
left: 21%;
width: 60%;
}
h6 {
font-weight: 400;
}
</style>
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
<!-- POSTER -->
<div id="main-container">
<div id="poster-wrapper">
<div id="poster-container">
<h1>Keep your distance.</h1>
<h3>6ft = <span id="obj-name">1 Bicycle</span> apart</h3>
<img id="person-left" class="pic person" src="img/woman_silh_1.png"/>
<img id="person-right" class="pic person" src="img/woman_silh_2.png"/>
<img id="object" class="pic" src="img/bicycle.png"/>
</div>
</div>
<!-- FORM -->
<div id="form">
<form>
<div class="form-group">
<label>Background Color</label><br>
<select id="background-color-select">
<option value="white" selected="selected">White</option>
<option value="lightblue" >Blue</option>
<option value="lavender">Purple</option>
<option value="#ffd296">Orange</option>
<option value="lightyellow">Yellow</option>
<option value="lightpink">Pink</option>
<option value="lightgrey">Gray</option>
</select>
</div>
<div class="form-group">
<label>Left Person</label><br>
<select id="left-person-select">
<option value="img/woman_silh_1.png" selected="selected">Female 1</option>
<option value="img/woman_silh_2.png">Female 2</option>
<option value="img/man_silh_1.png">Male 1</option>
<option value="img/man_silh_2.png">Male 2</option>
</select>
</div>
<div class="form-group">
<label>Right Person</label><br>
<select id="right-person-select">
<option value="img/woman_silh_1.png">Female 1</option>
<option value="img/woman_silh_2.png" selected="selected">Female 2</option>
<option value="img/man_silh_1.png" >Male 1</option>
<option value="img/man_silh_2.png">Male 2</option>
</select>
</div>
<div class="form-group">
<label>Object</label><br>
<select id="object-select">
<option value='{"name": "1 Bicycle", "src": "img/bicycle.png", "top": "-20px"}' selected="selected">Bicycle</option>
<option value='{"name": "1 Alligator", "src": "img/alligator.png", "top": "10px"}' >Alligator</option>
<option value='{"name": "3 Corgis", "src": "img/corgi.png", "top": "-70px"}'>Corgis</option>
<option value='{"name": "1 Eagle Wingspan", "src": "img/eagle.png", "top": "-250px"}'>Eagle</option>
<option value='{"name": "8 Eggo Waffle Boxes", "src": "img/waffle.png", "top": "-45px"}'>Eggo Waffles</option>
<option value='{"name": "1 Twin Bed", "src": "img/bed.png", "top": "-20px"}'>Twin Bed</option>
<option value='{"name": "1 Refrigerator", "src": "img/fridge.png", "top": "-20px"}'>Refrigerator</option>
<option value='{"name": "8 Nintendo Switches", "src": "img/switch.png", "top": "-55px"}'>Nintendo Switches</option>
<option value='{"name": "2 Goats", "src": "img/goat.png", "top": "-70px"}'>Goat</option>
<option value='{"name": "3 Raccoons", "src": "img/racoon.png", "top": "-50px"}'>Raccoon</option>
<option value='{"name": "4 Cats", "src": "img/cat.png", "top": "-35px"}'>Cat</option>
<option value='{"name": "2.5 Toilets", "src": "img/toilet.png", "top": "-75px"}'>Toilet</option>
</select>
</div>
<div class="form-group">
</div>
</form>
<button class="btn btn-lg btn-info" id="downloadPDF">Download PDF</button>
<br>
<h6>For best results, use Chrome or Firefox.</h6>
<h6>Source code available <a href="https://github.com/laurawilsonri/covid-poster-generator">here.</a></h6>
</div>
</div>
<script>
$('#downloadPDF').click(function () {
domtoimage.toPng(document.getElementById('poster-container'))
.then(function (blob) {
var pdf = new jsPDF('p','pt', [$('#poster-container').width(), $('#poster-container').height()]);
pdf.addImage(blob, 'PNG', 0, 0, $('#poster-container').width(), $('#poster-container').height());
pdf.save("covid-poster.pdf");
that.options.api.optionsChanged();
});
});
$(function() {
$('#left-person-select').on('change', function(event) {
document.getElementById("person-left").src = this.value
});
$('#right-person-select').on('change', function(event) {
document.getElementById("person-right").src = this.value
});
$('#background-color-select').on('change', function(event) {
document.getElementById("poster-container").style.background = this.value
});
$('#object-select').on('change', function(event) {
val = JSON.parse(this.value)
console.log(val)
document.getElementById("obj-name").textContent = val.name
document.getElementById("object").src = val.src
document.getElementById("object").style.top = val.top
});
});
</script>
</body>
</html>