Skip to content

Commit

Permalink
Add path resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-karpovich committed May 29, 2019
1 parent 1ac2f3d commit 4cbf2bf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const browserSync = require('browser-sync'),
const srcPath = {
'src': './src',
'html': './src/**/*.html',
'img': './src/**/*.+(jpg|jpeg|png|svg|gif)',
'img': './src/**/*.+(jpg|jpeg|png|svg|gif|ico)',
'css': ['./src/!(css|js)*/**/*.css'],
'cssLint': './src/**/*.css',
'js': './src/!(js|completed)*/**/*.js',
Expand Down
Binary file added src/favicon.ico
Binary file not shown.
14 changes: 9 additions & 5 deletions src/js/highlight/theme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@

let linkTheme = null;
let head = document.getElementsByTagName("head")[0];

let isMainPage = false;
if (document.body.children[0].getAttribute('src') === 'js/theme.js') {
isMainPage = true;
}
function resolvePath(path) {
return (isMainPage ? '' : '../../') + path;
}
function setTheme(themeName) {
if (linkTheme) {
head.removeChild(linkTheme);
Expand All @@ -9,11 +17,7 @@ function setTheme(themeName) {
linkTheme.rel = "stylesheet";
linkTheme.id = "theme";
linkTheme.type = "text/css";
if (document.body.children[0].getAttribute('src') === 'js/theme.js') {
linkTheme.href = `css/theme/${themeName}.css`;
} else {
linkTheme.href = `../../css/theme/${themeName}.css`;
}
linkTheme.href = resolvePath(`css/theme/${themeName}.css`);
head.appendChild(linkTheme);
}
const defaultTheme = "beige";
Expand Down
18 changes: 9 additions & 9 deletions src/js/reveal-initializer.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
(function (window) {

if (!window.Reveal) {
throw new Error("Reveal.js not found!");
throw new Error('Reveal.js not found!');
}

Reveal.initialize({
controls: true,
controlsTutorial: true,
controlsBackArrows: "faded",
controlsBackArrows: 'faded',
progress: false,
slideNumber: true,
history: true,
Expand All @@ -16,30 +16,30 @@
touch: true,
hideInactiveCursor: true,
hideAddressBar: true,
transition: "slide", // none/fade/slide/convex/concave/zoom
transition: 'slide', // none/fade/slide/convex/concave/zoom
});
Reveal.addEventListener("ready", function (event) {
Reveal.addEventListener('ready', function (event) {
presentable.toc({
framework: "revealjs"
framework: 'revealjs'
});
});

window.addEventListener("load", function () {
window.addEventListener('load', function () {

if (typeof (Worker) === undefined) {

return false;

}
let codeBlocks = document.getElementsByTagName("code");
let codeBlocks = document.getElementsByTagName('code');
if (codeBlocks) {

let worker = new Worker("../../js/worker.js");
let worker = new Worker(resolvePath('js/worker.js'));
worker.onmessage = function (event) {

let data = JSON.parse(event.data);
codeBlocks[data.index].innerHTML = data.result;
codeBlocks[data.index].classList.add("hljs");
codeBlocks[data.index].classList.add('hljs');

}
for (let i = 0; i < codeBlocks.length; ++i) {
Expand Down

0 comments on commit 4cbf2bf

Please sign in to comment.