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
(ns touchViews.core | |
(:use clojure.pprint) | |
(:require [com.ashafa.clutch :as db]) | |
(:require [com.ashafa.clutch.utils :as utils]) | |
(:require [com.ashafa.clutch.http-client :as http]) | |
(:require [clojure.contrib.json :as json]) | |
(:require [clojure.walk :as walk]) | |
(:require [clojure.contrib.string :as str]) | |
(:use [clojure.pprint]) | |
(:gen-class |
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
(defproject touchViews "1.0.0-SNAPSHOT" | |
:description "touch views in the DB forever via futures" | |
:dependencies [[org.clojure/clojure "1.2.1"] | |
[org.clojars.jhowarth/clojure-contrib "1.2.0-RC3"] | |
[com.ashafa/clutch "0.2.4"]] | |
:dev-dependencies [[swank-clojure "1.4.0-SNAPSHOT"]]) |
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
(ns touchViews.core | |
... | |
(:gen-class | |
:methods [#^{:static true} | |
[initViews [] void] | |
])) | |
... | |
(defn -initViews [] |
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
function object2array(obj,prefix){ | |
var keys = _.keys(obj); | |
var vals = _.values(obj); | |
var firstStep = _(_.zip(keys,vals)).chain() | |
.map(function(keyVal){ | |
var key = keyVal[0]; | |
var val = keyVal[1]; | |
return {name: applyPrefix(key,prefix), value:val}; | |
}) | |
.value(); |
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
$(html).find('.checkAlltimes').first() | |
.toggle(function() { | |
$(this).prop('checked', 'checked'); | |
$(this).parents('li').find('.startTime, .endTime') | |
.each(function(){ | |
$(this).parent().hide(); | |
}); | |
}, function() { | |
$(this).prop('checked', false); | |
$(this).parentsUntil('select').find(".startTime, .endTime") |
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
var Donut = Backbone.Model.extend({}); | |
var Donuts = Backbone.Collection.extend({ | |
model : Donut, | |
url : "/donuts" | |
}); | |
var bostonCream = new Donut({ | |
name : "Bostan Cream", | |
cream_filled : 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
/* i'm expecting the url() is http://localhost:5984/campaigns/AllDayAlltime but it comes out as http://localhost:5984/campaigns */ | |
function doc_setup(){ | |
var Campaign = Backbone.Model.extend({ | |
urlRoot:"http://localhost:5984/campaigns" | |
}); | |
var AllDayAlltime = new Campaign({url:"AllDayAlltime"}); | |
console.log(AllDayAlltime.url()); | |
}; |
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
//my models exist in this url | |
"http://localhost:5984/campaigns/[model id]" | |
//to get the list of my models i need to use this url | |
"http://localhost:5984/campaigns/_all_docs" | |
//how do i handle this in backbone? |
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
var Campaign = Backbone.Model.extend( | |
{ | |
idAttribute: "_id", | |
urlRoot:"http://localhost:5984/campaigns" | |
}); | |
var Campaigns = Backbone.Collection.extend( | |
{ | |
model: Campaign, | |
url:"http://localhost:5984/campaigns/_all_docs", | |
parse: function(response) { |
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
/* | |
>>> campaignList.at(0).fetch() | |
GET http://localhost:5984/campaigns/_all_docs/AllCanadaAllTerminal | |
I want this to happen | |
GET http://localhost:5984/campaigns/AllCanadaAllTerminal | |
*/ | |
var Campaign = Backbone.Model.extend( | |
{ |