X   Сообщение сайта
(Сообщение закроется через 3 секунды)



 

Здравствуйте, гость (

| Вход | Регистрация )

Открыть тему
Тема закрыта
> Счетчик обратного отсчета, Зацикленный...
Gera
Gera
Topic Starter сообщение 25.6.2014, 20:39; Ответить: Gera
Сообщение #1


Доброго времени суток.

Мне нужно создать для сайта счетчик обратного отсчета на 14 минут, чтобы после истечения времени счетчик снова возвращался на исходную позицию и снова шел обратный отсчет с 14 минут.

Подскажите, пожалуйста, ссылочку на какой-нибудь материал или статью как это делается? Спасибо заранее.


--------------------
Мой YouTube канал, где я рисую картины баллончиками в стиле Spray Paint Art и обучаю этому ТЫК
0
Вернуться в начало страницы
 
Ответить с цитированием данного сообщения
LennarM
LennarM
сообщение 26.6.2014, 1:03; Ответить: LennarM
Сообщение #2


Почитайте вот тут, не уверен, что есть про цикличность.
http://learn.javascript.ru/datetime


Поблагодарили: (1)
Вернуться в начало страницы
 
Ответить с цитированием данного сообщения
Gera
Gera
Topic Starter сообщение 7.7.2014, 17:12; Ответить: Gera
Сообщение #3


Есть код скрипта:
Код
<script type="text/javascript">
/////////////// Таймер
$(function(){

new MUTimer({
month: '16',
day: '3',
hour: 22,
tz: +2,
lab: 'timer'
});

});
///////////////////////
</script>

======================================================

/**
* MUTimer
* Version: 1.0.alpha (6/11/2012 02:00)
*
* <parameter_name: default_value - description>:
*
* Main:
* month: "0" - "*" for next month, "0" for this month or 1 through 12 for the month
* day: "+1" - Offset for day of month day or + day
* hour: "23" - 0 through 23 for the hours of the day
* tz: "0" - Offset for your timezone in hours from UTC
* lab: "mutimer" - The id of the page entry where the timezone countdown is to show
*
* Common:
* msg: "Sorry, you are too late…" - Show this message on timer expired
* url: "" - Redirection URL on timer expired (empty string - disable redirection)
* delay: 0 - Redirection delay on timer expired
*
* Usage example:
* new MUTimer({ month: '11', day: '11', hour: 12, tz: -8, lab: 'mymutimer' });
*/

/* CONFIGURATION OPTIONS */

var muStyleSheetPath = 'web/s/mutimer.css'; // path to the mutimer.css

/* DO NOT EDIT PAST THIS LINE */

// jQuery solution to add StyleSheets
function addstylesheet(path) {
if(document.createStyleSheet) { // IE
document.createStyleSheet(path);
} else { // Other
$('<link rel="stylesheet" type="text/css" href="'+path+'" />').appendTo('head');
}
}

addstylesheet(muStyleSheetPath); // add stylesheet to the HTML head section

/**
* MUTimer object
*/
function MUTimer(options)
{
this.config = { // defaults
month: 0,
day : '+1',
hour : 23,
tz : 0,
lab : 'mutimer',
msg : 'Sorry, you are too late…',
url : '',
delay: 0
};

// customizing with incoming options
if(options.month) this.config.month = options.month;
if(options.day) this.config.day = options.day+'';
if(options.hour) this.config.hour = options.hour;
if(options.tz) this.config.tz = options.tz;
if(options.lab) this.config.lab = options.lab;
if(options.msg) this.config.msg = options.msg;
if(options.url) this.config.url = options.url;
if(options.delay) this.config.delay = options.delay;

// inner options
this.config.msEmu = 999;
this.config.msTimer = null;
this.config.timer = document.getElementById(this.config.lab);

// start the timer if the container exists
if(this.config.timer) {
je = jQuery('#'+this.config.lab);
if(!je.hasClass('mutimer')) je.addClass('mutimer');
if(!je.hasClass('default')) je.addClass('default');
tdiff = setTZCountDown(this.config); // get time distance
displayTZCountDown(tdiff, this.config); // run timer
millisecondsEmulator(this.config); // run milliseconds emulator
}

return this.config
}

