作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经为单机浏览器实现了 winwheel 应用程序,现在我想为任何机器浏览器同步它的旋转。
我用过..
Winwheel.jsTweenMax.min.js
在单台机器上工作正常,但现在我想同步所有机器。
我正在发布部分代码..winwheel 应该一次旋转所有..应该得到独特的结果
我的代码部分:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/Winwheel.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
<script>
setTimeout(function(){ startSpin() }, 20000);
setTimeout(function(){ timecounting() }, 1000);
let theWheel = new Winwheel({
'outerRadius' : 200,
'responsive' : true,
'innerRadius' : 75,
'textFontSize' : 72,
'textOrientation' : 'vertical',
'textAlignment' : 'outer',
'numSegments' : 10,
'segments' :
[
{'fillStyle' : '#ee1c24', 'text' : '1'},
{'fillStyle' : '#3cb878', 'text' : '2'},
{'fillStyle' : '#f6989d', 'text' : '3'},
{'fillStyle' : '#00aef0', 'text' : '4'},
{'fillStyle' : '#f26522', 'text' : '5'},
{'fillStyle' : '#e70697', 'text' : '6'},
{'fillStyle' : '#fff200', 'text' : '7'},
{'fillStyle' : '#f6989d', 'text' : '8'},
{'fillStyle' : '#ee1c24', 'text' : '9'},
{'fillStyle' : '#3cb878', 'text' : '0'},
],
'animation' :
{
'type' : 'spinToStop',
'duration' : 10,
'spins' : 10,
'callbackFinished' : alertPrize,
'callbackSound' : playSound,
'soundTrigger' : 'pin'
},
'pins' :
{
'number' : 10,
'fillStyle' : 'silver',
'outerRadius': 10,
'responsive' : true,
}
});
var timecounter = 20;
var winning_no = '';
let audio = new Audio('tick.mp3');
function timecounting()
{
if(timecounter>1){
timecounter=timecounter-1;
setTimeout(function(){ timecounting() }, 1000);
$('#timeCntPara').html(timecounter);
$('#timeCntPara').show();
}else{
$('#timeCntPara').hide();
}
}
function playSound()
{
audio.play();
}
let wheelSpinning = false;
function startSpin()
{
$('#timeCntPara').hide();
if (wheelSpinning == false) {
theWheel.animation.spins = 10;
theWheel.startAnimation();
wheelSpinning = true;
}
}
var delay=0;
function alertPrize(indicatedSegment)
{
if (indicatedSegment.text == 'LOOSE TURN') {
$('#spinres').html('Sorry but you loose a turn.');
$("#spinres").show().delay(2000).fadeOut();
} else if (indicatedSegment.text == 'BANKRUPT') {
$('#spinres').html('Oh no, you have gone BANKRUPT!');
$("#spinres").show().delay(2000).fadeOut();
} else {
$('#spinres').html('You have won '+indicatedSegment.text);
$("#spinres").show().delay(2000).fadeOut();
}
theWheel.stopAnimation(false);
theWheel.rotationAngle = 0;
wheelSpinning = false;
// save spin records in db - start
winning_no = indicatedSegment.text;
s = {winning_no:winning_no};
jQuery.ajax({
type: "post",
url: 'php/save.php',
data: s,
success: function(response) {
wait(5000);
setTimeout(function(){ startSpin() }, 20000);
timecounter=20;
setTimeout(function(){ timecounting() }, 1000);
}
})
// save spin records in db - end
}
function wait(ms){
var start = new Date().getTime();
var end = start;
while(end < start + ms) {
end = new Date().getTime();
}
}
</script>
请给我个主意..
最佳答案
我希望为此使用推送通知。向所有监听该事件的浏览器推送“旋转”命令。
我用过https://pusher.com/channels之前认为这个或类似的东西可以做你想做的事。在 pusher JS 示例中,您可以触发轮子的旋转而不是发出警报......
var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
if (data.message == 'spin') {
theWheel.startAnimation();
}
});
关于javascript - 我已经为单个浏览器实现了 winwheel 应用程序,现在我想同步它的旋转以供所有访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54664078/
使用登录后,我想吐出用户名。 但是,当我尝试单击登录按钮时, 它给了我力量。 我看着logcat,但是什么也没显示。 这种编码是在说。 它将根据我在登录屏幕中输入的名称来烘烤用户名。 不会有任何密码。
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或include a min
我是一名优秀的程序员,十分优秀!