Skip to content

Commit 78bd06e

Browse files
author
Kevin Nadro
committed
added mathjax example
1 parent f7ad1be commit 78bd06e

File tree

6 files changed

+30
-15
lines changed

6 files changed

+30
-15
lines changed

algorithm/backtracking/knight's_tour/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"Knight’s tour problem": "A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. If the knight ends on a square that is one knight's move from the beginning square (so that it could tour the board again immediately, following the same path), the tour is closed, otherwise it is open.",
33
"Complexity": {
4-
"time": "Worst O(8<sup>N<sup>2</sup></sup>)",
5-
"space": "Worst O(N<sup>2</sup>)"
4+
"time": "Worst $$O(8^{N^{2}})$$",
5+
"space": "Worst $$O(N^2)$$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Knight%27s_tour'>Wikipedia</a>"

algorithm/backtracking/n_queens/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"Searching"
66
],
77
"Complexity": {
8-
"time": "Worst O(N!)",
9-
"space": "Worst O(N)"
8+
"time": "Worst $$O(N!)$$",
9+
"space": "Worst $$O(N)$$"
1010
},
1111
"References": [
1212
"<a href='http://www.geeksforgeeks.org/backtracking-set-3-n-queen-problem/'>geeksforgeeks</a>"

algorithm/number_theory/sieve_of_eratosthenes/desc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"Sieve of Eratosthenes": "Finding all prime numbers up to a given range.",
33
"Complexity": {
4-
"time": "O(n(log n)(log log n))",
5-
"space": "O(n<sup>1/2</sup>)"
4+
"time": "$$O(n\\,(log\\,n)(log\\,log\\,n))$$",
5+
"space": "$$O(n^{\\frac{1}{2}})$$"
66
},
77
"References": [
88
"<a href='https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes'>Wikipedia</a>"

index.html

+14-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@
1111
<title>Algorithm Visualizer</title>
1212
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">
1313
<link rel="stylesheet" href="public/algorithm_visualizer.min.css">
14+
<script type="text/x-mathjax-config">
15+
MathJax.Hub.Config({
16+
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]},
17+
styles: {
18+
".MJXc-display": {
19+
"display": "inline !important",
20+
"margin": "0 !important"
21+
},
22+
}
23+
});
24+
</script>
25+
<script type="text/javascript" async
26+
src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
27+
</script>
1428
</head>
1529

1630
<body>
@@ -36,7 +50,6 @@ <h3>
3650
<span class="btn-text">Generate</span>
3751
</div>
3852
</div>
39-
4053
<div class="btn" id="btn_share">
4154
<div class="wrapper">
4255
<i class="fa fa-share" aria-hidden="true"></i> Share <input type="text" class="collapse" id="shared">

js/dom/show_algorithm.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
'use strict';
22

33
const app = require('../app');
4-
5-
const {
6-
isScratchPaper
7-
} = require('../utils');
8-
4+
const utils = require('../utils');
95
const showDescription = require('./show_description');
106
const addFiles = require('./add_files');
117

@@ -14,7 +10,7 @@ module.exports = (category, algorithm, data, requestedFile) => {
1410
let category_name;
1511
let algorithm_name;
1612

17-
if (isScratchPaper(category)) {
13+
if (utils.isScratchPaper(category)) {
1814
$menu = $('#scratch-paper');
1915
category_name = 'Scratch Paper';
2016
algorithm_name = algorithm ? 'Shared' : 'Temporary';
@@ -45,4 +41,5 @@ module.exports = (category, algorithm, data, requestedFile) => {
4541

4642
showDescription(data);
4743
addFiles(category, algorithm, files, requestedFile);
44+
utils.renderMathJax();
4845
};

js/utils/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ const getFileDir = (category, algorithm, file) => {
1414
return `./algorithm/${category}/${algorithm}/${file}/`;
1515
};
1616

17+
const renderMathJax = () =>{
18+
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
19+
};
20+
1721
module.exports = {
1822
isScratchPaper,
1923
getAlgorithmDir,
20-
getFileDir
21-
};
24+
getFileDir,
25+
renderMathJax
26+
};

0 commit comments

Comments
 (0)