diff --git a/static/index.html b/static/index.html
index 9895d11a4..b4cf0b6de 100644
--- a/static/index.html
+++ b/static/index.html
@@ -3,7 +3,6 @@
KaTeX Test
-
@@ -11,5 +10,7 @@
+
+
diff --git a/static/main.css b/static/main.css
index ab9f3d0bc..a7f178a9d 100644
--- a/static/main.css
+++ b/static/main.css
@@ -4,7 +4,7 @@ body {
font-size: 72px;
}
-input {
+#input {
margin: 0px;
font-size: 100%;
width: 100%;
diff --git a/static/main.js b/static/main.js
index 63f817928..bf497edfd 100644
--- a/static/main.js
+++ b/static/main.js
@@ -1,6 +1,7 @@
-window.onload = function() {
+function init() {
var input = document.getElementById("input");
var math = document.getElementById("math");
+ var permalink = document.getElementById("permalink");
if ("oninput" in input) {
input.addEventListener("input", reprocess, false);
@@ -8,9 +9,20 @@ window.onload = function() {
input.attachEvent("onkeyup", reprocess);
}
+ permalink.addEventListener("click", function() {
+ window.location.search = "?text=" + encodeURIComponent(input.value);
+ });
+
+ var match = (/(?:^\?|&)text=([^&]+)/).exec(window.location.search);
+ if (match) {
+ input.value = decodeURIComponent(match[1]);
+ }
+
reprocess();
function reprocess() {
katex.process(input.value, math);
}
-};
+}
+
+init();