This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PouchCore | |
| constructor: (@remoteUrl,@onChange)-> | |
| if @remoteUrl.slice(0,4)=="http" #did we get a real url? | |
| parts = @remoteUrl.split("/") #split the url bu by the slashes | |
| @_dbName = parts.pop() #assign the last part as the db name | |
| while @_dbName == "" #unless it is an empty string | |
| @_dbName = parts.pop()#repeat until you find one | |
| Pouch @_dbName, (e, db) => #making the local db | |
| unless e #error would imply we are on an old browser | |
| @db = db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add: (doc, cb = ()-> true) -> | |
| unless "_id" of doc | |
| @db.post doc, cb | |
| else if "_id" of doc and doc._id.slice(0,8) != "_design/" | |
| @db.put doc, cb | |
| else if doc.length | |
| @db.bulkDocs doc, cb | |
| get: (id, cb = ()-> true) -> | |
| @db.get id, cb | |
| remove: (id, cb = ()-> true) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PouchCore | |
| constructor: (@remoteUrl,@onChange)-> | |
| if @remoteUrl.slice(0,4)=="http" #did we get a real url? | |
| parts = @remoteUrl.split("/") #split the url bu by the slashes | |
| @_dbName = parts.pop() #assign the last part as the db name | |
| while @_dbName == "" #unless it is an empty string | |
| @_dbName = parts.pop()#repeat until you find one | |
| Pouch @_dbName, (e, db) => #making the local db | |
| unless e #error would imply we are on an old browser | |
| @db = db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PouchCore | |
| constructor: (@remoteUrl,@onChange)-> | |
| if @remoteUrl.slice(0,4)=="http" #did we get a real url? | |
| parts = @remoteUrl.split("/") #split the url bu by the slashes | |
| @_dbName = parts.pop() #assign the last part as the db name | |
| while @_dbName == "" #unless it is an empty string | |
| @_dbName = parts.pop()#repeat until you find one | |
| Pouch @_dbName, (e, db) => #making the local db | |
| unless e #error would imply we are on an old browser | |
| @db = db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //instead of structuring them like this | |
| $("#someID").on("click", function(e){ | |
| e.preventDefault(); | |
| doStuff(); | |
| }); | |
| //I had to hang it all of the main div | |
| $("#body").on("click", "#someID", function(e){ | |
| e.preventDefault(); | |
| doStuff(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Pouch Demo</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <link href="css/bootstrap.min.css" rel="stylesheet"><!-- bootstrap css modified based on http://bootswatch.com/spacelab/--> | |
| </head> | |
| <body> | |
| <div id="body"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| templateText = """<div class="navbar navbar-inverse navbar-fixed-top"> | |
| <div class="navbar-inner"> | |
| <div class="container-fluid"> | |
| <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> | |
| <span class="icon-bar"></span> | |
| <span class="icon-bar"></span> | |
| <span class="icon-bar"></span> | |
| </a> | |
| <a class="brand" href="home" id="home">Pouch Demo</a> | |
| <div class="nav-collapse collapse"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ ()-> | |
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
| <meta name="viewport" content="width=1024, user-scalable=no"> | |
| <style> | |
| html { height: 100% } | |
| body { height: 100%; margin: 0; padding: 0;} | |
| #map{ height: 100% } | |
| </style> | |
| <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css" /> |