Truncate long URLs in output

This commit is contained in:
Marian Steinbach 2018-04-19 11:37:12 +02:00
parent a80142ee03
commit 7c286ca3ae
1 changed files with 8 additions and 1 deletions

View File

@ -8,6 +8,13 @@ import LazyLoad from 'vanilla-lazyload';
$(function(){
var trunc = function(s, length) {
if (s.length > length) {
s = s.substring(0, length) + '…';
}
return s;
};
var table = null;
$.getJSON('data/screenshots.json', function(screenshots){
@ -39,7 +46,7 @@ $(function(){
row.append('<td>' + (item.meta.city === null ? '' : item.meta.city) + '</td>');
// input URL
row.append('<td><a href="' + item.input_url + '">' + punycode.toUnicode(item.input_url) + '</a></td>');
row.append('<td><a href="' + item.input_url + '">' + trunc(punycode.toUnicode(item.input_url), 60) + '</a></td>');
// score
row.append('<td>' + item.score.toFixed(1) + '</td>');