Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>尾牙抽獎範例</title>
</head>
<body>
    亂數種子=<input value="12345" /> <input type="button" value="抽獎" />
   <script src="https://cdnjs.cloudflare.com/ajax/libs/seedrandom/2.4.2/seedrandom.js"></script>
  <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.4.js"></script>
  <script>
    var candidates = 
        "1.Jeffrey,2.Darkthread,3.球證,4.旁證,5.主辦,6.協辦,7.全都是我的人".split(',');
    $(":button").click(function() {
      Math.seedrandom($(":text").val());
      var list = $.map(candidates, function(n) {
                     return { name: n, rand: Math.random() }
                 });
      list.sort(function(a, b) { return a.rand - b.rand; });
      alert("得獎的是:" + list[0].name);
    });
  </script> 
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
darkthreadpro
0viewers