var city_is_visible = (document.currentScript.getAttribute('data-is-visible') == "true"); if (city_is_visible) { var lang = document.currentScript.getAttribute('data-lang'); if (lang == "zh-cn") lang = "zh"; const city_id = document.currentScript.getAttribute('data-city-id'); var city_version = document.currentScript.getAttribute('data-version'); if ((!city_version) || (city_version == "")) { city_version = 1; } const callback = document.currentScript.getAttribute('data-callback'); const parent_element_class = document.currentScript.getAttribute('data-parent-element-class'); const callback_exists = (callback) && (typeof window[callback] === "function"); const parent_element_class_exists = (parent_element_class); function ResizeElement(element) { $(element).show(); } if ((callback_exists) || (parent_element_class_exists)) { const page_from = document.currentScript.getAttribute('data-page-from'); $.ajax({ type: "POST", url: "/city_widget.php", data: {"city_id": city_id, "page_from": page_from, "lang": lang, "version": city_version}, success: function (response) { if ((response) && (response != "")) { var server_answer = JSON.parse(response); if (server_answer.status == "ok") { if (parent_element_class_exists) { $("." + parent_element_class).each(function () { $(this).html(server_answer.html); ResizeElement(this); }); } if (callback_exists) { window[callback](server_answer); } } } }, error: function (thrownError) { // do nothing } }); } }