Auto truncate of too long descriptions

This commit is contained in:
phl0
2025-04-17 09:36:39 +02:00
parent 4138bd8c65
commit cfcbc96b31
2 changed files with 30 additions and 4 deletions

View File

@@ -5,6 +5,8 @@
var lang_qso_title_previous_contacts = "<?= __("Previous Contacts"); ?>";
var lang_qso_title_times_worked_before = "<?= __("times worked before"); ?>";
var lang_qso_title_not_worked_before = "<?= __("Not worked before"); ?>";
var lang_qso_more = "<?= __("more"); ?>";
var lang_qso_less = "<?= __("less"); ?>";
var lang_dxccsummary_for = "<?= __("DXCC Summary for "); ?>";
var lang_lotw_upload_day_ago = "<?= __("LoTW User. Last upload was 1 day ago."); ?>";
var lang_lotw_upload_days_ago = "<?= __("LoTW User. Last upload was %x days ago."); ?>"; // due to the way the string is built (PHP to JS), %x is replaced with the number of days

View File

@@ -825,13 +825,37 @@ $("#callsign").on("focusout", function () {
$.getJSON(base_url + 'index.php/lookup/ham_of_note/' + $('#callsign').val().toUpperCase().replaceAll('Ø', '0').replaceAll('/','-'), function (result) {
if (result) {
$('#ham_of_note_info').text(result.description);
$('#ham_of_note_link').html(" "+result.linkname);
$('#ham_of_note_link').attr('href', result.link);
$('#ham_of_note_info').html('<span class="minimize">'+result.description+'</span>');
if (result.link != null) {
$('#ham_of_note_link').html(" "+result.linkname);
$('#ham_of_note_link').attr('href', result.link);
}
$('#ham_of_note_line').show("slow");
var minimized_elements = $('span.minimize');
var maxlen = 50;
minimized_elements.each(function(){
var t = $(this).text();
if(t.length < maxlen) return;
$(this).html(
t.slice(0,maxlen)+'<span>... </span><a href="#" class="more">'+lang_qso_more+'</a><span style="display:none;">'+ t.slice(maxlen,t.length)+' <a href="#" class="less">'+lang_qso_less+'</a></span>'
);
});
$('a.more', minimized_elements).click(function(event){
event.preventDefault();
$(this).hide().prev().hide();
$(this).next().show();
});
$('a.less', minimized_elements).click(function(event){
event.preventDefault();
$(this).parent().hide().prev().show().prev().show();
});
}
});
$('#dxcc_id').val(result.dxcc.adif).multiselect('refresh');
await updateStateDropdown('#dxcc_id', '#stateInputLabel', '#location_us_county', '#stationCntyInputEdit');
if (result.callsign_cqz != '' && (result.callsign_cqz >= 1 && result.callsign_cqz <= 40)) {