widgetize: Convert widgets from object to Map.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-02-06 03:45:39 +00:00 committed by Tim Abbott
parent 88c73602e0
commit 56436188a4
1 changed files with 8 additions and 8 deletions

View File

@ -1,9 +1,9 @@
const widgets = {}; const widgets = new Map([
["poll", poll_widget],
widgets.poll = poll_widget; ["tictactoe", tictactoe_widget],
widgets.tictactoe = tictactoe_widget; ["todo", todo_widget],
widgets.todo = todo_widget; ["zform", zform],
widgets.zform = zform; ]);
const widget_contents = {}; const widget_contents = {};
exports.widget_contents = widget_contents; exports.widget_contents = widget_contents;
@ -23,7 +23,7 @@ exports.activate = function (in_opts) {
events.shift(); events.shift();
if (!widgets[widget_type]) { if (!widgets.has(widget_type)) {
blueslip.warn('unknown widget_type', widget_type); blueslip.warn('unknown widget_type', widget_type);
return; return;
} }
@ -51,7 +51,7 @@ exports.activate = function (in_opts) {
// the HTML that will eventually go in this div. // the HTML that will eventually go in this div.
widget_elem = $('<div>').addClass('widget-content'); widget_elem = $('<div>').addClass('widget-content');
widgets[widget_type].activate({ widgets.get(widget_type).activate({
elem: widget_elem, elem: widget_elem,
callback: callback, callback: callback,
message: message, message: message,