From 7a319688de5c1f30af42b14f9c9bfd8f6e154414 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 31 Aug 2014 15:15:33 -0400 Subject: [PATCH] localize plugin installation process --- dashboard-ui/addplugin.html | 137 ++++++++---------- dashboard-ui/scripts/addpluginpage.js | 127 ++++++---------- dashboard-ui/scripts/mediacontroller.js | 4 +- dashboard-ui/scripts/mediaplayer.js | 12 +- dashboard-ui/scripts/supporterpage.js | 85 ++++++++++- dashboard-ui/supporter.html | 30 ++-- .../thirdparty/mediabrowser.apiclient.js | 5 +- 7 files changed, 215 insertions(+), 185 deletions(-) diff --git a/dashboard-ui/addplugin.html b/dashboard-ui/addplugin.html index b32aebbde6..0acd8c2999 100644 --- a/dashboard-ui/addplugin.html +++ b/dashboard-ui/addplugin.html @@ -13,70 +13,79 @@ ${TabCatalog} ${TabChannels} -
+ +

-

+

-

Install

-

-

- - -

+

${HeaderInstall}

-

- -

-

-
- +
+
+

+

+ + +

- -
+
+
-

Rating and Reviews

+

${HeaderReviews}


@@ -85,39 +94,17 @@
-

Developer Info

+

${HeaderDeveloperInfo}

-

Revision History

+

${HeaderRevisionHistory}

- - -
- Close -

Supporter-Only plug-ins are free for anyone who is an MB3 Supporter (with a valid MB3 key who has donated the minimum amount to the overall project).

-

- Anyone can install them and enjoy a free trial period of 14 days in most instances. The trial period may commence as soon as you install the plug-in.

-

These plug-ins will appear in the catalog with a "Supporter" banner.

-
- -
- Close -

- Premium plug-ins are developed by third-parties and require that you be an MB3 Supporter and also register the plug-in with its creator. - The cost of registering these plug-ins is set for each one by its creator and all revenues go to that person. -

-

Anyone can install them and enjoy a free trial period of 14 days in most instances. The trial period may commence as soon as you install the plug-in.

-

- You should install premium plug-ins without registering them first to take advantage of this trial period. Then, if you find the functionality useful, - you can register it via its detail page here in the catalog. -

-

These plug-ins will appear in the catalog with a "Premium" banner.

