public
Created

  • Download Gist
fin.coffee
CoffeeScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
$ ()->
linkaction = (e)->
if e.target.id != ""# and "login" "logout"
location.hash = e.target.id
e.preventDefault()
update()
true
$("#body").on "click","a",linkaction
$("#body").on "click","#editable",(e)->
e.preventDefault()
location.hash = location.hash.slice 1
update()
$("#body").on "click","#dontNote", ()->
e.preventDefault()
location.hash = "home"
update()
$("#body").on "submit","#noteForm", (e)->
e.preventDefault()
results =
body : $("#noteBody").val()
title : $("#noteTitle").val()
type : "note"
pouch.add results, (err, resp)->
location.hash = resp.id
update()
false
$("#body").on "click","#updateNote",(e)->
e.preventDefault()
if location.hash.slice(0,5) == '#edit'
docid =location.hash.slice(5)
pouch.get docid, (err,doc)->
return if err or doc.type isnt "note"
doc.body =$("#noteBody").val()
doc.title=$("#noteTitle").val()
pouch.add doc
location.hash = docid
update()
true
$("#body").on "click","#deleteNote",(e)->
e.preventDefault()
if location.hash.slice(0,5) == '#edit'
docid =location.hash.slice(5)
pouch.remove docid, ()->
location.hash ="home"
update()
true
$("#body").on "click","#cancelUpdate",(e)->
e.preventDefault()
location.hash="home"
update()
$("#body").on "click","#toggleStart",(e)->
e.preventDefault()
pouch.stop().start()
update()
true
window.onpopstate=()->
update()
window.pouch = new PouchCore location.protocol + "//"+ location.host + "/pd", (change)=>
if change.id[0] isnt "_" and (change.doc.type is 'note' or change.doc.type is 'page')
unless change.doc._deleted
obj[change.id] = change.doc
update()
else if change.doc._deleted and change.id of obj
delete obj[change.id]
update()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.