Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

218 lines (191 sloc) 6.269 kb
token = null
parentID = null
comment_post_id = null
post_user = null
mainLoad = ->
document.addEventListener "deviceready", postLoad, false
postLoad = ->
hideItems()
indexLoadUrl()
indexLoadUrl = ->
hideItems()
urlLink = "http://notesolution.showoff.io/api/v1/posts"
$.getJSON urlLink, (data) ->
$("#contentlist").empty()
i = 0
while i < data.length
post_data = data[i]
getUser(post_data.id)
$("#contentlist").append "<li> <div class='post_item'> <a href=\"#contentpage\" onClick=\"generateContent('" + post_data.id + "');\"> " + post_data.name + "</a> </div> </li>"
$("#content").append "<div class='post' style='display: none;'>" + post_data.url + "</div>"
i++
$("#contentlist").listview "refresh"
$("#account_sign_out").css "display", "none"
getUser = (postID) ->
postID = parseInt(postID)
urlLink = "http://notesolution.showoff.io/api/v1/posts/find_posted_user"
$.ajax
type: "POST"
url: urlLink
data:
id: postID
success: (data) ->
post_user = data.email
alert(post_user)
generateContent = (postID) ->
postID = parseInt(postID)
urlLink = "http://notesolution.showoff.io/api/v1/posts"
$.getJSON urlLink, (dataJSONList) ->
i = 0
while i < dataJSONList.length
post_data = dataJSONList[i]
postDataID = post_data.id
if postID is postDataID
postUrl = dataJSONList[i].url
$.getJSON "http://viewtext.org/api/text?url=" + postUrl + "&callback=?", (data) ->
$("#content").html data.content
$("#comment_list").empty()
commentLoad post_data.id
comment_post_id = post_data.id
i++
createLink = ->
url = document.getElementById("url").value
title = document.getElementById("title").value
urlLink = "http://notesolution.showoff.io/api/v1/posts"
if token?
urlLink = urlLink + "?auth_token=" + token
$.ajax
type: "POST"
url: urlLink
data:
url: url,
name: title,
kind: 'url'
success: ->
hideItems()
indexLoadUrl()
$.mobile.changePage "#mainpage"
else
alert "you must sign in first"
getToken = ->
email = document.getElementById("email").value
password = document.getElementById("password").value
data = "email=" + email + "&password=" + password
url = "http://notesolution.showoff.io/api/v1/tokens.json"
$.ajax
type: "POST"
url: url
data:
email: email
password: password
success: (data) ->
token = data.token
hideItems()
$.mobile.changePage "#mainpage"
$("#account_sign_in").css "display", "none"
$("#account_sign_out").css "display", "block"
signOutLoad = ->
logoutURL = "http://notesolution.showoff.io/api/v1/tokens/" + token + ".json"
$.ajax
type: "DELETE"
url: logoutURL
success: ->
token = null
$("#email").val ""
$("#password").val ""
$("#account_sign_in").css "display", "block"
$("#account_sign_out").css "display", "none"
commentLoad = (postID) ->
postID = parseInt(postID)
url = "http://notesolution.showoff.io/api/v1/comments"
$.getJSON url, (data) ->
comment_data = ""
i = 0
while i < data.length
comment_data = data[i]
commentPostID = comment_data.post_id
if postID is commentPostID
parentID = comment_data.id
unless comment_data.ancestry?
$("#comment_list").append "<li> <a href=\"#show_comment\" onClick=\"replyComment('" + comment_data.id + "')\"> <div class=\"parent_comments\">" + comment_data.body + "</div> </a> </li>"
else
$("#comment_list").append "<li> <a href=\"#show_comment\" onClick=\"replyComment('" + comment_data.id + "')\"> <div class=\"nested_comments\">" + comment_data.body + "</div> </a> </li>"
i++
$("#comment_list").listview "refresh"
$("#comment_content").val ""
replyComment = (commentID) ->
commentID = parseInt(commentID)
$("#reply_subject").empty()
url = "http://notesolution.showoff.io/api/v1/comments"
$.getJSON url, (data) ->
comment_data = ""
i = 0
while i < data.length
comment_data = data[i]
if commentID is comment_data.id
parentID = comment_data.id
$("#reply_subject").append "<div class=\"reply_content\">" + comment_data.body + "</div>"
i++
submitComment = ->
comment = document.getElementById("comment_content").value
urlLink = "http://notesolution.showoff.io/api/v1/comments"
if token?
urlLink = urlLink + "?auth_token=" + token
$.ajax
type: "POST"
url: urlLink
data:
body: comment
post_id: comment_post_id
success: ->
hideItems()
$.mobile.changePage "#mainpage"
else
alert "you must sign in first"
submitReply = ->
urlLink = "http://notesolution.showoff.io/api/v1/comments"
ancestryLink = "http://notesolution.showoff.io/api/v1/posts/" + comment_post_id + "/comments/new?parent_id=" + parentID
ancestry = null
if token?
urlLink = urlLink + "?auth_token=" + token
ancestryLink = ancestryLink + "?auth_token=" + token
getAncestryString ancestryLink, urlLink
getAncestryString = (link, urlLink) ->
if token?
comment = document.getElementById("reply_body").value
ancestryString = null
$.getJSON link, (data) ->
theResults = data
ancestryString = theResults.ancestry
$.ajax
type: "POST"
url: urlLink
data:
body: comment
post_id: comment_post_id
ancestry: ancestryString
success: ->
hideItems()
$.mobile.changePage "#mainpage"
else
alert "you must sign in first"
$.mobile.changePage "#mainpage"
checkUser = ->
unless token?
alert "you must sign in first"
$.mobile.changePage "#mainpage"
else
$.mobile.changePage "#reply"
checkUserSubmit = ->
$(".show_nested").css "display", "none"
unless token?
alert "you must sign in first"
$.mobile.changepage "#mainpage"
else
$(".submit_nested").css "display", "block"
showItems = ->
$(".submit_nested").css "display", "none"
$(".show_nested").css "display", "block"
hideItems = ->
$(".submit_nested").css "display", "none"
$(".show_nested").css "display", "none"
Jump to Line
Something went wrong with that request. Please try again.