Skip to content

Instantly share code, notes, and snippets.

@shogo-hta
Created October 20, 2010 13:03
Show Gist options
  • Select an option

  • Save shogo-hta/636371 to your computer and use it in GitHub Desktop.

Select an option

Save shogo-hta/636371 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>game</title>
<style>
#C{
position:relative;
}
.cell{
position:absolute;
background:#fff;
border:1px solid #999;
}
#O{
background:black;
color:white;
text-align:right;
position:fixed;
top:0px;
right:0px;
font-size:xx-large;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://cdn.socket.io/stable/socket.io.js"></script>
</head>
<body>
<div id="C"></div>
<div id="O">0</div>
<script>
/*
* リアルタイムWebハッカソン(http://atnd.org/events/8626)で書いたコードのクライアント側のコードです
*/
var c = document.getElementById('C');
var o = document.getElementById('O');
// マス目の数
var count = 5;
// マスの大きさ
var size = 50;
// 自機数
var own_limit = 5;
// ポイント
var mypoint = 0;
var cells = [];
var my_cells = [];
// 自機色
var color = 'blue';
// デフォルトカラー
var def_color = 'white';
var to_json = JSON.stringify;
// Socketに接続
var socket = new io.Socket('172.16.128.121',{port:3000});
socket.connect();
socket.on('message', function(data) {
//console.log(data);
data = JSON.parse(data);
var x = data.x;
var y = data.y;
var id = data.id;
if (data.color){
// 相手が埋めたとき、1ポイント
cells[y][x].flip(data.color, 1);
} else {
// 相手が空いたとき
cells[y][x].flip(def_color, 0);
}
// ラインが揃ってるかチェック
check_line();
});
function Cell(x, y){
var that = this;
this.x = x;
this.y = y;
var node = this.node = document.createElement('div');
node.className = 'cell';
node.addEventListener('click',function(){
// すでにチェック済みのセルなら終了
for(var i = 0, len = my_cells.length;i < len;i++){
if (my_cells[i] === that) return;
}
// セルを反転、自機は2ポイント
that.flip(color, 2);
// 自機を配信
socket.send(to_json({x:x,y:y,color:color}));
my_cells.push(that);
if(own_limit < my_cells.length){
// 自機の上限を超えていたら古いものを削除
var d = my_cells.shift();
d.flip(def_color);
socket.send(to_json({x:d.x,y:d.y}));
}
check_line();
},false);
node.style.left = x * size + 'px';
node.style.top = y * size + 'px';
node.style.width = node.style.height = size+'px';
c.appendChild(node);
}
Cell.prototype.flip = function(color, flipPoint){
this.node.style.backgroundColor = color;
this.fliped = flipPoint;
};
Cell.prototype.toString = function(){
return this.fliped || '';
};
Cell.prototype.valueOf = function(){
return this.fliped || 0;
};
function check_line(){
var ds;
for (var i = 0, ok;i < count;i++){
// toStringを定義しているので、joinしたときにflipedの値が連結される
var v = cells[i].join('');
var c = vcells[i].join('');
if (c.length === count || v.length === count){
if (c.length === count){
ok = c;
ds = vcells[i];
} else {
ok = v;
ds = cells[i];
}
if(ok){
// 一列揃った場合はセルをデフォルトに戻し、自機配列からそのセルを削除する
for(var k = 0;k < ds.length;k++){
var d = ds[k];
d.flip(def_color, 0);
var m = my_cells.length;
while(m--){
var co = my_cells[m];
if (co === d){
my_cells.splice(m, 1);
}
}
}
}
break;
}
}
if (ok){
// okにはポイントが入っているので、分割して各値を加算する
for (var i= 0, a=ok.split(''),l=a.length;i < l;i++){
mypoint += +a[i];
}
o.innerHTML = mypoint;
}
}
var vcells = [];
(function(){
for (var y = 0;y < count;y++){
var col = [];
for(var x = 0;x < count;x++){
col.push(new Cell(x, y));
}
cells.push(col);
}
for (var x = 0;x < count;x++){
var col = [];
for(var y = 0;y < count;y++){
col.push(cells[y][x]);
}
vcells.push(col);
}
})();
</script>
</body>
</html>
@slicemasternet01

Copy link
Copy Markdown

Gist is such a convenient way to share small scripts and reusable code without creating a full repo. I like how easy it is to update and fork snippets for quick experiments. When testing browser-based mini projects, games like Slice Master
are a fun example of how compact code can create engaging interactions.

@elanor1per

elanor1per commented May 22, 2026

Copy link
Copy Markdown

Wow, it looks great! I myself often look for new games, and it's interesting. I myself recently came across https://bestonlinecasinonz.showcasejewellers.co.nz/ where there are various collections with bonuses and the like. Maybe it will be useful for you to look at it to understand how to make money on it.

@bistnazar-commits

