Skip to content

Commit dc1ceda

Browse files
authored
Merge pull request algorithm-visualizer#209 from nadr0/adding-mathjax
Adding mathjax
2 parents 252a10a + 0ccdcf1 commit dc1ceda

File tree

6 files changed

+33
-15
lines changed

6 files changed

+33
-15
lines changed

algorithm/backtracking/knight's_tour/desc.json

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 17 additions & 1 deletion
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">
@@ -109,6 +122,9 @@ <h3>
109122
<a href="https://github.com/simonwhitaker/github-fork-ribbon-css">
110123
<button class="indent">simonwhitaker/github-fork-ribbon-css</button>
111124
</a>
125+
<a href="https://github.com/mathjax/MathJax">
126+
<button class="indent">mathjax/MathJax</button>
127+
</a>
112128
</div>
113129
</div>
114130
<a class="github-fork-ribbon left-bottom" href="http://github.com/parkjs814/AlgorithmVisualizer"

js/dom/show_algorithm.js

Lines changed: 3 additions & 6 deletions
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

Lines changed: 7 additions & 2 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy