Skip to content

Commit

Permalink
Enable zh-cn run script.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptonerdcn committed Dec 12, 2023
1 parent eb920da commit 21663e2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions theme/js/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
const maxWorkers = 1
const worker = new Worker('js/worker.cjs')
const maxWorkers = 1;
let workerPath = '';

// path to mjs. This is the path to the current script, which is the last script in the document.
const scripts = document.getElementsByTagName('script');
const currentScript = scripts[scripts.length - 1];
const scriptUrl = currentScript.src;

if (window.location.pathname.startsWith('/zh-cn')) {
workerPath = new URL('../js/worker.cjs', scriptUrl).toString();
} else {
workerPath = new URL('./worker.cjs', scriptUrl).toString();
}


console.log(workerPath);
const worker = new Worker(workerPath);

window.runFunc = async (cairo_program) => {
return new Promise((resolve, reject) => {
Expand All @@ -19,4 +34,4 @@ window.runFunc = async (cairo_program) => {
reject(error);
};
});
}
};

0 comments on commit 21663e2

Please sign in to comment.