PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
Webdesign: HTML/CSS, Responsive Design, Sass...
jQuery Countdown
Beitrag
<blockquote data-quote="ovbb" data-source="post: 2391612" data-attributes="member: 73698"><p>hallo</p><p></p><p>ich nehme mal an, dass der ursprung des scrips dieser <a href="http://tutorialzine.com/2011/12/countdown-jquery/" target="_blank">http://tutorialzine.com/2011/12/countdown-jquery/</a> ist.</p><p></p><p>Hab das mal eben ausprobiert.</p><p></p><p>die 2 Dateien die du brauchst ist eine index.html und eine jquery.countdown.js imgleichen verzeichnis.</p><p></p><p>grundsätzlich läuft das ding aber hat noch ein paar macken.</p><p>mit der zeile " ts = new Date(2014, 7, 19)," solltest du das datum einstellen können bis zu welchem er countdown läuft. das mit den 10 tagen ist unnötig (link oben lesen).</p><p></p><p>hierbei kannst du dann auch eine funktino schreiben, welche dir immer den letzten Tag vom aktuellen monat errechnet und fertig <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":-)" title="Smile :-)" loading="lazy" data-shortname=":-)" /></p><p></p><p>index.html</p><p>[CODE]</p><p><html></p><p><head></p><p><link rel="stylesheet" type="text/css" href="jquery.countdown.css" /></p><p></head></p><p><body style="background-color: gray"></p><p><div id="countdown" class="countdownHolder"></p><p> <span class="countDays"></p><p> <span class="position"></p><p> <span class="digit static"></span></p><p> </span></p><p> <span class="position"></p><p> <span class="digit static"></span></p><p> </span></p><p> </span></p><p></p><p> <span class="countDiv countDiv0"></span></p><p></p><p> <span class="countHours"></p><p> <span class="position"></p><p> <span class="digit static"></span></p><p> </span></p><p> <span class="position"></p><p> <span class="digit static"></span></p><p> </span></p><p> </span></p><p></p><p> <span class="countDiv countDiv1"></span></p><p></p><p> <span class="countMinutes"></p><p> <span class="position"></p><p> <span class="digit static"></span></p><p> </span></p><p> <span class="position"></p><p> <span class="digit static"></span></p><p> </span></p><p> </span></p><p></p><p> <span class="countDiv countDiv2"></span></p><p></p><p> <span class="countSeconds"></p><p> <span class="position"></p><p> <span class="digit static"></span></p><p> </span></p><p> <span class="position"></p><p> <span class="digit static"></span></p><p> </span></p><p> </span></p><p></p><p> <span class="countDiv countDiv3"></span></p><p> </p><p> <div id="note"></div></p><p></div></p><p><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script></p><p><script src="jquery.countdown.js"></script></p><p></body</p><p></html></p><p>[/CODE]</p><p></p><p>jquery.countdown.js</p><p>[CODE]</p><p>/**</p><p> * @name jQuery Countdown Plugin</p><p> * @author Martin Angelov</p><p> * @version 1.0</p><p> * @url http://tutorialzine.com/2011/12/countdown-jquery/</p><p> * @license MIT License</p><p> */</p><p></p><p>(function($){</p><p> </p><p> // Number of seconds in every time division</p><p> var days = 24*60*60,</p><p> hours = 60*60,</p><p> minutes = 60;</p><p> </p><p> // Creating the plugin</p><p> $.fn.countdown = function(prop){</p><p> </p><p> var options = $.extend({</p><p> callback : function(){},</p><p> timestamp : 0</p><p> },prop);</p><p> </p><p> var left, d, h, m, s, positions;</p><p></p><p> // Initialize the plugin</p><p> init(this, options);</p><p> </p><p> positions = this.find('.position');</p><p> </p><p> (function tick(){</p><p> </p><p> // Time left</p><p> left = Math.floor((options.timestamp - (new Date())) / 1000);</p><p> </p><p> if(left < 0){</p><p> left = 0;</p><p> }</p><p> </p><p> // Number of days left</p><p> d = Math.floor(left / days);</p><p> updateDuo(0, 1, d);</p><p> left -= d*days;</p><p> </p><p> // Number of hours left</p><p> h = Math.floor(left / hours);</p><p> updateDuo(2, 3, h);</p><p> left -= h*hours;</p><p> </p><p> // Number of minutes left</p><p> m = Math.floor(left / minutes);</p><p> updateDuo(4, 5, m);</p><p> left -= m*minutes;</p><p> </p><p> // Number of seconds left</p><p> s = left;</p><p> updateDuo(6, 7, s);</p><p> </p><p> // Calling an optional user supplied callback</p><p> options.callback(d, h, m, s);</p><p> </p><p> // Scheduling another call of this function in 1s</p><p> setTimeout(tick, 1000);</p><p> })();</p><p> </p><p> // This function updates two digit positions at once</p><p> function updateDuo(minor,major,value){</p><p> switchDigit(positions.eq(minor),Math.floor(value/10)%10);</p><p> switchDigit(positions.eq(major),value%10);</p><p> }</p><p> </p><p> return this;</p><p> };</p><p></p><p></p><p> function init(elem, options){</p><p> elem.addClass('countdownHolder');</p><p></p><p> // Creating the markup inside the container</p><p> $.each(['Days','Hours','Minutes','Seconds'],function(i){</p><p> $('<span class="count'+this+'">').html(</p><p> '<span class="position">\</p><p> <span class="digit static">0</span>\</p><p> </span>\</p><p> <span class="position">\</p><p> <span class="digit static">0</span>\</p><p> </span>'</p><p> ).appendTo(elem);</p><p> </p><p> if(this!="Seconds"){</p><p> elem.append('<span class="countDiv countDiv'+i+'"></span>');</p><p> }</p><p> });</p><p></p><p> }</p><p></p><p> // Creates an animated transition between the two numbers</p><p> function switchDigit(position,number){</p><p> </p><p> var digit = position.find('.digit')</p><p> </p><p> if(digit.is(':animated')){</p><p> return false;</p><p> }</p><p> </p><p> if(position.data('digit') == number){</p><p> // We are already showing this number</p><p> return false;</p><p> }</p><p> </p><p> position.data('digit', number);</p><p> </p><p> var replacement = $('<span>',{</p><p> 'class':'digit',</p><p> css:{</p><p> top:'-2.1em',</p><p> opacity:0</p><p> },</p><p> html:number</p><p> });</p><p> </p><p> // The .static class is added when the animation</p><p> // completes. This makes it run smoother.</p><p> </p><p> digit</p><p> .before(replacement)</p><p> .removeClass('static')</p><p> .animate({top:'2.5em',opacity:0},'fast',function(){</p><p> digit.remove();</p><p> })</p><p></p><p> replacement</p><p> .delay(100)</p><p> .animate({top:0,opacity:1},'fast',function(){</p><p> replacement.addClass('static');</p><p> });</p><p> }</p><p>})(jQuery);</p><p></p><p>$(function(){</p><p></p><p> var note = $('#note'),</p><p> ts = new Date(2014, 7, 19),</p><p> newYear = false;</p><p></p><p> if((new Date()) > ts){</p><p> // The new year is here! Count towards something else.</p><p> // Notice the *1000 at the end - time must be in milliseconds</p><p> ts = (new Date()).getTime() + 10*24*60*60*1000;</p><p> newYear = false;</p><p> }</p><p></p><p> $('#countdown').countdown({</p><p> timestamp : ts,</p><p> callback : function(days, hours, minutes, seconds){</p><p></p><p> var message = "";</p><p></p><p> message += days + " day" + ( days==1 ? '':'s' ) + ", ";</p><p> message += hours + " hour" + ( hours==1 ? '':'s' ) + ", ";</p><p> message += minutes + " minute" + ( minutes==1 ? '':'s' ) + " and ";</p><p> message += seconds + " second" + ( seconds==1 ? '':'s' ) + " <br />";</p><p></p><p> if(newYear){</p><p> message += "left until the new year!";</p><p> }</p><p> else {</p><p> message += "left to 10 days from now!";</p><p> }</p><p></p><p> note.html(message);</p><p> }</p><p> });</p><p></p><p>});</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="ovbb, post: 2391612, member: 73698"] hallo ich nehme mal an, dass der ursprung des scrips dieser [url]http://tutorialzine.com/2011/12/countdown-jquery/[/url] ist. Hab das mal eben ausprobiert. die 2 Dateien die du brauchst ist eine index.html und eine jquery.countdown.js imgleichen verzeichnis. grundsätzlich läuft das ding aber hat noch ein paar macken. mit der zeile " ts = new Date(2014, 7, 19)," solltest du das datum einstellen können bis zu welchem er countdown läuft. das mit den 10 tagen ist unnötig (link oben lesen). hierbei kannst du dann auch eine funktino schreiben, welche dir immer den letzten Tag vom aktuellen monat errechnet und fertig :-) index.html [CODE] <html> <head> <link rel="stylesheet" type="text/css" href="jquery.countdown.css" /> </head> <body style="background-color: gray"> <div id="countdown" class="countdownHolder"> <span class="countDays"> <span class="position"> <span class="digit static"></span> </span> <span class="position"> <span class="digit static"></span> </span> </span> <span class="countDiv countDiv0"></span> <span class="countHours"> <span class="position"> <span class="digit static"></span> </span> <span class="position"> <span class="digit static"></span> </span> </span> <span class="countDiv countDiv1"></span> <span class="countMinutes"> <span class="position"> <span class="digit static"></span> </span> <span class="position"> <span class="digit static"></span> </span> </span> <span class="countDiv countDiv2"></span> <span class="countSeconds"> <span class="position"> <span class="digit static"></span> </span> <span class="position"> <span class="digit static"></span> </span> </span> <span class="countDiv countDiv3"></span> <div id="note"></div> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="jquery.countdown.js"></script> </body </html> [/CODE] jquery.countdown.js [CODE] /** * @name jQuery Countdown Plugin * @author Martin Angelov * @version 1.0 * @url http://tutorialzine.com/2011/12/countdown-jquery/ * @license MIT License */ (function($){ // Number of seconds in every time division var days = 24*60*60, hours = 60*60, minutes = 60; // Creating the plugin $.fn.countdown = function(prop){ var options = $.extend({ callback : function(){}, timestamp : 0 },prop); var left, d, h, m, s, positions; // Initialize the plugin init(this, options); positions = this.find('.position'); (function tick(){ // Time left left = Math.floor((options.timestamp - (new Date())) / 1000); if(left < 0){ left = 0; } // Number of days left d = Math.floor(left / days); updateDuo(0, 1, d); left -= d*days; // Number of hours left h = Math.floor(left / hours); updateDuo(2, 3, h); left -= h*hours; // Number of minutes left m = Math.floor(left / minutes); updateDuo(4, 5, m); left -= m*minutes; // Number of seconds left s = left; updateDuo(6, 7, s); // Calling an optional user supplied callback options.callback(d, h, m, s); // Scheduling another call of this function in 1s setTimeout(tick, 1000); })(); // This function updates two digit positions at once function updateDuo(minor,major,value){ switchDigit(positions.eq(minor),Math.floor(value/10)%10); switchDigit(positions.eq(major),value%10); } return this; }; function init(elem, options){ elem.addClass('countdownHolder'); // Creating the markup inside the container $.each(['Days','Hours','Minutes','Seconds'],function(i){ $('<span class="count'+this+'">').html( '<span class="position">\ <span class="digit static">0</span>\ </span>\ <span class="position">\ <span class="digit static">0</span>\ </span>' ).appendTo(elem); if(this!="Seconds"){ elem.append('<span class="countDiv countDiv'+i+'"></span>'); } }); } // Creates an animated transition between the two numbers function switchDigit(position,number){ var digit = position.find('.digit') if(digit.is(':animated')){ return false; } if(position.data('digit') == number){ // We are already showing this number return false; } position.data('digit', number); var replacement = $('<span>',{ 'class':'digit', css:{ top:'-2.1em', opacity:0 }, html:number }); // The .static class is added when the animation // completes. This makes it run smoother. digit .before(replacement) .removeClass('static') .animate({top:'2.5em',opacity:0},'fast',function(){ digit.remove(); }) replacement .delay(100) .animate({top:0,opacity:1},'fast',function(){ replacement.addClass('static'); }); } })(jQuery); $(function(){ var note = $('#note'), ts = new Date(2014, 7, 19), newYear = false; if((new Date()) > ts){ // The new year is here! Count towards something else. // Notice the *1000 at the end - time must be in milliseconds ts = (new Date()).getTime() + 10*24*60*60*1000; newYear = false; } $('#countdown').countdown({ timestamp : ts, callback : function(days, hours, minutes, seconds){ var message = ""; message += days + " day" + ( days==1 ? '':'s' ) + ", "; message += hours + " hour" + ( hours==1 ? '':'s' ) + ", "; message += minutes + " minute" + ( minutes==1 ? '':'s' ) + " and "; message += seconds + " second" + ( seconds==1 ? '':'s' ) + " <br />"; if(newYear){ message += "left until the new year!"; } else { message += "left to 10 days from now!"; } note.html(message); } }); }); [/CODE] [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ★ = 12, ◇ = 4 und die Hälfte von ★ zu ◇ addiert wird, was ist das Ergebnis?
Antworten
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
Webdesign: HTML/CSS, Responsive Design, Sass...
jQuery Countdown
Oben