2020-11-22 14:39:10 -07:00
extends layout
block content
2024-03-20 18:20:03 -06:00
- var selected_captcha_object = null
- var selected_captcha_name = ''
if settings.claim_address_page.enable_captcha == true
each captcha, name in settings.captcha
if selected_captcha_object == null && captcha != null && captcha.enabled == true
- selected_captcha_object = captcha
- selected_captcha_name = name
2020-11-22 14:39:10 -07:00
script.
2021-04-11 18:46:19 -06:00
$(document).ready(function () {
2020-12-26 22:01:36 -07:00
$('#claimInstructions').on('show.bs.collapse', function () {
2023-10-19 20:26:27 -06:00
$('#showClaimInstructions').html('<i class="fa-solid fa-angle-down" style="margin-right:5px;"></i><span>Hide claim instructions</span>');
2020-12-26 22:01:36 -07:00
}).on('hide.bs.collapse', function () {
2023-10-19 20:26:27 -06:00
$('#showClaimInstructions').html('<i class="fa-solid fa-angle-up" style="margin-right:5px;"></i><span>Show claim instructions</span>');
2020-12-26 22:01:36 -07:00
}).on('shown.bs.collapse', function () {
fixFooterHeightAndPosition();
}).on('hidden.bs.collapse', function () {
fixFooterHeightAndPosition();
});
2020-12-05 18:40:05 -07:00
$('#claimForm').on('submit', function (e) {
2020-11-22 14:39:10 -07:00
e.preventDefault();
2020-11-29 19:29:38 -07:00
var address = $('input#address').val();
var message = $('input#message').val();
var signature = $('input#signature').val();
2024-03-20 18:20:03 -06:00
var recaptcha2 = ($('#g-recaptcha-response').length > 0 ? $('#g-recaptcha-response').val() : '');
var hcaptcha = ($('textarea[name^="h-captcha-response"]').length > 0 ? $('textarea[name^="h-captcha-response"]').val() : '');
2020-12-12 20:21:49 -07:00
2020-12-26 22:01:36 -07:00
if (address == null || address.trim().length == 0) {
showClaimAlert('warning', 'Please enter the wallet address you wish to claim', false);
$('input#address').focus();
} else if (signature == null || signature.trim().length == 0) {
2020-12-23 18:40:10 -07:00
showClaimAlert('warning', 'Please enter the signature value from your wallet software', false);
2020-12-26 22:01:36 -07:00
$('input#signature').focus();
2024-03-20 18:20:03 -06:00
} else if (
(
'#{selected_captcha_name}' == 'google_recaptcha2' &&
'#{settings.captcha.google_recaptcha2.captcha_type}' == 'checkbox' &&
$('#g-recaptcha-response').length > 0 &&
recaptcha2 == ''
) ||
(
$('textarea[name^="h-captcha-response"]').length > 0 &&
hcaptcha == ''
)
) {
showClaimAlert('warning', 'The captcha validation has not been set', false);
2020-12-12 20:21:49 -07:00
} else {
2024-03-20 19:36:16 -06:00
$('button.btn-success').attr('disabled', true);
2024-03-20 18:20:03 -06:00
if ('#{selected_captcha_name}' == 'google_recaptcha2' && '#{settings.captcha.google_recaptcha2.captcha_type}' == 'invisible') {
grecaptcha.execute();
} else if ('#{selected_captcha_name}' == 'google_recaptcha3') {
grecaptcha.ready(function() {
grecaptcha.execute('#{(selected_captcha_name != '' && settings.captcha[selected_captcha_name].site_key != null ? settings.captcha[selected_captcha_name].site_key : '')}', {action: 'submit'}).then(function(token) {
submitForm(token);
});
});
} else if (recaptcha2 != '') {
submitForm(recaptcha2);
} else if (hcaptcha != '') {
submitForm(hcaptcha);
} else {
submitForm('');
}
2020-11-29 19:29:38 -07:00
}
2020-11-22 14:39:10 -07:00
});
2020-12-26 22:01:36 -07:00
if ('!{hash}' != 'null' && '!{hash}' != '') {
$('<div id="claimAlert"></div>').insertBefore('#claimForm');
$('#claimAlert').html(generateAlertHTML('info', true, ('!{claim_name}' == '' ? 'Unc' : 'C') + 'laimed address', '<strong>!{hash}</strong> is currently ' + ('!{claim_name}' == '' ? 'un' : '') + 'claimed' + ('!{claim_name}' == '' ? '' : ' as <strong>' + displayAsText('!{claim_name}') + '.</strong>')));
}
2021-04-10 22:22:46 -06:00
if (#{settings.shared_pages.page_header.page_title_image.enable_animation} == true && #{settings.claim_address_page.page_header.show_img} == true)
startRotateElement('img#header-img');
2020-11-22 14:39:10 -07:00
});
2024-03-20 18:20:03 -06:00
function displayAsText(str) {
return str.replace(/</g, '<').replace(/>/g, '>');
}
function showClaimAlert(claimClass, warnMsg, removedClaim) {
if ($('#claimAlert').length == 0)
$('<div id="claimAlert"></div>').insertBefore('#claimForm');
$('#claimAlert').html(generateAlertHTML(claimClass, true, (claimClass == 'success' ? (removedClaim ? 'Address claim removed successfully' : 'Address claimed successfully') : (claimClass == 'danger' ? 'Failed to claim address' : 'Required field missing')), (claimClass == 'success' ? '<strong>' + $('input#address').val() + '</strong> will now be referred to as <strong>' + (removedClaim ? $('input#address').val() : displayAsText($('#message').val())) + '</strong> throughout the website' : warnMsg) + '.'));
fixFooterHeightAndPosition();
}
function generateAlertHTML(alertClass, allowDismiss, headerText, msgText) {
return '<div class="alert alert-' + alertClass + (allowDismiss ? ' alert-dismissible fade show' : '') + '" role="alert">' +
(allowDismiss ? '<button type="button" class="btn-close" data-bs-dismiss="alert"></button>' : '') +
'<div' + (msgText == null || msgText == '' ? '' : ' class="cardSpacer"') + '>' +
'<span class="fa-solid ' + (alertClass == 'success' ? 'fa-circle-check' : (alertClass == 'danger' ? 'fa-circle-exclamation' : (alertClass == 'info' ? 'fa-circle-info' : 'fa-triangle-exclamation'))) + '" style="margin-right:5px"></span>' +
'<strong>' + headerText + '</strong>' +
'</div>' +
(msgText == null || msgText == '' ? '' : '<span>' + msgText + '</span>') +
'</div>';
}
function submitForm(captchaData) {
const url = '/claim';
let postData = {
'address': $('input#address').val(),
'message': $('input#message').val(),
'signature': $('input#signature').val()
};
if ('#{selected_captcha_name}' != '' && captchaData != '')
postData['#{selected_captcha_name}'] = captchaData;
$.ajax({
type: 'post',
url: url,
data: postData
})
.done(function(data) {
showClaimAlert((data.status == 'success' ? 'success' : 'danger'), data.message, (data.status == 'success' && message == ''));
if (
'#{selected_captcha_name}' == 'google_recaptcha2' &&
'#{settings.captcha.google_recaptcha2.captcha_type}' == 'checkbox'
) {
// clear out the captcha to allow the form to be submitted again
grecaptcha.reset();
2024-03-20 19:44:05 -06:00
} else if (
'#{selected_captcha_name}' == 'hcaptcha'
) {
// clear out the captcha to allow the form to be submitted again
hcaptcha.reset()
2024-03-20 18:20:03 -06:00
}
2024-03-20 19:36:16 -06:00
$('button.btn-success').attr('disabled', false);
2024-03-20 18:20:03 -06:00
});
}
function onSubmit(token) {
submitForm(token);
// ensure the onSubmit event can fire again without needing to reload the page in the event that the server returns an error and the form must be submitted again
grecaptcha.reset();
2024-03-20 19:36:16 -06:00
$('button.btn-success').attr('disabled', false);
2024-03-20 18:20:03 -06:00
}
2020-12-26 22:01:36 -07:00
.col-xs-12.col-md-12
2021-04-10 22:22:46 -06:00
if settings.claim_address_page.page_header.show_img == true || settings.claim_address_page.page_header.show_title == true || settings.claim_address_page.page_header.show_description == true
#page-header-container(style='align-items:' + (settings.claim_address_page.page_header.show_img == true && settings.claim_address_page.page_header.show_title == true && settings.claim_address_page.page_header.show_description == true ? 'flex-start' : 'center'))
if settings.claim_address_page.page_header.show_img == true
#header-img-container
img#header-img(src=(settings.shared_pages.page_header.page_title_image == null || settings.shared_pages.page_header.page_title_image.image_path == null || settings.shared_pages.page_header.page_title_image.image_path == '' ? '/img/page-title-img.png' : settings.shared_pages.page_header.page_title_image.image_path))
#page-title-container
if settings.claim_address_page.page_header.show_title == true
2024-06-16 18:58:12 -06:00
h3#page-title #{settings.localization.claim_title.replace('{1}', settings.coin.name)}
2021-04-10 22:22:46 -06:00
if settings.claim_address_page.page_header.show_description == true
if settings.claim_address_page.page_header.show_title != true
#page-title-container
2024-06-16 18:58:12 -06:00
.sub-page-header.text-muted=settings.localization.claim_description.replace('{1}', settings.coin.name)
2021-04-10 22:22:46 -06:00
else
2024-06-16 18:58:12 -06:00
.sub-page-header.text-muted=settings.localization.claim_description.replace('{1}', settings.coin.name)
2021-04-10 22:22:46 -06:00
.cardSpacer.clearfix
2020-12-12 20:21:49 -07:00
.card.card-default.border-0.cardSpacer
2020-11-23 14:09:40 -07:00
.card-header
2020-12-26 22:01:36 -07:00
strong Claim Wallet Address
2020-11-29 19:29:38 -07:00
.card-body
2024-06-16 18:58:12 -06:00
a#showClaimInstructions.instructions.badge.bg-primary(href='#claimInstructions', style='font-size:100%;margin-bottom:15px;', data-bs-toggle='collapse' role='button' aria-expanded='false' aria-controls='claimInstructions')
2023-10-19 20:26:27 -06:00
i.fa-solid.fa-angle-up(style='margin-right:5px;')
2020-12-26 22:01:36 -07:00
span Show claim instructions
2023-10-11 19:32:26 -06:00
div#claimInstructions.collapse
div.alert.alert-primary
div
span Use the
span.fw-bold Sign Message
span feature from your
span.fw-bold #{settings.coin.name}
span wallet to verify ownership of a wallet address that belongs to you.
br
div Enter the following data into the wallet software:
br
div
span.fw-bold Address:
if hash == null || hash == ''
span=' <wallet address from the form below>'
else
span #{hash}
div
span.fw-bold Message:
span=' <display name from the form below>'
br
div
span Click the
span.fw-bold Sign Message
span button in the wallet, and copy/paste the resulting
span.fw-bold Signature
span at the bottom of this form.
br
div
span Finally, click the
span.fw-bold Claim
span button below to claim your address, which will display your custom display name instead of the default wallet address on this site.
br
div
span.fw-bold NOTE:
span You can update your claimed address at any time, as often as you wish. To remove a previously claimed display name, simply sign a blank message to return the address back to its original value.
2020-11-29 19:29:38 -07:00
form#claimForm
.form-group
2020-12-12 20:21:49 -07:00
fieldset.entryField
2022-03-12 18:24:24 -07:00
label.form-label(for='address') Wallet Address
2020-12-26 22:01:36 -07:00
if hash == null || hash == ''
input#address.form-control(type='text', maxlength='70')
else
input#address.form-control(type='text', value=hash, readonly='readonly', maxlength='70')
2020-11-29 19:29:38 -07:00
.form-group
2020-12-12 20:21:49 -07:00
fieldset.entryField
2022-03-12 18:24:24 -07:00
label.form-label.mt-3(for='message') Display Name
2020-12-12 20:21:49 -07:00
input#message.form-control(type='text', placeholder='Display Name', maxlength='50')
2020-11-29 19:29:38 -07:00
.form-group
2020-12-12 20:21:49 -07:00
fieldset.entryField
2022-03-12 18:24:24 -07:00
label.form-label.mt-3(for='signature') Signature
input#signature.form-control.mb-3(type='text', placeholder='Signature', maxlength='100')
2024-03-20 18:20:03 -06:00
if settings.claim_address_page.enable_captcha == true && selected_captcha_object != null
case selected_captcha_name
when 'google_recaptcha2'
if settings.captcha.google_recaptcha2.captcha_type == 'invisible'
div#recaptcha.g-recaptcha(data-sitekey=settings.captcha[selected_captcha_name].site_key, data-callback='onSubmit' data-size='invisible')
else
.form-group
fieldset.entryField
div(class='g-recaptcha mb-3', data-sitekey=settings.captcha[selected_captcha_name].site_key)
when 'hcaptcha'
.form-group
fieldset.entryField
div.h-captcha(data-sitekey=settings.captcha[selected_captcha_name].site_key)
.form-group
fieldset.entryField
button.btn.btn-success(type='submit') Claim