agenda: week number displayed next to the selected date

Closes #3113x
This commit is contained in:
Serghei Mihai 2013-07-30 14:07:02 +02:00
parent 816ea06c76
commit c4ef26cbd6
2 changed files with 7 additions and 2 deletions

View File

@ -8,10 +8,15 @@
}
});
$('#date-selector').on('change', function () {
var date = $(this).datepicker('getDate')
var date = $(this).datepicker('getDate');
var year = date.getFullYear();
var month = date.getMonth() + 1;
var first_jan = new Date(year, 0, 1);
var dayOfYear = ((date - first_jan + 1) / 86400000);
var week = Math.ceil(dayOfYear/7);
var day = date.getDate();
var current_date = $(this).attr('value');
$(this).attr('value', current_date + ' (' + week + ')');
var url_tpl = $(this).data('url');
var new_date = year + '-' + month + '-' + day;
var url = url_tpl.replace(/[0-9]{4}-[0-9]{2}-[0-9]{2}/, new_date);

View File

@ -3,7 +3,7 @@
<div id="datesel">
<a id="arrow" href="{% url url_name date=previous_month service=service %}">««</a>&nbsp;
<a id="arrow" href="{% url url_name date=previous_day service=service %}">«</a>
<input data-url="{% url url_name date=date service=service %}" id="date-selector" value="{{ date|date:"DATE_FORMAT"|title }}" readonly="readonly" />
<input data-url="{% url url_name date=date service=service %}" id="date-selector" value="{{ date|date:"DATE_FORMAT"|title}} ({{date|date:"W"}})" readonly="readonly" />
<a id="arrow" href="{% url url_name date=next_day service=service %}">»</a>&nbsp;
<a id="arrow" href="{% url url_name date=next_month service=service %}">»»</a>
{% if date != today %}<a id="datesel-today-link" href="{% url url_name service=service date=today %}">Aujourd'hui</a>{% endif %}