diff --git a/static/js/poll_widget.js b/static/js/poll_widget.js index 7434f26ec43faa..30d51e124626d3 100644 --- a/static/js/poll_widget.js +++ b/static/js/poll_widget.js @@ -3,7 +3,10 @@ import render_widgets_poll_widget_results from "../templates/widgets/poll_widget import * as people from "./people"; -export class PollData { +const people = require("./people"); +const rendered_markdown = require("./rendered_markdown"); + +class PollData { // This object just holds data for a poll, although it // works closely with the widget's concept of how data // should be represented for rendering, plus how the @@ -204,8 +207,10 @@ export function activate(opts) { const waiting = !is_my_poll && !has_question; const author_help = is_my_poll && !has_question; + const content = elem.find(".poll-widget"); elem.find(".poll-question-header").toggle(!input_mode); elem.find(".poll-question-header").text(question); + rendered_markdown.update_elements(content); elem.find(".poll-edit-question").toggle(can_edit); update_edit_controls(); diff --git a/static/js/rendered_markdown.js b/static/js/rendered_markdown.js index 4c7240ffb35110..9e66c5e0250898 100644 --- a/static/js/rendered_markdown.js +++ b/static/js/rendered_markdown.js @@ -169,6 +169,26 @@ export const update_elements = (content) => { } }); + content.find("h4.poll-question-header").each(function () { + if ($(this).text().includes("/) + .pop(); + const time_string = $(this) + .text() + .match(//) + .pop(); + const rendered_time = timerender.render_markdown_timestamp(parseISO(time_string), text); + $(this).text( + $(this) + .text() + .replace(//, ""), + ); + $(this).append(``); + } + }); + content.find("span.timestamp-error").each(function () { const time_str = $(this).text().replace("Invalid time format: ", ""); const text = i18n.t("Invalid time format: __timestamp__", {timestamp: time_str});