function urltitle(description, id) { // Trim the description to 30 characters let title = description.substring(0, 30); // Replace specific characters with a hyphen title = title.replace(/['"&]/g, ''); title = title.replace(/[^A-Za-z0-9\-_]/g, '-'); // Remove consecutive hyphens title = title.replace(/--+/g, '-'); // Remove leading and trailing hyphens title = title.replace(/^-+|-+$/g, ''); // Convert ID to hexadecimal let hexString = parseInt(id).toString(16); // Combine title and hexString return title + '-' + hexString; } function doRelatedSearch() { var term = $('#apa-search2-text').val(); if (term.length < 1) return; $.ajax({ url: `https://51ce-74-80-248-93.ngrok-free.app/example/${escape(term)}`, dataType: 'json', headers: { 'ngrok-skip-browser-warning': 'true' }, success: function (data) { //debugger; var $parent = $('#apa-search2 div.results'); if ($parent.is(':visible')) { $parent.html(''); $parent.hide(); } //$parent.append('

Search results for '+term+'

'); var $ul = $(''); for (var i in data) { var link = 'https://www.marks4antiques.com/apa/' + data[i].link; var $l = $('
  • '); // linode var pid = btoa(data[i].id + ',max'); var phoid = data[i].image_key ? data[i].image_key : data[i].photo; $l.append('' + data[i].description.substring(0, 30) + ''); $l.append('' + (data[i].description.substring(0, 30)) + ''); $l.append(''); $l.append('[more like this]'); $l.appendTo($ul); } $parent.append($ul); $bottom = '

    ...many more examples with full details are available to our members - Learn more

    \n'; $parent.append($bottom); $parent.slideDown('fast'); }, error: function (err) { var $parent = $('#apa-search div.results'); if ($parent.is(':visible')) { $parent.html(''); $parent.hide(); } $parent.append('

    NO RESULTS. Please modify your search - click here for help

    '); $parent.slideDown('fast'); } }); } var $input = $('').attr('placeholder', 'Search for items...').attr('id', 'apa-search-text'); var $button = $('