let login_is_visible = (document.currentScript.getAttribute('data-is-visible') == "true");
let urlParams = new URLSearchParams(window.location.search);
if (login_is_visible)
{
let login_lang = document.currentScript.getAttribute('data-lang');
let login_callback = document.currentScript.getAttribute('data-callback');
let login_parent_element_class = document.currentScript.getAttribute('data-parent-element-class');
var login_profile_avatar_image = document.currentScript.getAttribute('data-avatar-element-class');
var login_version = document.currentScript.getAttribute('data-version');
if ((!login_version) ||
(login_version == ""))
{
login_version = 1;
}
let login_callback_exists = (login_callback) && (typeof window[login_callback] === "function");
let login_parent_element_class_exists = (login_parent_element_class);
function ResizeElement(element)
{
$(element).show();
}
if ((login_callback_exists) ||
(login_parent_element_class_exists))
{
let original_url = window.location.href;
if (window.location.pathname == "/login_widget.php")
original_url = urlParams.get("original_url");
$.ajax({
type: "POST",
url: "/login_widget.php",
data: {
"lang": login_lang,
"mode": "login_widget_ajax",
"version": login_version,
"original_url": original_url
},
success: function (response)
{
if ((response) &&
(response != ""))
{
let server_answer = JSON.parse(response);
if (server_answer.status == "ok")
{
if ((login_profile_avatar_image) &&
(server_answer.profile_avatar_image_html))
{
$("." + login_profile_avatar_image).each(function ()
{
$(this).html(server_answer.profile_avatar_image_html);
});
}
if (login_parent_element_class_exists)
{
$("." + login_parent_element_class).each(function ()
{
$(this).html(server_answer.html);
ResizeElement(this);
});
}
if (login_callback_exists) {
window[login_callback](server_answer);
}
}
}
},
error: function (thrownError)
{
// do nothing
}
});
}
}