Last active
September 17, 2020 15:04
-
-
Save okj579/445a393a14c8dcd8d736e61656312d80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Imos Redmine Wiedervorlage überfällig | |
// @match *://*.redmine.imos.net/* | |
// @icon https://kunden.redmine.imos.net/favicon.ico | |
// @version 2.1.1 | |
// @downloadURL https://raw.githubusercontent.com/imosnet/userscripts/master/redmine-overdue.user.js | |
// @grant none | |
// ==/UserScript== | |
jQuery(function($) { | |
var $form = $('form.edit_issue'), | |
dueDateSelector = 'input#issue_due_date', | |
$dueDate = $form.find(dueDateSelector), | |
$submit = $form.find('input[name=commit]'), | |
today; | |
$form.on('change.overdue', dueDateSelector, function(){ | |
var val = this.value, | |
color = val < today ? 'red' : val == today ? 'darkorange' : ''; | |
$(this).add(this.labels).css({color: color}); | |
}) | |
$submit.on('click', function(){ | |
if ($dueDate.val() < today) { | |
return confirm("Willst du wirklich das Wiedervorlagedatum in der Vergangenheit lassen?"); | |
} | |
}); | |
function update(){ | |
today = (new Date).toJSON().slice(0,10); | |
$dueDate = $form.find(dueDateSelector); | |
$dueDate.trigger('change.overdue'); | |
} | |
// Wenn Formular aktualisiert wird | |
new MutationObserver(update).observe($('#all_attributes')[0], {childList: true}); | |
(function updateDate() { | |
var now = new Date, | |
tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0); | |
setTimeout(updateDate, tomorrow.getTime() - now.getTime()); | |
update(); | |
})(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment