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 doSearch() { var term = $('#apa-search-text').val(); if (term.length < 1) return; sessionStorage.setItem("search_word", term); $.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-search div.results'); if ($parent.is(':visible')) { $parent.html(''); $parent.hide(); } $parent.append('
Search results for ' + term + '
'); var $ul = $('