tidying
This commit is contained in:
parent
d4bab117da
commit
708cf03dec
@ -1,26 +1,26 @@
|
|||||||
function shorten(){
|
function shorten() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/api/v1/shorten',
|
url: '/api/v1/shorten',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
data: {url: $('#url-field').val()},
|
data: { url: $('#url-field').val() },
|
||||||
success: function(data){
|
success: data => {
|
||||||
console.log('data', data);
|
console.log('data', data);
|
||||||
const $link = $('#link');
|
const $link = $('#link');
|
||||||
const resultHTML = `<a class="result" href="${data.shortUrl}">${data.shortUrl}</a>`;
|
const resultHTML = `<a class="result" href="${data.shortUrl}">${data.shortUrl}</a>`;
|
||||||
$link.html(resultHTML);
|
$link.html(resultHTML);
|
||||||
$link.hide().fadeIn('slow');
|
$link.hide().fadeIn('slow');
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#url-field").keyup(function(event){
|
$('#url-field').keyup( (event) => {
|
||||||
if(event.keyCode === 13){
|
if(event.keyCode === 13)
|
||||||
$("#btn-shorten").click();
|
$('#btn-shorten').click();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#btn-shorten').on('click', function(){
|
$('#btn-shorten').on('click', () => {
|
||||||
shorten();
|
shorten();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user