;(function ($) {
"use strict"
$("document").ready(function () {
function bb_begin_ajax() {
$(".bb-ajax-loading").css({ display: "flex" })
}
function bb_end_ajax() {
$(".bb-ajax-loading").css({ display: "none" })
}
$("body").on("click", ".wpe-vertify-button", function () {
var $self = $(this),
_purchase_code = $($(this).data("target")).val(),
_slug = $(this).data("slug")
$self.attr("disabled", "disabled")
bb_begin_ajax()
if (_purchase_code == "") {
$.growl({
title: "Warning",
message: "Please enter your License Key!",
location: "br",
style: "warning",
})
bb_end_ajax()
$self.removeAttr("disabled")
} else {
$.post(
SCROLLMAGIC.VERIFY,
{
license: _purchase_code,
id: 9,
url:
window.location.protocol +
"//" +
window.location.hostname,
},
function (response) {
response = $.parseJSON(response)
bb_end_ajax()
var _license = -1
if (typeof response.success != undefined) {
if (response.success == true) {
$.growl({
title: "Succesfully",
message: "Successfully verified!",
location: "br",
style: "notice",
})
_license = 1
} else {
var msg = "Error undefined"
switch (response.error) {
case "missing":
msg = "License doesn't exist"
break
case "missing_url":
msg = "URL not provided"
break
case "license_not_activable":
msg =
"Attempting to activate a bundle's parent license"
break
case "disabled":
msg = "License key revoked"
break
case "no_activations_left":
msg = "No activations left"
break
case "expired":
msg = "License has expired"
break
case "key_mismatch":
msg =
"License is not valid for this product"
break
case "invalid_item_id":
msg = "Invalid Item ID"
break
case "item_name_mismatch":
msg =
"License is not valid for this product"
break
default:
msg = "Error undefined"
break
}
$.growl({
title: "Error",
message: msg,
location: "br",
style: "error",
})
}
} else {
$.growl({
title: "Error",
message: "Error undefined",
location: "br",
style: "error",
})
}
$.ajax({
method: "POST",
url: ajaxurl,
data: {
action: "wpe_update_license",
slug: _slug,
license: _license,
},
})
$self.removeAttr("disabled")
}
)
}
})
})
})(window.jQuery)