Files
zulip/static/js/realm_playground.js
Sumanth V Rao a510dac024 settings_playground: Add UI to create a new playground.
The design of the form is similar to the linkifiers page
and is styled similarly.

The introduction text for "Code playgrounds" is improved
with more details and examples.

Also, we can remove the hardcoded playground and the fix
we had previously done to prevent breaking the hardcoded
playground.
2021-05-04 11:39:33 -07:00

27 lines
853 B
JavaScript

const map_language_to_playground_info = new Map();
export function update_playgrounds(playgrounds_data) {
map_language_to_playground_info.clear();
for (const data of Object.values(playgrounds_data)) {
const element_to_push = {
id: data.id,
name: data.name,
url_prefix: data.url_prefix,
};
if (map_language_to_playground_info.has(data.pygments_language)) {
map_language_to_playground_info.get(data.pygments_language).push(element_to_push);
} else {
map_language_to_playground_info.set(data.pygments_language, [element_to_push]);
}
}
}
export function get_playground_info_for_languages(lang) {
return map_language_to_playground_info.get(lang);
}
export function initialize(playground_data) {
update_playgrounds(playground_data);
}