[rewrite] Accreditation page script

An attempt to rewrite the Accreditation page script using a module pattern

by davehol

HTML

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<div class="captioned-image media-image-gallery-type image-square m-icon-overlay-container">

  <a data-lightbox-src="/content/rmit-ui/en/media-objects/rmit-images/college-of-business-images/school-of-accounting-prize-giving-gallery.html" href="#" class="no-outline js-launch-lightbox remove-outline">
    <div class="scaled-background" style="background-image: url(&quot;/content/dam/rmit/rmit-images/college-of-business-images/prize-giving/Medal_image.jpg.transform/rendition-640x640/image.jpg&quot;);">
      <img class="js-responsive-image bg-cover offset-content" alt="View our valued partners" data-ri-sm="/content/dam/rmit/rmit-images/college-of-business-images/prize-giving/Medal_image.jpg.transform/rendition-640x640/image.jpg" data-ri-xxs="/content/dam/rmit/rmit-images/college-of-business-images/prize-giving/Medal_image.jpg.transform/rendition-800x800/image.jpg"
        src="/content/dam/rmit/rmit-images/college-of-business-images/prize-giving/Medal_image.jpg.transform/rendition-640x640/image.jpg">

      <div class="m-icon-overlay">
        <div class="m-icon-overlay-bg"></div>
        <div class="m-icon-overlay-icon-bg"></div>
        <span class="m-icon-overlay-icon grunticon-camera-gal-wht-40"></span>
      </div>
    </div>
    <div class="call-to-action caption">
      <span class="grunticon-arw-right-red-20"></span><span class="span-outline remove-outline">View our valued partners</span>
    </div>
  </a>
</div>
<div class="dave"></div>
<div class="dave"></div>
<div class="dave"></div>
<div class="m-explore-more not-hide">
  <h3>Explore more</h3>

  <ul>

    <li><a href="/about/our-education/academic-schools/accounting"><span style="font-size: 1em;line-height: 1.571em;">Accounting</span></a></li>


    <li><a href="/about/giving-to-rmit"><span style="font-size: 1em; line-height: 1.571em;">Giving to RMIT</span></a></li>
  </ul>
</div>

JavaScript

/*
 * Access Google Spreadsheet to obtain Professional Acreditation information
 * to produce a list based on program code.
 * 
 * Author: David Holinger
 * Date: 01/11/2017
 */

var accredApp = (function() {

  var acredData = [];

  //cache DOM
  var $exMoreLinks = $(".m-explore-more > ul");
  var $imageGal = $(".media-image-gallery-type > a");
  var $overlay = $(".m-icon-overlay");
  var $caption = $(".caption");
  var $attachList = $(".dave");

  // Only run if querystring present, else mod image to static state
  (window.location.search == "") ? render(): modImage(false);

  // If querystring present obtain data from SSheet and initialise page build
  function render() {
    getData(function buildElems() {
      var isGallery = false;
      var firstPara = $("<div>");
      var firstParaText = "See below for current program accreditations and information about membership and development opportunities for students and graduates."
      firstPara.append("<h2>" + acredData[0].prog + "</h2><p>" + firstParaText + "</p>");
      $.each(acredData, function(index) {
        firstPara.append("<hr><h4>" + acredData[index].org + "</h4>");
        if (acredData[index].desc.trim() !== "Not Applicable") {
          firstPara.append("<p>" + acredData[index].desc + "</p>");
        }
        if (acredData[index].opps !== "None") {
          firstPara.append("<h5>Membership and Opportunities</h5>");
          firstPara.append(formatOpps(acredData[index].opps));
        }
        if (acredData[index].gallery != "") {
          isGallery = true;
        }
        firstPara.append("<p><a href='https://" + acredData[index].url + "'>Visit the website</a></p>");
        $attachList.eq(0).append(firstPara);
      });
      updateExMore(acredData[0].prog, acredData[0].code.toLowerCase());
      modImage(isGallery, acredData[0].code);
      alert(isGallery);
    });
  }

  //Obtain data from Google SSheet and add to 'acredData' array 
  function getData(callback) {
    var pcode =...