组会名单
为了确保每个人都能公平地参与每周的组会汇报,汇报的顺序将采用以下方式生成:以当年已度过的周数为种子,使用线性同余法生成随机数,然后将名单进行重新排列。名单会每周自动更新,生成名单的代码放在页面末尾。
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| <script> function seededRandom(seed) { const a = 1664525; const c = 1013904223; const m = 4294967296; seed = (a * seed + c) % m; return seed; } function shuffleArray(array) { const today = new Date(); let seed = Math.ceil((today - new Date(today.getFullYear(), 0, 1)) / (7 * 24 * 60 * 60 * 1000))+4; for (let i = 0; i < names.length; i++) { seed = seededRandom(seed); const j = Math.floor(seed/4294967296 * (i)); [array[i], array[j]] = [array[j], array[i]]; } } const names = [ "刘友琼", "马鹏飞", "安然", "王泰", "陈奇星", "薛静", "顾钦天", "李俊逸", "朱长江", "王璇", "魏艳红", "郭俊辉", "施丽红", "张秉正" ]; shuffleArray(names) for (let i = 1; i <= names.length; i++) { const today = new Date(); const weekNumber = Math.ceil((today - new Date(today.getFullYear(), 0, 1)) / (7 * 24 * 60 * 60 * 1000)); const randomName = names[i-1]; document.getElementById(`weeknumber`).textContent = `2024年第${weekNumber}周组会汇报顺序`; document.getElementById(`number${i}`).textContent = `${i}: ${randomName}`; } </script>
|