You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wubloader/thrimbletrimmer/TestPage.html

151 lines
4.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Thrimbletrimmer Goes Forth</title>
<meta name="google-signin-client_id" content="345276493482-r84m2giavk10glnmqna0lbq8e1hdaus0.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js?onload=onGLoad" async defer></script>
<script type="text/javascript">
var user;
function onSignIn(googleUser) {
user = googleUser;
var profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
console.log('ID Token: ' + googleUser.getAuthResponse().id_token);
}
function signOut() {
user = null;
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('User signed out.');
});
}
</script>
<style type="text/css">
#google-sign-in {
margin-bottom: 10px;
}
#output-zone {
border-bottom: 1px solid #000;
padding-bottom: 2px;
}
</style>
</head>
<body>
<div id="google-sign-in">
<!-- https://developers.google.com/identity/sign-in/web/sign-in -->
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<a href="#" onclick="signOut();">Sign out</a>
</div>
<div>
<input id="server" value="" placeholder="Server name" />
<input id="rowId" value="04860aa4-d6a5-11e9-9d36-2a2ae2dbcce4" placeholder="Row ID" />
<input type="button" onclick="getRow()" value="Get Row"/>
<a href="/thrimshim">All Rows</a>
<div id="output-zone">
<h3>Row Output</h3>
<div id="rowdump"></div>
</div>
</div>
<div>
<br/>
<input type="button" onclick="testAuth()" value="Test Auth" /><br />
<input type="button" onclick="testSubmit()" value="Test Submit" /><br />
<input type="button" onclick="testManualLink()" value="Test Manual Link" /><input id="manualLink" value="google.ca"/><br />
<input type="button" onclick="testReset()" value="Test Reset" /><br />
</div>
<script>
function getRow() {
fetch(document.getElementById("server").value+"/thrimshim/"+document.getElementById("rowId").value).then(function (response) {
response.text().then(function(data) {
document.getElementById("rowdump").innerText = data;
});
});
}
function testAuth() {
fetch(document.getElementById("server").value+"/thrimshim/auth-test", {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
test: "123 Hello World?",
token: user.getAuthResponse().id_token
})
}).then(function(response) {
if (response.status !== 200) {
console.log('Looks like there was a problem. Status Code: ' + response.status);
return;
}
// Examine the text in the response
response.json().then(function(data) {
console.log(data);
});
}).catch(function(err) {
console.log('Fetch Error :-S', err);
});
}
function testSubmit() {
var wubData = {
allow_holes: "true",
experimental: "true",
state: "EDITED",
token: user.getAuthResponse().id_token,
upload_location: "YouTube",
uploader_whitelist: null,
video_channel: "rpglimitbreak",
video_description: "Test Description",
video_end: "2019-09-14T03:54:28.546",
video_quality: "source",
video_start: "2019-09-14T03:48:06.546",
video_title: "Test"
}
//Submit to thrimshim
fetch(document.getElementById("server").value+"/thrimshim/"+document.getElementById("rowId").value, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(wubData)
}).then(data => console.log(data));
}
function testManualLink() {
fetch(document.getElementById("server").value+"/thrimshim/manual-link/"+document.getElementById("rowId").value, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
link: document.getElementById("manualLink").value,
token: user.getAuthResponse().id_token
})
}).then(data => console.log(data));
}
function testReset() {
fetch(document.getElementById("server").value+"/thrimshim/reset/"+document.getElementById("rowId").value, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({token: user.getAuthResponse().id_token})
}).then(data => console.log(data));
}
</script>
</body>
</html>