update docs

This commit is contained in:
Leo Horie 2016-06-20 09:22:00 -04:00
parent b9ce90765d
commit ce0c30a235
11 changed files with 849 additions and 236 deletions

View file

@ -11,7 +11,7 @@ var api = {
},
thread : function(id) {
T.timeEnd("Setup")
return request({method: "GET", url: T.apiUrl + "/comments/" + id}).then(T.transformResponse)
return request({method: "GET", url: T.apiUrl + "/comments/" + id}).map(T.transformResponse)
},
newThread : function(text) {
return request({method: "POST", url: T.apiUrl + "/threads/create",data: {text: text}})
@ -24,20 +24,19 @@ var api = {
var threads = [], current = null, loaded = false, error = false, notFound = false
function loadThreads() {
loaded = false
api.home().then(function(response) {
api.home().map(function(response) {
document.title = "ThreaditJS: Mithril | Home"
threads = response.data
loaded = true
}, function() {
loaded = error = true
})
.then(m.redraw)
}
function loadThread(id) {
loaded = false
notFound = false
api.thread(id).then(function(response) {
api.thread(id).map(function(response) {
document.title = "ThreaditJS: Mithril | " + T.trimTitle(response.root.text);
loaded = true
current = response
@ -46,7 +45,6 @@ function loadThread(id) {
if (response.status === 404) notFound = true
else error = true
})
.then(m.redraw)
}
function unloadThread() {
current = null
@ -54,11 +52,10 @@ function unloadThread() {
function createThread() {
var threadText = document.getElementById("threadText")
api.newThread(threadText.value).then(function(response) {
api.newThread(threadText.value).map(function(response) {
threadText.value = "";
threads.push(response.data);
})
.then(m.redraw)
return false
}
@ -69,12 +66,11 @@ function showReplying(vnode) {
}
function submitComment(vnode) {
api.newComment(vnode.state.newComment, vnode.attrs.node.id).then(function(response) {
api.newComment(vnode.state.newComment, vnode.attrs.node.id).map(function(response) {
vnode.state.newComment = ""
vnode.state.replying = false
vnode.attrs.node.children.push(response.data)
})
.then(m.redraw)
return false
}