Skip to content

Instantly share code, notes, and snippets.

<div class="btn-group mt-1 mx-auto">
<button id="gantt-day" type="button" class="gantt-period btn btn-sm btn-secondary">Day</button>
<button id="gantt-week" type="button" class="gantt-period btn btn-sm btn-secondary">Week</button>
<button id="gantt-month" type="button" class="gantt-period btn btn-sm btn-secondary">Month</button>
</div>
<script>
document.querySelectorAll(".gantt-period").forEach(function(button) {
button.addEventListener("click", function(event) {
railsGantt.gantt.change_view_mode(event.currentTarget.innerHTML);
{
"window.zoomLevel": 0,
"editor.minimap.enabled": false,
"editor.fontFamily": "'monospace'",
"editor.fontSize": 14,
"files.exclude": {
"**/node_modules": true
},
"files.defaultLanguage": "txt",
"workbench.startupEditor": "newUntitledFile",

Comparison Between AJAX and Ruby

Both of these pieces of code:

  • Make an HTTP GET request to the same URL
  • Parse the response (which is in JSON format) into datatypes (Hash for Ruby and Object for JavaScript)
  • Retrieve the results array and iterate over each Star Wars character

Ruby

Comparisons Between Ruby and JavaScript

Iterating through over an array and printing each element

Ruby:

my_array = ["first_element", "second_element", "third_element"]

my_array.each do |element|
  puts element

DOM Manipulation/Parsing

Reading and Writing Element Attributes

Remember:

<element attribute="value">InnerHTML</element>

Example:

import random
g = random.randrange(-10, 11, 1)
f = random.randrange(-10, 11, 1)
a = []
for i in range(0,10):
try:
x = int(input(" %d" %g + " + " + "%d = " %f))