-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.html
executable file
·130 lines (113 loc) · 6.5 KB
/
home.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
<html>
<head>
<title>Home — maker.rocks</title>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/notie/dist/notie.min.css">
<link rel="stylesheet" href="style.css">
<link rel="shortcut icon" href="img/emoji.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body class="home">
<header class="contains-nav">
<h1 class="logo"><a href="/"><img src="img/emoji.png" alt=""> <span class="logo-text">maker.rocks</span></a></h1>
<nav>
<a class="btn view-profile" href="#">View profile</a>
<a class="btn" href="/logout">Log out</a>
</nav>
</header>
<section class="hero">
<form action="javascript:void(0)" onsubmit="submitForm()">
<h1>Accounts</h1>
<label>Product Hunt username <input name="productHuntUsername" type="text" placeholder="rrhoover"></label>
<label>Twitter username <input name="twitterUsername" type="text" placeholder="jack"></label>
<label>Makerlog username <input name="makerlogUsername" type="text" placeholder="sergio"></label>
<label>WIP.chat username <input name="wipUsername" type="text" placeholder="marckohlbrugge"></label>
<label>Twitch username <input name="twitchUsername" type="text" placeholder="justinkan"></label>
<label>Medium username <input name="mediumUsername" type="text" placeholder="diannamallen"></label>
<label>Dev.To username <input name="devtoUsername" type="text" placeholder="b3u"></label>
<label>Telegram username <input name="telegramUsername" type="text" placeholder="durov"></label>
<label>Patreon username <input name="patreonUsername" type="text" placeholder="andreyazimov"></label>
<label>Buy Me A Coffee username <input name="bmcUsername" type="text" placeholder="jijo"></label>
<label>GitHub username <input name="gitHubUsername" type="text" placeholder="mojombo"></label>
<label>LinkedIn username <input name="linkedinUsername" type="text" placeholder="konstantin"></label>
<label>YouTube URL <input name="youtubeURL" type="text" placeholder="https://www.youtube.com/channel/UCms6bsRIHFSscZhxK0-K-rQ"></label>
<label>Your website URL <input name="personalWebsite" type="text" placeholder="https://ethan.link"></label>
<label>Your blog URL <input name="personalBlog" type="text" placeholder="https://ethan.link/blog"></label>
<label>Public email address <input name="publicEmail" type="email" placeholder="[email protected]"></label>
<label>Bio (max 500 chars) <div><textarea name="bio" placeholder="Markdown supported" oninput="updateBioCharCount()"></textarea><div class="char-count"></div></div></label>
<label>Profile color <div class="hue-picker-wrapper">
<div class="hue-picker-preview">45</div>
<input name="profileHue" type="range" min="0" max="359" class="hue-picker" value="45" oninput="updateHuePreview()">
</div></label>
<button type="submit" class="btn">Save settings</button>
</form>
</section>
</body>
</html>
<script src="https://unpkg.com/notie"></script>
<script>
if(localStorage.signedIn !== 'true') {
window.location = '/';
}
// Start HSL
var hslGradientStops = [];
for(var i = 0; i < 360; i++) {
hslGradientStops.push(`hsl(${i}, 100%, 69%)`);
}
document.body.setAttribute('style',`--hue-gradient: linear-gradient(90deg,${hslGradientStops.join(',')}); ${document.body.getAttribute('style')}`);
// End HSL
fetch('https://functions.maker.rocks/getmetadata', {method: 'POST', body: JSON.stringify({
username: localStorage.username,
code: localStorage.code
})}).then(r => r.json()).then(res => {
console.log(res);
for(var i = 0; i < Object.keys(res).length; i++) {
var elem = document.querySelector(`label [name="${Object.keys(res)[i]}"]`);
if(elem !== null) {
elem.value = res[Object.keys(res)[i]];
}
}
document.querySelector('.btn.view-profile').href = '/' + res.username;
updateHuePreview();
updateBioCharCount();
});
function submitForm() {
document.querySelector('button[type="submit"]').innerHTML = 'Processing...';
var metadataInputs = document.querySelectorAll('input[name], textarea[name]');
var metadata = {};
for(var i = 0; i < metadataInputs.length; i++) {
metadataInputs[i].value = metadataInputs[i].value.replace(/^@/,'');
metadata[metadataInputs[i].getAttribute('name')] = metadataInputs[i].value;
}
if (metadata.bio && metadata.bio.length > 500) {
delete metadata.bio;
}
console.log(metadata);
fetch('https://functions.maker.rocks/editmetadata', {method: 'POST', body: JSON.stringify({
username: localStorage.username,
code: localStorage.code,
metadata: metadata
})}).then(res => {
document.querySelector('button[type="submit"]').innerHTML = 'Save settings';
console.log(res);
notie.alert({ type: 1, text: 'Saved!'});
});
}
function updateHuePreview() {
document.querySelector('.hue-picker-preview').style.background = `hsl(${document.querySelector('.hue-picker').value}, 100%, 69%)`;
document.querySelector('.hue-picker-preview').style.color = `hsl(${document.querySelector('.hue-picker').value}, 100%, 30%)`;
document.querySelector('.hue-picker-preview').innerHTML = document.querySelector('.hue-picker').value;
}
function updateBioCharCount() {
const el = document.querySelector('textarea[name="bio"]');
el.nextSibling.innerText = `${el.value.length} characters`;
el.nextSibling.style.color = el.value.length > 500 ? 'var(--sub-red-color)' : '';
}
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-103555680-7"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-103555680-7');
</script>