JSFiddle - React, Tailwind, and code Playground

by muthusamy

HTML

<head>      
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  <script type="text/javascript" src="http://code.jquery.com/ui/1.8.21/jquery-ui.min.js"></script>  
</head>

<body> 
  <div class="maincontain">
  <div class="container">
  <img src="http://designbeep.designbeep.netdna-cdn.com/wp-content/uploads/2010/11/1.collection-of-character-mascot-illustrator-tutorial.jpg">
  
     <ul style="display:none;" id="wordlist">
     
        <li data-word="mum" data-audio="http://www.wav-sounds.com/cartoon/porkypig2.wav" data-pic="http://www.clker.com/cliparts/5/e/7/f/1195445022768793934Gerald_G_Lady_Face_Cartoon_1.svg.med.png"></li>
         
        <li data-word="cat" data-audio="http://www.wav-sounds.com/cartoon/bugsbunny2.wav" data-pic="http://www.clker.com/cliparts/c/9/9/5/119543969236915703Gerald_G_Cartoon_Cat_Face.svg.med.png"></li>
      
        <li data-word="bear" data-audio="http://www.wav-sounds.com/cartoon/daffyduck1.wav" data-pic="http://www.clker.com/cliparts/a/2/c/0/1195440948271207911zeimusu_spotty_dog.svg.med.png"></li>
      
        <li data-word="bug" data-audio="http://www.wav-sounds.com/cartoon/daffyduck2.wav" data-pic="http://www.clker.com/cliparts/4/b/4/2/1216180545881311858laurent_scarabe.svg.med.png"></li>
      
<li data-word="rat" data-audio="http://www.wav-sounds.com/cartoon/bugsbunny1.wav" data-pic="http://www.clker.com/cliparts/C/j/X/e/k/D/mouse-md.png"></li>
        
        <li data-word="father" data-audio="http://www.wav-sounds.com/cartoon/porkypig1.wav" data-pic="http://www.clker.com/cliparts/3/a/6/6/119544474191128182Gerald_G_Man_Face_6_-_World_Label.svg.med.png"></li>
      
      </ul>
  <div class="squares">
      
            <div id="drag1" class="drag ui-widget-content box-style2" tabindex="0" data-letter="a">
            <p>a</p>
            </div>    
            
            
            <div id="drag2" class="drag ui-widget-content box-style" tabindex="0"...

CSS

.drag {

    display:block;
    height:61px;
    line-height:25px;
    width:61px;
    text-align: center;
    background:#ddd;    
    float:left;  
    -webkit-transition: -webkit-transform 0.1s ease-in;

 
}

.drag:hover {

    -webkit-box-shadow: inset 20px 0px 10px 5px darkblue;
    box-shadow: inset 0px 0px 10px 5px darkblue;      
}

table {
    clear:both;
    line-height:25px;
     text-align:center;    

}

.drop {
   
    height:61.5px;
    width:61.5px;
    cursor: move;
    -moz-transition: all 1s ease-out;
    -webkit-transition: all 1s ease-out;
    opacity: 1;
}
.maincontain {
    
    width: 868px;
    border: solid 8pt lightgreen;
    -webkit-box-shadow: 4px 4px 4px green;
    -moz-box-shadow: 4px 4px 4px green;
    box-shadow: 4px 4px 4px green;  
    background: #cc66ff;       
}

.container {
       
    height: 373px;
    position: relative;
    width: 1000px;       
}

.container > img {
        
    height: 373px;
    position: absolute;
    width: 373px;
    cursor: move;
                  
}

table {
    margin: 0;
    padding: 0;
    line-height: 56px;
               
}
 
article, aside, figure, footer, header, hgroup,
menu, nav, section {
    
    display: block;    
}
  
table td {
    
    border: 1px solid white;
    border-style: dashed;
    position: relative;
    vertical-align: top;
    cursor: move;
    min-height:60px;
    max-width:60.3px;
    min-width:60.3px;
    max-height:60px;
    background: #cc66ff;
    float: left;         
}
    
table td div {
         
    position: absolute;
    width: 59.5px;
    height: 59.5px;
    cursor: move;
    opacity: 1;
}

.tablestyle{
  
    position: absolute;
    color: transparent;
    font-family: arial;
    font-size: 35pt;
    text-align: center; 
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

      
}


.spellword {
 
    -webkit-box-shadow: inset 0px 0px...

JavaScript

var listOfWords = [];
var rndWord = [];
var counter = 0;
var ul = document.getElementById("wordlist");
var i;

for (i = 0; i < ul.children.length; ++i) {

    listOfWords.push({
        "name": ul.children[i].getAttribute("data-word"),
        "pic": ul.children[i].getAttribute("data-pic"),
        "audio": ul.children[i].getAttribute("data-audio")
    });
}

var chosenWords = [];
var copylist = listOfWords.slice();

for (var x = 0; x < ul.children.length; x++) {
    var rand = Math.floor(Math.random() * (copylist.length));
    chosenWords.push(copylist[rand].name);
    copylist.splice(rand, 1);
    if (chosenWords.length < 12) {
        chosenWords.push('   ');
    }

}

var shuffledWords = [];
shuffledWords = chosenWords.sort(function() {
    return 0.5 - Math.random()
});


var unusedShuffledWords = shuffledWords.slice();

function getXSpaces(numOfSpaces) {
    var answer = "";
    for (var i = 0; i < numOfSpaces; i++) {
        answer += " ";
    }
    return answer;
}


function getWordToFitIn(spaceAvail, wordlist) {
    var foundIndex = -1;

    var answer = _.find(wordlist, function(word, index) {
        if (word.length <= spaceAvail) {
            foundIndex = index;
            return true;
        }
    });


    if (foundIndex == -1) {
        answer = getXSpaces(spaceAvail);

        _.find(wordlist, function(word, index) {
            if (word[0] == " ") {
                foundIndex = index;
                return true;
            }
        });
    }


    if (foundIndex != -1) {
        wordlist.splice(foundIndex, 1);
    }
    return answer;

}

var guesses = {};
var tbl = document.createElement('table');
tbl.className = 'tablestyle';
var wordsPerRow = 2;
var numRows = 6;
var numLetters = 6;

for (var i = 0; i < numRows; i++) {
    if (unusedShuffledWords.length == 0) {
        break;
    }
    var row = document.createElement('tr');
    var spaceAvailInRow = numLetters;
    while (spaceAvailInRow) {
        var word =...