update translations

This commit is contained in:
Luke Pulverenti 2015-05-26 11:31:50 -04:00
parent 4e86a39f8c
commit 28f378f8db
19 changed files with 284 additions and 64 deletions

View file

@ -1,28 +1,105 @@
(function () {
function validatePlayback(deferred) {
var updatedProducts = [];
function updateProductInfo(p) {
updatedProducts = updatedProducts.filter(function (r) {
return r.alias != p.alias;
});
updatedProducts.push(p);
}
function isAndroid() {
var platform = (device.platform || '').toLowerCase();
return platform.indexOf('android') != -1;
}
function validatePlayback(deferred) {
// Don't require validation on android
if (platform.indexOf('android') != -1) {
if (isAndroid()) {
deferred.resolve();
return;
}
deferred.resolve();
validateFeature({
id: 'appunlock',
alias: "premium features"
}, deferred);
}
function validateLiveTV(deferred) {
var platform = (device.platform || '').toLowerCase();
// Don't require validation if not android
if (platform.indexOf('android') == -1) {
if (!isAndroid()) {
deferred.resolve();
return;
}
validateFeature({
id: 'premiumunlock',
alias: "premium features"
}, deferred);
}
function validateSmb(deferred) {
// Don't require validation if not android
if (!isAndroid()) {
deferred.resolve();
return;
}
validateFeature({
id: 'premiumunlock',
alias: "premium features"
}, deferred);
}
function validateFeature(info, deferred) {
var products = updatedProducts.filter(function (r) {
return r.alias == info.alias;
});
var product = products.length ? products[0] : null;
if (product && product.owned) {
deferred.resolve();
return;
}
// Get supporter status
ConnectionManager.getRegistrationInfo('appunlock', ApiClient).done(function (registrationInfo) {
if (registrationInfo.IsRegistered) {
deferred.resolve();
return;
}
showInAppPurchaseInfo(info, product, registrationInfo, deferred);
}).fail(function () {
deferred.reject();
});
}
function showInAppPurchaseInfo(info, product, serverRegistrationInfo, deferred) {
var requiresLocalValidation = serverRegistrationInfo.IsLocalValidationRequired;
var canPurchase = product != null && product.canPurchase;
// Can only purchase if product != null
deferred.resolve();
}
@ -57,4 +134,82 @@
}
};
function validateProduct(product, callback) {
// product attributes:
// https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md#validation-error-codes
callback(true, {
});
//callback(true, { ... transaction details ... }); // success!
//// OR
//callback(false, {
// error: {
// code: store.PURCHASE_EXPIRED,
// message: "XYZ"
// }
//});
//// OR
//callback(false, "Impossible to proceed with validation");
}
function initializeStore() {
// Let's set a pretty high verbosity level, so that we see a lot of stuff
// in the console (reassuring us that something is happening).
store.verbosity = store.INFO;
store.validator = validateProduct;
if (isAndroid) {
store.register({
id: "premiumunlock",
alias: "premium features",
type: store.NON_CONSUMABLE
});
} else {
// iOS
store.register({
id: "appunlock",
alias: "premium features",
type: store.NON_CONSUMABLE
});
}
// When purchase of the full version is approved,
// show some logs and finish the transaction.
store.when("premium feautres").approved(function (order) {
log('You just unlocked the FULL VERSION!');
order.finish();
});
// The play button can only be accessed when the user
// owns the full version.
store.when("premium feautres").updated(function (product) {
updateProductInfo(product);
});
// When every goes as expected, it's time to celebrate!
// The "ready" event should be welcomed with music and fireworks,
// go ask your boss about it! (just in case)
store.ready(function () {
console.log("Store ready");
// After we've done our setup, we tell the store to do
// it's first refresh. Nothing will happen if we do not call store.refresh()
store.refresh();
});
}
// We must wait for the "deviceready" event to fire
// before we can use the store object.
initializeStore();
})();