2025-04-03 15:57:14 -04:00
< script >
2024-10-08 11:37:59 -04:00
async function checkDuplicate() {
2025-04-03 15:57:14 -04:00
var url='https://forge.ilot.io/api/v1/repos/ilot/registration/issues';
2024-10-08 11:37:59 -04:00
var email = document.getElementById("email").value;
const response = await fetch(url, {
headers: {
2025-04-03 15:57:14 -04:00
'authorization': 'token b8d8617bb6049c0e47b7bba5cd0931799f54609c',
2024-10-08 11:37:59 -04:00
'Content-Type': 'application/json',
},
})
const result = await response.json();
let index = result
.findIndex(item => item.title === email);
if (index !== -1) {
return true;
} else {
return false;
}
}
async function createIssue() {
2025-04-03 15:57:14 -04:00
var url = 'https://forge.ilot.io/api/v1/repos/ilot/registration/issues';
2024-10-08 11:37:59 -04:00
var mathspamtrap = document.getElementById("math-spam-trap").value;
var agreetoterms = document.getElementById("agree-to-terms").checked;
var email = document.getElementById("email").value;
if(!agreetoterms) {
2025-04-03 15:57:14 -04:00
alert("Registration requires agreement of Code of Conduct.");
2024-10-08 11:37:59 -04:00
return false;
}
if(!email) {
2025-04-03 15:57:14 -04:00
alert("Email cannot be empty.");
2024-10-08 11:37:59 -04:00
return false;
}
if(mathspamtrap != "9") {
2025-04-03 15:57:14 -04:00
alert("Wrong math answer.");
2024-10-08 11:37:59 -04:00
return false;
}
if(await checkDuplicate(email) === true) {
2025-04-03 15:57:14 -04:00
alert("This email address has already requested an account.");
2024-10-08 11:37:59 -04:00
return false;
}
var name = document.getElementById("name").value;
var name = name.replace (/^/,'Name: ');
var aboutme = document.getElementById("about-me").value;
var aboutme = aboutme.replace (/^/,'About me: ');
var howfound = document.getElementById("how-found").value;
var howfound = howfound.replace (/^/,'How I found ilot: ');
var ocuser = document.getElementById("oc-user").value;
var ocuser = ocuser.replace (/^/,'OpenCollective Profile: ');
2025-04-03 15:57:14 -04:00
var description = name + "\n\n" + aboutme + "\n\n" + howfound + "\n\n" + ocuser;
2024-10-08 11:37:59 -04:00
console.log('Description:', description);
fetch(url, {
method: 'POST',
headers: {
2025-04-03 15:57:14 -04:00
'authorization': 'token b8d8617bb6049c0e47b7bba5cd0931799f54609c',
2024-10-08 11:37:59 -04:00
'Content-Type': 'application/json',
},
2025-04-03 15:57:14 -04:00
body: JSON.stringify({ title: email, body: description }),
2024-10-08 11:37:59 -04:00
})
.then(response => response.json())
.then(result => {
console.log('Success:', result);
2025-04-03 15:57:14 -04:00
alert("Request submitted. A working group member will process your registration shortly. If you receive no contact within seven days of registration, please send an email to support@ilot.io.");
2024-10-08 11:37:59 -04:00
})
.catch(error => {
console.error('Error:', error)
});
}
2025-04-03 15:57:14 -04:00
< / script >