<commit_before>---
layout: default
---

## Week 7 - Overview

Students should be comfortable with the following at the end of this week:

* JavaScript
* jQuery
* Unobtrusive JavaScript
* AJAX


## Important Links

* [Tabula Railsa](https://github.com/tiyd-rails-2015-08/tabula_railsa)
* [Challenge Submission Form](http://goo.gl/forms/JhvP6hX7VN)
* [Homework Submission Form](http://goo.gl/forms/2Gki2xhdO6)


## Monday - JavaScript

**Challenge:** [Helpers](https://github.com/masonfmatthews/rails_assignments/blob/master/challenges/rails_helpers.md)

* Starting Point: [Tabula Railsa](https://github.com/tiyd-rails-2015-08/tabula_railsa)

* Agile
  * ON BOARD: Style matters early (sadly)
* Random Topics
  * `config.action_controller.action_on_unpermitted_parameters = :raise`
* Javascript in `node`
  * Surprisingly similar to ruby
  * `var` keyword
  * hashes vs "objects"
  * numbers are all floats
  * `do..end` vs `{}`
  * `else if`
  * `==` vs `===`
    * `1 == "1"`
    * `[1, 2, 3] === [1, 2, 3]`... sigh
  * Weird returns (`var` lines, or `a++`)
  * capitalization in variable names
* Functions
  * methods vs functions
  * implicit vs explicit return
  * First, define them as we would in Ruby: `function sayHi() { alert("Hi"); }`
  * Can be stored in variables
  * `[1, 2, 3].forEach(function (number) { console.log(number * number); });`

    <!-- function greet(greeting) {
      return function() {
        return greeting + " world!";
      };
    }
    var hello = greet("Hello");
    var goodbye = greet("Goodbye");
    hello(); // Hello world!
    goodbye(); // Goodbye world! -->

* The DOM
* JavaScript in Chrome console - load up google.com search results
  * `document.getElementById()`
  * `document.getElementsByClassName()`
  * `.value` or `.value = "default"`
  * `.style.color` or `.style.color = "blue"`
* JavaScript in a Rails app: `javascript_playground` repository
  * `application.js`
  * `alert()` on every page
  * `console.log()` on every page
  * Work through the exercises on the playground root page.
  * `onclick=` attributes in HTML tags
  * Functions in `application.js`
  * `.lastElementChild` - it's sometimes tough to know what's a function and what's just a value!
  * `.cloneNode(true)`
  * `.appendChild(copy)`
  * `<script>` tags to run the JavaScript when the page loads.<commit_msg>Clean up prior day lectures.<commit_after>---
layout: default
---

## Week 7 - Overview

Students should be comfortable with the following at the end of this week:

* JavaScript
* jQuery
* Unobtrusive JavaScript
* AJAX


## Important Links

* [Tabula Railsa](https://github.com/tiyd-rails-2015-08/tabula_railsa)
* [Challenge Submission Form](http://goo.gl/forms/JhvP6hX7VN)
* [Homework Submission Form](http://goo.gl/forms/2Gki2xhdO6)


## Monday - JavaScript

**Challenge:** [Helpers](https://github.com/masonfmatthews/rails_assignments/blob/master/challenges/rails_helpers.md)

* Starting Point: [Tabula Railsa](https://github.com/tiyd-rails-2015-08/tabula_railsa)

* Agile
  * ON BOARD: Style matters early (sadly)
* Random Topics
  * `config.action_controller.action_on_unpermitted_parameters = :raise`
* Javascript in `node`
  * Surprisingly similar to ruby
  * `var` keyword
  * hashes vs "objects"
  * numbers are all floats
  * `do..end` vs `{}`
  * `else if`
  * `==` vs `===`
    * `1 == "1"`
    * `[1, 2, 3] === [1, 2, 3]`... sigh
  * Weird returns (`var` lines, or `a++`)
  * capitalization in variable names
* Functions
  * methods vs functions
  * implicit vs explicit return
  * First, define them as we would in Ruby: `function sayHi() { alert("Hi"); }`
  * Can be stored in variables
  * `[1, 2, 3].forEach(function (number) { console.log(number * number); });`

    <!-- function greet(greeting) {
      return function() {
        return greeting + " world!";
      };
    }
    var hello = greet("Hello");
    var goodbye = greet("Goodbye");
    hello(); // Hello world!
    goodbye(); // Goodbye world! -->

* The DOM
* JavaScript in Chrome console - load up google.com search results
  * `document.getElementById()`
  * `document.getElementsByClassName()`
  * `.value` or `.value = "default"`
  * `.style.color` or `.style.color = "blue"`
* JavaScript in a Rails app: [javascript_playground repository](https://github.com/tiyd-rails-2015-08/javascript_playground_starting_point)
  * `application.js`
  * `alert()` on every page
  * `console.log()` on every page
  * Work through the exercises on the playground root page.
  * `onclick=` attributes in HTML tags
  * Functions in `application.js`
  * `.lastElementChild` - it's sometimes tough to know what's a function and what's just a value!
  * `.cloneNode(true)`
  * `.appendChild(copy)`
  * `<script>` tags to run the JavaScript when the page loads.
{'fraction_non_alphanumeric': 0.1503885738290275, 'fraction_numerical': 0.013442554085276202, 'mean_word_length': 3.641325536062378, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7100318', 'n_tokens_mistral': 1671, 'n_tokens_neox': 1543, 'n_words': 447}