This file contains 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
cartodb.createLayer(map, { | |
user_name: 'dmonay', | |
type: 'cartodb', | |
sublayers: [{ | |
sql: "SELECT * FROM bathymetry_layers", | |
cartocss: "#bathymetry_layers{ polygon-fill: #598cdb;polygon-opacity: 0.2;line-color: #FFF;line-width: 0;line-opacity: 1;}" | |
},{ | |
sql: "SELECT * FROM pm25_na", | |
cartocss: $('#pm25_na').html().format('pm25_2000'), | |
interactivity: "cartodb_id, the_geom, pm25_2000, pm25_2001, pm25_2002, pm25_2003, pm25_2004, pm25_2005, pm25_2006, pm25_2007, pm25_2008, pm25_2009, pm25_2010, pm25_2011, pm25_2012, country" |
This file contains 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
{ | |
sql: "SELECT * FROM pm25_na", | |
cartocss: $('#pm25_na').html().format('pm25_2012'), | |
interactivity: "cartodb_id, the_geom, pm25_2000, pm25_2001, pm25_2002, pm25_2003, pm25_2004, pm25_2005, pm25_2006, pm25_2007, pm25_2008, pm25_2009, pm25_2010, pm25_2011, pm25_2012, country" | |
} |
This file contains 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
<script type="cartocss/html" id="pm25_na"> | |
/*Country Styles*/ | |
#pm25_na{ | |
polygon-fill: #FFFFB2; | |
polygon-opacity: 0.8; | |
line-color: #FFF; | |
line-width: 1; | |
line-opacity: 1; | |
} |
This file contains 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
String.prototype.format = (function (i, safe, arg) { | |
function format() { | |
var str = this, | |
len = arguments.length + 1; | |
for (i = 0; i < len; arg = arguments[i++]) { | |
safe = typeof arg === 'object' ? JSON.stringify(arg) : arg; | |
str = str.replace(RegExp('\\{' + (i - 1) + '\\}', 'g'), safe); | |
} | |
return str; |
This file contains 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 changePowerTotal(currentPower, GenID, GenStat, GenPower) { | |
if(GenStat == 'on') { | |
currentPower += GenPower; | |
return alert("Generator #"+GenID+" is now on adding "+GenPower+" MW, for a total of "+currentPower+" MW!"); | |
} | |
else if(GenStat == 'off') { | |
if (currentPower <= 0) { | |
currentPower = 0; | |
} | |
else { |
This file contains 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 listOfSharks = ["Sea Pain", "Great Wheezy", | |
"DJ Chewie", "Lil' Bitey", | |
"Finmaster Flex", "Swim Khalifa", | |
"Ice Teeth", "The Notorious J.A.W."]; | |
var listOfTargets = ["icicle bat", "snow yeti", | |
"killer penguin", "frost tiger", | |
"polar bear", "iceberg", | |
"blue witch", "wooly mammoth"]; | |
function makeTargetAssigner( sharks, targets ){ | |
return function (shark) { |
This file contains 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 fridge = { | |
addItem: function(name, type, expirationDate, healthRating) { | |
this[name] = {type: type, expirationDate: expirationDate, healthRating: healthRating}; | |
}, | |
removeItem: function(name){ | |
var recentlyRemoved = delete this[name]; | |
} | |
}; | |
fridge.addItem("bannana", "fruit", "2 weeks", "100"); | |
fridge.addItem("steak", "meat", "1 weeks", "70"); |
This file contains 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
String.prototype.checkFor = function (input) { | |
var result = 0; | |
for (var i = 0; i<this.length; i++) {//use this to check for the length of the actual string | |
this.charAt(i) == input ? result++ : false; //we can use a ternary conditional here. | |
} | |
return result; | |
}; | |
console.log("This is a good string".checkFor("o")); //Now we can use the new method on a string and log it out. |
This file contains 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 Tool(name, type, use, cost) { | |
this.name = name; | |
this.type = type; | |
this.use = use; | |
this.cost = cost; | |
//You can also add inherited functions here for everything created using this constructor | |
this.useTool = function () { | |
alert("Alright, be careful with that "+this.name+"!"); | |
} | |
} |
This file contains 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 sansTemple(floor){ | |
var happensNext; | |
switch(floor) { | |
//Notice how you can use a stacking method to reduce redundency in cases. Now lower level also works for the basement cond. | |
case "lower level" : | |
case "basement" : | |
welcomeMessage = "Welcome to the basement!"; | |
case 1 : | |
welcomeMessage = "You have entered the First Floor!"; | |
break |
OlderNewer