-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (44 loc) · 1.7 KB
/
index.js
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
function launch() {
document.querySelector('#setup-div').style.display = 'none';
document.querySelector('#main-div').style.display = 'flex';
}
function submit() {
const subdomain = document.querySelector('#subdomain').value;
const token = document.querySelector('#token').value;
const file = document.querySelector('#file').files[0];
const title = document.querySelector('#title').value;
const description = document.querySelector('#description').value;
const color = document.querySelector('#color').value;
const site_name = document.querySelector('#site_name').value;
document.querySelector('#subdomain').value = '';
document.querySelector('#token').value = '';
document.querySelector('#file').value = '';
document.querySelector('#title').value = '';
document.querySelector('#description').value = '';
document.querySelector('#color').value = '';
document.querySelector('#site_name').value = '';
const url = ('https://' + subdomain + '/api/files/create');
const og_properties = JSON.stringify({
title: title,
description: description,
color: color,
site_name: site_name
});
var formData = new FormData();
formData.append('file', file);
formData.append('token', token);
formData.append('og_properties', og_properties);
fetch(url, {
method: 'POST',
body: formData
})
.then((response) => response.json())
.then((result) => {
navigator.clipboard.writeText(result.url);
console.log('Result: ' + result);
})
.catch((error) => {
navigator.clipboard.writeText(error);
console.error('Error: ' + error);
});
}