Fix special font script

parent 5c0f6aed
Pipeline #512 passed with stage
in 2 minutes and 22 seconds
......@@ -5,8 +5,7 @@
<span><a href="https://gitlab.poul.org/sito/poul-jekyll">Source code</a></span>
<span class="desktop-only"><a href="#" id="fix-sotto-storto-link"
onclick="fixSottoStortoCit(); return false;">Fix rotation</a></span>
<span><a href="#" id="fix-open-dyslexic-link"
onclick="fixOpenDyslexic(); return false;">Enable futuristic font</a></span>
<span><a href="#" id="fix-open-dyslexic-link">Enable futuristic font</a></span>
</div>
<div class="socials">
{% if site.social.telegram %}
......
......@@ -80,8 +80,6 @@
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="{{ '/site/assets/vendor/leaflet@1.6.0/leaflet.js' | static_url }}"></script>
<script>
// share the static_url with js
const static_url = "{{ site.static_url }}"
</script>
<!-- OpenDyslexic script -->
<script src="{{ '/assets/js/special_font.js' | relative_url }}"></script>
</head>
......@@ -25,37 +25,3 @@ function fixSottoStortoCit() {
document.getElementById('fix-sotto-storto-link').text = "Lol no, put it back";
}
}
// opendyslexic mod
var __opendyslexic_loaded = false;
function fixOpenDyslexic() {
if (!__opendyslexic_loaded) {
var od_font = document.createElement('style');
const font_path_regular = static_url + 'site/assets/fonts/opendyslexic/compiled/OpenDyslexic-Regular.otf';
const font_path_bold = static_url + 'site/assets/fonts/opendyslexic/compiled/OpenDyslexic-Bold.otf';
const font_path_italic = static_url + 'site/assets/fonts/opendyslexic/compiled/OpenDyslexic-Italic.otf';
od_font.appendChild(document.createTextNode(
// font-face
`@font-face { font-family: OpenDyslexic; src: url('${font_path_regular}') format('opentype'); }\n`
+ `@font-face { font-family: OpenDyslexic; font-weight: bold; src: url('${font_path_bold}') format('opentype'); }\n`
+ `@font-face { font-family: OpenDyslexic; font-style: italic; src: url('${font_path_italic}') format('opentype'); }\n`
// class rule
+ ".opendyslexic, .opendyslexic p, .opendyslexic a, .opendyslexic span, .opendyslexic div" +
".opendyslexic h1, .opendyslexic h2 , .opendyslexic h3 { font-family: 'OpenDyslexic' !important }"
));
document.getElementsByTagName("head")[0].appendChild(od_font);
__opendyslexic_loaded = true
}
if (document.body.classList.contains("opendyslexic")) {
document.body.classList.remove("opendyslexic");
document.getElementById('fix-open-dyslexic-link').innerHTML = 'Enable futuristic font'
} else {
document.body.classList.add("opendyslexic");
document.getElementById('fix-open-dyslexic-link').innerHTML = 'Disable futuristic font'
}
}
---
---
"use strict";
const font_path_regular = "{{ 'site/assets/fonts/opendyslexic/compiled/OpenDyslexic-Regular.otf' | static_url }}";
const font_path_bold = "{{ 'site/assets/fonts/opendyslexic/compiled/OpenDyslexic-Bold.otf' | static_url }}";
const font_path_italic = "{{ 'site/assets/fonts/opendyslexic/compiled/OpenDyslexic-Italic.otf' | static_url }}";
var __opendyslexic_loaded = false;
document.addEventListener('DOMContentLoaded', () => {
document.querySelector("#fix-open-dyslexic-link").addEventListener("click", () => {
if (!__opendyslexic_loaded) {
let od_font = document.createElement('style');
od_font.appendChild(document.createTextNode(
// font-face
`@font-face { font-family: OpenDyslexic; src: url('${font_path_regular}') format('opentype'); }\n`
+ `@font-face { font-family: OpenDyslexic; font-weight: bold; src: url('${font_path_bold}') format('opentype'); }\n`
+ `@font-face { font-family: OpenDyslexic; font-style: italic; src: url('${font_path_italic}') format('opentype'); }\n`
// class rule
+ ".opendyslexic, .opendyslexic p, .opendyslexic a, .opendyslexic span, .opendyslexic div" +
".opendyslexic h1, .opendyslexic h2 , .opendyslexic h3 { font-family: 'OpenDyslexic' !important }"
));
document.getElementsByTagName("head")[0].appendChild(od_font);
__opendyslexic_loaded = true
}
if (document.body.classList.contains("opendyslexic")) {
document.body.classList.remove("opendyslexic");
document.getElementById('fix-open-dyslexic-link').innerHTML = 'Enable futuristic font'
} else {
document.body.classList.add("opendyslexic");
document.getElementById('fix-open-dyslexic-link').innerHTML = 'Disable futuristic font'
}
});
});
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment