|
@ -7,11 +7,16 @@ |
|
|
<p> |
|
|
<p> |
|
|
{title} by {author}, id = {_id} |
|
|
{title} by {author}, id = {_id} |
|
|
</p> |
|
|
</p> |
|
|
<button onclick={loadPost(this._id)}>Load it</button> |
|
|
<button |
|
|
|
|
|
class="btn btn-primary" |
|
|
|
|
|
onclick={loadPost(this._id)}> |
|
|
|
|
|
Load it |
|
|
|
|
|
</button> |
|
|
</li> |
|
|
</li> |
|
|
</ul> |
|
|
</ul> |
|
|
<span>title</span><input ref="title"> |
|
|
<span>title</span><input ref="title"> |
|
|
<span>author</span><input ref="author"></input> |
|
|
<span>author</span><input ref="author"></input> |
|
|
|
|
|
<span>Editing post {_id}</span> |
|
|
<textarea onfocus={clearplaceholder} |
|
|
<textarea onfocus={clearplaceholder} |
|
|
onblur={checkplaceholder} |
|
|
onblur={checkplaceholder} |
|
|
oninput={echo} |
|
|
oninput={echo} |
|
@ -46,6 +51,8 @@ this.querystring = querystring; |
|
|
this.converter = new showdown.Converter(); |
|
|
this.converter = new showdown.Converter(); |
|
|
this.converted = "<h3>Nothing here yet</h3>"; |
|
|
this.converted = "<h3>Nothing here yet</h3>"; |
|
|
|
|
|
|
|
|
|
|
|
this._id = false; |
|
|
|
|
|
|
|
|
this.placeholderText = "Write a post!" |
|
|
this.placeholderText = "Write a post!" |
|
|
this.placeholder = this.placeholderText; |
|
|
this.placeholder = this.placeholderText; |
|
|
this.focused = false; |
|
|
this.focused = false; |
|
@ -87,6 +94,10 @@ submit() { |
|
|
"csrf_token" : this.opts.csrf_token |
|
|
"csrf_token" : this.opts.csrf_token |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (this._id) { |
|
|
|
|
|
post["_id"] = this._id; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var headers = { |
|
|
var headers = { |
|
|
"headers" : { |
|
|
"headers" : { |
|
|
"Content-Type" : "application/x-www-form-urlencoded", |
|
|
"Content-Type" : "application/x-www-form-urlencoded", |
|
@ -111,6 +122,9 @@ loadPost(_id) { |
|
|
axios.get(`/blog/getpost/${_id}`) |
|
|
axios.get(`/blog/getpost/${_id}`) |
|
|
.then(function(resp) { |
|
|
.then(function(resp) { |
|
|
self.refs.textarea.value = resp.data.content; |
|
|
self.refs.textarea.value = resp.data.content; |
|
|
|
|
|
self.refs.title.value = resp.data.title; |
|
|
|
|
|
self.refs.author.value = resp.data.author; |
|
|
|
|
|
self._id = _id; |
|
|
self.focused = true; |
|
|
self.focused = true; |
|
|
self.update(); |
|
|
self.update(); |
|
|
self.echo(); |
|
|
self.echo(); |
|
|