62 lines
2.3 KiB
HTML
62 lines
2.3 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<title>{{ .Name }}</title>
|
||
|
<!-- Pass through the cost of the plugin to the page -->
|
||
|
<meta id="cost" content="{{ .Cost }}">
|
||
|
<meta id="multipleCostsSupported" content="{{ .MultipleCostsSupported }}">
|
||
|
<meta id="name" content="{{ .Name }}">
|
||
|
<meta id="canReturnTokens" content="{{ .CanReturn }}">
|
||
|
<script src="/static/js/jwt.min.js"></script>
|
||
|
<script>
|
||
|
async function sendCost(amount, optional) {
|
||
|
if (document.getElementById('multipleCostsSupported').content !== 'true') {
|
||
|
amount = BigInt(document.getElementById('cost').content)
|
||
|
}
|
||
|
|
||
|
// Save updated points to local storage
|
||
|
let response = await fetch('/api/' + document.getElementById('name').content, {
|
||
|
"method": "POST",
|
||
|
"headers": {
|
||
|
"Content-Type": "application/json",
|
||
|
"Authorization": localStorage.getItem("accessToken")
|
||
|
},
|
||
|
"body": JSON.stringify({
|
||
|
"points": amount.toString(),
|
||
|
"optional": optional || "none"
|
||
|
})
|
||
|
})
|
||
|
if (response.status === 200) {
|
||
|
let data = await response.json()
|
||
|
if (document.getElementById('canReturnTokens').content === 'true') {
|
||
|
alert("You got " + data['profit'] + " points")
|
||
|
} else {
|
||
|
{{ .OnDataReturn }}
|
||
|
}
|
||
|
} else {
|
||
|
let data = await response.json()
|
||
|
alert("Failed to activate plugin: " + data['error'])
|
||
|
}
|
||
|
}
|
||
|
|
||
|
document.addEventListener('DOMContentLoaded', async () => {
|
||
|
let response = await fetch('/api/getPoints', {
|
||
|
"method": "GET",
|
||
|
"headers": {
|
||
|
"Authorization": localStorage.getItem("accessToken")
|
||
|
}
|
||
|
})
|
||
|
let data = await response.json()
|
||
|
document.getElementById('pointAmount').innerText = "You have " + data['points'] + " points"
|
||
|
})
|
||
|
</script>
|
||
|
</head>
|
||
|
<body>
|
||
|
{{ .PluginHTML }}
|
||
|
<p id="pointAmount">Loading...</p>
|
||
|
<script>
|
||
|
{{ .PluginScript }}
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|