Skip to content

Commit

Permalink
fix bug where Markdown content was not successfully loaded from local…
Browse files Browse the repository at this point in the history
…Storage
  • Loading branch information
jhvst committed Dec 8, 2014
1 parent 8c94217 commit 857d96c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions templates/post/edit.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@
localStorage.removeItem({{.Slug}});
localStorage.removeItem({{.Title}});
var html = document.getElementById("text").innerHTML;
{{if Markdown}}
{{else}}
{{if not Markdown}}
document.new.content.value = html;
{{end}}
return
Expand Down
7 changes: 3 additions & 4 deletions templates/post/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
// LocalStorage loops(?) to save both post title and content to cache.
// Looks ugly, but better than AJAX based failover, right?
// Modified version of this: https://gist.github.com/addyosmani/d1f3ca715ac902788c2d
{{if .Markdown}}
{{if Markdown}}

with({
l: localStorage // Alias for localStorage, where we'll store text content
// This is some sort of variable initialization. It also checks whether there is anything in cache already.
}) with(document.getElementById("text")) if (l.getItem("c") != null) {
value = [l.c], // Replace placeholder text with localstorage content.
oninput = function () {
l.c = value // Save HTML context to localStorage.
l.c = value // Save Markdown context to localStorage.
}
} else {
oninput = function () {
Expand Down Expand Up @@ -70,8 +70,7 @@
localStorage.removeItem("t");
localStorage.removeItem("c");
var html = document.getElementById("text").innerHTML;
{{if Markdown}}
{{else}}
{{if not Markdown}}
document.new.content.value = html;
{{end}}
return
Expand Down

0 comments on commit 857d96c

Please sign in to comment.