Skip to content

Commit 0b829b7

Browse files
committed
Add hash saving too
1 parent c070833 commit 0b829b7

File tree

3 files changed

+2440
-0
lines changed

3 files changed

+2440
-0
lines changed

index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<script src="codemirror/markdown/markdown.js"></script>
1010
<script src="codemirror/gfm/gfm.js"></script>
1111
<script src="codemirror/javascript/javascript.js"></script>
12+
<script src="rawinflate.js"></script>
13+
<script src="rawdeflate.js"></script>
1214
<link rel="stylesheet" href="codemirror/lib/codemirror.css">
1315
<link rel="stylesheet" href="default.css">
1416
<style>
@@ -81,6 +83,9 @@
8183
c.className += ' ' + (c.getAttribute('language') || 'no-highlight');
8284
hljs.highlightBlock(c);
8385
}
86+
87+
clearTimeout(hashto);
88+
hashto = setTimeout(updateHash, 1000);
8489
}
8590

8691
var SD = new Showdown.converter();
@@ -137,6 +142,17 @@
137142
}
138143
})
139144

145+
var hashto;
146+
147+
function updateHash(){
148+
window.location.hash = btoa(RawDeflate.deflate(editor.getValue()));
149+
}
150+
151+
if(window.location.hash){
152+
editor.setValue(RawDeflate.inflate(atob(window.location.hash.replace(/^#/, ''))));
153+
}
154+
155+
140156
update(editor);
141157

142158
editor.focus();

0 commit comments

Comments
 (0)