Skip to content

Instantly share code, notes, and snippets.

@goonoo
Created September 30, 2014 06:57
Show Gist options
  • Select an option

  • Save goonoo/adb74458ce18f7e8cd66 to your computer and use it in GitHub Desktop.

Select an option

Save goonoo/adb74458ce18f7e8cd66 to your computer and use it in GitHub Desktop.
Trello를 이용한 Standing Meeting을 위한 Timer
// ==UserScript==
// @name Trello Timer
// @namespace http://blmarket.net/users
// @description Display open time for each cards
// @include https://trello.com/board/*
// @include https://trello.com/b/*
// @version 1
// @grant none
// ==/UserScript==
var lastTitle, lastTimer;
function init($) {
var $elem = $('body');
var $timer = $('#trello-timer').length === 1 ? $('#trello-timer') :
$('<div id="trello-timer" style="position:fixed;bottom:0;leftj:0;z-index:99999999999;' +
'padding:10px 20px;font-size:50px;line-height:1;color:#fff;font-weight:bold;' +
'background:#000;opacity:.8"><span data-time="0">00:00</span>' +
'<b style="position:absolute;top:-10px;right:-10px;width:20px;height:20px;border-radius:10px;' +
'background:red;color:#fff;text-align:center;font-size:15px;line-height:16px;text-shadow:0 0 5px #000">&times;</b></div>').appendTo($elem);
var $t = $timer.find('span');
var f = function (n) {
return n.toString().length >= 2 ? n : '0' + n;
};
var intervalId;
var resetTimer = function () {
$timer.css('color', '#fff');
$timer.css('font-size', '50px');
$t.data('time', 0).text('00:00');
};
$timer.css('cursor', 'pointer').on('mouseenter', function () {
$t.css('color', '#f44');
}).on('mouseleave', function () {
$t.css('color', 'inherit');
}).on('click', function () {
resetTimer();
}).find('b').on('click', function () {
$timer.remove();
clearInterval(intervalId);
});
// when click member filter, reset timer
$(document).on('mousedown', '.js-member-item', function (e) {
resetTimer();
});
intervalId = setInterval(function () {
var time = Number($t.data('time')) + 1;
if (time > 3 * 60) {
$timer.css('font-size', '100px');
$timer.css('color', 'yellow');
}
$t.data('time', time).text( f(parseInt(time / 60, 10)) + ':' + f(time % 60) );
}, 1000);
}
setTimeout(function() {
init(typeof unsafeWindow !== 'undefined' ? unsafeWindow.jQuery : window.jQuery);
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment