diff --git a/bower.json b/bower.json index bf3d397..516eaa2 100644 --- a/bower.json +++ b/bower.json @@ -17,6 +17,7 @@ ], "dependencies": { "mui": "^0.9.20", - "zepto": "^1.2.0" + "zepto": "^1.2.0", + "jquery": "^3.2.1" } } diff --git a/config.js b/config.js index c174262..b4c7b58 100644 --- a/config.js +++ b/config.js @@ -1,7 +1,8 @@ const config = {}; config.db = {}; -config.webhost = 'http://nurl.co/'; +//config.webhost = 'http://nurl.co/'; +config.webhost = 'http://localhost:7000/'; config.port = 7000; config.db.host = 'localhost'; diff --git a/gulpfile.js b/gulpfile.js index 0171afa..359ab36 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -49,7 +49,7 @@ gulp.task('appJS', function() { gulp.task('vendor', function() { return gulp.src([ - 'bower_components/zepto/zepto.min.js', + 'bower_components/jquery/dist/jquery.min.js', 'bower_components/mui/packages/cdn/js/mui.min.js' ]) .pipe(concat('vendor.js')) diff --git a/public/javascripts/shorten.js b/public/javascripts/shorten.js index 1d9f210..add76d2 100644 --- a/public/javascripts/shorten.js +++ b/public/javascripts/shorten.js @@ -1,39 +1,26 @@ -$('#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 = `${data.shortUrl}`; - $link.html(resultHTML); - // $link.hide().fadeIn('slow'); - $link.hide().show(); - } - }); +function shorten(){ + $.ajax({ + url: '/api/v1/shorten', + type: 'POST', + dataType: 'JSON', + data: {url: $('#url-field').val()}, + success: function(data){ + console.log('data', data); + const $link = $('#link'); + const resultHTML = `${data.shortUrl}`; + $link.html(resultHTML); + $link.hide().fadeIn('slow'); + } + }); +} + +$("#url-field").keyup(function(event){ + if(event.keyCode === 13){ + $("#btn-shorten").click(); + } }); -(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); +$('#btn-shorten').on('click', function(){ + shorten(); +}); \ No newline at end of file diff --git a/views/index.html b/views/index.html index b86df38..6fff448 100644 --- a/views/index.html +++ b/views/index.html @@ -18,12 +18,10 @@