Copy link
Copy Markdown
<title>چالش استاد جدول تناوبی | ۱۵۰ سوال آرایش الکترونی و گروه</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
    body {
        background: linear-gradient(145deg, #1a3f2c 0%, #0e2a1c 100%);
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        font-family: 'Segoe UI', 'Tahoma', system-ui, sans-serif;
        padding: 20px;
    }

    .game-container {
        max-width: 800px;
        width: 100%;
        background: #2d2a1e;
        background-image: radial-gradient(circle at 10% 20%, rgba(80,70,40,0.4) 2%, transparent 2.5%);
        background-size: 28px 28px;
        border-radius: 60px 60px 40px 40px;
        box-shadow: 0 25px 40px rgba(0,0,0,0.5), inset 0 1px 3px rgba(255,255,200,0.2);
        padding: 20px 20px 35px;
        border-bottom: 8px solid #b87c2e;
    }

    .lab-header {
        background: #3e3a2b;
        border-radius: 50px;
        padding: 12px 20px;
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        flex-wrap: wrap;
        gap: 12px;
        margin-bottom: 25px;
        box-shadow: inset 0 1px 4px #1e1b0f, 0 5px 10px rgba(0,0,0,0.3);
        border: 1px solid #c9a458;
    }

    .score-box, .best-box, .level-box {
        background: #1f2a1b;
        padding: 6px 18px;
        border-radius: 60px;
        color: #f7ecc7;
        font-weight: bold;
        font-size: 1rem;
        box-shadow: inset 0 0 3px #769c6b, 0 2px 4px black;
    }

    .score-box span, .best-box span, .level-box span {
        color: #ffd966;
        font-size: 1.3rem;
        margin-right: 8px;
    }

    .question-card {
        background: #fef7e0;
        background-image: linear-gradient(to bottom, #fff9e8, #fcf0d5);
        border-radius: 48px;
        padding: 25px 18px;
        margin: 15px 0;
        border: 2px solid #e0b354;
        box-shadow: 0 12px 18px rgba(0,0,0,0.3), inset 0 1px 3px rgba(255,255,200,0.8);
        text-align: center;
    }

    .question-text {
        font-size: 1.4rem;
        font-weight: bold;
        color: #2c3a1f;
        line-height: 1.4;
        margin-bottom: 25px;
    }

    .options-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
        gap: 14px;
        margin: 15px 0 10px;
    }

    .option-btn {
        background: #2a3b2c;
        padding: 12px 6px;
        border-radius: 60px;
        font-size: 0.95rem;
        font-weight: bold;
        color: #faf3cf;
        text-align: center;
        cursor: pointer;
        transition: all 0.2s;
        border: 1px solid #9c8142;
        box-shadow: 0 5px 0 #141c0f;
    }

    .option-btn:hover {
        background: #3e5a38;
        transform: translateY(-2px);
        box-shadow: 0 7px 0 #141c0f;
    }

    .option-btn:active {
        transform: translateY(4px);
        box-shadow: 0 1px 0 #141c0f;
    }

    .disabled-opt {
        pointer-events: none;
        opacity: 0.6;
    }

    .feedback {
        margin: 20px auto 10px;
        padding: 10px;
        border-radius: 60px;
        font-size: 1.1rem;
        font-weight: bold;
        text-align: center;
        background: #1e2a1a;
        color: #e6dba0;
    }

    .next-area {
        display: flex;
        justify-content: center;
        margin: 15px 0 10px;
    }

    .next-btn {
        background: #e6b13e;
        border: none;
        font-size: 1.2rem;
        font-weight: bold;
        padding: 10px 35px;
        border-radius: 60px;
        color: #241f0d;
        cursor: pointer;
        box-shadow: 0 6px 0 #7a4f1a;
        transition: 0.07s linear;
    }

    .next-btn:active {
        transform: translateY(3px);
        box-shadow: 0 3px 0 #7a4f1a;
    }

    .restart-btn {
        background: #5f4c2b;
        color: #ffecb3;
        border: none;
        padding: 7px 22px;
        border-radius: 40px;
        font-size: 0.9rem;
        font-weight: bold;
        margin-top: 10px;
        cursor: pointer;
    }

    @media (max-width: 550px) {
        .question-text {
            font-size: 1rem;
        }
        .option-btn {
            font-size: 0.8rem;
            padding: 8px 4px;
        }
        .score-box, .best-box, .level-box {
            font-size: 0.8rem;
            padding: 3px 10px;
        }
    }

    footer {
        text-align: center;
        color: #a99567;
        margin-top: 20px;
        font-size: 0.7rem;
    }

    .progress-bar {
        width: 100%;
        background: #2e2a1a;
        border-radius: 20px;
        height: 10px;
        margin: 10px 0;
        overflow: hidden;
    }

    .progress-fill {
        width: 0%;
        height: 100%;
        background: #ffb347;
        border-radius: 20px;
        transition: width 0.3s;
    }
</style>
🧪 مرحله 1 / 15
⚗️ امتیاز 0
🏆 رکورد 0
<div class="progress-bar">
    <div class="progress-fill" id="progressFill"></div>
</div>

<div class="question-card">
    <div class="question-text" id="questionText">
        در حال بارگذاری...
    </div>
    <div class="options-grid" id="optionsContainer">
        <div class="option-btn">الف</div>
        <div class="option-btn">ب</div>
        <div class="option-btn">ج</div>
        <div class="option-btn">د</div>
    </div>
    <div class="feedback" id="feedbackMsg">
        ✨ پاسخ صحیح را انتخاب کنید ✨
    </div>
</div>

<div class="next-area">
    <button class="next-btn" id="nextBtn">▶ سوال بعدی</button>
</div>
<div style="display: flex; justify-content: center;">
    <button class="restart-btn" id="restartBtn">🔄 شروع مجدد</button>
</div>
<footer>⚛️ طراحی: دکتر رقیه پورقبادی | چالش استاد جدول تناوبی | ۱۵۰ سوال تخصصی</footer>
<script> // ============================================== // بانک ۱۵۰ سوال کامل بخش اول (آرایش الکترونی، گروه، ردیف) // ============================================== const allQuestions = [ // 1-10 { text: "اگر آرایش لایه ظرفیت اتمی 3s² 3p⁴ باشد، این عنصر در کدام گروه و کدام دوره قرار دارد؟", options: ["گروه ۱۶، دوره ۳", "گروه ۱۴، دوره ۴", "گروه ۴، دوره ۳", "گروه ۱۶، دوره ۲"], correct: 0, difficulty: 1 }, { text: "عنصری در دوره ۴ و گروه ۲ قرار دارد. آرایش الکترونی لایه ظرفیت آن چیست؟", options: ["4s¹", "4s²", "3d²", "4s² 3d²"], correct: 1, difficulty: 1 }, { text: "کدام آرایش الکترونی متعلق به یک عنصر بلوک p است؟", options: ["[Ne] 3s²", "[Ar] 4s² 3d⁵", "[He] 2s² 2p³", "[Xe] 6s²"], correct: 2, difficulty: 1 }, { text: "عنصری با آرایش الکترونی 1s² 2s² 2p⁶ 3s² 3p⁵ در کدام گروه قرار دارد؟", options: ["گروه ۱۷", "گروه ۱۵", "گروه ۷", "گروه ۵"], correct: 0, difficulty: 1 }, { text: "عنصر Mg (۱۲) در کدام دوره و کدام گروه قرار دارد؟", options: ["دوره ۲، گروه ۲", "دوره ۳، گروه ۲", "دوره ۳، گروه ۱۲", "دوره ۲، گروه ۱۲"], correct: 1, difficulty: 1 }, { text: "کدام یک از عناصر زیر در یک گروه قرار دارند؟", options: ["Na, Mg, Al", "F, Cl, Br", "C, N, O", "He, Ne, Ar"], correct: 1, difficulty: 1 }, { text: "عنصری که آخرین الکترون آن وارد اوربیتال 3p شود، در کدام بلوک قرار دارد؟", options: ["s", "p", "d", "f"], correct: 1, difficulty: 1 }, { text: "کدام عنصر دارای ۴ الکترون ظرفیت است؟", options: ["C", "Na", "Cl", "He"], correct: 0, difficulty: 1 }, { text: "عنصر Ca (۲۰) در کدام گروه و دوره است؟", options: ["دوره ۴، گروه ۲", "دوره ۳، گروه ۲", "دوره ۴، گروه ۲۰", "دوره ۴، گروه ۱۲"], correct: 0, difficulty: 1 }, { text: "یک عنصر بلوک d در دوره ۴ قرار دارد. حداکثر چند الکترون در لایه 3d آن می‌تواند باشد؟", options: ["۲", "۸", "۱۰", "۱۸"], correct: 2, difficulty: 1 }, // 11-20 { text: "اگر آرایش الکترونی به [Ar] 4s¹ ختم شود، این عنصر در کدام گروه است؟", options: ["گروه ۱", "گروه ۱۱", "گروه ۱ یا ۱۱", "گروه ۲"], correct: 2, difficulty: 1 }, { text: "عنصر P (۱۵) چندمین عنصر گروه خود است (از بالا)؟", options: ["دوم", "سوم", "چهارم", "پنجم"], correct: 1, difficulty: 1 }, { text: "کدام گزینه در مورد عنصر Fe (۲۶) درست است؟", options: ["در دوره ۶ قرار دارد", "در گروه ۸ قرار دارد", "یک عنصر بلوک p است", "آرایش آن به 4s² 3d⁵ ختم می‌شود"], correct: 1, difficulty: 1 }, { text: "عنصری با عدد اتمی ۳۴ در کدام گروه قرار دارد؟", options: ["۱۴", "۱۵", "۱۶", "۱۷"], correct: 2, difficulty: 1 }, { text: "کدام عنصر در دوره ۲ قرار ندارد؟", options: ["B", "O", "Ne", "Mg"], correct: 3, difficulty: 1 }, { text: "آرایش الکترونی [Ne] 3s² 3p¹ مربوط به کدام عنصر است؟", options: ["B", "Al", "Ga", "Mg"], correct: 1, difficulty: 1 }, { text: "عنصری در گروه ۲ و دوره ۵ قرار دارد. عدد اتمی آن چند است؟", options: ["۲۰", "۳۸", "۵۶", "۸۸"], correct: 1, difficulty: 1 }, { text: "کدام عنصر در بلوک d و گروه ۱۲ است؟", options: ["Zn", "Ca", "Mg", "Hg"], correct: 0, difficulty: 1 }, { text: "عنصر I (۵۳) در کدام دوره است؟", options: ["۴", "۵", "۶", "۷"], correct: 1, difficulty: 1 }, { text: "کدام آرایش مربوط به یک گاز نجیب است؟", options: ["1s²2s²2p⁵", "1s²2s²2p⁶3s²3p⁶", "1s²2s²2p⁶3s²", "1s²2s²2p³"], correct: 1, difficulty: 1 }, // 21-30 { text: "عنصری با ۳ لایه الکترونی و ۶ الکترون در لایه آخر، در کدام گروه است؟", options: ["۲", "۱۴", "۱۶", "۶"], correct: 2, difficulty: 1 }, { text: "عنصر Cr (۲۴) چند الکترون در لایه ظرفیت دارد؟", options: ["۱", "۲", "۶", "۷"], correct: 0, difficulty: 1 }, { text: "کدام یک در یک دوره با K (۱۹) قرار دارد؟", options: ["Na", "Ca", "Rb", "Be"], correct: 1, difficulty: 1 }, { text: "عنصری در گروه ۱۷ و دوره ۳ قرار دارد. عدد اتمی آن چقدر است؟", options: ["۹", "۱۷", "۳۵", "۵۳"], correct: 1, difficulty: 1 }, { text: "کدام عنصر بلوک f است؟", options: ["U", "Fe", "Al", "S"], correct: 0, difficulty: 1 }, { text: "آرایش [Xe] 6s² 4f⁷ مربوط به کدام عنصر است؟", options: ["گادولینیم", "یوروپیم", "تربیوم", "ساماریم"], correct: 1, difficulty: 1 }, { text: "عنصر Ag (۴۷) در کدام بلوک قرار دارد؟", options: ["s", "p", "d", "f"], correct: 2, difficulty: 1 }, { text: "کدام عنصر در گروه ۱ قرار دارد ولی در بلوک s نیست؟", options: ["H", "Li", "Na", "K"], correct: 0, difficulty: 1 }, { text: "اگر آخرین الکترون وارد 2p شود، عنصر در کدام دوره است؟", options: ["۱", "۲", "۳", "۴"], correct: 1, difficulty: 1 }, { text: "عنصر Ba (۵۶) در کدام گروه و کدام دوره است؟", options: ["گروه ۲، دوره ۶", "گروه ۱، دوره ۶", "گروه ۲، دوره ۵", "گروه ۱، دوره ۵"], correct: 0, difficulty: 1 }, // 31-40 (سطح 2) { text: "کدام عنصر به احتمال زیاد یک فلز قلیایی است؟", options: ["[Ne] 3s²", "[He] 2s¹", "[Ne] 3s²3p⁵", "[Ar] 4s²3d¹⁰"], correct: 1, difficulty: 2 }, { text: "عنصر Sr (۳۸) چند الکترون در لایه 4d دارد؟", options: ["۰", "۲", "۱۰", "۸"], correct: 0, difficulty: 2 }, { text: "یک عنصر با عدد اتمی ۸۰ در کدام گروه قرار دارد؟", options: ["۱۲", "۲", "۱۰", "۱۸"], correct: 0, difficulty: 2 }, { text: "کدام عنصر در بلوک d قرار ندارد؟", options: ["Fe", "Zn", "Cu", "Ca"], correct: 3, difficulty: 2 }, { text: "آرایش الکترونی [Ar] 4s² 3d¹⁰ 4p² مربوط به کدام عنصر است؟", options: ["C", "Si", "Ge", "Sn"], correct: 2, difficulty: 2 }, { text: "عنصری در دوره ۶ و گروه ۱۴ قرار دارد. نام آن چیست؟", options: ["C", "Si", "Ge", "Pb"], correct: 3, difficulty: 2 }, { text: "کدام عنصر یک شبه‌فلز است و در گروه ۱۴ قرار دارد؟", options: ["B", "Si", "Al", "P"], correct: 1, difficulty: 2 }, { text: "عنصر Kr (۳۶) در کدام بلوک است؟", options: ["s", "p", "d", "f"], correct: 1, difficulty: 2 }, { text: "یک عنصر بلوک d با ۵ الکترون در لایه 3d چند الکترون در لایه 4s دارد؟", options: ["۱", "۲", "۰", "۵"], correct: 1, difficulty: 2 }, { text: "عنصر Mo (۴۲) چند الکترون ظرفیت دارد؟", options: ["۱", "۲", "۶", "۵"], correct: 0, difficulty: 2 }, // 41-50 { text: "کدام یک از عناصر زیر در یک دوره با Se (۳۴) قرار دارد؟", options: ["S", "Br", "Te", "Ge"], correct: 1, difficulty: 2 }, { text: "عنصری با آرایش [Ar] 4s² 3d¹⁰ 4p⁵ در کدام گروه است؟", options: ["۱۷", "۱۵", "۷", "۵"], correct: 0, difficulty: 2 }, { text: "کدام عنصر در گروه ۱۸ قرار ندارد؟", options: ["He", "Ne", "Ar", "H"], correct: 3, difficulty: 2 }, { text: "عنصری در بلوک f، دوره ۷، چندمین ردیف جدول است؟", options: ["۶", "۷", "۸", "۵"], correct: 1, difficulty: 2 }, { text: "عنصر Cu (۲۹) در کدام گروه قرار دارد؟", options: ["۱", "۱۱", "۹", "۱۰"], correct: 1, difficulty: 2 }, { text: "کدام آرایش متعلق به یک عنصر گروه ۲ است؟", options: ["[Ne] 3s²", "[Ar] 4s²3d¹", "[He] 2s¹", "[Ne] 3s²3p²"], correct: 0, difficulty: 2 }, { text: "عنصری با ۵ الکترون در لایه 3d و ۲ الکترون در 4s، در کدام گروه است؟", options: ["۵", "۷", "۶", "۸"], correct: 1, difficulty: 2 }, { text: "عنصر Al در مقایسه با B در کدام ویژگی متفاوت است؟", options: ["گروه", "تعداد لایه‌ها", "تعداد الکترون‌های ظرفیت", "بلوک"], correct: 1, difficulty: 2 }, { text: "کدام عنصر در بلوک p و دوره ۲ است؟", options: ["Li", "Be", "O", "He"], correct: 2, difficulty: 2 }, { text: "عنصر K (۱۹) چند لایه الکترونی دارد؟", options: ["۲", "۳", "۴", "۵"], correct: 2, difficulty: 2 }, // 51-60 (سطح 3) { text: "عنصری در گروه ۱۶ و دوره ۴. نام آن چیست؟", options: ["O", "S", "Se", "Te"], correct: 2, difficulty: 3 }, { text: "کدام عنصر به دلیل آرایش ns² np⁶ واکنش‌پذیری بسیار کمی دارد؟", options: ["Na", "Cl", "Ne", "H"], correct: 2, difficulty: 3 }, { text: "عنصر U (۹۲) در کدام بلوک جدول قرار دارد؟", options: ["d", "p", "f", "s"], correct: 2, difficulty: 3 }, { text: "کدام عنصر در گروه ۱۷ و دوره ۵ است؟", options: ["F", "Cl", "Br", "I"], correct: 3, difficulty: 3 }, { text: "آرایش الکترونی 1s² مربوط به کدام عنصر است؟", options: ["H", "He", "Li", "Be"], correct: 1, difficulty: 3 }, { text: "عنصر Zn (۳۰) در کدام گروه قرار دارد؟", options: ["۲", "۱۰", "۱۱", "۱۲"], correct: 3, difficulty: 3 }, { text: "عنصری با ۳ لایه الکترونی و ۷ الکترون در لایه آخر، در کدام گروه است؟", options: ["۵", "۱۵", "۷", "۱۷"], correct: 3, difficulty: 3 }, { text: "کدام عنصر در دوره ۴ و بلوک d است؟", options: ["K", "Ca", "Sc", "Br"], correct: 2, difficulty: 3 }, { text: "عنصر Cs (۵۵) در کدام گروه و دوره است؟", options: ["۱، ۵", "۱، ۶", "۱، ۷", "۲، ۶"], correct: 1, difficulty: 3 }, { text: "کدام آرایش برای یک عنصر واسطه صحیح است؟", options: ["[Ne] 3s²", "[Ar] 4s²3d¹⁰4p¹", "[Ar] 4s²3d⁵", "[He] 2s²2p⁶"], correct: 2, difficulty: 3 }, // 61-70 { text: "عنصر V (۲۳) چند الکترون در لایه 3d دارد؟", options: ["۲", "۳", "۵", "۱۰"], correct: 1, difficulty: 3 }, { text: "عنصر گروه ۱، دوره ۳ چند پروتون دارد؟", options: ["۳", "۱۱", "۱۹", "۳۷"], correct: 1, difficulty: 3 }, { text: "کدام عنصر در یک گروه با اکسیژن قرار دارد؟", options: ["N", "F", "S", "C"], correct: 2, difficulty: 3 }, { text: "عنصری با آرایش 1s² 2s² 2p⁶ 3s¹ در کدام گروه است؟", options: ["۱", "۲", "۱۱", "۳"], correct: 0, difficulty: 3 }, { text: "عنصر Ti (۲۲) در کدام بلوک است؟", options: ["s", "p", "d", "f"], correct: 2, difficulty: 3 }, { text: "کدام عنصر در دوره ۲، گروه ۱۴ است؟", options: ["C", "Si", "Ge", "Sn"], correct: 0, difficulty: 3 }, { text: "عنصر Br با Cl در چه چیزی مشترک است؟", options: ["تعداد لایه‌ها", "تعداد الکترون‌های ظرفیت", "دوره", "بلوک"], correct: 1, difficulty: 3 }, { text: "عنصری در گروه ۱۳، دوره ۳. عدد اتمی آن؟", options: ["۵", "۱۳", "۳۱", "۴۹"], correct: 1, difficulty: 3 }, { text: "کدام عنصر بلوک d است و در گروه ۷ قرار دارد؟", options: ["Mn", "Tc", "Re", "همه موارد"], correct: 3, difficulty: 3 }, { text: "عنصر Ba (۵۶) چند لایه الکترونی اصلی دارد؟", options: ["۴", "۵", "۶", "۷"], correct: 2, difficulty: 3 }, // 71-80 { text: "کدام آرایش برای لایه ظرفیت یک عنصر گروه ۱۶ صحیح است؟", options: ["ns² np⁴", "ns² np⁵", "ns² np²", "ns² np⁶"], correct: 0, difficulty: 3 }, { text: "عنصر Sc (۲۱) در کدام دوره است؟", options: ["۳", "۴", "۵", "۲"], correct: 1, difficulty: 3 }, { text: "عنصری در بلوک d، گروه ۱۰، دوره ۵. نام آن؟", options: ["Ni", "Pd", "Pt", "Fe"], correct: 1, difficulty: 3 }, { text: "کدام عنصر دارای ۳ الکترون در لایه 2p است؟", options: ["B", "C", "N", "O"], correct: 2, difficulty: 3 }, { text: "عنصر Fe (۲۶) چند الکترون در لایه ظرفیت دارد؟", options: ["۲", "۸", "۳", "۶"], correct: 0, difficulty: 3 }, { text: "کدام عنصر در گروه ۱۸ و دوره ۱ است؟", options: ["He", "Ne", "Ar", "H"], correct: 0, difficulty: 3 }, { text: "یک عنصر با ۷ الکترون ظرفیت در کدام گروه است؟", options: ["۱۵", "۱۶", "۱۷", "۷"], correct: 2, difficulty: 3 }, { text: "عنصر Sn (۵۰) در کدام بلوک قرار دارد؟", options: ["s", "p", "d", "f"], correct: 1, difficulty: 3 }, { text: "عنصر Mg با کدام عنصر در یک دوره است؟", options: ["Be", "Ca", "Na", "Sr"], correct: 2, difficulty: 3 }, { text: "کدام آرایش متعلق به یک عنصر گروه ۳ است؟", options: ["[He]2s²2p¹", "[Ne]3s²3p¹", "[Ar]4s²3d¹", "همه موارد"], correct: 3, difficulty: 3 }, // 81-90 (سطح 4) { text: "عنصر Be (۴) چند الکترون در لایه 2s دارد؟", options: ["۱", "۲", "۳", "۴"], correct: 1, difficulty: 4 }, { text: "عنصری در دوره ۵، گروه ۲. عدد اتمی آن؟", options: ["۲۰", "۳۸", "۵۶", "۸۸"], correct: 1, difficulty: 4 }, { text: "کدام عنصر در گروه ۱۴ و دوره ۲ است؟", options: ["C", "Si", "Ge", "Pb"], correct: 0, difficulty: 4 }, { text: "آرایش [Xe] 6s² 4f¹⁴ 5d¹⁰ 6p⁵ برای کدام عنصر است؟", options: ["I", "At", "Br", "Cl"], correct: 1, difficulty: 4 }, { text: "عنصر Cr (۲۴) بر خلاف قاعده معمول، چه آرایشی دارد؟", options: ["4s²3d⁴", "4s¹3d⁵", "4s⁰3d⁶", "4s²3d⁵"], correct: 1, difficulty: 4 }, { text: "عنصری با ۴ لایه الکترونی و ۲ الکترون در لایه آخر، در کدام گروه است؟", options: ["۱", "۲", "۱۲", "۱۸"], correct: 1, difficulty: 4 }, { text: "کدام عناصر در بلوک f و گروه ۳ هستند؟", options: ["لانتانیدها", "اکتینیدها", "هر دو", "هیچکدام"], correct: 2, difficulty: 4 }, { text: "عنصر Nb (۴۱) در کدام دوره است؟", options: ["۴", "۵", "۶", "۷"], correct: 1, difficulty: 4 }, { text: "کدام عنصر در گروه ۱۷ است ولی در دوره ۳ قرار ندارد؟", options: ["F", "Cl", "Br", "At"], correct: 2, difficulty: 4 }, { text: "عنصر Cs (۵۵) به کدام خانواده تعلق دارد؟", options: ["فلز قلیایی", "فلز قلیایی خاکی", "هالوژن", "گاز نجیب"], correct: 0, difficulty: 4 }, // 91-100 { text: "کدام عنصر در بلوک p و گروه ۱۶ و دوره ۳ است؟", options: ["O", "S", "Se", "Te"], correct: 1, difficulty: 4 }, { text: "عنصر Ag (۴۷) چند الکترون در لایه 4d دارد؟", options: ["۱۰", "۹", "۸", "۷"], correct: 0, difficulty: 4 }, { text: "عنصر Cl در کدام گروه و بلوک است؟", options: ["۱۷، p", "۷، p", "۱۷، d", "۷، s"], correct: 0, difficulty: 4 }, { text: "کدام عناصر در یک دوره با As (۳۳) قرار دارند؟", options: ["P", "Sb", "Se", "Ge"], correct: 2, difficulty: 4 }, { text: "عنصری با آرایش لایه ظرفیت 5s² 5p³ در کدام گروه است؟", options: ["۱۳", "۱۴", "۱۵", "۱۶"], correct: 2, difficulty: 4 }, { text: "عنصر K با کدام عنصر خواص شیمیایی مشابه‌تری دارد؟", options: ["Na", "Ca", "Ar", "Cl"], correct: 0, difficulty: 4 }, { text: "کدام عنصر در گروه ۳ و دوره ۴ است؟", options: ["B", "Al", "Sc", "Y"], correct: 2, difficulty: 4 }, { text: "عنصر Ni (۲۸) در کدام بلوک قرار دارد؟", options: ["s", "p", "d", "f"], correct: 2, difficulty: 4 }, { text: "آرایش [Kr] 5s² 4d¹⁰ 5p⁴ متعلق به کدام عنصر است؟", options: ["S", "Se", "Te", "Po"], correct: 2, difficulty: 4 }, { text: "عنصری با عدد اتمی ۳۱ چند لایه الکترونی دارد؟", options: ["۳", "۴", "۵", "۶"], correct: 1, difficulty: 4 }, // 101-110 { text: "کدام عنصر در گروه ۲ و دوره ۷ قرار دارد؟", options: ["Ra", "Ba", "Sr", "Mg"], correct: 0, difficulty: 4 }, { text: "عنصر Mn (۲۵) چند الکترون در لایه 3d دارد؟", options: ["۳", "۵", "۷", "۱۰"], correct: 1, difficulty: 4 }, { text: "کدام عنصر در بلوک d، گروه ۱۱، دوره ۴ است؟", options: ["Cu", "Ag", "Au", "Rg"], correct: 0, difficulty: 4 }, { text: "یک عنصر با ۵ الکترون ظرفیت در کدام گروه است؟", options: ["۱۳", "۱۴", "۱۵", "۵"], correct: 2, difficulty: 4 }, { text: "عنصر Hg (۸۰) در کدام دوره است؟", options: ["۵", "۶", "۷", "۴"], correct: 1, difficulty: 4 }, { text: "کدام عنصر با Mg در یک گروه است؟", options: ["Be", "Ca", "Sr", "همه موارد"], correct: 3, difficulty: 4 }, { text: "آرایش [He] 2s² 2p⁶ متعلق به کدام عنصر است؟", options: ["Ne", "F⁻", "O²⁻", "همه موارد"], correct: 0, difficulty: 4 }, { text: "عنصر Mo (۴۲) بر خلاف قاعده چند الکترون در لایه 5s دارد؟", options: ["۰", "۱", "۲", "۳"], correct: 1, difficulty: 4 }, { text: "عنصری در گروه ۱۳ و دوره ۵. نام آن؟", options: ["B", "Al", "Ga", "In"], correct: 3, difficulty: 4 }, { text: "کدام عنصر در بلوک p است ولی گروه آن ۱۸ نیست؟", options: ["He", "Ne", "Ar", "Cl"], correct: 3, difficulty: 4 }, // 111-120 { text: "عنصر Ge (۳۲) در کدام گروه و بلوک است؟", options: ["۱۴، p", "۴، p", "۱۴، d", "۴، s"], correct: 0, difficulty: 4 }, { text: "عنصری با آرایش [Ar] 4s² 3d¹⁰ در کدام گروه است؟", options: ["۲", "۱۰", "۱۲", "۱۱"], correct: 2, difficulty: 4 }, { text: "کدام عنصر در دوره ۶ و گروه ۱ است؟", options: ["Li", "Na", "K", "Cs"], correct: 3, difficulty: 4 }, { text: "عنصر N (۷) چند الکترون در لایه 2p دارد؟", options: ["۱", "۲", "۳", "۴"], correct: 2, difficulty: 4 }, { text: "عنصر Rb (۳۷) در مقایسه با K در کدام ویژگی متفاوت است؟", options: ["گروه", "تعداد الکترون‌های ظرفیت", "دوره", "بلوک"], correct: 2, difficulty: 4 }, { text: "کدام عنصر یک فلز قلیایی خاکی در دوره ۴ است؟", options: ["Mg", "Ca", "Sr", "Ba"], correct: 1, difficulty: 4 }, { text: "عنصر Na در کدام بلوک است؟", options: ["s", "p", "d", "f"], correct: 0, difficulty: 4 }, { text: "عنصری در گروه ۱۶ و دوره ۶. عدد اتمی آن حدوداً؟", options: ["۳۴", "۵۲", "۸۴", "۱۶"], correct: 2, difficulty: 4 }, { text: "کدام عنصر آرایش لایه ظرفیت 3s² 3p⁶ دارد؟", options: ["Ne", "Ar", "Kr", "Xe"], correct: 1, difficulty: 4 }, { text: "عنصر Co (۲۷) در کدام گروه قرار دارد؟", options: ["۸", "۹", "۷", "۱۰"], correct: 1, difficulty: 4 }, // 121-130 { text: "کدام عنصر در گروه ۱۵ و دوره ۴ است؟", options: ["N", "P", "As", "Sb"], correct: 2, difficulty: 5 }, { text: "عنصر O با کدام گزینه در یک گروه است؟", options: ["S", "N", "F", "Ne"], correct: 0, difficulty: 5 }, { text: "آرایش [Ar] 4s² 3d⁵ برای کدام عنصر است؟", options: ["Cr", "Mn", "Fe", "Co"], correct: 1, difficulty: 5 }, { text: "عنصر Ra (۸۸) در کدام گروه و دوره است؟", options: ["۲، ۷", "۲، ۶", "۱، ۷", "۱، ۶"], correct: 0, difficulty: 5 }, { text: "کدام عنصر در بلوک f و دوره ۶ قرار دارد؟", options: ["La", "Ce", "Lu", "همه موارد"], correct: 1, difficulty: 5 }, { text: "یک عنصر با آرایش [Ne] 3s² 3p² در کدام گروه است؟", options: ["۱۳", "۱۴", "۱۵", "۱۶"], correct: 1, difficulty: 5 }, { text: "عنصر Se (۳۴) چند الکترون در لایه 4s دارد؟", options: ["۱", "۲", "۳", "۴"], correct: 1, difficulty: 5 }, { text: "کدام عنصر در دوره ۳ و گروه ۱۷ است؟", options: ["F", "Cl", "Br", "I"], correct: 1, difficulty: 5 }, { text: "عنصر In (۴۹) در کدام بلوک قرار دارد؟", options: ["s", "p", "d", "f"], correct: 1, difficulty: 5 }, { text: "کدام عنصر دارای آرایش 5s² 4d² است؟", options: ["Ti", "Zr", "Hf", "Rf"], correct: 1, difficulty: 5 }, // 131-140 { text: "عنصری در گروه ۱۱ و دوره ۵. نام آن؟", options: ["Cu", "Ag", "Au", "Rg"], correct: 1, difficulty: 5 }, { text: "عنصر H گاهی در کدام گروه قرار می‌گیرد؟", options: ["۱", "۱۷", "۱ و ۱۷", "۱۸"], correct: 2, difficulty: 5 }, { text: "آرایش [Kr] 5s² 4d¹⁰ 5p¹ برای کدام عنصر است؟", options: ["B", "Al", "Ga", "In"], correct: 3, difficulty: 5 }, { text: "عنصر Zr (۴۰) در کدام دوره و بلوک است؟", options: ["۴، d", "۵، d", "۴، p", "۵، p"], correct: 1, difficulty: 5 }, { text: "کدام عنصر در گروه ۲ و دوره ۴ است؟", options: ["Be", "Mg", "Ca", "Sr"], correct: 2, difficulty: 5 }, { text: "عنصر S (۱۶) چند الکترون در لایه 3s دارد؟", options: ["۱", "۲", "۳", "۴"], correct: 1, difficulty: 5 }, { text: "کدام عنصر در بلوک d و گروه ۶ است؟", options: ["Cr", "Mo", "W", "همه موارد"], correct: 3, difficulty: 5 }, { text: "عنصری در دوره ۵ و گروه ۱۲. عدد اتمی آن؟", options: ["۳۰", "۴۸", "۸۰", "۱۱۲"], correct: 1, difficulty: 5 }, { text: "آرایش [Xe] 6s² 4f⁷ برای کدام عنصر است؟", options: ["Eu", "Gd", "Tb", "Sm"], correct: 0, difficulty: 5 }, { text: "عنصر Ag (۴۷) چند الکترون در لایه 4d دارد؟", options: ["۹", "۱۰", "۸", "۷"], correct: 1, difficulty: 5 }, // 141-150 { text: "کدام عنصر در گروه ۱ و دوره ۲ است؟", options: ["H", "Li", "Na", "K"], correct: 1, difficulty: 5 }, { text: "عنصر As (۳۳) در کدام گروه است؟", options: ["۱۴", "۱۵", "۱۶", "۱۷"], correct: 1, difficulty: 5 }, { text: "کدام عنصر در یک دوره با Ca (۲۰) نیست؟", options: ["K", "Sc", "Sr", "Ar"], correct: 2, difficulty: 5 }, { text: "آرایش [Ne] 3s² 3p⁵ متعلق به کدام عنصر است؟", options: ["O", "F", "S", "Cl"], correct: 3, difficulty: 5 }, { text: "عنصر Ba (۵۶) در کدام بلوک است؟", options: ["s", "p", "d", "f"], correct: 0, difficulty: 5 }, { text: "عنصری در گروه ۱۴ و دوره ۶. نام آن؟", options: ["C", "Si", "Ge", "Pb"], correct: 3, difficulty: 5 }, { text: "کدام عنصر دارای ۲ الکترون در لایه 4s و ۳ الکترون در 3d است؟", options: ["Sc", "Ti", "V", "Cr"], correct: 2, difficulty: 5 }, { text: "عنصر Te (۵۲) در کدام گروه است؟", options: ["۱۴", "۱۵", "۱۶", "۱۷"], correct: 2, difficulty: 5 }, { text: "کدام عبارت در مورد عنصر Li (۳) درست است؟", options: ["گروه ۱، دوره ۳", "گروه ۱، دوره ۲", "گروه ۲، دوره ۳", "گروه ۲، دوره ۲"], correct: 1, difficulty: 5 }, { text: "عنصر Au (۷۹) در کدام بلوک و گروه است؟", options: ["d، گروه ۱۱", "s، گروه ۱", "p، گروه ۱۱", "d، گروه ۱۰"], correct: 0, difficulty: 5 } ]; // متغیرهای بازی let currentStage = 1; let currentScore = 0; let bestScore = localStorage.getItem("periodicBest150") ? parseInt(localStorage.getItem("periodicBest150")) : 0; let currentQuestionObj = null; let answered = false; let currentQuestionsList = []; let stageQuestionIndex = 0; let totalStages = 15; let questionsPerStage = 10; function getQuestionsForStage(stage) { let filtered = []; if (stage <= 5) { filtered = allQuestions.filter(q => q.difficulty === 1 || q.difficulty === 2); } else if (stage <= 10) { filtered = allQuestions.filter(q => q.difficulty === 2 || q.difficulty === 3); } else { filtered = allQuestions.filter(q => q.difficulty === 3 || q.difficulty === 4 || q.difficulty === 5); } if (filtered.length < questionsPerStage) filtered = allQuestions; for (let i = filtered.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [filtered[i], filtered[j]] = [filtered[j], filtered[i]]; } return filtered.slice(0, questionsPerStage); } function updateUI() { document.getElementById("levelDisplay").innerText = currentStage; document.getElementById("scoreDisplay").innerText = currentScore; document.getElementById("bestDisplay").innerText = bestScore; let progress = (stageQuestionIndex / questionsPerStage) * 100; document.getElementById("progressFill").style.width = progress + "%"; } function playCorrect() { try { let audioCtx = new (window.AudioContext || window.webkitAudioContext)(); let osc = audioCtx.createOscillator(); let gain = audioCtx.createGain(); osc.connect(gain); gain.connect(audioCtx.destination); osc.frequency.value = 880; gain.gain.value = 0.15; osc.start(); gain.gain.exponentialRampToValueAtTime(0.00001, audioCtx.currentTime + 0.4); osc.stop(audioCtx.currentTime + 0.35); } catch(e) {} } function playWrong() { try { let audioCtx = new (window.AudioContext || window.webkitAudioContext)(); let osc = audioCtx.createOscillator(); let gain = audioCtx.createGain(); osc.connect(gain); gain.connect(audioCtx.destination); osc.frequency.value = 440; gain.gain.value = 0.15; osc.start(); gain.gain.exponentialRampToValueAtTime(0.00001, audioCtx.currentTime + 0.4); osc.stop(audioCtx.currentTime + 0.35); } catch(e) {} } function playCheer() { try { let audioCtx = new (window.AudioContext || window.webkitAudioContext)(); let osc1 = audioCtx.createOscillator(); let osc2 = audioCtx.createOscillator(); let gain = audioCtx.createGain(); osc1.connect(gain); osc2.connect(gain); gain.connect(audioCtx.destination); osc1.frequency.value = 523.25; osc2.frequency.value = 659.25; gain.gain.value = 0.12; osc1.start(); osc2.start(); gain.gain.exponentialRampToValueAtTime(0.00001, audioCtx.currentTime + 1); osc1.stop(audioCtx.currentTime + 0.9); osc2.stop(audioCtx.currentTime + 0.9); } catch(e) {} } function loadNextQuestion() { if (stageQuestionIndex >= currentQuestionsList.length) { if (currentStage < totalStages) { playCheer(); document.getElementById("feedbackMsg").innerHTML = "🎉 تبریک! مرحله " + currentStage + " را پشت سر گذاشتی! 🎉"; currentStage++; stageQuestionIndex = 0; currentQuestionsList = getQuestionsForStage(currentStage); updateUI(); loadNextQuestion(); return; } else { document.getElementById("feedbackMsg").innerHTML = "🏆 قهرمان! بر تمام رازهای جدول تناوبی مسلط شدی! 🏆"; document.querySelector(".next-btn").style.display = "none"; playCheer(); return; } } answered = false; currentQuestionObj = currentQuestionsList[stageQuestionIndex]; document.getElementById("questionText").innerHTML = currentQuestionObj.text; let optsDiv = document.getElementById("optionsContainer"); optsDiv.innerHTML = ""; currentQuestionObj.options.forEach((opt, idx) => { let btn = document.createElement("div"); btn.className = "option-btn"; btn.innerText = opt; btn.onclick = () => checkAnswer(idx); optsDiv.appendChild(btn); }); document.getElementById("feedbackMsg").innerHTML = "🧪 گزینه صحیح را انتخاب کنید..."; document.querySelectorAll(".option-btn").forEach(btn => btn.classList.remove("disabled-opt")); updateUI(); } function checkAnswer(selectedIdx) { if (answered) return; answered = true; let isCorrect = (selectedIdx === currentQuestionObj.correct); if (isCorrect) { currentScore += 10; playCorrect(); document.getElementById("feedbackMsg").innerHTML = "✅ پاسخ صحیح! +۱۰ امتیاز ✅"; if (currentScore > bestScore) { bestScore = currentScore; localStorage.setItem("periodicBest150", bestScore); updateUI(); } } else { playWrong(); let correctLetter = String.fromCharCode(65 + currentQuestionObj.correct); document.getElementById("feedbackMsg").innerHTML = `❌ پاسخ نادرست! پاسخ صحیح: گزینه ${correctLetter} : ${currentQuestionObj.options[currentQuestionObj.correct]} ❌`; } updateUI(); document.querySelectorAll(".option-btn").forEach(btn => btn.classList.add("disabled-opt")); stageQuestionIndex++; updateUI(); } function nextQuestionHandler() { if (!answered && stageQuestionIndex < currentQuestionsList.length) { document.getElementById("feedbackMsg").innerHTML = "⚠️ لطفا ابتدا یک گزینه را انتخاب کنید!"; return; } loadNextQuestion(); } function restartGame() { currentStage = 1; currentScore = 0; stageQuestionIndex = 0; answered = false; currentQuestionsList = getQuestionsForStage(1); updateUI(); loadNextQuestion(); document.querySelector(".next-btn").style.display = "block"; document.getElementById("feedbackMsg").innerHTML = "🔄 بازی از نو شروع شد! موفق باشی ⚛️"; playCheer(); } function initGame() { document.getElementById("bestDisplay").innerText = bestScore; currentQuestionsList = getQuestionsForStage(1); updateUI(); loadNextQuestion(); document.getElementById("nextBtn").onclick = nextQuestionHandler; document.getElementById("restartBtn").onclick = restartGame; } initGame(); </script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment