Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fabiomontefuscolo/efad3ad628e03829c7f6beca961cf5c5 to your computer and use it in GitHub Desktop.
Save fabiomontefuscolo/efad3ad628e03829c7f6beca961cf5c5 to your computer and use it in GitHub Desktop.
Customize redmine time tracker page
// ==UserScript==
// @name HacklabCode
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://code.hacklab.com.br/time_entries/new
// @match https://code.hacklab.com.br/time_entries/*/edit
// @grant none
// ==/UserScript==
(function() {
'use strict';
var $date = $('#time_entry_spent_on');
var $date_row = $date.parent();
var $pane = $date_row.parent();
var $cal_row = $('<div>')
.css('padding-left', '180px')
.insertAfter($date_row);
var $cal_style = $('<style>')
.attr('type', 'text/css')
.text(
'.ui-datepicker-current-day .ui-state-active,'
+ '.ui-widget-content .ui-datepicker-current-day .ui-state-active,'
+ '.ui-widget-header .ui-datepicker-current-day .ui-state-active'
+ '{ background-color: green; background-image: none; color: white; }'
).insertBefore($cal_row);
var cur_date = $date.val();
$cal_row.datepicker({
altField: "#time_entry_spent_on",
altFormat: 'yy-mm-dd',
dateFormat: "yy-mm-dd",
numberOfMonths: 3,
showCurrentAtPos: 1,
onSelect: function(dateText, datePicker) { datePicker.drawMonth += $cal_row.datepicker("option", "showCurrentAtPos"); }
});
$cal_row.datepicker('setDate', cur_date);
// coloca um textarea para o campo de comentários
$('#time_entry_comments').each(function(i, el) {
var attrs = {'rows': 5};
var value = $(el).val();
$.each(el.attributes, function(j, attr) {
attrs[attr.nodeName] = attr.nodeValue;
});
$('<textarea>', attrs).insertAfter(el).val(value);
$(el).remove();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment