{"comment":{"url":"https://api.github.com/repos/abbyhowell/girl-develop-it-JS-102/comments/21918677","html_url":"https://github.com/abbyhowell/girl-develop-it-JS-102/commit/7724433bb09435a6a04073619153fb03ec4dbe12#commitcomment-21918677","id":21918677,"user":{"login":"askdesign","id":7075272,"avatar_url":"https://avatars3.githubusercontent.com/u/7075272?v=3","gravatar_id":"","url":"https://api.github.com/users/askdesign","html_url":"https://github.com/askdesign","followers_url":"https://api.github.com/users/askdesign/followers","following_url":"https://api.github.com/users/askdesign/following{/other_user}","gists_url":"https://api.github.com/users/askdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/askdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/askdesign/subscriptions","organizations_url":"https://api.github.com/users/askdesign/orgs","repos_url":"https://api.github.com/users/askdesign/repos","events_url":"https://api.github.com/users/askdesign/events{/privacy}","received_events_url":"https://api.github.com/users/askdesign/received_events","type":"User","site_admin":false},"position":null,"line":null,"path":null,"commit_id":"7724433bb09435a6a04073619153fb03ec4dbe12","created_at":"2017-04-26T16:54:00Z","updated_at":"2017-04-26T16:54:00Z","body":"// https://openclipart.org/search/json/?query=elephants - query changed from unicorn\r\n\r\n// CLASS 3 CODE\r\n\r\nvar elephants; // originally was unicorns; changed all unicorns in code to elephants\r\n\r\nfunction loadJSON(file, callback) {\r\n  var xobj = new XMLHttpRequest();\r\n    xobj.overrideMimeType(\"application/json\");\r\n  \txobj.open('GET', file, true);\r\n  \txobj.onreadystatechange = function () {\r\n    \tif (xobj.readyState == 4 && xobj.status == \"200\") {\r\n     // Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode\r\n     callback(xobj.responseText);\r\n    }\r\n  };\r\n  xobj.send(null);\r\n}\r\n\r\n\r\nfunction getRandomThing(array) {\r\n  var randomNumberBetween0And1 = Math.random();\r\n  var highestNumber = array.length;\r\n  var randomInteger = Math.floor(\r\n    randomNumberBetween0And1 * highestNumber\r\n  );\r\n  return array[randomInteger];\r\n}\r\n\r\nfunction getImage() {\r\n  var img = document.createElement('img');\r\n  var elephant = getRandomThing(elephants);\r\n  img.src = elephant.svg.url;\r\n  return img;\r\n}\r\n\r\nfunction handleClick(event) {\r\n  if (event.target.childElementCount > 0) {\r\n    return;\r\n  }\r\n  var today = new Date().getDate();\r\n  if (event.target.innerHTML > today) {\r\n    return;\r\n  }\r\n  var img = getImage();\r\n  event.target.appendChild(img);\r\n}\r\n\r\nfunction getDay(num) {\r\n  var day = document.createElement('div');\r\n  day.classList.add('day');\r\n  day.innerHTML = num;\r\n  day.addEventListener('click', handleClick);\r\n  return day;\r\n}\r\n\r\nfunction drawCalendar() {\r\n  var container = document.getElementsByClassName('container')[0];\r\n  var year = new Date().getFullYear();\r\n  var month = new Date().getMonth() + 1;\r\n  var daysInMonth = new Date(year, month, 0).getDate();\r\n\r\n  for (var i = 1; i <= daysInMonth; i ++) {\r\n    var day = getDay(i);\r\n    container.appendChild(day);\r\n  }\r\n}\r\n\r\nfunction getElephantsThenDrawCalendar() { // originally getUnicornsThenDrawCalendar\r\n  loadJSON('elephantsData.json', function(data) { // originally 'unicornData.json'\r\n    elephants = JSON.parse(data).payload;\r\n    drawCalendar();\r\n  });\r\n}\r\n\r\ngetElephantsThenDrawCalendar();\r\n"}}
{"actor":{"display_login":"askdesign"}}