40 lines
986 B
JavaScript
40 lines
986 B
JavaScript
$('#btn-shorten').on('click', function(){
|
|
$.ajax({
|
|
url: '/api/v1/shorten',
|
|
type: 'POST',
|
|
dataType: 'JSON',
|
|
data: {url: $('#url-field').val()},
|
|
success: function(data){
|
|
const $link = $('#link');
|
|
const resultHTML = `<a class="result" href="${data.shortUrl}">${data.shortUrl}</a>`;
|
|
$link.html(resultHTML);
|
|
// $link.hide().fadeIn('slow');
|
|
$link.hide().show();
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
(function($) {
|
|
$.extend($.fn, {
|
|
fadeIn: function(ms) {
|
|
if(typeof(ms) === 'undefined') ms = 500;
|
|
|
|
$(this).css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, ms);
|
|
|
|
return this;
|
|
},
|
|
|
|
fadeOut: function(ms)
|
|
{
|
|
if(typeof(ms) === 'undefined') ms = 500;
|
|
|
|
$(this).css({ opacity: 1 }).animate({ opacity: 0 }, ms, 'linear', function() {
|
|
$(this).css('display', 'none');
|
|
});
|
|
|
|
return this;
|
|
}
|
|
});
|
|
})(Zepto);
|