-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.html
58 lines (55 loc) · 1.92 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
<!DOCTYPE html>
<html>
<head>
<title>Tesla FleetAPI Setup</title>
<style>
body {
font-family: Helvetica, Arial, sans-serif;
}
.code {
font-family: monospace;
background-color: #f4f4f4;
color: blue;
padding: 2px 4px;
border-radius: 4px;
display: inline-block;
}
</style>
</head>
<body>
<h1>Tesla FleetAPI Setup</h1>
<p>Copy the code below and paste it into the "code" field in the Tesla FleetAPI setup script.</p>
<h3>Authorization Code</h3>
<script>
// Function to extract GET parameter from URL
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
// Get the value of the "code" parameter
var code = getParameterByName('code');
// If the "code" parameter is not present, display an error message
if (!code) {
document.write('<p>Error: "code" parameter is missing from the URL.</p>');
}
else {
document.write('<div class="code">' + code + ' <button onclick="copyToClipboard()">Copy</button></div>');
}
// Function to copy the code to clipboard
function copyToClipboard() {
var tempInput = document.createElement('input');
tempInput.value = code;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand('copy');
document.body.removeChild(tempInput);
alert('Code copied to clipboard!');
}
</script>
</body>
</html>