public
Last active

  • Download Gist
misc-update.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
obj={}#this will store the data we get from pouch
converter = new Showdown.converter()
update = ->
window.views = {sideList : []}
if location.hash == ""
hash="home"
location.hash="home"
else if location.hash.slice(0,5) == '#edit'
hash = location.hash.slice(5)
views.edit = true
else
hash = location.hash.slice(1)
if hash not of obj
hash = "home"
for key of obj#itterate through all the items every update, I'd not do this in real life if i were you
if hash == key
views.title=obj[key].title
views.body=obj[key].body
views[key]=true
if "type" of obj[key] and obj[key].type == "note"
item = {key:key,title:obj[key].title}
if hash == key
views.editable=true
item.active=true
else
item.active=false
views.sideList.push item
views.up = pouch.up
views.hash = hash
views.md =()->
(text, render)->
converter.makeHtml(render(text))
if views.title is "New Note"
views.newNote = true
$("#body").empty().append(template(views))
if views.edit or views.title is "New Note"
ta = $("#noteBody")
t2 = $("#tab2")
tt = $("#noteTitle")
ch=()->
t2.empty().append("<h3>#{tt.val()}</h3>"+converter.makeHtml(ta.val()))
ch()
ta.on "change", ch
tt.on "change", ch
document.title = views.title

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.