Add message type icons to search result items
This is code I'm working on which auto-suggests message search results as the user types. It works well, but the challenge is that it does not show the "message type" icon next to the results, as shown in this screenshot, such as for "solved" posts vs. normal forum posts.
Does anyone know how to modify the code below to include the message type icons? Thanks!
<#assign result_list_size = 6 />
<#assign results_label = text.format('searchBeforePostField.success-text.title') />
<#-- Search only within current language -->
<#assign languageScope = coreNode.settings.name.get("profile.language")>
<@liaAddScript>
;(function($) {
$(document).ready(function() {
//console.log('got here 1');
function runSearch() {
var subjectValue = $("#lia-subject").val();
if (subjectValue.length > 0) {
//console.log('got here 2');
$.ajax({
type: "GET",
url: "/${community.id}/restapi/vc/search/messages",
data: ({
//"q":subjectValue,
"one_or_more":subjectValue, //less precise search than q
//"filter": "labels%2Clocation",
"location": "category%3A${languageScope}",
"page_size":"${result_list_size}",
"restapi.response_style":"view",
"xslt":"json.xsl"
}),
success: function(result) {
$(".lia-form-subscriptions-fieldset-toggle").before("<div id='ajax_search_results'></div>")
//console.log('got here 3');
//console.log(subjectValue);
if (result.response.messages == null || result.response.messages.message.length < 1) {
//$("#ajax_search_results").empty();
//console.log('got here 4');
} else {
//console.log('got here 5');
var msgMarkup = "<fieldset><legend>${results_label}</legend>";
msgMarkup += "<table class='lia-list-wide'>";
if (typeof result.response.messages.message.length === 'undefined') {
msgMarkup += "<tr><td><a href='" + result.response.messages.message.view_href + "'>" + result.response.messages.message.subject.$ + "</a></td></tr>";
} else {
$.each(result.response.messages.message, function(index, msg) {
msgMarkup += "<tr><td><a href='" + msg.view_href + "'>" + msg.subject.$ + "</a></td></tr>";
});
}
msgMarkup += "</table>";
msgMarkup += "</fieldset>";
$("#ajax_search_results").empty().append(msgMarkup);
}
}
//end Ajax
});
//end if statement
}
//end runSearch function
}
// run on keystroke
$("#lia-subject").on('keyup', function () {
runSearch();
});
//run on page load
runSearch();
}); //end document ready
})(LITHIUM.jQuery);
</@liaAddScript>