mirror of https://github.com/istio/istio.io.git
5 lines
2.6 KiB
JavaScript
5 lines
2.6 KiB
JavaScript
const click="click",mouseenter="mouseenter",mouseleave="mouseleave",active="active";
|
|
"use strict";const escapeChars={"¢":"cent","£":"pound","¥":"yen","€":"euro","©":"copy","®":"reg","<":"lt",">":"gt",'"':"quot","&":"amp","'":"#39"},regex=/[¢£¥€©®<>"&']/g;function escapeHTML(a){return a.replace(regex,function(a){return"&"+escapeChars[a]+";"})}function saveFile(a,b){const c=document.createElement("a");c.setAttribute("href","data:text/text;charset=utf-8,"+encodeURI(b)),c.setAttribute("download",a),c.click()}function printText(a){const b=window.open("","","left=0,top=0,width=100,height=100,toolbar=0,scrollbars=0,status=0,location=0,menubar=0",!1);b.document.write("<html><body><pre><code>"+a+"</code></pre></html>"),b.document.close(),b.focus(),b.print(),b.close()}function navigateToUrlOrRoot(a){const b=new XMLHttpRequest;b.open("GET",a,!0),b.onreadystatechange=()=>{if(4===b.readyState&&404===b.status){const b=new URL(a);b.pathname="",a=b.toString()}window.location.href=a},b.send()}function onDOMLoaded(a){listen(document,"DOMContentLoaded",a)}function getById(a){return document.getElementById(a)}function query(a,b){return a.querySelector(b)}function queryAll(a,b){return a.querySelectorAll(b)}function listen(a,b,c){a.addEventListener(b,c)}
|
|
"use strict";const darkThemeClass="dark-theme",darkTheme="Dark Theme",darkThemeItem="dark-theme-item",lightTheme="Light Theme",lightThemeItem="light-theme-item",styleCookie="style";function applyStyleSheet(a){a===darkTheme?document.body.classList.add(darkThemeClass):document.body.classList.remove(darkThemeClass);let b=getById(lightThemeItem);b&&(a===lightTheme?b.classList.add(active):b.classList.remove(active)),b=getById(darkThemeItem),b&&(a===darkTheme?b.classList.add(active):b.classList.remove(active))}function createCookie(a,b,c){let d="";if(c){const a=new Date;a.setTime(a.getTime()+1e3*(60*(60*(24*c)))),d="; expires="+a.toGMTString()}document.cookie=a+"="+b+d+"; path=/"}function readCookie(a){const b=a+"=",d=document.cookie.split(";");for(let e,c=0;c<d.length;c++){for(e=d[c];" "===e.charAt(0);)e=e.substring(1,e.length);if(0===e.indexOf(b)){let a=e.substring(b.length,e.length);return"light"===a?a=lightTheme:"dark"===a&&(a=darkTheme),a}}return null}function loadActiveStyleSheet(){let a=readCookie(styleCookie);null!==a&&applyStyleSheet(a)}loadActiveStyleSheet(),onDOMLoaded(()=>{function a(a){applyStyleSheet(a),createCookie(styleCookie,a)}loadActiveStyleSheet(),listen(getById(lightThemeItem),click,()=>(a(lightTheme),!1)),listen(getById(darkThemeItem),click,()=>(a(darkTheme),!1))});
|
|
|
|
//# sourceMappingURL=styleSwitcher.min.js.map
|