-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.html
More file actions
200 lines (188 loc) · 6.19 KB
/
editor.html
File metadata and controls
200 lines (188 loc) · 6.19 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Editor</title>
</head>
<body>
<div>
<input id="title" placeholder="Title"><br>
<input type="URL" id="url" placeholder="Banner URL"><br>
<textarea placeholder="Content"></textarea>
<button onclick="generate()">Download</button>
<code id="text">Your code goes here. Copy it to clipboard after clicking < Download ></code>
</div>
<style>
@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
background: #101010;
color: white;
font-size: 105%;
}
div {
width: 75%;
margin: 15px auto;
text-align: center;
font-family: 'Open Sans', sans-serif;
}
#text {
display: block;
width: 100%;
text-align: left;
padding:15px;
background: #151515;
border-radius: 15px;
position: relative;
left:10px;
}
input,
textarea,
button {
background: #151515;
border: none;
border-radius: 15px;
width: 100%;
min-height: 50px;
margin: 10px;
padding: 15px;
}
textarea {
min-height: 500px;
font-family: 'Open Sans', sans-serif;
}
</style>
<script>
function copy(text) {
/* Get the text field */
var copyText = document.createElement("input");
copyText.value = text
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /* For mobile devices */
/* Copy the text inside the text field */
document.execCommand("copy");
}
function truncate(str) {
if (str.length <= 500) { return str; }
const subString = str.substr(0, 499); // the original check
return subString.substr(0, subString.lastIndexOf(" ")) + "…";
}
function download(content, name, type) {
let a = document.createElement("a");
let file = new Blob([content], { type: type });
a.href = URL.createObjectURL(file);
a.download = name;
a.click()
}
function generate() {
let title = document.querySelector('#title').value
let banner = document.querySelector('#url').value
let html = document.querySelector('textarea').value
let content = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script data-ad-client="ca-pub-3261220848498193" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"><\/script>
<link rel="stylesheet" href="css/article look v2.css">
<link rel="stylesheet"
href="css/highlights/atom-one-dark.css">
<title>${title} - The Shaman</title>
</head>
<body>
<div id="cookies">
<p>
By using my website, you agree to <a href="cookies.html">cookie policy</a>
</p>
<button onclick="document.querySelector('#cookies').remove();localStorage.TheShamanCookiePolicyDisplayed = 'yes'">OK</button>
</div>
<style>
#cookies{
position:fixed;
background: #101010;
border-radius: 10px;
bottom:0;
right:0;
z-index: 1000;
padding:15px;
margin:10px;
}
#cookies button{
margin-top:10px;
width:100%;
color:white;
background:#151515;
border:none;
padding:5px;
border-radius: 10px;
}
#cookies a{
color:white;
}
</style>
<script>
if(localStorage.TheShamanCookiePolicyDisplayed == 'yes'){
document.querySelector('#cookies').remove()
}
<\/script>
<style>
:root {
--banner-url:url("${banner}")
}
#banner{
background: var(--banner-url);
background-size: cover;
background-position: center;
}
</style>
<header></header>
<main>
<section>
<a href="#" id="up">
<i class="fas fa-arrow-up"></i>
</a>
<div id="banner">
<span class="cover"></span>
<div>
<div>
<h1>${title}</h1>
</div>
</div>
</div>
<article>${html}</article>
</section>
</main>
<footer></footer>
<script src="https://kit.fontawesome.com/c947efe878.js" crossorigin="anonymous"><\/script>
<script src="js/article beh.js"><\/script>
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.5.0/build/highlight.min.js"><\/script>
<script>
document.addEventListener('DOMContentLoaded', (event) => {
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightBlock(block)
})
})
<\/script>
</body>
</html>`
let filename = `${title.toLowerCase().replace(/ /g, "-")}.html`
let e = document.createElement('p')
e.innerHTML = html
download(content.replace(/<\./g, "<<!---->"), filename, `text/html`)
let tocopy = `<article>
<a href="${filename}">
<h1>${title}</h1>
<img src="${banner}">
${truncate(e.innerText)}
</a>
</article>`
document.querySelector('#text').innerText = tocopy
copy(tocopy)
}
</script>
</body>
</html>