link shorten bugfix

subdomains and & in url didn't work
This commit is contained in:
Hannes Mannerheim 2014-09-25 14:02:36 +02:00
parent e5120f5bdf
commit 91291925c0

View File

@ -863,14 +863,17 @@ function shortenUrlsInBox(shortenButton) {
$.each(shortenButton.parent().parent().siblings('.syntax-middle').find('span.url'),function(key,obj){ $.each(shortenButton.parent().parent().siblings('.syntax-middle').find('span.url'),function(key,obj){
var url = $.trim($(obj).html().replace(/&amp;/gi,'&').replace(/&nbsp;/gi,'').replace(/<br>/gi,'')); var url = $.trim($(obj).text());
display_spinner(); display_spinner();
$.ajax({ url: window.urlShortenerAPIURL + '?format=jsonp&action=shorturl&signature=' + window.urlShortenerSignature + '&url=' + encodeURIComponent(url), type: "GET", dataType: "jsonp", success: function(data) { $.ajax({ url: window.urlShortenerAPIURL + '?format=jsonp&action=shorturl&signature=' + window.urlShortenerSignature + '&url=' + encodeURIComponent(url), type: "GET", dataType: "jsonp", success: function(data) {
if(typeof data.shorturl != 'undefined') { if(typeof data.shorturl != 'undefined') {
shortenButton.parent().parent().siblings('.queet-box-syntax').html(shortenButton.parent().parent().siblings('.queet-box-syntax').html().replace(data.url.url, data.shorturl));
console.log(data.url);
shortenButton.parent().parent().siblings('.queet-box-syntax').html(shortenButton.parent().parent().siblings('.queet-box-syntax').html().replace($('<div/>').text(data.url.url).html(), data.shorturl));
shortenButton.parent().parent().siblings('.queet-box-syntax').trigger('keyup'); shortenButton.parent().parent().siblings('.queet-box-syntax').trigger('keyup');
shortenButton.addClass('disabled'); // make sure the button is disabled right after shortenButton.addClass('disabled'); // make sure the button is disabled right after
} }