jQuery(document).ready(function ($) { //$("#a2widget").html('
Loading AlternativeTo Widget
'); $(".a2options").each(function (index, value) { var a2widget = $(this).next(); a2widget.css("display", "none"); //if ($('#a2options').length != 0) { var a2options = $(this).val().split(","); var a2app = a2options[1]; var a2count = a2options[0]; var a2category = a2options[2]; var a2theme = a2options[3]; var is_preview = a2options[4]; var a2license = a2options[5]; var a2platform = a2options[6]; var ref = "?ref=plugin"; var callUrl = "http://api.alternativeto.net/" + a2category + "/" + a2app + "/?count=" + a2count; if(a2platform != ''){ callUrl += "&platform=" + a2platform; } if(a2license != ''){ callUrl += "&license=" + a2license; } callUrl += "&jsoncallback=?"; if (is_preview == 1) { ref = ""; }; $.ajax({ type: "GET", dataType: "json", url: callUrl, success: function (data) { var sHtml = ""; if (a2theme == "default") { sHtml = "
"; sHtml += "
" + data.Votes + "likes

"; sHtml += "" + data.Name + "

"; sHtml += "

" + data.ShortDescription + "

"; sHtml += "

Platforms

" + a2_getPlatformString(data.Platforms, false) + "
"; sHtml += "

License

" + a2_getLicenseString(data.License) + "
"; sHtml += "
"; sHtml += "
"; sHtml += "

The best alternatives to " + data.Name + " from AlternativeTo

"; sHtml += "
"; } else if (a2theme == "small") { sHtml = "
"; sHtml += "

" + data.Name + "

"; sHtml += "" + data.Votes + " likes, " + a2_getLicenseString(data.License, false) + " for " + a2_getPlatformString(data.Platforms) + "
"; sHtml += "

The best alternatives to " + data.Name + " from AlternativeTo

"; sHtml += "
"; } else if (a2theme == "minimal") { sHtml = data.Name + " alternatives: "; $.each(data.Items, function (i, item) { sHtml += '' + item.Name + ', '; }); sHtml = sHtml.slice(0, -2); } console.log(a2widget); a2widget.html(sHtml); a2widget.css("display", "block"); return; } }); }); }); function a2_getPlatformString(platform, shortVersion) { if (shortVersion) return platform.join(", ").replace("Windows", "Win"); else return platform.join(", "); } function a2_getLicenseString(license) { return license.replace('Free with limited functionality', 'Free (Limited)'); } function a2_cutString(itemName) { var name; if (itemName.length > 24) { name = itemName.substring(0, 24) + "..."; } else { name = itemName; } return name; }