-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopengraphtests.html
168 lines (157 loc) · 5.45 KB
/
opengraphtests.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
<html>
<head>
<link rel="shortcut icon" type="image/png" href="favicon.png" />
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background: linear-gradient(#87CEEB, #FFE0B2);
background-repeat: no-repeat;
background-color: #FFE0B2;
background-size: 100% 1000px;
margin: auto;
max-width: 700px;
padding: 10px 10px;
border-left: 1px solid #C0C0C0;
border-right: 1px solid #C0C0C0;
font-size: 16px;
}
div.div1 {
text-align: center;
}
</style>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Masterjun | Open Graph Tests</title>
<meta property="og:site_name" content="TASVideos" />
<meta property="og:title" content="Post by Masterjun" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://masterjun3.github.io/opengraphtests.html" />
<meta property="og:image" content="https://i.imgur.com/xljvuh5.png" />
<meta property="og:description"
content="Encoders' corner → [Guide] Creating a quick HD encode in BizHawk" />
</head>
<body>
<a href=".">< Back</a><br>
<div class="div1">
<h1>Open Graph Tests</h1>
<table>
<tr>
<td><span>Site Name:</span></td>
<td><input id="input_sitename" oninput="change()" style="width: 63.5ch;" /></td>
</tr>
<tr>
<td><span>Title:</span></td>
<td><input id="input_title" oninput="change()" style="width: 63.5ch;" /></td>
</tr>
<tr>
<td><span>Description:</span></td>
<td><textarea id="input_description" oninput="change()" cols="60" rows="6"></textarea></td>
</tr>
<tr>
<td><span>Image:</span></td>
<td><input id="input_image" oninput="change()" style="width: 63.5ch;" /></td>
</tr>
</table>
<style>
.container {
background-color: #313338;
padding: 78px;
}
.grid {
text-align: left;
display: grid;
padding: .5rem 1rem 1rem .75rem;
color: rgb(219, 222, 225);
background-color: rgb(43, 45, 49);
max-width: 516px;
border-radius: 4px;
}
.gridelement {
margin-top: 8px;
}
.sitename {
grid-column: 1/1;
font-size: 0.75rem;
font-weight: 400;
}
.title {
grid-column: 1/1;
color: rgb(0, 168, 252);
font-size: 1rem;
font-weight: 600;
}
.title:not(:hover) {
text-decoration: none;
}
.description {
grid-column: 1/1;
font-size: 0.875rem;
font-weight: 400;
}
.image {
grid-row: 1/8;
grid-column: 2/2;
margin-left: 16px;
}
</style>
<div class="container">
<div class="grid">
<div class="gridelement sitename"><span id="sitename"></span></div>
<div class="gridelement"><a class="title" href="#" id="title"></a></div>
<div class="gridelement description"><span id="description"></span></div>
<div class="gridelement image"><img style="width: 80px; cursor: pointer;" id="image" /></div>
</div>
</div>
<script>
let input_sitename = document.getElementById('input_sitename');
let input_title = document.getElementById('input_title');
let input_description = document.getElementById('input_description');
let input_image = document.getElementById('input_image');
let sitename = document.getElementById('sitename');
let title = document.getElementById('title');
let description = document.getElementById('description');
let image = document.getElementById('image');
function toBase64(s) {
return btoa(Array.from(new TextEncoder().encode(s), (x) => String.fromCodePoint(x)).join("")).replaceAll("=", "").replaceAll("+", "-").replaceAll("/", "_");
}
function fromBase64(s) {
return new TextDecoder().decode(Uint8Array.from(atob(s.replaceAll("-", "+").replaceAll("_", "/")), (m) => m.codePointAt(0)));
}
function change() {
sitename.innerText = input_sitename.value;
title.innerText = input_title.value;
description.innerText = input_description.value;
image.src = input_image.value;
if (title.innerText.length > 60) {
title.innerText = title.innerText.substring(0, 60 - 3) + "...";
}
if (description.innerText.length > 350) {
description.innerText = description.innerText.substring(0, 350 - 3) + "...";
}
let query = [input_sitename.value, input_title.value, input_description.value, input_image.value];
let url = new URL(window.location);
url.searchParams.set("q", toBase64(JSON.stringify(query)));
window.history.replaceState({}, null, url);
}
function fill() {
let url = new URL(window.location);
let q = url.searchParams.get("q");
if (q) {
query = JSON.parse(fromBase64(q));
input_sitename.value = query[0];
input_title.value = query[1];
input_description.value = query[2];
input_image.value = query[3];
} else {
input_sitename.value = "TASVideos";
input_title.value = "Post by Masterjun";
input_description.value = "Encoders' corner → [Guide] Creating a quick HD encode in BizHawk";
input_image.value = "https://i.imgur.com/xljvuh5.png";
}
change();
}
fill();
</script>
</div>
</body>
</html>