{"id":316,"date":"2020-12-19T17:05:01","date_gmt":"2020-12-19T10:05:01","guid":{"rendered":"https:\/\/khoahocthethao.vn\/?page_id=316"},"modified":"2024-11-18T08:53:17","modified_gmt":"2024-11-18T01:53:17","slug":"e-sport","status":"publish","type":"page","link":"https:\/\/khoahocthethao.vn\/index.php\/e-sport\/","title":{"rendered":"E-sport"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"316\" class=\"elementor elementor-316\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-0288e5e elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"0288e5e\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-2555097\" data-id=\"2555097\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-39b9743 elementor-widget elementor-widget-heading\" data-id=\"39b9743\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">\u1ede \u0111\u00e2y t\u1ed5ng h\u1ee3p c\u00e1c b\u1ed9 m\u00f4n th\u1ec3 thao \u0111i\u1ec7n t\u1eed E-sports<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-593159e elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"593159e\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-e996e21\" data-id=\"e996e21\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-43ed786 elementor-widget elementor-widget-shortcode\" data-id=\"43ed786\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\">    <div class=\"rt-stats-box\" data-nonce=\"4e4c7d1c59\" style=\"max-width:980px;\">\n        <div style=\"display:flex; gap:10px; align-items:center; flex-wrap:wrap;\">\n            <label for=\"rt-year\">N\u0103m:<\/label>\n            <select class=\"rt-year\" id=\"rt-year\"><option value=\"2026\">2026<\/option><option value=\"2025\">2025<\/option><option value=\"2024\">2024<\/option><\/select>\n            <button type=\"button\" class=\"rt-open\">Open chart<\/button>\n\n                    <\/div>\n\n        <p class=\"rt-status\" style=\"margin-top:10px;\"><\/p>\n\n        <div style=\"margin-top:15px;\">\n            <canvas class=\"rt-country-chart\" style=\"width:100%; height:350px;\"><\/canvas>\n        <\/div>\n        <div style=\"margin-top:15px;\">\n            <canvas class=\"rt-hist-chart\" style=\"width:100%; height:350px;\"><\/canvas>\n        <\/div>\n    <\/div>\n\n    <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/chart.js\"><\/script>\n    <script>\n    (function(){\n      function parseJsonSafe(text){\n        try { return JSON.parse(text); }\n        catch(e){ console.log(\"Non-JSON:\", text); return {success:false, data:\"Non-JSON response\"}; }\n      }\n\n      function getAjax(url){\n        return fetch(url, { method:\"GET\", credentials:\"same-origin\" })\n          .then(r => r.text())\n          .then(t => parseJsonSafe(t));\n      }\n\n      function postAjax(url, data){\n        return fetch(url, {\n          method: \"POST\",\n          headers: {\"Content-Type\":\"application\/x-www-form-urlencoded; charset=UTF-8\"},\n          body: new URLSearchParams(data).toString(),\n          credentials: \"same-origin\"\n        }).then(r => r.text()).then(t => parseJsonSafe(t));\n      }\n\n      document.querySelectorAll('.rt-stats-box').forEach(function(box){\n        var nonce = box.getAttribute('data-nonce');\n        var selYear = box.querySelector('.rt-year');\n        var btnOpen = box.querySelector('.rt-open');\n        var btnRebuild = box.querySelector('.rt-rebuild');\n        var status = box.querySelector('.rt-status');\n\n        var countryCanvas = box.querySelector('.rt-country-chart');\n        var histCanvas = box.querySelector('.rt-hist-chart');\n\n        var countryChart = null;\n        var histChart = null;\n\n        function renderCharts(payload){\n          var cLabels = (payload.countries || []).map(x => x.country_code || '??');\n          var cCounts = (payload.countries || []).map(x => Number(x.cnt || 0));\n\n          if (countryChart) countryChart.destroy();\n          countryChart = new Chart(countryCanvas.getContext('2d'), {\n            type: 'bar',\n            data: { labels: cLabels, datasets: [{ label: 'Top countries (count)', data: cCounts }] },\n            options: { responsive: true, scales: { y: { beginAtZero: true } } }\n          });\n\n          var hLabels = (payload.hist || []).map(x => (Number(x.bucket)\/100).toFixed(2) + \"s\");\n          var hCounts = (payload.hist || []).map(x => Number(x.cnt || 0));\n\n          if (histChart) histChart.destroy();\n          histChart = new Chart(histCanvas.getContext('2d'), {\n            type: 'bar',\n            data: { labels: hLabels, datasets: [{ label: 'Histogram', data: hCounts }] },\n            options: {\n              responsive: true,\n              scales: {\n                y: { beginAtZero: true },\n                x: { ticks: { autoSkip: true, maxTicksLimit: 20 } }\n              }\n            }\n          });\n        }\n\n        function openStats(){\n          status.textContent = 'Loading stats...';\n          var year = selYear.value;\n\n          var url = \"https:\/\/khoahocthethao.vn\/wp-admin\/admin-ajax.php\" +\n                    \"?action=rt_get_year_stats_v34&year=\" + encodeURIComponent(year);\n\n          getAjax(url).then(function(res){\n            if (!res || !res.success) {\n              status.textContent = 'Error: ' + (res && res.data ? res.data : 'Unknown');\n              return;\n            }\n\n            var data = res.data || {};\n            var validCount = Number(data.valid_count || 0);\n\n            if ((!data.hist || data.hist.length === 0) && (!data.countries || data.countries.length === 0)) {\n              if (validCount === 0) status.textContent = 'N\u0103m ' + year + ' kh\u00f4ng c\u00f3 d\u1eef li\u1ec7u h\u1ee3p l\u1ec7 (0.150\u20132.0).';\n              else status.textContent = 'Ch\u01b0a build stats cho n\u0103m ' + year + ' (c\u00f3 ' + validCount + ' record h\u1ee3p l\u1ec7). Admin b\u1ea5m Rebuild.';\n              return;\n            }\n\n            status.textContent = 'Showing stats for ' + year + ' (valid records: ' + validCount + ')';\n            renderCharts(data);\n          }).catch(function(err){\n            console.log(err);\n            status.textContent = 'Error loading stats.';\n          });\n        }\n\n        btnOpen.addEventListener('click', openStats);\n\n        if (btnRebuild) {\n          btnRebuild.addEventListener('click', function(){\n            var year = selYear.value;\n            status.textContent = 'Rebuilding stats for ' + year + '...';\n\n            postAjax(\"https:\/\/khoahocthethao.vn\/wp-admin\/admin-ajax.php\", {\n              action: \"rt_rebuild_stats_v34\",\n              nonce: nonce,\n              year: year\n            }).then(function(res){\n              if (!res || !res.success) {\n                status.textContent = 'Rebuild failed: ' + (res && res.data ? res.data : 'Unknown');\n                return;\n              }\n              status.textContent = 'Rebuild done for ' + year + '. Loading charts...';\n              openStats();\n            }).catch(function(err){\n              console.log(err);\n              status.textContent = 'Rebuild error.';\n            });\n          });\n        }\n      });\n    })();\n    <\/script>\n    <\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\u1ede \u0111\u00e2y t\u1ed5ng h\u1ee3p c\u00e1c b\u1ed9 m\u00f4n th\u1ec3 thao \u0111i\u1ec7n t\u1eed E-sports<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","footnotes":""},"class_list":["post-316","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/khoahocthethao.vn\/index.php\/wp-json\/wp\/v2\/pages\/316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/khoahocthethao.vn\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/khoahocthethao.vn\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/khoahocthethao.vn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/khoahocthethao.vn\/index.php\/wp-json\/wp\/v2\/comments?post=316"}],"version-history":[{"count":7,"href":"https:\/\/khoahocthethao.vn\/index.php\/wp-json\/wp\/v2\/pages\/316\/revisions"}],"predecessor-version":[{"id":4056,"href":"https:\/\/khoahocthethao.vn\/index.php\/wp-json\/wp\/v2\/pages\/316\/revisions\/4056"}],"wp:attachment":[{"href":"https:\/\/khoahocthethao.vn\/index.php\/wp-json\/wp\/v2\/media?parent=316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}