Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Website Link: https://5050.iserv.ml
- const FFModule = (function() {
- var form = $('#gnrt-form'),
- firstLink = $('#link-1'),
- secondLink = $('#link-2'),
- resultInp = $('#link-3'),
- submitBtn = $('#btn-submit'),
- vanillaInp = resultInp.get(0),
- result = '',
- init = function() {
- form.submit(function(event) {
- event.preventDefault();
- var link1 = encodeURI(firstLink.val());
- var link2 = encodeURI(secondLink.val());
- if(link1.length === 0 || link2.length === 0) {
- resultInp.val('One of the links is invalid.');
- return false;
- }
- var long = link1 + ';' + link2;
- submitBtn.attr('disabled', true);
- $.post('shorten.php', {'url': long}).done(function(data) {
- data = JSON.parse(data);
- if(data.error) {
- console.info('Error:', data.message || data.msg);
- result = 'Error, please try again.';
- } else result = data.id;
- submitBtn.attr('disabled', false);
- resultInp.val(result);
- });
- });
- },
- cpy = function() {
- vanillaInp.select();
- document.execCommand("copy");
- };
- return {
- Initialize: init,
- Copy: cpy
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement