Skip to content

v1.3.0

Latest
Compare
Choose a tag to compare
@HamzaElkotp HamzaElkotp released this 23 Sep 03:21

Loading Page content from Body key in JSON Object

  • changed jsonRead function name to intContent.
  • initialized new variable named contentBox in global liked with HTML element that has contentBox id
  • made a for loop to loop through the Body key in the object.
  • every item it loops on, inner it to contentBox HTML element.

improve code

  • when the website loads the Home page content "main page" is not loaded yet
  • this is because I made the content doesn't load until the user click.
  • but the user wants to see the "main page" content without clicking.
  • this fixed using intHomeContent function, and it won't work until programmer call it.
  • it takes three args:
    jsonpages: the path of the JSON file that load content from.
    homePageSPAname: the name that recorded in SPAname key inside JSON object
    keyName: the nickname to the SPAname, so if in JSON you make HomeName instead of SPAname just tell Sparling.js that.
    =================================
    example:
    this is our Object inside JSON file that represent our Home page:
    {"HomeName": "examlehome", "HomeURL": "home2", "Hometitle": "Home}
    and this is the default way:
    {"SPAname": "name", "SPAurl": "home2", "SPAtitle": "Home}
    so to can load home page content in the right way, call it like that:

intHomeContent("JSON Path", "examlehome", "HomeName");