daily pastebin goal
54%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var pieces = [];
  2.  var puzzleNode;
  3.  var nextNode;
  4. function sramblePieces() {
  5.  pieces = document.getElementById('puzzleContainer').getChildNodes();
  6.  pieces.sort( function() {return 0.5 - Math.random()} );
  7.  puzzleNode = document.getElementById('puzzleContainer').getFirstChild().getId();
  8.  for(i=0; i < pieces.length; i++) {
  9.    oldNode = document.getElementById(puzzleNode);
  10.    newNode = document.getElementById(pieces[i].getId());
  11.    document.getElementById('puzzleContainer').replaceChild(oldNode, newNode);
  12.    puzzleNode = document.getElementById(puzzleNode).getNextSibling().getId();
  13.  }
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top