Permalink
Browse files

Use TinyUrls during sharing question in other social networking websites

  • Loading branch information...
1 parent 91e6b6f commit b8182ebf5374b7470a7d8d6ec0b5c9274df60c81 @rtnpro committed Sep 4, 2011
Showing with 19 additions and 6 deletions.
  1. +19 −6 askbot/skins/default/media/js/post.js
@@ -1555,12 +1555,25 @@ var socialSharing = function(){
var share_page = function(service_name){
if (SERVICE_DATA[service_name]){
var url = SERVICE_DATA[service_name]['url'];
- url = url.replace('{URL}', URL);
- url = url.replace('{TEXT}', TEXT);
- var params = SERVICE_DATA[service_name]['params'];
- if(!window.open(url, "sharing", params)){
- window.location.href=share_url;
- }
+ $.ajax({
+ async: false,
+ url: "http://json-tinyurl.appspot.com/?&callback=?",
+ dataType: "json",
+ data: {'url':URL},
+ success: function(data){
+ url = url.replace('{URL}', data.tinyurl);
+ },
+ error: function(data){
+ url = url.replace('{URL}', URL);
+ },
+ complete: function(data){
+ url = url.replace('{TEXT}', TEXT);
+ var params = SERVICE_DATA[service_name]['params'];
+ if(!window.open(url, "sharing", params)){
+ window.location.href=share_url;
+ }
+ }
+ });
}
}

0 comments on commit b8182eb

Please sign in to comment.