{"id":383,"date":"2025-12-01T12:52:48","date_gmt":"2025-12-01T05:52:48","guid":{"rendered":"http:\/\/www.nsh.ac.th\/?p=383"},"modified":"2025-12-01T13:37:39","modified_gmt":"2025-12-01T06:37:39","slug":"game-%e0%b8%9b-1","status":"publish","type":"post","link":"http:\/\/www.nsh.ac.th\/?p=383","title":{"rendered":"Game \u0e1b.1"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"th\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>\u0e40\u0e01\u0e21\u0e40\u0e15\u0e34\u0e21\u0e04\u0e33\u0e28\u0e31\u0e1e\u0e17\u0e4c \u0e1b.2<\/title>\n    <link href=\"https:\/\/fonts.googleapis.com\/css2?family=Sarabun:wght@400;700&#038;display=swap\" rel=\"stylesheet\">\n    <style>\n        body {\n            font-family: 'Sarabun', sans-serif;\n            background-color: #f0f8ff;\n            display: flex;\n            justify-content: center;\n            align-items: center;\n            min-height: 100vh;\n            margin: 0;\n        }\n\n        .container {\n            background-color: white;\n            padding: 30px;\n            border-radius: 20px;\n            box-shadow: 0 10px 25px rgba(0,0,0,0.1);\n            width: 90%;\n            max-width: 500px;\n            text-align: center;\n            border: 5px solid #FFD700;\n            position: relative;\n            overflow: hidden;\n        }\n\n        h1 {\n            color: #ff6f61;\n            margin-bottom: 20px;\n            font-size: 1.8rem;\n        }\n\n        .score-board {\n            font-size: 1.2rem;\n            color: #555;\n            margin-bottom: 20px;\n            background: #eee;\n            padding: 5px 15px;\n            border-radius: 50px;\n            display: inline-block;\n        }\n\n        .question-box {\n            font-size: 2rem;\n            font-weight: bold;\n            color: #333;\n            margin-bottom: 30px;\n            padding: 30px 20px;\n            background-color: #e6f7ff;\n            border-radius: 15px;\n            border: 2px dashed #87CEEB;\n        }\n\n        .options-grid {\n            display: grid;\n            grid-template-columns: 1fr 1fr;\n            gap: 15px;\n        }\n\n        .option-btn {\n            background-color: #fff;\n            border: 2px solid #ddd;\n            border-radius: 10px;\n            padding: 15px;\n            font-size: 1.5rem;\n            font-family: 'Sarabun', sans-serif;\n            cursor: pointer;\n            transition: all 0.2s;\n            color: #555;\n        }\n\n        .option-btn:hover:not(:disabled) {\n            background-color: #fff9c4;\n            transform: scale(1.05);\n            border-color: #FFD700;\n        }\n\n        .option-btn.correct {\n            background-color: #4CAF50 !important;\n            color: white;\n            border-color: #4CAF50;\n        }\n\n        .option-btn.wrong {\n            background-color: #f44336 !important;\n            color: white;\n            border-color: #f44336;\n        }\n\n        .btn-control {\n            margin-top: 25px;\n            padding: 12px 30px;\n            font-size: 1.2rem;\n            background-color: #2196F3;\n            color: white;\n            border: none;\n            border-radius: 50px;\n            cursor: pointer;\n            font-family: 'Sarabun', sans-serif;\n            box-shadow: 0 4px 6px rgba(0,0,0,0.1);\n        }\n\n        .btn-control:hover {\n            background-color: #1976D2;\n        }\n\n        .hidden {\n            display: none;\n        }\n\n        #result-screen h2 {\n            font-size: 3rem;\n            color: #FFD700;\n        }\n        \n        #final-score {\n            font-size: 1.5rem;\n            color: #333;\n        }\n    <\/style>\n<\/head>\n<body>\n\n    <div class=\"container\">\n        <div id=\"game-screen\">\n            <h1>\u0e40\u0e01\u0e21\u0e40\u0e15\u0e34\u0e21\u0e04\u0e33\u0e28\u0e31\u0e1e\u0e17\u0e4c<\/h1>\n            <div class=\"score-board\">\u0e04\u0e30\u0e41\u0e19\u0e19: <span id=\"score\">0<\/span><\/div>\n            \n            <div class=\"question-box\" id=\"question-text\">\n                <\/div>\n\n            <div class=\"options-grid\" id=\"options-container\">\n                <\/div>\n\n            <button id=\"next-btn\" class=\"btn-control hidden\" onclick=\"nextQuestion()\">\u0e02\u0e49\u0e2d\u0e16\u0e31\u0e14\u0e44\u0e1b \u2794<\/button>\n        <\/div>\n\n        <div id=\"result-screen\" class=\"hidden\">\n            <h1>\u0e08\u0e1a\u0e40\u0e01\u0e21\u0e41\u0e25\u0e49\u0e27\u0e08\u0e49\u0e32!<\/h1>\n            <h2>\ud83c\udf89<\/h2>\n            <p id=\"final-score\">\u0e44\u0e14\u0e49\u0e04\u0e30\u0e41\u0e19\u0e19\u0e23\u0e27\u0e21: 0\/0<\/p>\n            <button class=\"btn-control\" onclick=\"restartGame()\">\u0e40\u0e25\u0e48\u0e19\u0e43\u0e2b\u0e21\u0e48\u0e2d\u0e35\u0e01\u0e04\u0e23\u0e31\u0e49\u0e07 \u21ba<\/button>\n        <\/div>\n    <\/div>\n\n    <script>\n        \/\/ --- \u0e2a\u0e48\u0e27\u0e19\u0e41\u0e01\u0e49\u0e44\u0e02\u0e04\u0e33\u0e16\u0e32\u0e21 ---\n        const questions = [\n            {\n                text: \"\u0e1a\u0e32\u0e14_______\",   \/\/ \u0e42\u0e08\u0e17\u0e22\u0e4c\u0e02\u0e49\u0e2d 1\n                correct: \"\u0e40\u0e08\u0e47\u0e1a\",      \/\/ \u0e04\u0e33\u0e15\u0e2d\u0e1a\u0e17\u0e35\u0e48\u0e16\u0e39\u0e01\n                options: [\"\u0e1b\u0e48\u0e27\u0e22\", \"\u0e40\u0e08\u0e47\u0e1a\", \"\u0e41\u0e1c\u0e25\", \"\u0e15\u0e32\u0e22\"] \/\/ \u0e15\u0e31\u0e27\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14\n            },\n            {\n                text: \"\u0e19\u0e49\u0e33_______\",    \/\/ \u0e42\u0e08\u0e17\u0e22\u0e4c\u0e02\u0e49\u0e2d 2\n                correct: \"\u0e40\u0e14\u0e37\u0e2d\u0e14\",     \/\/ \u0e04\u0e33\u0e15\u0e2d\u0e1a\u0e17\u0e35\u0e48\u0e16\u0e39\u0e01\n                options: [\"\u0e40\u0e22\u0e47\u0e19\", \"\u0e44\u0e2b\u0e25\", \"\u0e40\u0e14\u0e37\u0e2d\u0e14\", \"\u0e41\u0e02\u0e47\u0e07\"] \/\/ \u0e15\u0e31\u0e27\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14\n            },\n            {\n                text: \"\u0e42\u0e23\u0e07_______\",\n                correct: \"\u0e40\u0e23\u0e35\u0e22\u0e19\",\n                options: [\"\u0e1a\u0e32\u0e25\", \"\u0e40\u0e23\u0e35\u0e22\u0e19\", \"\u0e07\u0e32\u0e19\", \"\u0e41\u0e23\u0e21\"]\n            },\n            {\n                text: \"\u0e01\u0e23\u0e30_______\",\n                correct: \"\u0e15\u0e48\u0e32\u0e22\",\n                options: [\"\u0e23\u0e2d\u0e01\", \"\u0e15\u0e48\u0e32\u0e22\", \"\u0e40\u0e1b\u0e4b\u0e32\", \"\u0e14\u0e32\u0e29\"]\n            },\n            {\n                text: \"\u0e04\u0e38\u0e13_______\",\n                correct: \"\u0e04\u0e23\u0e39\",\n                options: [\"\u0e2b\u0e21\u0e2d\", \"\u0e1b\u0e39\u0e48\", \"\u0e04\u0e23\u0e39\", \"\u0e1e\u0e48\u0e2d\"]\n            }\n        ];\n        \/\/ ----------------------\n\n        let currentQuestionIndex = 0;\n        let score = 0;\n\n        const questionText = document.getElementById('question-text');\n        const optionsContainer = document.getElementById('options-container');\n        const scoreDisplay = document.getElementById('score');\n        const nextBtn = document.getElementById('next-btn');\n        const gameScreen = document.getElementById('game-screen');\n        const resultScreen = document.getElementById('result-screen');\n        const finalScoreText = document.getElementById('final-score');\n\n        startGame();\n\n        function startGame() {\n            currentQuestionIndex = 0;\n            score = 0;\n            scoreDisplay.textContent = score;\n            gameScreen.classList.remove('hidden');\n            resultScreen.classList.add('hidden');\n            showQuestion();\n        }\n\n        function showQuestion() {\n            resetState();\n            let currentQuestion = questions[currentQuestionIndex];\n            questionText.textContent = currentQuestion.text;\n\n            \/\/ \u0e2a\u0e25\u0e31\u0e1a\u0e15\u0e33\u0e41\u0e2b\u0e19\u0e48\u0e07\u0e15\u0e31\u0e27\u0e40\u0e25\u0e37\u0e2d\u0e01 (Shuffle) \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e44\u0e21\u0e48\u0e43\u0e2b\u0e49\u0e04\u0e33\u0e15\u0e2d\u0e1a\u0e2d\u0e22\u0e39\u0e48\u0e17\u0e35\u0e48\u0e40\u0e14\u0e34\u0e21\u0e40\u0e2a\u0e21\u0e2d\n            \/\/ (\u0e16\u0e49\u0e32\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e43\u0e2b\u0e49\u0e15\u0e31\u0e27\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e2d\u0e22\u0e39\u0e48\u0e17\u0e35\u0e48\u0e40\u0e14\u0e34\u0e21\u0e15\u0e25\u0e2d\u0e14 \u0e25\u0e1a\u0e1a\u0e23\u0e23\u0e17\u0e31\u0e14 shuffle \u0e19\u0e35\u0e49\u0e2d\u0e2d\u0e01\u0e44\u0e14\u0e49\u0e04\u0e23\u0e31\u0e1a)\n            const shuffledOptions = currentQuestion.options.sort(() => Math.random() - 0.5);\n\n            shuffledOptions.forEach(option => {\n                const button = document.createElement('button');\n                button.textContent = option;\n                button.classList.add('option-btn');\n                button.addEventListener('click', () => selectAnswer(button, currentQuestion.correct));\n                optionsContainer.appendChild(button);\n            });\n        }\n\n        function resetState() {\n            nextBtn.classList.add('hidden');\n            while (optionsContainer.firstChild) {\n                optionsContainer.removeChild(optionsContainer.firstChild);\n            }\n        }\n\n        function selectAnswer(selectedBtn, correctAnswer) {\n            const selectedWord = selectedBtn.textContent;\n            const buttons = optionsContainer.querySelectorAll('.option-btn');\n\n            if (selectedWord === correctAnswer) {\n                selectedBtn.classList.add('correct');\n                score++;\n                scoreDisplay.textContent = score;\n            } else {\n                selectedBtn.classList.add('wrong');\n                buttons.forEach(btn => {\n                    if (btn.textContent === correctAnswer) {\n                        btn.classList.add('correct');\n                    }\n                });\n            }\n\n            buttons.forEach(btn => btn.disabled = true);\n            nextBtn.classList.remove('hidden');\n        }\n\n        function nextQuestion() {\n            currentQuestionIndex++;\n            if (currentQuestionIndex < questions.length) {\n                showQuestion();\n            } else {\n                showResult();\n            }\n        }\n\n        function showResult() {\n            gameScreen.classList.add('hidden');\n            resultScreen.classList.remove('hidden');\n            finalScoreText.textContent = `\u0e19\u0e49\u0e2d\u0e07\u0e17\u0e33\u0e44\u0e14\u0e49: ${score} \u0e08\u0e32\u0e01 ${questions.length} \u0e04\u0e30\u0e41\u0e19\u0e19`;\n        }\n        \n        function restartGame() {\n            startGame();\n        }\n    <\/script>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>\u0e40\u0e01\u0e21\u0e40\u0e15\u0e34\u0e21\u0e04\u0e33\u0e28\u0e31\u0e1e\u0e17\u0e4c \u0e1b.2 \u0e40\u0e01\u0e21\u0e40\u0e15\u0e34\u0e21\u0e04\u0e33\u0e28\u0e31\u0e1e\u0e17\u0e4c \u0e04\u0e30\u0e41\u0e19\u0e19: 0 \u0e02\u0e49\u0e2d\u0e16\u0e31\u0e14\u0e44\u0e1b \u2794 \u0e08\u0e1a\u0e40\u0e01\u0e21\u0e41\u0e25\u0e49\u0e27\u0e08\u0e49\u0e32! \ud83c\udf89 \u0e44\u0e14\u0e49\u0e04\u0e30\u0e41\u0e19\u0e19\u0e23\u0e27\u0e21: 0\/0 \u0e40\u0e25\u0e48\u0e19\u0e43\u0e2b\u0e21\u0e48\u0e2d\u0e35\u0e01\u0e04\u0e23\u0e31\u0e49\u0e07 \u21ba<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-383","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.nsh.ac.th\/index.php?rest_route=\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.nsh.ac.th\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nsh.ac.th\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nsh.ac.th\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nsh.ac.th\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=383"}],"version-history":[{"count":12,"href":"http:\/\/www.nsh.ac.th\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":403,"href":"http:\/\/www.nsh.ac.th\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions\/403"}],"wp:attachment":[{"href":"http:\/\/www.nsh.ac.th\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nsh.ac.th\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nsh.ac.th\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}