Browse Source

Add comments

master
Arsen Musayelyan 6 months ago
parent
commit
f45802f372
  1. 6
      internal/cards/calc.go
  2. 2
      internal/cards/plot.go
  3. 2
      main.go

6
internal/cards/calc.go

@ -26,9 +26,11 @@ import (
)
const calcExtraHead = `
<!-- Import KaTeX for math rendering -->
<link rel="stylesheet" href="/static/katex.min.css">
<script defer src="/static/katex.min.js"></script>
<!-- Import Nerdamer for equation evaluator -->
<script src="/static/nerdamer.core.js"></script>
<script src="/static/Algebra.js"></script>
<script src="/static/Calculus.js"></script>
@ -38,7 +40,9 @@ const solveRenderScript = `
<div id="calc-content" class="subtitle mx-2 my-0"></div>
<script>
window.onload = () => {
latex = nerdamer.convertToLaTeX(nerdamer('%s').toString())
// Execute input and get output as LaTeX
latex = nerdamer('%s').latex()
// Use KaTeX to render output to #calc-content div
katex.render(latex, document.getElementById('calc-content'))
}
</script>`

2
internal/cards/plot.go

@ -35,6 +35,7 @@ const plotExtraHead = `
const plotScript = `
<div id="plot-content" class="container"></div>
<script>
// Create function to draw plot in #plot-content
plotFn = () => functionPlot({
target: '#plot-content',
grid: true,
@ -43,6 +44,7 @@ plotFn = () => functionPlot({
fn: '%s'
}]
})
// Create resize observer that runs plot function
new ResizeObserver(plotFn).observe(document.getElementById('plot-content'))
</script>`

2
main.go

@ -26,6 +26,8 @@ import (
"net"
"net/http"
"os"
"path"
"path/filepath"
"strconv"
"strings"
"time"

Loading…
Cancel
Save