document.body.addEventListener('click', function(e) {
if ( e.target.name === 'rating' ) {
var request = new XMLHttpRequest();
request.open('post', '/rating/');
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
request.send('quote=' + e.target.parentNode.getAttribute('data-quote-id') + '&rating=' + e.target.value + '&photo=' + document.getElementsByClassName('picture')[0].src.split('/').pop());
document.getElementById('thank-you').className = 'show';
}
});
if (document.getElementById('pagination-input')) {
document.getElementById('pagination-input').addEventListener('keypress', function(e) {
if (e.keyCode === 13) {
var page = parseInt(e.target.value, 10);
if ( page >= 1 && page <= parseInt(document.getElementById('pagination-total').innerHTML, 10) ) {
var path = location.pathname;
var position = path.indexOf('Seite/');
if ( position ) {
path = path.substr(0, position);
}
location.href = path + (page === 1 ? '' : 'Seite/' + page + '/') + location.search;
}
}
});
}