sS gazelleBot_suggestPostTypes(Cl postTypes, SS jsonData, bool alwaysShowText default false) { S f_type = cast jsonData.get("f_type"); postTypes = listWithout(postTypes, dropTrailingRoundBracketStuff(f_type)); ret !alwaysShowText && empty(postTypes) ? "" : "Suggested post " + (l(postTypes) == 1 ? "type" : "types") + ": " + joinWithCommaOr("-", safeMap(type -> { bool selected = eq(f_type, type); if (selected) ret span_title("Post type is already selected", b(htmlEncode2(type))); ret ahref_js([[ const selectize = $("select[name=f_type]").data('selectize'); //console.log("selectize: " + selectize); var type = ]] + jsQuote(type) + [[; selectize.addOption({value: type, text: type}); selectize.setValue(type); ]], htmlEncode2(type), title := "Click to accept suggestion"); }, takeFirst(3, postTypes))); }