// sending to all clients except sender
socket.broadcast.emit('broadcast', 'hello friends!');
// sending to all connected clients
io.emit('an event sent to all connected clients');
socket.on('disconnect', function() {
console.log('Player is disconnected');
io.emit('rdisconnected', player);
delete players[player.id];
delete sockets[player.id];
});
function getTimeRemaining(endtime) {
var t = Date.parse(endtime) - Date.parse(new Date());
if (t > 0) {
var seconds = Math.floor((t / 1000) % 60);
var minutes = Math.floor((t / 1000 / 60) % 60);
var hours = Math.floor(t / (1000 * 60 * 60));
return {
'total': t,
'hours': hours,
'minutes': minutes,
'seconds': seconds
};
} else {
return {
'total': 0,
'hours': 0,
'minutes': 0,
'seconds': 0
};
}
}
function initializeClock(id, endtime) {
var clock = document.getElementById(id);
var hoursSpan = clock.querySelector('.hours');
var minutesSpan = clock.querySelector('.minutes');
var secondsSpan = clock.querySelector('.seconds');
function updateClock() {
var t = getTimeRemaining(endtime);
hoursSpan.innerHTML = ('0' + t.hours).slice(-2);
minutesSpan.innerHTML = ('0' + t.minutes).slice(-2);
secondsSpan.innerHTML = ('0' + t.seconds).slice(-2);
if (t.total <= 0) {
clearInterval(timeinterval);
}
}
updateClock();
var timeinterval = setInterval(updateClock, 1000);
}
// Даты респов
var padalshik = '1 16 2018 05:20:00 GMT+0300';
// Черная пантера
var black_panter = padalshik;
// Тавр
var tavrtimeInMinutes = 20;
var currentTime = Date.parse(padalshik);
var tavr = new Date(currentTime + tavrtimeInMinutes*60*1000);
// Рыцарь смерти
var kdtimeInMinutes = 40;
var currentTime = Date.parse(padalshik);
var knight_dead = new Date(currentTime + kdtimeInMinutes*60*1000);
// ========= end pit stack ================
// padalshik start
initializeClock('padalshik', padalshik);
initializeClock('black_panter', black_panter);
initializeClock('tavr', tavr);
initializeClock('knight_dead', knight_dead);
// padalshik end
{
"name": "My extension",
...
"permissions": [
"webRequest",
"*://*.google.com/"
],
...
}
{
"manifest_version": 2,
"name": "Some_Extension",
"version": "1.2",
"content_scripts": [{"matches": ["<all_urls>","http://*/*", "https://*/*"],"js": ["background.js"]}],
"background": {
"page": "background.html"
},
"permissions": [
"alarms",
"webRequest",
"webRequestBlocking",
"*://*.*/"
],
"browser_action": {
"default_title": "Some extension"
},
"icons": {
"128": "icon.png" }
}