{"id":428,"date":"2025-03-25T20:44:28","date_gmt":"2025-03-25T13:44:28","guid":{"rendered":"https:\/\/glowpax.top\/?p=428"},"modified":"2025-04-08T20:43:11","modified_gmt":"2025-04-08T13:43:11","slug":"speed-reading","status":"publish","type":"post","link":"https:\/\/glowpax.top\/?p=428","title":{"rendered":"Speed Reading"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><em><strong>Speed Reading<\/strong><\/em><\/h2>\n\n\n\n<p><\/p>\n\n\n    <div id=\"speed-reading-container\">\n        <form method=\"get\" class=\"speed-search-form\" style=\"margin-bottom: 10px;\">\n            <input type=\"text\" name=\"speed_search\" value=\"\" placeholder=\"T\u00ecm ki\u1ebfm chung (ti\u00eau \u0111\u1ec1 & n\u1ed9i dung)\" style=\"width: 300px;\">\n            <input type=\"submit\" value=\"T\u00ecm ki\u1ebfm\" class=\"button\">\n                    <\/form>\n\n        <table class=\"speed-reading-table\">\n            <thead>\n                <tr>\n                    <th>ID<\/th>\n                    <th>Ti\u00eau \u0111\u1ec1<\/th>\n                    <th>T\u1ed1c \u0111\u1ed9<\/th>\n                    <th>L\u01b0\u1ee3t xem<\/th>\n                    <th>H\u00e0nh \u0111\u1ed9ng<\/th>\n                <\/tr>\n            <\/thead>\n            <tbody>\n            <tr><td>17<\/td><td>Jumptask<\/td><td>0.25x (20s)<\/td><td class='views-count' data-id='17'>0<\/td><td>\n                        <button class='speed-read-btn' data-id='17'>\u0110\u1ecdc nhanh<\/button>\n                        <button class='specific-search-btn' data-id='17'>T\u00ecm trong b\u00e0i<\/button>\n                        <\/td><\/tr><tr><td>2<\/td><td>Vocabulary 1 (20\/200)<\/td><td>1x (5s)<\/td><td class='views-count' data-id='2'>0<\/td><td>\n                        <button class='speed-read-btn' data-id='2'>\u0110\u1ecdc nhanh<\/button>\n                        <button class='specific-search-btn' data-id='2'>T\u00ecm trong b\u00e0i<\/button>\n                        <\/td><\/tr>            <\/tbody>\n        <\/table>\n\n        <div id=\"speed-reading-wrapper\" style=\"display: none;\">\n            <div id=\"speed-reading-meta\" style=\"margin-bottom: 10px;\"><\/div>\n\n            <form id=\"specific-search-form\" style=\"margin-bottom: 10px; display: none;\">\n                <input type=\"text\" id=\"specific-search-input\" value=\"\" placeholder=\"T\u00ecm trong n\u1ed9i dung b\u00e0i n\u00e0y\" style=\"width: 300px;\">\n                <input type=\"submit\" value=\"T\u00ecm\" class=\"button\">\n            <\/form>\n\n            <div id=\"speed-reading-display\" style=\"padding: 20px; border: 12px solid #ddd; min-height: 100px;\">\n                <div id=\"speed-reading-content\"><\/div>\n            <\/div>\n\n            <div style=\"margin-top: 10px;\">\n                <button id=\"start-speed-reading\" style=\"margin-right: 10px;\">Speed Reading<\/button>\n                <button id=\"back-to-list\">Quay l\u1ea1i<\/button>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <style>\n        .speed-reading-table { width:100%; border-collapse:collapse; margin:20px 0; }\n        .speed-reading-table th, .speed-reading-table td { border:1px solid #ddd; padding:8px; text-align:left; }\n        #speed-reading-content { text-align:center; font-size:18px; }\n        #start-speed-reading, #back-to-list, .speed-read-btn, .specific-search-btn { background:#0073aa; color:white; border:none; padding:5px 10px; cursor:pointer; margin-right:5px; }\n        #back-to-list { background:#6c757d; }\n        .speed-search-form .button, #specific-search-form .button { background:#0073aa; color:white; border:none; padding:5px 10px; cursor:pointer; vertical-align:middle; }\n        .speed-search-form input[type=\"text\"], #specific-search-input { padding:5px; vertical-align:middle; }\n        .highlight { background-color: yellow; }\n    <\/style>\n\n    <script>\n    document.addEventListener('DOMContentLoaded', function() {\n        const readButtons = document.querySelectorAll('.speed-read-btn');\n        const searchButtons = document.querySelectorAll('.specific-search-btn');\n        let currentLines = [];\n        let currentIndex = 0;\n        let intervalId = null;\n        let currentPostId = null;\n        let currentSpeed = 1;\n        let isReadingMode = false;\n\n        readButtons.forEach(button => {\n            button.addEventListener('click', function() {\n                loadPost(this.getAttribute('data-id'), true);\n            });\n        });\n\n        searchButtons.forEach(button => {\n            button.addEventListener('click', function() {\n                loadPost(this.getAttribute('data-id'), false);\n            });\n        });\n\n        function loadPost(postId, readingMode) {\n            currentPostId = postId;\n            isReadingMode = readingMode;\n\n            fetch(`https:\/\/glowpax.top\/wp-admin\/admin-ajax.php?action=get_speed_post&id=${currentPostId}`, {\n                method: 'GET',\n                headers: { 'Content-Type': 'application\/json' }\n            })\n            .then(response => response.json())\n            .then(data => {\n                if (data.error) return;\n                document.getElementById('speed-reading-container').querySelector('table').style.display = 'none';\n                const wrapper = document.getElementById('speed-reading-wrapper');\n                wrapper.style.display = 'block';\n\n                currentSpeed = parseFloat(data.speed) || 1;\n                const views = data.views !== null && data.views !== undefined ? data.views : 0;\n                document.getElementById('speed-reading-meta').innerHTML = `\n                    Ng\u00e0y \u0111\u0103ng: ${data.created_at} |\n                    L\u01b0\u1ee3t xem: <span id=\"current-views\">${views}<\/span> |\n                    T\u1ed1c \u0111\u1ed9: ${data.speed_label}\n                `;\n\n                const specificSearchForm = document.getElementById('specific-search-form');\n                specificSearchForm.style.display = 'block';\n                document.getElementById('start-speed-reading').style.display = readingMode ? 'inline-block' : 'none';\n\n                currentLines = data.content.split('\\n').slice(data.start_line - 1, data.end_line).filter(line => line.trim() !== '');\n                document.getElementById('speed-reading-content').innerHTML = data.content.replace(\/\\n\/g, '<br>');\n            })\n            .catch(error => console.error('Fetch error:', error));\n        }\n\n        document.getElementById('specific-search-form').addEventListener('submit', function(e) {\n            e.preventDefault();\n            const searchTerm = document.getElementById('specific-search-input').value.trim();\n            if (!searchTerm || !currentPostId) return;\n\n            fetch(`https:\/\/glowpax.top\/wp-admin\/admin-ajax.php?action=get_speed_post&id=${currentPostId}`, {\n                method: 'GET',\n                headers: { 'Content-Type': 'application\/json' }\n            })\n            .then(response => response.json())\n            .then(data => {\n                if (data.error) return;\n                let content = data.content.replace(\/\\n\/g, '<br>');\n                if (searchTerm) {\n                    const regex = new RegExp(searchTerm, 'gi');\n                    content = content.replace(regex, match => `<span class=\"highlight\">${match}<\/span>`);\n                }\n                document.getElementById('speed-reading-content').innerHTML = content;\n            });\n        });\n\n        document.getElementById('start-speed-reading').addEventListener('click', function() {\n            if (!currentPostId || !currentLines.length) return;\n\n            if (intervalId) clearInterval(intervalId);\n            currentIndex = 0;\n            const contentDiv = document.getElementById('speed-reading-content');\n            const timePerLine = (5 \/ currentSpeed) * 1000;\n\n            intervalId = setInterval(() => {\n                if (currentIndex < currentLines.length) {\n                    contentDiv.innerHTML = currentLines[currentIndex];\n                    currentIndex++;\n                } else {\n                    clearInterval(intervalId);\n                    contentDiv.innerHTML = currentLines.join('<br>');\n                    updateViews();\n                }\n            }, timePerLine);\n        });\n\n        document.getElementById('back-to-list').addEventListener('click', function() {\n            document.getElementById('speed-reading-wrapper').style.display = 'none';\n            document.getElementById('speed-reading-container').querySelector('table').style.display = 'table';\n            if (intervalId) clearInterval(intervalId);\n            document.getElementById('specific-search-input').value = '';\n        });\n\n        function updateViews() {\n            if (!currentPostId) return;\n\n            fetch(`https:\/\/glowpax.top\/wp-admin\/admin-ajax.php?action=update_views&id=${currentPostId}`, {\n                method: 'POST',\n                headers: { 'Content-Type': 'application\/x-www-form-urlencoded' }\n            })\n            .then(response => response.json())\n            .then(data => {\n                if (data.success) {\n                    const newViews = data.views;\n                    document.getElementById('current-views').textContent = newViews;\n                    const viewCell = document.querySelector(`.views-count[data-id=\"${currentPostId}\"]`);\n                    if (viewCell) viewCell.textContent = newViews;\n                }\n            })\n            .catch(error => console.error('Error updating views:', error));\n        }\n    });\n    <\/script>\n    \n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Speed Reading<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-428","post","type-post","status-publish","format-standard","hentry","category-menu"],"_links":{"self":[{"href":"https:\/\/glowpax.top\/index.php?rest_route=\/wp\/v2\/posts\/428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/glowpax.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/glowpax.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/glowpax.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/glowpax.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=428"}],"version-history":[{"count":3,"href":"https:\/\/glowpax.top\/index.php?rest_route=\/wp\/v2\/posts\/428\/revisions"}],"predecessor-version":[{"id":443,"href":"https:\/\/glowpax.top\/index.php?rest_route=\/wp\/v2\/posts\/428\/revisions\/443"}],"wp:attachment":[{"href":"https:\/\/glowpax.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/glowpax.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/glowpax.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}