- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
function randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
// Settings are here
var total_items = 50;
var d = new Date();
var min_items_left = 12;
var max_items_left = 20;
var remaining_items = randomIntFromInterval(min_items_left, max_items_left);
var min_of_remaining_items = 1;
var decrease_after = 1.7;
var decrease_after_first_item = 0.17;
(function($) {
$.fn.progressbar = function() {
var a = "<p>Hurry! Only <span class='count'>" + remaining_items + "</span> left in stock.</p>" + "<div class='progressbar'><div style='width:100%'></div></div>";
this.addClass('items-count');
this.html(a + this.html());
updateMeter(this);
var b = this;
setTimeout(function() {
remaining_items--;
if (remaining_items < min_of_remaining_items) {
remaining_items = randomIntFromInterval(min_items_left, max_items_left)
}
$('.count').css('background-color', '#CE0201');
$('.count').css('color', '#fff');
setTimeout(function() {
$('.count').css('background-color', '#fff');
$('.count').css('color', '#CE0201')
}, 1000 * 60 * 0.03);
b.find(".count").text(remaining_items);
updateMeter(b)
}, 1000 * 60 * decrease_after_first_item);
setInterval(function() {
remaining_items--;
if (remaining_items < min_of_remaining_items) {
remaining_items = randomIntFromInterval(min_items_left, max_items_left)
}
$('.count').css('background-color', '#CE0201');
$('.count').css('color', '#fff');
setTimeout(function() {
$('.count').css('background-color', '#fff');
$('.count').css('color', '#CE0201')
}, 1000 * 60 * 0.03);
b.find(".count").text(remaining_items);
updateMeter(b)
}, 1000 * 60 * decrease_after)
};
function updateMeter(a) {
var b = 100 * remaining_items / total_items;
if (remaining_items < 10) {
a.find('.progressbar div:first').addClass('less-than-ten')
}
a.find('.progressbar').addClass('active progress-striped');
setTimeout(function() {
myanimate(a.find('.progressbar div:first'), b);
a.find('.progressbar').removeClass('active progress-striped')
}, 1000)
}
}(jQuery));
function myanimate(a, b) {
var c = 0;
var d = parseInt(a.closest('.progressbar').css('width'));
var e = Math.floor(100 * parseInt(a.css('width')) / d);
if (e > b) {
c = e
}
function frame() {
if (e > b) {
c--
} else {
c++
}
a.css('width', c + '%');
if (c == b || c <= 0 || c >= 100) clearInterval(f)
}
var f = setInterval(frame, 40)
}
$(document).ready(function() {
$("#progress_bar").progressbar();
var tag = "ctdn-12-12".match(/\d+/g);
var hour = 14;
var theDaysBox = $("#numdays");
var theHoursBox = $("#numhours");
var theMinsBox = $("#nummins");
var theSecsBox = $("#numsecs");
var d = new Date();
var n = d.getDay();
var date = 1;
var gg = 0;
var hh = 0;
var ii = 0;
var nsec = 0 - d.getSeconds();
if (nsec < 0) {
nsec = 60 - d.getSeconds();
gg = 1
}
var nmin = 0 - d.getMinutes() - gg;
if (nmin < 0) {
nmin = 60 - d.getMinutes() - gg;
hh = 1
}
var nhrs = 14 - d.getHours() - hh;
if (nhrs < 0) {
nhrs = 38 - d.getHours() - hh;
ii = 1
}
var ndat = date - 1;
if (ndat < 0) {
var mmon = d.getMonth();
ndat = 30 + date - d.getDate() - ii
}
theSecsBox.html(nsec);
theMinsBox.html(nmin);
theHoursBox.html(nhrs);
theDaysBox.html(ndat);
var refreshId = setInterval(function() {
var e = theSecsBox.text();
var a = theMinsBox.text();
var c = theHoursBox.text();
var b = theDaysBox.text();
if (e == 0 && a == 0 && c == 0 && b == 0) {} else {
if (e == 0 && a == 0 && c == 0) {
theDaysBox.html(b - 1);
theHoursBox.html("23");
theMinsBox.html("59");
theSecsBox.html("59")
} else {
if (e == 0 && a == 0) {
theHoursBox.html(c - 1);
theMinsBox.html("59");
theSecsBox.html("59")
} else {
if (e == 0) {
theMinsBox.html(a - 1);
theSecsBox.html("59")
} else {
theSecsBox.html(e - 1)
}
}
}
}
}, 1000);
});
#progress_bar {
margin-top: 15px
}
.progressbar.progressbar {
background: #ffe8e8;
border: 0px solid whitesmoke;
height: 11px
}
.progressbar.progressbar div {
background: #d95350;
height: 11px
}
.progressbar.progressbar.active div {
-webkit-animation: 2s linear 0s normal none infinite running progress-bar-stripes;
animation: 2s linear 0s normal none infinite running progress-bar-stripes
}
.progress-striped.progressbar.progressbar div {
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0) 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, rgba(0, 0, 0, 0) 75%, rgba(0, 0, 0, 0));
background-size: 40px 40px
}
.items-count {
margin-top: 0px;
margin-bottom: 0px
}
.count {
color: #a94442;
padding: 1px
}
.items-count p {
padding-bottom: 5px;
margin: 0;
text-transform: uppercase;
font-weight: 700;
text-align: center;
font-family: "Open Sans", Arial, sans-serif
}
.progressbar {
position: relative;
display: block;
background-color: #ca0000;
border: 1px solid #ddd;
margin-bottom: 15px;
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1)
}
.progressbar > div {
background-color: #ca0000;
width: 0;
margin-bottom: 0;
height: 15px
}
.progressbar > div.less-than-ten {
background-color: #ca0000 !important
}
#clock-ticker {
display: block;
margin-bottom: 15px
}
#clock-ticker .block {
position: relative;
color: #000;
font-weight: bold;
float: left;
text-align: center;
width: 25%
}
#clock-ticker .block .flip-top {
width: 88px;
height: 39px;
line-height: 40px;
font-size: 40px;
text-align: center
}
#clock-ticker .block .label,
span.flip-top {
color: #000;
font-weight: bold;
text-align: center;
font-size: 14px;
text-transform: uppercase;
width: 88px;
line-height: 25px;
font-family: "Open Sans", Arial, sans-serif
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="items-count" id="progress_bar"></div>
<div id="clock-ticker" class="clearfix">
<div class="block"><span class="flip-top" id="numdays">0</span>
<br><span class="label">Days</span>
</div>
<div class="block"><span class="flip-top" id="numhours">1</span>
<br><span class="label">Hours</span>
</div>
<div class="block"><span class="flip-top" id="nummins">23</span>
<br><span class="label">Minutes</span>
</div>
<div class="block"><span class="flip-top" id="numsecs">36</span>
<br><span class="label">Seconds</span>
</div>
我想在网站上显示一个倒数计时器,它应该说快点,只有 X 库存,下面是红色条,然后是一个带有数字的计时器。带数字的计时器工作正常,但我看不到只抓紧时间和显示红色进度条。谁能指出我正确的方向?谢谢
代码在这里,
<style>#progress_bar{margin-top:15px}.progressbar.progressbar{background:#ffe8e8;border:0px solid whitesmoke;height:11px}.progressbar.progressbar div{background:#d95350;height:11px}.progressbar.progressbar.active div{-webkit-animation:2s linear 0s normal none infinite running progress-bar-stripes;animation:2s linear 0s normal none infinite running progress-bar-stripes}.progress-striped.progressbar.progressbar div{background-image:-webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0) 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, rgba(0, 0, 0, 0) 75%, rgba(0, 0, 0, 0));background-size:40px 40px}.items-count{margin-top:0px;margin-bottom:0px}.count{color:#a94442;padding:1px}.items-count p{padding-bottom:5px;margin:0;text-transform:uppercase;font-weight:700;text-align:center;font-family:"Open Sans",Arial,sans-serif}.progressbar{position:relative;display:block;background-color:#ca0000;border:1px solid #ddd;margin-bottom:15px;-webkit-box-shadow:inset 0 1px 2px rgba(0, 0, 0, .1);box-shadow:inset 0 1px 2px rgba(0, 0, 0, .1)}.progressbar > div{background-color:#ca0000;width:0;margin-bottom:0;height:15px}.progressbar > div.less-than-ten{background-color:#ca0000 !important}#clock-ticker{display:block;margin-bottom:15px}#clock-ticker .block{position:relative;color:#000;font-weight:bold;float:left;text-align:center;width:25%}#clock-ticker .block .flip-top{width:88px;height:39px;line-height:40px;font-size:40px;text-align:center}#clock-ticker .block .label,span.flip-top{color:#000;font-weight:bold;text-align:center;font-size:14px;text-transform:uppercase;width:88px;line-height:25px;font-family:"Open Sans",Arial,sans-serif}</style>
<script type="text/javascript">
function randomIntFromInterval(min, max) {return Math.floor(Math.random() * (max - min + 1) + min);}
// Settings are here
var total_items = 50;
var d = new Date();
var min_items_left = 12;
var max_items_left = 20;
var remaining_items = randomIntFromInterval(min_items_left, max_items_left);
var min_of_remaining_items = 1;
var decrease_after = 1.7;
var decrease_after_first_item = 0.17;
(function($){$.fn.progressbar=function(){var a="<p>Hurry! Only <span class='count'>"+remaining_items+"</span> left in stock.</p>"+"<div class='progressbar'><div style='width:100%'></div></div>";this.addClass('items-count');this.html(a+this.html());updateMeter(this);var b=this;setTimeout(function(){remaining_items--;if(remaining_items<min_of_remaining_items){remaining_items=randomIntFromInterval(min_items_left,max_items_left)}$('.count').css('background-color','#CE0201');$('.count').css('color','#fff');setTimeout(function(){$('.count').css('background-color','#fff');$('.count').css('color','#CE0201')},1000*60*0.03);b.find(".count").text(remaining_items);updateMeter(b)},1000*60*decrease_after_first_item);setInterval(function(){remaining_items--;if(remaining_items<min_of_remaining_items){remaining_items=randomIntFromInterval(min_items_left,max_items_left)}$('.count').css('background-color','#CE0201');$('.count').css('color','#fff');setTimeout(function(){$('.count').css('background-color','#fff');$('.count').css('color','#CE0201')},1000*60*0.03);b.find(".count").text(remaining_items);updateMeter(b)},1000*60*decrease_after)};function updateMeter(a){var b=100*remaining_items/total_items;if(remaining_items<10){a.find('.progressbar div:first').addClass('less-than-ten')}a.find('.progressbar').addClass('active progress-striped');setTimeout(function(){myanimate(a.find('.progressbar div:first'),b);a.find('.progressbar').removeClass('active progress-striped')},1000)}}(jQuery));function myanimate(a,b){var c=0;var d=parseInt(a.closest('.progressbar').css('width'));var e=Math.floor(100*parseInt(a.css('width'))/d);if(e>b){c=e}function frame(){if(e>b){c--}else{c++}a.css('width',c+'%');if(c==b||c<=0||c>=100)clearInterval(f)}var f=setInterval(frame,40)} $(document).ready(function(){$("#progress_bar").progressbar();var tag="ctdn-12-12".match(/\d+/g);var hour=14;var theDaysBox=$("#numdays");var theHoursBox=$("#numhours");var theMinsBox=$("#nummins");var theSecsBox=$("#numsecs");var d=new Date();var n=d.getDay();var date=1;var gg=0;var hh=0;var ii=0;var nsec=0-d.getSeconds();if(nsec<0){nsec=60-d.getSeconds();gg=1}var nmin=0-d.getMinutes()-gg;if(nmin<0){nmin=60-d.getMinutes()-gg;hh=1}var nhrs=14-d.getHours()-hh;if(nhrs<0){nhrs=38-d.getHours()-hh;ii=1}var ndat=date-1;if(ndat<0){var mmon=d.getMonth();ndat=30+date-d.getDate()-ii}theSecsBox.html(nsec);theMinsBox.html(nmin);theHoursBox.html(nhrs);theDaysBox.html(ndat);var refreshId=setInterval(function(){var e=theSecsBox.text();var a=theMinsBox.text();var c=theHoursBox.text();var b=theDaysBox.text();if(e==0&&a==0&&c==0&&b==0){}else{if(e==0&&a==0&&c==0){theDaysBox.html(b-1);theHoursBox.html("23");theMinsBox.html("59");theSecsBox.html("59")}else{if(e==0&&a==0){theHoursBox.html(c-1);theMinsBox.html("59");theSecsBox.html("59")}else{if(e==0){theMinsBox.html(a-1);theSecsBox.html("59")}else{theSecsBox.html(e-1)}}}}},1000);});</script>
<div class="items-count" id="progress_bar"></div><div id="clock-ticker" class="clearfix"><div class="block"><span class="flip-top" id="numdays">0</span><br><span class="label">Days</span></div><div class="block"><span class="flip-top" id="numhours">1</span><br><span class="label">Hours</span></div><div class="block"><span class="flip-top" id="nummins">23</span><br><span class="label">Minutes</span></div><div class="block"><span class="flip-top" id="numsecs">36</span><br><span class="label">Seconds</span></div>
最佳答案
function randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
// Settings are here
var total_items = 50;
var d = new Date();
var min_items_left = 12;
var max_items_left = 20;
var remaining_items = randomIntFromInterval(min_items_left, max_items_left);
var min_of_remaining_items = 1;
var decrease_after = 1.7;
var decrease_after_first_item = 0.17;
(function($) {
$.fn.progressbar = function() {
var a = "<p>Hurry! Only <span class='count'>" + remaining_items + "</span> left in stock.</p>" + "<div class='progressbar'><div style='width:100%'></div></div>";
this.addClass('items-count');
this.html(a + this.html());
updateMeter(this);
var b = this;
setTimeout(function() {
remaining_items--;
if (remaining_items < min_of_remaining_items) {
remaining_items = randomIntFromInterval(min_items_left, max_items_left)
}
$('.count').css('background-color', '#CE0201');
$('.count').css('color', '#fff');
setTimeout(function() {
$('.count').css('background-color', '#fff');
$('.count').css('color', '#CE0201')
}, 1000 * 60 * 0.03);
b.find(".count").text(remaining_items);
updateMeter(b)
}, 1000 * 60 * decrease_after_first_item);
setInterval(function() {
remaining_items--;
if (remaining_items < min_of_remaining_items) {
remaining_items = randomIntFromInterval(min_items_left, max_items_left)
}
$('.count').css('background-color', '#CE0201');
$('.count').css('color', '#fff');
setTimeout(function() {
$('.count').css('background-color', '#fff');
$('.count').css('color', '#CE0201')
}, 1000 * 60 * 0.03);
b.find(".count").text(remaining_items);
updateMeter(b)
}, 1000 * 60 * decrease_after)
};
function updateMeter(a) {
var b = 100 * remaining_items / total_items;
if (remaining_items < 10) {
a.find('.progressbar div:first').addClass('less-than-ten')
}
a.find('.progressbar').addClass('active progress-striped');
setTimeout(function() {
myanimate(a.find('.progressbar div:first'), b);
a.find('.progressbar').removeClass('active progress-striped')
}, 1000)
}
}(jQuery));
function myanimate(a, b) {
var c = 0;
var d = parseInt(a.closest('.progressbar').css('width'));
var e = Math.floor(100 * parseInt(a.css('width')) / d);
if (e > b) {
c = e
}
function frame() {
if (e > b) {
c--
} else {
c++
}
a.css('width', c + '%');
if (c == b || c <= 0 || c >= 100) clearInterval(f)
}
var f = setInterval(frame, 40)
}
$(document).ready(function() {
$("#progress_bar").progressbar();
var tag = "ctdn-12-12".match(/\d+/g);
var hour = 14;
var theDaysBox = $("#numdays");
var theHoursBox = $("#numhours");
var theMinsBox = $("#nummins");
var theSecsBox = $("#numsecs");
var d = new Date();
var n = d.getDay();
var date = 1;
var gg = 0;
var hh = 0;
var ii = 0;
var nsec = 0 - d.getSeconds();
if (nsec < 0) {
nsec = 60 - d.getSeconds();
gg = 1
}
var nmin = 0 - d.getMinutes() - gg;
if (nmin < 0) {
nmin = 60 - d.getMinutes() - gg;
hh = 1
}
var nhrs = 14 - d.getHours() - hh;
if (nhrs < 0) {
nhrs = 38 - d.getHours() - hh;
ii = 1
}
var ndat = date - 1;
if (ndat < 0) {
var mmon = d.getMonth();
ndat = 30 + date - d.getDate() - ii
}
theSecsBox.html(nsec);
theMinsBox.html(nmin);
theHoursBox.html(nhrs);
theDaysBox.html(ndat);
var refreshId = setInterval(function() {
var e = theSecsBox.text();
var a = theMinsBox.text();
var c = theHoursBox.text();
var b = theDaysBox.text();
if (e == 0 && a == 0 && c == 0 && b == 0) {} else {
if (e == 0 && a == 0 && c == 0) {
theDaysBox.html(b - 1);
theHoursBox.html("23");
theMinsBox.html("59");
theSecsBox.html("59")
} else {
if (e == 0 && a == 0) {
theHoursBox.html(c - 1);
theMinsBox.html("59");
theSecsBox.html("59")
} else {
if (e == 0) {
theMinsBox.html(a - 1);
theSecsBox.html("59")
} else {
theSecsBox.html(e - 1)
}
}
}
}
}, 1000);
});
#progress_bar {
margin-top: 15px
}
.progressbar.progressbar {
background: #ffe8e8;
border: 0px solid whitesmoke;
height: 11px
}
.progressbar.progressbar div {
background: #d95350;
height: 11px
}
.progressbar.progressbar.active div {
-webkit-animation: 2s linear 0s normal none infinite running progress-bar-stripes;
animation: 2s linear 0s normal none infinite running progress-bar-stripes
}
.progress-striped.progressbar.progressbar div {
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0) 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, rgba(0, 0, 0, 0) 75%, rgba(0, 0, 0, 0));
background-size: 40px 40px
}
.items-count {
margin-top: 0px;
margin-bottom: 0px
}
.count {
color: #a94442;
padding: 1px
}
.items-count p {
padding-bottom: 5px;
margin: 0;
text-transform: uppercase;
font-weight: 700;
text-align: center;
font-family: "Open Sans", Arial, sans-serif
}
.progressbar {
position: relative;
display: block;
background-color: #ca0000;
border: 1px solid #ddd;
margin-bottom: 15px;
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1)
}
.progressbar > div {
background-color: #ca0000;
width: 0;
margin-bottom: 0;
height: 15px
}
.progressbar > div.less-than-ten {
background-color: #ca0000 !important
}
#clock-ticker {
display: block;
margin-bottom: 15px
}
#clock-ticker .block {
position: relative;
color: #000;
font-weight: bold;
float: left;
text-align: center;
width: 25%
}
#clock-ticker .block .flip-top {
width: 88px;
height: 39px;
line-height: 40px;
font-size: 40px;
text-align: center
}
#clock-ticker .block .label,
span.flip-top {
color: #000;
font-weight: bold;
text-align: center;
font-size: 14px;
text-transform: uppercase;
width: 88px;
line-height: 25px;
font-family: "Open Sans", Arial, sans-serif
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="items-count" id="progress_bar"></div>
<div id="clock-ticker" class="clearfix">
<div class="block"><span class="flip-top" id="numdays">0</span>
<br><span class="label">Days</span>
</div>
<div class="block"><span class="flip-top" id="numhours">1</span>
<br><span class="label">Hours</span>
</div>
<div class="block"><span class="flip-top" id="nummins">23</span>
<br><span class="label">Minutes</span>
</div>
<div class="block"><span class="flip-top" id="numsecs">36</span>
<br><span class="label">Seconds</span>
</div>
关于javascript - 在我的网站上显示倒数计时器时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41391049/
如果我有一个变量 8589934592 示例: var a = (8589934592 | 0); //a is 0 var b = (8589934591223 | 0); //b
随着我们提高音阶,音符频率增加; #define A4 440 // These are the frequencies of the notes in herts #define A
我有一个这样组织的列表: [('down', 0.0098000000000000309), ('up', 0.0015000000000000568), ('down', 0.00890000000
如果我有一个多项式 P,有没有办法计算 P^-1 模 Q,即 Q 是另一个多项式?我知道这两个多项式的系数都属于以 z 为模的整数域,即 z 是一个整数。 我不确定 SymPy 是否已经在其 galo
对于给定的文件,我可以向后计算行数吗?即从 EOF 开始,计算行数直到开始? 我可以 fseek 到文件末尾。从那里开始,继续寻找新行字符(新行的指示)并继续增加我的 line_number 计数。但
有什么方法可以编写带除法的 C 代码来命令编译器在代码中需要常规除法精度的几个特定位置不使用快速除法(通过倒数数学),即使在全局允许倒数数学的情况下也是如此? 理想情况下,有一种方法不是特定于编译器的
我正在尝试将照片从我计算机上的本地文件导入到我的 HTML 文件中。我已经设法做到了,但它是按升序排列的。我尝试添加一个变量 JavaScript $(document).ready( functio
我正在尝试使用 commons-math 计算 2 尾学生分布的逆。我正在使用 Excel 来比较值并验证结果是否正确。 所以使用excel计算TINV,自由度为5,我使用95.45% =TINV(0
我有一个 jQuery 相机插件,它使用以下命令来拍摄快照。 这是它运行的代码。 function take_snapshot() { // take snapshot and get i
我刚刚学会了训练 brain.js network 并且只是在玩它。然后我很好奇是否可以采取相反的方式 - 从输出预测输入? 这是我的代码 const brain = require('brain.j
如果精度不重要,有什么方法可以提高速度的倒数(X 的除法 1)? 所以,我需要计算 1/X。是否有一些解决方法让我失去精度但做得更快? 最佳答案 𝗛𝗲𝗿𝗲𝗛𝗲𝗿𝗲𝗛𝗼𝘄𝗧𝗼?
令 N 为整数。如果N = 2536,则反转N为6352。如果N = 1000000,则反转N为1。 给定一个整数 M,其中 1 <= M <= 10^(100000)。 我们需要找到一个整数 N 是
我是一名优秀的程序员,十分优秀!