{"id":15406,"date":"2022-05-22T01:27:46","date_gmt":"2022-05-22T04:27:46","guid":{"rendered":"http:\/\/enjoyit.com.ar\/enjoyit\/?page_id=15406"},"modified":"2022-05-22T01:27:46","modified_gmt":"2022-05-22T04:27:46","slug":"dice","status":"publish","type":"page","link":"https:\/\/enjoyit.com.ar\/learning\/dice\/","title":{"rendered":""},"content":{"rendered":"\n<div class=\"dice__scene\">\n    <div id=\"dice__cube\" class=\"show-front\">\n        <div class=\"dice__side dice__side--front\"><\/div>\n    \t<div class=\"dice__side dice__side--back\"><\/div>\n    \t<div class=\"dice__side dice__side--right\"><\/div>\n    \t<div class=\"dice__side dice__side--left\"><\/div>\n    \t<div class=\"dice__side dice__side--top\"><\/div>\n\t<div class=\"dice__side dice__side--bottom\"><\/div>\n    <\/div>\n<\/div>\n<div style=\"text-align: right;\">\n    <button class=\"demo__button\" id=\"dice__btn\">Roll the dice<\/button>\n<\/div>\n\n<script src=\"https:\/\/code.jquery.com\/jquery-3.4.1.slim.min.js\" integrity=\"sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8=\" crossorigin=\"anonymous\"><\/script>\n<script>\n$(document).ready(function() {\n  var history = [];\n  var dice = $('#dice__cube');\n  var animationSpeed = dice.css('transition-duration').split(',')[0].replace(\/[^-\\d\\.]\/g, '') * 1000;\n\n    function randomizeNumber(low, high) {\n        var random = Math.floor((Math.random() * high) + low);\n        return random;\n    }\n\n    function rollDice(side) {\n        var currentClass = dice.attr('class').split(' ')[0];\n        var newClass = 'show-' + side;\n\n        dice.removeClass();\n\n    if (currentClass == newClass) {\n            dice.addClass(newClass + ' show-same');\n\n      \/\/ Remove animation class after animation has finished\n      setTimeout(function() {\n        dice.removeClass('show-same');\n      }, animationSpeed);\n        } else {\n      dice.addClass(newClass);\n    }\n\n    history.push(side);\n    }\n\n    function soundEffect() {\n        var audio = $(\"#dice__audio\")[0];\n        audio.pause();\n        audio.currentTime = 0;\n        audio.play();\n    }\n\n    $('#dice__btn').on('click ', function() {\n        var number = randomizeNumber(1, 6);\n\n        if (number == 1) { rollDice('front'); }\n        else if (number == 2) { rollDice('back'); }\n        else if (number == 3) { rollDice('right'); }\n        else if (number == 4) { rollDice('left'); }\n        else if (number == 5) { rollDice('top'); }\n        else if (number == 6) { rollDice('bottom'); }\n\n        \/\/soundEffect();\n    });\n});\n\n<\/script>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Roll the dice<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-15406","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/enjoyit.com.ar\/learning\/wp-json\/wp\/v2\/pages\/15406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyit.com.ar\/learning\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/enjoyit.com.ar\/learning\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyit.com.ar\/learning\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyit.com.ar\/learning\/wp-json\/wp\/v2\/comments?post=15406"}],"version-history":[{"count":17,"href":"https:\/\/enjoyit.com.ar\/learning\/wp-json\/wp\/v2\/pages\/15406\/revisions"}],"predecessor-version":[{"id":15439,"href":"https:\/\/enjoyit.com.ar\/learning\/wp-json\/wp\/v2\/pages\/15406\/revisions\/15439"}],"wp:attachment":[{"href":"https:\/\/enjoyit.com.ar\/learning\/wp-json\/wp\/v2\/media?parent=15406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}