-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
197 lines (170 loc) · 5.85 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=0.70;">
<title>Twibbon App</title>
<meta property="og:title" content="Twibbon App">
<meta property="og:image" content="https://pui-real.pages.dev/img/og.png">
<meta property="og:description" content="Ini adalah situs web tempat Anda dapat menambahkan foto ke bingkai.">
<meta name="msapplication-TileColor" content="#af0a1a">
<meta name="theme-color" content="#ffffff">
<link rel="shortcut icon" href="img/fav-16.png">
<link rel="icon" type="image/png" sizes="32x32" href="img/fav-32.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/fav-16.png">
<link rel="apple-touch-icon" href="img/fav-57.png">
<link rel="apple-touch-icon" sizes="114x114" href="img/fav-114.png">
<link rel="apple-touch-icon" sizes="72x72" href="img/fav-72.png">
<link rel="apple-touch-icon" sizes="144x144" href="img/fav-144.png">
<link rel="manifest" href="pwa-manifest.json">
<link rel="stylesheet" href="css/style.css">
<style type="text/css">
button, label, canvas, div {
box-sizing: border-box;
}
#input-file {
position: absolute;
left: -10000px;
}
#preview {
border: 1px solid #eee;
margin: 10px 0;
background: #eee;
width: 100%;
}
.frame-option {
padding: 10px;
line-height: 0;
width: 25%;
background: transparent;
border: 0;
}
.frame-option:focus {
border: 1px solid #669ada;
outline: none;
position: relative;
padding: 9px;
border-radius: 10px;
}
.frame-option img {
border-radius: 5px;
background-image: url(./placeholder.png);
background-size: 100% 100%;
pointer-events: none;
}
.frame-option:not(:first-child) {
margin-left: -1px;
}
.wrapper {
width: 100%;
padding: 10px;
max-width: 360px;
min-width: 240px;
margin: 0 auto;
}
.action {
font-size: 13px;
text-decoration: none;
cursor: pointer;
color: #669ada;
padding: 10px 20px;
border-radius: 50px;
border: 1px solid;
display: block;
text-align: center;
}
.action[href=''] {
display: none;
}
.buttons {
flex-wrap: wrap;
display: flex;
margin-bottom: 10px;
}
</style>
<script type='text/javascript' src="js/main.js"></script>
</head>
<body>
<article>
<h1>TWIBBON GENERATOR</h1>
<p>Ini adalah situs web tempat Anda dapat menambahkan foto ke bingkai.</p>
<div class="wrapper">
<!--
<label class="action">
<input type="file" id="input-file" accept="image/*">
Select Image
</label>
-->
<canvas id="preview" width="500" height="500" title="Preview"></canvas><br>
<div class="buttons">
<button type="button" class="frame-option">
<img src="./assets/frame-01.png" alt="Frame option 1" width="100%">
</button>
<button type="button" class="frame-option">
<img src="./assets/frame-02.png" alt="Frame option 2" width="100%">
</button>
<button type="button" class="frame-option">
<img src="./assets/frame-03.png" alt="Frame option 3" width="100%">
</button>
<button type="button" class="frame-option">
<img src="./assets/frame-04.png" alt="Frame option 4" width="100%">
</button>
</div>
<label class="action">
<input type="file" id="input-file" accept="image/*">
Pilih Gambar
</label>
</br>
<a download="twibbon-by-ferryayunda.png" class="action" id="download-link" href="">Simpan Twibbon</a>
<img src="./assets/placeholder.png" alt="" width="1" id="placeholder" hidden>
</div>
<p>Fitur: Tidak perlu keterampilan pengeditan tambahan. Dibutuhkan kurang dari dua menit untuk melakukannya dan bebas biaya. Ini sudah tersedia, ramah pengguna dan tersedia untuk semua.</p>
<script type="text/javascript">
const input = document.getElementById('input-file')
const canvas = document.getElementById('preview')
const context = canvas.getContext('2d')
const ph = document.getElementById('placeholder')
const dlLink = document.getElementById('download-link')
dlLink.hidden = true
input.addEventListener('change', drawImageFromInput)
function drawImageFromInput (callback) {
context.clearRect(0, 0, 500, 500)
if (input.files.length === 0) {
context.drawImage(ph, 0, 0, 500, 500)
if (typeof callback === 'function') callback()
} else {
const img = new Image()
img.addEventListener('load', function() {
context.drawImage(img, 0, 0, 500, 500)
for(var optionImage of document.querySelectorAll('.frame-option img')) {
optionImage.style.backgroundImage = `url("${img.src}")`
}
if (typeof callback === 'function') callback()
})
img.src = URL.createObjectURL(input.files[0])
}
}
function prepareDownloadLink () {
if (input.files[0]) {
dlLink.setAttribute('download', input.files[0].name.replace(/\.\w+$/, '-framed.png') ) }
dlLink.hidden = false
dlLink.href = canvas.toDataURL()
}
for (var button of document.querySelectorAll('.frame-option')) {
button.addEventListener('click', function (event) {
drawImageFromInput(function () {
const image = event.target.querySelector('img')
context.drawImage(image, 0, 0, 500, 500)
prepareDownloadLink()
})
})
}
placeholder.onload = drawImageFromInput
</script>
</article>
<footer>
<p><a target="_blank" rel="noopener" href="https://www.facebook.com/bungferry.wa">Copyright © 2023 Ferry Ayunda.</a></p>
</footer>
</body>
</html>