Skip to content

Instantly share code, notes, and snippets.

View behtea's full-sized avatar

Muhammad Ariel Akilie behtea

View GitHub Profile
var posts = []
var post = {
url: 'http://jsonplaceholder.typicode.com/posts/',
$el: $('<div class="post">').appendTo($('body')),
initialize: function(id){
this.$el.attr('id', id)
this.url += id
var thisPost = this // wtf? http://stackoverflow.com/questions/4886632/what-does-var-that-this-mean-in-javascript
$.get( this.url, function(data){
var to_be_run_on_server_response = function(weather_data){
$('#container').append(weather_data.main.temp)
}
$.get('http://api.openweathermap.org/data/2.5/weather?q=San%20Francisco&mode=json&units=imperial').success(to_be_run_on_server_response)
$.ajax({
method: 'GET',
url: 'http://api.openweathermap.org/data/2.5/weather?q=San%20Francisco&mode=json&units=imperial',
success: function(weather_data){
console.log(weather_data)
}
})
var complex_object = {
string: "I'm a string!",
number: 42,
array: ["all sorts of stuff", 10, true, undefined, {me: "an object", more: "find me in here!"}, function(){console.log('beepity-beep')}],
simple_object: {name: 'bob', location: 'basement'},
fn: function(){
console.log("fn has been invoked! Checking both kinds of invocation-time inputs...")
console.log("what is my calling context?", this)
console.log("what are my arguments?", arguments)
}
var them_dogs = [{
name: 'Henry',
age: 0.5,
breed: 'Aussie',
food: 'kibble',
toys: ['tennis ball', 'chew toy'],
picture: 'http://rubyriverminiaustralianshepherds.com/wp-content/uploads/aussie-puppy-for-sale-940x412.jpg'
}, {
name: 'Tilly',
age: 5,
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
margin: 0 auto;
width:960px;
}
</style>
<html>
<head>
</head>
<body>
<h1>mah payge</h1>
<p>yup, yup</p>
<script>
// the interpreter will skip any line that starts with a double slash
// these lines are explanatory comments to help squishy-brained humans
<form action="form-responses/new" method="POST">
<input type="text" name="firstname" value="default" size="100" autofocus>
<input type="password" name="pswd">
<input type="email" name="userEmail" placeholder="hello@site.com">
<input type="radio" name="weird" value="code-blue" checked><span>pick this!</span>
<input type="radio" name="weird" value="code-red" checked><span>or pick this</span>
<input type="checkbox" name="optin" value="trusting" checked>You agree to everything
<input type="checkbox" name="optout" value="skeptical" disabled>Wait, what?

Exercise: Boxes, Boxes, Everywhere!

Make a very boxy web page...

  1. Create a bunch of dang divs and spans on your page.
  2. This is a web page about boxes. Add content about boxes. Cardboard boxes, metal boxes, self-imposed emotional boxes, whatever...
  3. Using a mix of class, id, and tag selectors, give boxes different background-colors.
  4. Give boxes a set height, width, border, padding, and margin.
  5. Figure out what "giving" an element each of these css rules does:
  6. border-radius: 10px;