(function ($, document, window) {
function populateHistory(packageInfo, page) {
var html = '';
for (var i = 0, length = Math.min(packageInfo.versions.length, 10) ; i < length; i++) {
var version = packageInfo.versions[i];
html += '
';
}
$('#revisionHistory', page).html(html);
}
function populateVersions(packageInfo, page, installedPlugin) {
var html = '';
for (var i = 0, length = packageInfo.versions.length; i < length; i++) {
var version = packageInfo.versions[i];
html += '';
}
var selectmenu = $('#selectVersion', page).html(html);
if (!installedPlugin) {
$('#pCurrentVersion', page).hide().html("");
}
var packageVersion = packageInfo.versions.filter(function (current) {
return current.classification == "Release";
})[0];
// If we still don't have a package version to select, pick the first Beta build
if (!packageVersion) {
packageVersion = packageInfo.versions.filter(function (current) {
return current.classification == "Beta";
})[0];
}
selectmenu.selectmenu('refresh');
if (packageVersion) {
var val = packageVersion.versionStr + '|' + packageVersion.classification;
selectmenu.val(val).selectmenu('refresh');
}
}
function populateReviews(id, page) {
ApiClient.getPackageReviews(id, null, null, 3).done(function (positive) {
var html = '';
if (positive && positive.length > 0) {
html += '
";
for (var i = 0; i < positive.length; i++) {
var review = positive[i];
html += "
";
html += "";
html += new Date(review.timestamp).toDateString();
html += " " + RatingHelpers.getStoreRatingHtml(review.rating, review.id, review.name, true);
html += " " + review.title;
html += "";
if (review.review) {
html += "
";
html += review.review;
html += "
";
}
html += "
";
html += "";
}
html += "
";
html += "
";
}
$('#latestReviews', page).html(html).trigger('create');
});
}
function renderPackage(pkg, installedPlugins, pluginSecurityInfo, page) {
var installedPlugin = installedPlugins.filter(function (ip) {
return ip.Name == pkg.name;
})[0];
populateVersions(pkg, page, installedPlugin);
populateHistory(pkg, page);
if (pkg.totalRatings > 0) populateReviews(pkg.id, page);
$('.pluginName', page).html(pkg.name);
if (pkg.targetSystem == 'Server') {
$("#btnInstallDiv", page).show();
$("#nonServerMsg", page).hide();
$("#pSelectVersion", page).show();
} else {
$("#btnInstallDiv", page).hide();
$("#pSelectVersion", page).hide();
var msg = Globalize.translate('MessageInstallPluginFromApp');
$("#nonServerMsg", page).html(msg).show();
}
if (pkg.shortDescription) {
$('#tagline', page).show().html(pkg.shortDescription);
} else {
$('#tagline', page).hide();
}
$('#overview', page).html(pkg.overview || "");
$('#developer', page).html(pkg.owner);
if (pkg.isPremium) {
$('.premiumPackage', page).show();
// Fill in registration info
var regStatus = "";
if (pkg.isRegistered) {
regStatus += "
";
regStatus += Globalize.translate('MessageFeatureIncludedWithSupporter');
} else {
var expDateTime = new Date(pkg.expDate).getTime();
var nowTime = new Date().getTime();
if (expDateTime <= nowTime) {
regStatus += "
";
regStatus += Globalize.translate('MessageTrialExpired');
}
else if (expDateTime > new Date(1970, 1, 1).getTime()) {
regStatus += "