diff --git a/dashboard-ui/scripts/addpluginpage.js b/dashboard-ui/scripts/addpluginpage.js index 0119f0591d..61a06cf5c4 100644 --- a/dashboard-ui/scripts/addpluginpage.js +++ b/dashboard-ui/scripts/addpluginpage.js @@ -58,84 +58,42 @@ } function populateReviews(id, page) { - // Get the latest positive and negative reviews - var promise1 = ApiClient.getPackageReviews(id, 4, null, 3, true); - var promise2 = ApiClient.getPackageReviews(id, null, 2, 3, true); - $.when(promise1, promise2).done(function (response1, response2) { - //positive - var html = '
'; - html += '

Latest Outstanding Reviews

'; + ApiClient.getPackageReviews(id, null, null, 3).done(function (positive) { + + var html = ''; - var positive = response1[0]; - var hasReviews = false; if (positive && positive.length > 0) { + + html += '
'; + html += '

' + Globalize.translate('HeaderLatestReviews') + '

'; + + html += "

"; + for (var i = 0; i < positive.length; i++) { var review = positive[i]; - if (review.title) { - hasReviews = true; - 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 += ""; + 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 += "
"; } - if (!hasReviews) { - html += "

No Outstanding Reviews with additional information

"; - } - - html += "
"; - - //negative - html += '
'; - html += '

Latest Negative Reviews

'; - var negative = response2[0]; - hasReviews = false; - if (negative && negative.length > 0) { - for (var i = 0; i < negative.length; i++) { - review = negative[i]; - if (review.title) { - hasReviews = true; - 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 += "
"; - } - } - } - - if (!hasReviews) { - html += "

No Negative Reviews with additional information

"; - } - - html += "
"; - $('#latestReviews', page).html(html).trigger('create'); - }); - } function renderPackage(pkg, installedPlugins, pluginSecurityInfo, page) { @@ -157,7 +115,8 @@ } else { $("#btnInstallDiv", page).hide(); $("#pSelectVersion", page).hide(); - var msg = "This plug-in must be installed from " + pkg.targetSystem; + + var msg = Globalize.translate('MessageInstallPluginFromApp'); $("#nonServerMsg", page).html(msg).show(); } @@ -178,14 +137,15 @@ // Fill in registration info var regStatus = ""; if (pkg.isRegistered) { - regStatus += "You are currently registered for this feature"; } else { + if (new Date(pkg.expDate).getTime() < new Date(1970, 1, 1).getTime()) { } else { if (new Date(pkg.expDate).getTime() <= new Date().getTime()) { - regStatus += "The trial period for this feature has expired"; + regStatus += Globalize.translate('MessageTrialExpired'); } else { - regStatus += "The trial period for this feature will expire in " + Math.round((new Date(pkg.expDate).getTime() - new Date().getTime()) / (86400000)) + " day(s)"; + + regStatus += Globalize.translate('MessageTrialWillExpireIn').replace('{0}', Math.round((new Date(pkg.expDate).getTime() - new Date().getTime()) / (86400000))); } } } @@ -205,15 +165,17 @@ $('#featureId', page).val(pkg.featureId); $('#featureName', page).val(pkg.name); $('#amount', page).val(pkg.price); - $('#regPrice', page).html("

Price: $" + pkg.price.toFixed(2) + " (USD)

"); + + $('#regPrice', page).html("

" + Globalize.translate('ValuePriceUSD').replace('{0}', "$" + pkg.price.toFixed(2)) + "

"); + var url = "http://mb3admin.com/admin/service/user/getPayPalEmail?id=" + pkg.owner; + $.getJSON(url).done(function (dev) { if (dev.payPalEmail) { $('#payPalEmail', page).val(dev.payPalEmail); } else { $('#ppButton', page).hide(); - $('#noEmail', page).show(); } }); } else { @@ -241,9 +203,9 @@ } //Ratings and Reviews - var ratingHtml = "Overall " + RatingHelpers.getStoreRatingHtml(pkg.avgRating, pkg.id, pkg.name); + var ratingHtml = RatingHelpers.getStoreRatingHtml(pkg.avgRating, pkg.id, pkg.name); ratingHtml += ""; - ratingHtml += " " + pkg.totalRatings + " Reviews"; + ratingHtml += " " + Globalize.translate('ValueReviewCount').replace('{0}', pkg.totalRatings); ratingHtml += ""; $('#ratingLine', page).html(ratingHtml); @@ -265,7 +227,9 @@ } if (installedPlugin) { - $('#pCurrentVersion', page).show().html("You currently have version " + installedPlugin.Version + " installed."); + + var currentVersionText = Globalize.translate('MessageYouHaveVersionInstalled').replace('{0}', '' + installedPlugin.Version + ''); + $('#pCurrentVersion', page).show().html(currentVersionText); } else { $('#pCurrentVersion', page).hide().html(""); @@ -332,16 +296,9 @@ Dashboard.hideLoadingMsg(); - Dashboard.confirm("Are you sure you wish to reinstall the same version you already have? In most cases this will not have any effect.", "Plugin Reinstallation", function (confirmResult) { - - if (confirmResult) { - - Dashboard.showLoadingMsg(); - performInstallation(name, guid, vals[1], version); - } else { - $('#btnInstall', page).buttonEnabled(true); - } - + Dashboard.alert({ + message: Globalize.translate('MessageAlreadyInstalled'), + title: Globalize.translate('HeaderPluginInstallation') }); } else { performInstallation(name, guid, vals[1], version); diff --git a/dashboard-ui/scripts/mediacontroller.js b/dashboard-ui/scripts/mediacontroller.js index 9d3671b87d..22d4354941 100644 --- a/dashboard-ui/scripts/mediacontroller.js +++ b/dashboard-ui/scripts/mediacontroller.js @@ -2,13 +2,13 @@ function setMirrorModeEnabled(enabled) { - var val = enabled ? '1' : ''; + var val = enabled ? '1' : '0'; store.setItem('displaymirror-' + Dashboard.getCurrentUserId(), val); } function isMirrorModeEnabled() { - return (store.getItem('displaymirror-' + Dashboard.getCurrentUserId()) || '') == '1'; + return (store.getItem('displaymirror--' + Dashboard.getCurrentUserId()) || '') != '0'; } var currentDisplayInfo; diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index 08cf56d1ee..e79d9f9b20 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -250,7 +250,9 @@ return false; } - if ((videoStream.Codec || '').toLowerCase().indexOf('h264') == -1) { + var isH264 = (videoStream.Codec || '').toLowerCase().indexOf('h264') != -1; + + if (!isH264) { console.log('Transcoding because the content is not h264'); return false; } @@ -282,9 +284,11 @@ var extension = (mediaSource.Container || '').toLowerCase(); - // m4v's and mp4's with high profile failing in chrome - if (videoStream && videoStream.Profile == 'High') { - //return false; + var profile = (videoStream ? (videoStream.Profile || '') : '').toLowerCase(); + + // only support high, baseline variants and main variants + if (isH264 && profile != 'high' && profile.indexOf('baseline') == -1 && profile.indexOf('main') == -1) { + return false; } if (extension == 'm4v' || extension == 'mkv') { diff --git a/dashboard-ui/scripts/supporterpage.js b/dashboard-ui/scripts/supporterpage.js index 05413f4c3f..ae85494556 100644 --- a/dashboard-ui/scripts/supporterpage.js +++ b/dashboard-ui/scripts/supporterpage.js @@ -32,7 +32,7 @@ //change command back $('#ppCmd', page).val('_xclick'); } - + function setItemNumber(page, itemNumber) { $('#ppItemNo', page).val(itemNumber); } @@ -67,6 +67,61 @@ $("#donateAmt", page).val(getDonationAmount(page)); } + function loadUserInfo(page) { + + ApiClient.getJSON(ApiClient.getUrl('System/SupporterInfo')).done(function (info) { + + + $('.hfPlanType', page).val(info.PlanType || ''); + $('.hfIsActive', page).val(info.IsActiveSupporter.toString()); + + $('.radioDonationType', page).checked(false).checkboxradio('refresh'); + + if (info.PlanType == 'Lifetime' && info.IsActiveSupporter) { + + // If they have an active lifetime plan, select the one-time option + $('#radioOneTimeDonation', page).checked(true).checkboxradio('refresh'); + + } else { + + // For all other statuses, select lifetime, to either acquire or upgrade + $('#radioLifetimeSupporter', page).checked(true).checkboxradio('refresh'); + } + + $('.radioDonationType:checked', page).trigger('change'); + + if (info.IsActiveSupporter || info.IsExpiredSupporter) { + $('.currentPlanInfo', page).show(); + } else { + $('.currentPlanInfo', page).hide(); + } + + if (info.IsActiveSupporter && info.PlanType == 'Lifetime') { + + $('.planSummary', page) + .html('You have a lifetime supporter club membership. You can provide additional donations on a one-time or recurring basis using the options below. Thank you for supporting Media Browser.') + .css('color', 'green'); + + } + else if (info.IsActiveSupporter) { + + $('.planSummary', page) + .html('You have an active ' + info.PlanType + ' membership. You can upgrade your plan using the options below.') + .css('color', 'green'); + + } + else if (info.IsExpiredSupporter) { + + var expirationDate = info.ExpirationDate ? parseISO8601Date(info.ExpirationDate, { toLocal: true }) : new Date(); + expirationDate = expirationDate.toLocaleDateString(); + + $('.planSummary', page) + .html('Your ' + info.PlanType + ' membership expired on ' + expirationDate + '.') + .css('color', 'red'); + } + }); + } + $(document).on('pageinit', "#supporterPage", function () { var page = this; @@ -102,7 +157,6 @@ $('.fldOneTimeDonationAmount', page).hide(); removeRecurringFields(page); setItemNumber(page, 'MBSupporter'); - $('#oneTimeDescription').hide(); } }); @@ -123,10 +177,29 @@ $('.radioDonationType', page).trigger('change'); - // TODO: Pull down supporter status - // If already lifetime, had that option, but allow them to add monthly - many supporters probably will - // If already monthly, hide monthly option - // Or possibly not hide and select that option, but that will imply that changing the option will update their PP (can we do that?) + loadUserInfo(page); }); + window.SupporterPage = { + + onSubmit: function () { + + var form = this; + var page = $(form).parents('.page'); + + if ($('.hfIsActive', page).val() == 'true') { + + var currentPlanType = $('.hfPlanType', page).val(); + + if (currentPlanType != 'Lifetime') { + + // Use a regular alert to block the submission process until they hit ok + alert('After completing this transaction you will need to cancel your previous recurring donation from within your PayPal account. Thank you for supporting Media Browser.'); + } + } + + } + + }; + })(); \ No newline at end of file diff --git a/dashboard-ui/supporter.html b/dashboard-ui/supporter.html index 7f49f4daa7..4660302769 100644 --- a/dashboard-ui/supporter.html +++ b/dashboard-ui/supporter.html @@ -23,7 +23,11 @@

${HeaderSupporterBenefit}

-
+ + +
${HeaderDonationType} @@ -34,7 +38,7 @@
- + +
${LabelRecurringDonationCanBeCancelledHelp}
-
+
-

${OptionOneTimeDescription}

- - +

@@ -88,18 +91,27 @@ - +

${DonationNextStep}

${ButtonEnterSupporterKey}

+ + + + +
+ + diff --git a/dashboard-ui/thirdparty/mediabrowser.apiclient.js b/dashboard-ui/thirdparty/mediabrowser.apiclient.js index 7cc266da0d..99db72cd2d 100644 --- a/dashboard-ui/thirdparty/mediabrowser.apiclient.js +++ b/dashboard-ui/thirdparty/mediabrowser.apiclient.js @@ -3196,7 +3196,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getPackageReviews = function (packageId, minRating, maxRating, limit, forceTitle) { + self.getPackageReviews = function (packageId, minRating, maxRating, limit) { if (!packageId) { throw new Error("null packageId"); @@ -3213,9 +3213,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi if (limit) { options.Limit = limit; } - if (forceTitle) { - options.ForceTitle = true; - } var url = self.getUrl("Packages/" + packageId + "/Reviews", options);