Advertisement
kirtan13497

wheel Spinning

Sep 28th, 2023 (edited)
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 6.17 KB | Source Code | 0 0
  1. <?php
  2. // Exit if accessed directly
  3. if( ! defined ( 'ABSPATH' ) )
  4.    exit;
  5.  
  6. /**
  7. * Template Name: Dev Template
  8. *
  9. * @package WordPress
  10. * @subpackage divi-child
  11. * @since divi
  12. */
  13. get_header ();
  14. ?>
  15. <link rel="stylesheet" href="https://acea1.admaiora.com/wheel/main.css" type="text/css" />
  16. <script type="text/javascript" src="https://acea1.admaiora.com/wheel/Winwheel.js"></script>
  17. <style type="text/css">
  18.     .sc_container{
  19.         display:inline-block;
  20.         padding-top:150px;
  21.     }
  22.     .power_controls{
  23.         width:auto;
  24.         margin:0px !important;
  25.         text-align:center;
  26.         margin-top:30px !important;
  27.     }
  28.     .power_controls .play_btn_wrapper{
  29.         margin-bottom:15px;
  30.     }
  31.     .custom_play_bg{
  32.         position:relative;
  33.     }
  34.     .custom_play_bg::after {
  35.         content: "";
  36.         width: 33px;
  37.         height: 53px;
  38.         background-image: url(https://acea1.admaiora.com/wheel/custom_pointer.png);
  39.         background-size: 100%;
  40.         background-position: center;
  41.         background-repeat: no-repeat;
  42.         position: absolute;
  43.         left: calc(50% - 2px);
  44.         transform: translateX(-50%);
  45.         top: 37px;
  46.         z-index: 2;
  47.     }
  48.     .custom_play_bg #canvas{
  49.         position:relative;
  50.         z-index:2;
  51.     }
  52.     .custom_play_bg::before {
  53.         content: "";
  54.         position: absolute;
  55.         bottom: -8px;
  56.         left: 50%;
  57.         transform: translateX(-50%);
  58.         width: 242px;
  59.         height: 8px;
  60.         border-radius: 21px;
  61.         background-color: #ba5f5f;
  62.         filter: blur(8px);
  63.         z-index: -1;
  64.     }
  65.     .custom_play_bg .fixed_wheel_center_point {
  66.         position: absolute;
  67.         top: calc(50% + 2px);
  68.         right: unset;
  69.         left: 50%;
  70.         z-index: 2;
  71.         transform: translate(-50%,-50%);
  72.     }
  73. </style>
  74. <div class="sc_container">
  75.     <div class="custom_play_bg" style="background-image: url(https://acea1.admaiora.com/wheel//wheel_back.png);display:inline-block;">
  76.         <canvas id="canvas" width="315" height="418">
  77.             <p style="{color: white}" align="center">Sorry, your browser doesn't support canvas. Please try another.</p>
  78.         </canvas>
  79.         <img src="https://acea1.admaiora.com/wheel/fixed_wheel_center_point.png" class="fixed_wheel_center_point" alt="no-img" />
  80.     </div>
  81.     <div class="power_controls">
  82.         <div class="play_btn_wrapper">
  83.             <?php echo do_shortcode ( '[custom_wheel_button]' ); ?>
  84.         </div>
  85.     </div>
  86. </div>
  87. <script>
  88.     const positive_angle = ["0-21", "69-111", "159-201", "250-292", "339-360"];
  89.     var positive_array = [];
  90.     const negative_angle = ["24-66", "114-156", "204-247", "295-336"];
  91.     var negative_array = [];
  92.  
  93.     positive_angle.forEach(function (item, index) {
  94.         if (item) {
  95.             var indi_item = item.split("-");
  96.             for (let i = parseInt(indi_item[0]); i <= parseInt(indi_item[1]); i++) {
  97.                positive_array.push(i);
  98.            }
  99.        }
  100.    });
  101.    negative_angle.forEach(function (item, index) {
  102.        if (item) {
  103.            var indi_item = item.split("-");
  104.            for (let i = parseInt(indi_item[0]); i <= parseInt(indi_item[1]); i++) {
  105.                negative_array.push(i);
  106.            }
  107.        }
  108.    });
  109.    let theWheel = new Winwheel({
  110.        'numSegments': 4, // Specify number of segments.
  111.        'outerRadius': 150, // Set outer radius so wheel fits inside the background.
  112.        'drawMode': 'image', // drawMode must be set to image.
  113.        'drawText': true, // Need to set this true if want code-drawn text on image wheels.
  114.        'textFontSize': 12, // Set text options as desired.
  115.        'textOrientation': 'curved',
  116.        'textDirection': 'reversed',
  117.        'textAlignment': 'outer',
  118.        'textMargin': 5,
  119.        'textFontFamily': 'monospace',
  120.        'textStrokeStyle': 'black',
  121.        'textLineWidth': 2,
  122.        'textFillStyle': 'white',
  123.        'animation': // Specify the animation to use.
  124.                {
  125.                    'type': 'spinToStop',
  126.                    'duration': 5, // Duration in seconds.
  127.                    'spins': 8, // Number of complete spins.
  128.                    'stopAngle':50,
  129.                    'callbackFinished': alertPrize,
  130.                }
  131.    });
  132.  
  133.    let loadedImg = new Image();
  134.  
  135.    loadedImg.onload = function ()
  136.    {
  137.        theWheel.wheelImage = loadedImg;    // Make wheelImage equal the loaded image object.
  138.        theWheel.draw();                    // Also call draw function to render the wheel.
  139. //        theWheel.animation.stopAngle = 20;
  140.    }
  141.  
  142.    loadedImg.src = "https://acea1.admaiora.com/wheel/planes1.png";
  143.    let wheelPower = 0;
  144.    let wheelSpinning = false;
  145.  
  146.    function powerSelected(powerLevel)
  147.    {
  148.        if (wheelSpinning == false) {
  149.            document.getElementById('pw1').className = "";
  150.            document.getElementById('pw2').className = "";
  151.            document.getElementById('pw3').className = "";
  152.  
  153.            if (powerLevel >= 1) {
  154.                 document.getElementById('pw1').className = "pw1";
  155.             }
  156.  
  157.             if (powerLevel >= 2) {
  158.                 document.getElementById('pw2').className = "pw2";
  159.             }
  160.  
  161.             if (powerLevel >= 3) {
  162.                 document.getElementById('pw3').className = "pw3";
  163.             }
  164.  
  165.             wheelPower = powerLevel;
  166.         }
  167.     }
  168.     function startSpin(flag)
  169.     {
  170.         if (wheelSpinning == false) {
  171.             var stopAt = 0;
  172.             if (flag == true) {
  173.                 const positive_array_random = Math.floor(Math.random() * positive_array.length);
  174.                 stopAt = positive_array[positive_array_random];
  175.             } else {
  176.                 const negative_array_random = Math.floor(Math.random() * negative_array.length);
  177.                 stopAt = negative_array[negative_array_random];
  178.             }
  179.             theWheel.animation.stopAngle = stopAt;
  180.             theWheel.startAnimation();
  181.             wheelSpinning = true;
  182.         }
  183.     }
  184.     function alertPrize(indicatedSegment)
  185.     {
  186. //        alert("The wheel stopped on " + indicatedSegment.text);
  187.     }
  188. </script>
  189.  
  190. <?php get_footer (); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement