Table of Contents for
Web Design Blueprints

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Web Design Blueprints by Benjamin LaGrone Published by Packt Publishing, 2016
  1. Cover
  2. Table of Contents
  3. Web Design Blueprints
  4. Web Design Blueprints
  5. Credits
  6. About the Author
  7. About the Reviewer
  8. www.PacktPub.com
  9. Preface
  10. What you need for this book
  11. Who this book is for
  12. Conventions
  13. Reader feedback
  14. Customer support
  15. 1. Responsive Web Design
  16. Getting familiar with the basics
  17. Using media queries for responsive design
  18. Working with responsive media
  19. Building responsive layouts
  20. Summary
  21. 2. Flat UI
  22. Flat UI color
  23. Creating a flat UI layout
  24. Summary
  25. 3. Parallax Scrolling
  26. Color classes
  27. Using SVG font icons
  28. Getting the fonts
  29. That's no moon!
  30. OMG, it's full of stars!
  31. Clouds, birds, and airplanes
  32. The rocket
  33. Terra firma
  34. Next up, the CSS
  35. Styling the objects with CSS
  36. Styling the ground objects
  37. Writing the JavaScript effects
  38. Setting the row height
  39. Spreading the objects
  40. Spreading the clouds
  41. Loading the page functions
  42. Smoothening the scroll
  43. Updating elements on the scroller
  44. Collecting the moving elements
  45. Creating functions for the element types
  46. Setting the left positions
  47. Creating the rocket's movement function
  48. Finally, moving the earth
  49. Summary
  50. 4. Single Page Applications
  51. Getting to work
  52. Getting the old files
  53. Object and function conventions
  54. Creating utility functions
  55. Working with the home structure
  56. Setting up other sections
  57. Performing housekeeping
  58. Creating a callBack function for the API
  59. Summary
  60. 5. The Death Star Chapter
  61. Dropping in the parallax game
  62. Loading elements from JSON
  63. What can be done in the shared levels service
  64. Editing the home JavaScript
  65. Creating the other pages – credits and leaderboard
  66. Creating the second level
  67. Summary
  68. Index

Performing housekeeping

There are some scripts that are to run on the home page and they are living in the wrong places. The first one is the clock script in the index.html HEAD SCRIPT element. We don't want that there. It only runs in the home page, and it isn't in our separation of concerns methodology. So cut the script out of the index script tag and paste it into the home.js file.  

In the routing.js file there is a function called home.loadSections. This is also outside of its home. When we created it, we noted it with a TODO to move later. So now cut it out and paste it into the home.js file.

Now the /app/home/home.js file has the full home object including home.dayArray, home.monthArray, the home.getTime function, the home.correctDigit function, and the home.loadSections function. It should be followed by calls to the home.loadSections and home.getTime functions.

The home function should look like the following example without much more modification:

console.log(id)
var home = {};
home.dayArray = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
home.monthArray = ["January","February","March","April","May","June","July","August","September","October","November","December"];
home.getTime = function(){
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
var d=home.dayArray[today.getDay()];
var mo=home.monthArray[today.getMonth()];
var y=today.getFullYear();
m = home.correctDigit(m);
s = home.correctDigit(s);
document.getElementById('time').innerHTML = "<br><h1 class='large'>"+h+":"+m+":"+s+"</h1>&nbsp;<span class='dark'>"+d+",</span class='dark'>&nbsp;<span class='dark'>"+mo+"</span>&nbsp;<span class='dark'>"+y+"</span>";
var t = setTimeout(function(){home.getTime()},500);
};
home.correctDigit = function(i){
if (i<10)i = "0" + i;  // add zero in front of numbers < 10
return i;
};

home.loadSections = function() {
for (i = 0; i < routing.routesArray.length; i++) {
routing.routesArray[i].callBack.call();
services.getPage(pageRoute.partial,routing.routesArray[i].path,services.routing.writeHTML);
}

};

home.getTime();
home.loadSections();