Guest User

Untitled

a guest
Dec 9th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. // Object model
  2. var Event = function() {
  3. this.headline = "";
  4. this.hour = "";
  5. this.duration = "";
  6. this.speaker = [];
  7. this.company = "";
  8. }
  9.  
  10. // List that will be populated w/ the final data
  11. var eventsList = []
  12.  
  13. // Function to extract the info and saving in the eventsList array
  14. var events = () => {
  15. let s = document.getElementsByClassName("schedule-track");
  16. Array.from(s).map(i => {
  17.  
  18. if (i.classList.length === 1) {
  19. // Create a new local Object
  20. let d = new Event;
  21.  
  22. // Extract event information
  23. d.headline = i.querySelector(".break-line-h5 a:last-child").innerText;
  24. d.hour = i.querySelector(".schedule-hour").innerText;
  25. d.duration = i.querySelector(".schedule-duration").innerText;
  26. Array.from(i.getElementsByClassName("schedule-speaker-name")).map(o => d.speaker.push(o.lastElementChild.innerText));
  27. i.querySelector(".schedule-speaker-company") ? d.company = i.querySelector(".schedule-speaker-company").innerText : "";
  28.  
  29. // Update eventsList w/ the current event
  30. eventsList.push(d);
  31. }
  32. });
  33.  
  34. // Transform data to JSON and log in the console
  35. console.log(JSON.stringify(eventsList));
  36. }
Add Comment
Please, Sign In to add comment