function setTZCountDown(config)
{
var toDate = new Date();
if(config.month == '*') toDate.setMonth(toDate.getMonth() + 1);
else if(parseInt(config.month) > 0) {
if(parseInt(config.month) <= toDate.getMonth()) toDate.setYear(toDate.getYear() + 1);
toDate.setMonth(parseInt(config.month) - 1);
}
if(config.day.substr(0,1) == '+') {
var day1 = parseInt(config.day.substr(1));
toDate.setDate(toDate.getDate() + day1);
}
else toDate.setDate(config.day);

toDate.setHours(config.hour);
toDate.setMinutes(0 - (config.tz * 60));
toDate.setSeconds(0);
var fromDate = new Date();
fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());
var diffDate = new Date(0);
diffDate.setMilliseconds(toDate - fromDate);
return Math.floor(diffDate.valueOf()/1000);
}

function displayTZCountDown(tdiff, config)
{
if(tdiff < 0) {
config.timer.innerHTML = '<div class="expired">'+config.msg+'</div>';
if(config.url != '') {
if(config.delay) {
setTimeout('document.location.href="' + config.url + '"', config.delay * 1000);
} else {
document.location.href = config.url;
}
}
} else {
var secs = tdiff % 60;
if (secs < 10) secs = '0' + secs;
var tdiff1 = (tdiff - secs) / 60;
var mins = tdiff1 % 60;
if(mins < 10) mins = '0' + mins;
tdiff1 = (tdiff1 - mins) / 60;
var hours = tdiff1 % 24;
if(hours < 10) hours = '0' + hours;
var days = (tdiff1 - hours) / 24;
var hourone = hours+'ddd';
var minsone = mins+'ddd';
var secsone = secs+'ddd';


// reset milliseconds emulator
clearTimeout(config.msTimer);
config.msEmu = 999;
millisecondsEmulator(config);






var t = '';
t += ' <div class="timer">';

t += ' <div class="hour"><div class="h h1" >'+hourone[0]+'</div><div class="h">'+hourone[1]+'</div><span></span></div>';
t += ' <div class="min"><div class="m m1">'+minsone[0]+'</div><div class="m">'+minsone[1]+'</div><span></span></div>';
t += ' <div class="sec"><div class="s s1">'+secsone[0]+'</div><div class="s">'+secsone[1]+'</div></div>';

t += ' </div>';

config.timer.innerHTML = t;

setTimeout(function(){displayTZCountDown(tdiff-1,config)} ,999);
}
}

function millisecondsEmulator(config)
{
config.msEmu -= 29;
if(config.msEmu <= 0) config.msEmu = 999;

e = document.getElementById(config.lab+'-ms');
if(!e) return;

var ms = config.msEmu;
if(config.msEmu < 100) ms = '0' + ms;
else if(config.msEmu < 10) ms = '00' + ms;
e.innerHTML = ms + '<span>msec</span>';

config.msTimer = setTimeout(function(){millisecondsEmulator(config)}, 33);
}


Не могу понять как его вставить на страницу, что таймер этот обратного отсчет заработал. Подскажите, пожалуйста.


--------------------
Мой YouTube канал, где я рисую картины баллончиками в стиле Spray Paint Art и обучаю этому ТЫК
Вернуться в начало страницы
 
Ответить с цитированием данного сообщения
AtaELL
AtaELL
сообщение 7.7.2014, 17:20; Ответить: AtaELL
Сообщение #4


Вот посмотрите разбор счетчика
http://spydec.com/post/91/

Замечание модератора:
Эта тема была закрыта автоматически ввиду отсутствия активности в ней на протяжении 100+ дней.
Если Вы считаете ее актуальной и хотите оставить сообщение, то воспользуйтесь кнопкой
или обратитесь к любому из модераторов.


Сообщение отредактировал AtaELL - 7.7.2014, 17:21


Поблагодарили: (1)
Вернуться в начало страницы
 
Ответить с цитированием данного сообщения
Открыть тему
Тема закрыта
2 чел. читают эту тему (гостей: 2, скрытых пользователей: 0)
Пользователей: 0


Свернуть

> Похожие темы

  Тема Ответов Автор Просмотров Последний ответ
Открытая тема (нет новых ответов) Написать счетчик
php либо javascript
1 Raptor-Ice 1162 3.2.2014, 17:03
автор: Optimizmator
Открытая тема (нет новых ответов) Нужен счетчик обратного отсчета. Назовите стоимость.
1 Макс13 3888 18.9.2013, 11:14
автор: -Макс13-
Открытая тема (нет новых ответов) Таймер обратного отсчета
3 stops2012 7994 6.11.2011, 1:45
автор: -Galen-


 



RSS Текстовая версия Сейчас: 24.4.2024, 15:52
Дизайн