define(['jQuery'], function ($) {
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];
}
if (packageVersion) {
var val = packageVersion.versionStr + '|' + packageVersion.classification;
selectmenu.val(val);
}
}
function populateReviews(id, page) {
ApiClient.getPackageReviews(id, null, null, 3).then(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();
if (review.rating) {
html += 'star';
html += review.rating.toFixed(1);
}
html += " " + review.title;
html += "";
if (review.review) {
html += "
";
html += review.review;
html += "
";
}
html += "
";
html += "";
}
html += "
";
html += "
";
}
$('#latestReviews', page).html(html).trigger('create');
});
}
function renderPluginInfo(page, pkg, pluginSecurityInfo) {
if (AppInfo.isNativeApp) {
return;
}
require(['jQuery'], function ($) {
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 += "