MCPcopy Index your code
hub / github.com/zhongsp/TypeScript / set_theme

Function set_theme

docs/book.js:327–367  ·  view source on GitHub ↗
(theme, store = true)

Source from the content-addressed store, hash-verified

325 }
326
327 function set_theme(theme, store = true) {
328 let ace_theme;
329
330 if (theme == 'coal' || theme == 'navy') {
331 stylesheets.ayuHighlight.disabled = true;
332 stylesheets.tomorrowNight.disabled = false;
333 stylesheets.highlight.disabled = true;
334
335 ace_theme = "ace/theme/tomorrow_night";
336 } else if (theme == 'ayu') {
337 stylesheets.ayuHighlight.disabled = false;
338 stylesheets.tomorrowNight.disabled = true;
339 stylesheets.highlight.disabled = true;
340 ace_theme = "ace/theme/tomorrow_night";
341 } else {
342 stylesheets.ayuHighlight.disabled = true;
343 stylesheets.tomorrowNight.disabled = true;
344 stylesheets.highlight.disabled = false;
345 ace_theme = "ace/theme/dawn";
346 }
347
348 setTimeout(function () {
349 themeColorMetaTag.content = getComputedStyle(document.documentElement).backgroundColor;
350 }, 1);
351
352 if (window.ace && window.editors) {
353 window.editors.forEach(function (editor) {
354 editor.setTheme(ace_theme);
355 });
356 }
357
358 var previousTheme = get_theme();
359
360 if (store) {
361 try { localStorage.setItem('mdbook-theme', theme); } catch (e) { }
362 }
363
364 html.classList.remove(previousTheme);
365 html.classList.add(theme);
366 updateThemeSelected();
367 }
368
369 // Set theme
370 var theme = get_theme();

Callers 1

book.jsFile · 0.85

Calls 3

get_themeFunction · 0.85
updateThemeSelectedFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected