#!/bin/bash

# A script to create an html file from a pre-defined directory of files.
# Copyright (C) 2013-2020 Blackosx <darwindumper@yahoo.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# =======================================================================
#
# This script:
# 1- creates and initialises an html report. Two files are written to and
# then combined at the end. The first file contains the header and the css
# which is appended to as the script runs. The second file is built with the
# Javascript and the html. At the end both files are merged in to one.
#
# 2- scans through a pre-defined set of folders and if locating a set file
# will read the file and place the contents in to the html document. Any
# translations that might be required are also done, for example substituting
# spaces for an html non-breaking space to maintain column spacing.
#
# 3- Calculate table column widths and adjusts accordingly depending on the
# width set by the gMasterFrameWidth global variable. At this point in time,
# the overview section has not been set up to resize. This is to be done.
#
# *************************************************************************************
# The script takes 6 arguments passed to it when called.
# 1 - Path       : Directory of DarwinDumper dumps to read.
# 2 - CodecID    : A string of the audio codec ID to display in the header.
# 3 - Privacy    : A string to instruct the privacy routine to mask sensitive data.
# 4 - SIP        : A string showing state of System Integrity Protection.
# *************************************************************************************
#
# Thanks to STLVNUB for the idea of using embedded images.

# ---------------------------------------------------------------------------------------
Initialise()
{
    local passedDirToRead="$1"
    local passedCodecID="$2"
    local passedPrivacyState="$3"
    local passedSic="$4"

    # Global Vars - HTML
    gMasterFrameWidth="1060px" # Change this line to alter the width of the html output.
    gTableState="none" # default html Sub section (used in DMI Tables / Bootloader Config sections) table state. Use none for collapsed; block for visible
    gCodecID="$passedCodecID"
    gPrivateState="$passedPrivacyState"
    gSic="$passedSic"
    declare -i gTableBoxWidth
    declare -i gTableTextBoxWidth
    gColOne=0; gColTwo=0; gColThree=0; gColFour=0; gColFive=0; gColSix=0; gColSeven=0; gColEight=0

    # Base64 strings - Images converted at http://webcodertools.com/imagetobase64converter
    privateStamp="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAAWCAMAAAC4wk/kAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAMAUExURQAAANUtLY4oMuwfFuklHKUxM6AwLqIvK58yLnw7OaYsKbM6OpkxMN8kIOsoGpYxL+giHMIpIdUqG7YrJpwwLog4M7EwJrIpJ5QxNK4uKtAoJPk3MsInJP9QToo3M8AoIpM3NIw2M7EqJrMqJ9slHf8qJLkpJcElJ7IqKNEjHv8gE4Y6OcomIcgmH6wvKZIzM98lG54sJ4U6NpQ3OpM2N5MzM7IqJIYxMe0iGeUlG4g2NKgtK3dAP9YnH9MlHb4mI7YoJrQoKOolHKcxL+4kGZM2Nf8kFf8pItcnE8UhHdQkIf8gEbkuKP84M+QnI7svLO4gFvsiF/8fErsoI74nJeMhG7crK70uLukiHbQpJbEwJsIqKJszM8UnIv8mHNMlH/odFP8gGOQiGv8vJf9ORMIqJv8nHv8vJf8oHX8AANkhGs4jHdwkHbIqKbkoJdMnHfYiFcwqI502MII8PKkyLqoxLZw0L540NP9VS9cjH8gjHf8gF3o3NZkwMPEgG+kgF/8fFf8eEv8qIb0pJeEiGv8hFf8iGYY2Mv8zLf8oH/84MIM4Nv8lG5QxL+8jHKAzMPoeEsUoI/8vJtEkIK4xL6syL/8jG9MnIpUzMtwiGqcwK64sKok2NIs0MtEoJs4qI6ksKMAlIqMuKv9RS8wqJJQ6N3o+PPgeFX44OIQ0NeghGf8sJPAhGY8yMNwlHoo5NdchHPUiGf8nGrwtKPEhFuMkHLcqKrgtKekdFYE1NIIzMP4fFaQxLP8cD/9DPP8+N7QwLX02NrgyLbIqJ98mINQkHqcyL3o5OassKsgnINsjHcgjHckoJcwmIIE7O9gpId0eF9crJ9MrJPAdEsUjHqUqKPQcEuwgFrEpJHw3Np8wLf8jF+MeFp4tK9IhGv9JQ/86M4g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NfX2EyFXFKSaTl/VDBqOh9PLUV7SilfO0teTmKQXwIGAoaHhzRuPnl6eRg5GUdGR4uNjJaXlpCSkdPT1EJpQCNdNUCJX16GXcXFxaOkpGhoaDs9O7+/wD6DWCJGJ8jHyFmVayVgMipYNxoyISxJMGFiYSA9I+bl5sHCwkFBQD1pQZmonJGilFZnWHCXa1p/WEdtSD9fQpzCm6Gto2yIcGFuY6+3sIacjHWCeDdsRvDy9ANHFzRTN16BaFN0WwlRIIWQhnmWgMTCxD5TQhYZFcPIx4WofcIYPPkAAADEdFJOUwAgLhYSA0sLAQQnAZm1/MYItQL5O/m1/vnGGmD+hqf7ct364vr8+vr6+u7+/Lz///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////6iCSuzAAAgAElEQVR42u2beVxTZ9r3x5a69G2t49jX1q3LTJ+2M/OQsCQiAQMhIUgCFAiRgIQtmECgshMggECAhsgmW8JWFmUH2WQrguyyyiKIUhcUEH3c61KXdt7rPsEW2zjT+bx9/psfh3OfE05yfe/fdd3XST4f8oc//Ef/0Sv0f35v/VvR1/6vzGntv3Hh2nUb1vyu2rBh3W9FgIs2rNmw7ndF2LDhjbXr1qxZ9xsQ1q6F8Os2rFr94fYd//ef6I//nnZs37rpdZjSun9FsPEP69ZsUFv91p95qZv/9j+q9cknn/zP37/+93Qu2enB+9s3gRlr1679p/HB99X/7Uf/G0T506v17nvvvof0rlLvvax3V0p59vnnf/p8W/pnOzZtUFu3duOr469ds+a1HZ+1vvv5e+f2HwbpHz59WClDfX1D2GPb4d37dxpiD2QGcDI5nLadhocMDQ33Gx42jN25E/5kiI0vZLVz556de859/bc//a32s+1b1Da8kmDjWjW11X+2f+/zbbtP797/1Vdf7YFtzzd7vgGh3Vcvtm+++uobeM3pnX+T1BfX37l76PA3y5crn4J2X33z1Z5vzn3zQnu+2rn/3Neff+31/mtqa15BgOJv/Qz/p6+tDM6d23Xu3HEQjMd37dp1fNc+JOUeG+FBy4WWFvl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h6c/P0/X09v///+/v7/7+/uXk8Pbz/v///evo8/f39f///////+Lo79jY4d3d5OPl7dDM2fTy9/fy/Pfx//j0//P0/+fk7v//+v////////369f///+Xn8eDo8drU4djU4vf0+Ojo6OLU5QAAAA0QHAoNGg4SIBQZKhYVIENCYR4dJxoZIS8nLiYlKWt0pRMTGxEUJCMfJxsfND09WBwaGichH1FDPS4wRwACEj4yMzY2U////+nq9UlHZxkeMHeMxXF6rwMEDHmDtX2IumFvpICRxkRRjiEdGjEnJAsKEF9FR7jB5GpVTH1mXy4tNCQmOyAQFjUqNIOZ1Pbz/ysiJpWp4CAjPHaP0CAeH3qV1+/z/TcwLxMUFFhMTp+t3V9GP0c0NFdpqJei0WVPRmJQTnBSU2aFzUU8OVE/ODs5QIeEjzQrKIJnXkg8LuTk8ldUdZhtbnV2n4JjWHdcWOnc7paGolZTXmVccfDr8iMjNUQyPFY9RmR4uI2k30A9Q4mRvoKMvV1xsTIeHk9ObY2Zy5N1aHB5qq2z3k9aknZseFhFPL25x1hhlaSmzPv8/Vx2vcbG5XpPUUZhs4l6lWROOtC4ysykuohzX6V0dTY0PHVzlbSAgJOOpax9fLKst7yIiCgmSZqYpKOfrD0vPCwtQsvH04yj2nGFu2ZXWmdHTFhmnYaCqSgrQm6Gx2xjcio7gKOx4VRUaHNaULy415OcvbW1209fn6y75Vt7yMbA39zf7NTN6YZtcpCNl83I45eAeH1eYqimtN/L3zxPk6aw1WdkgzFJmMm0yZ+ixpNjY4dVVdCswt22xv/g43VWQ+PD0dHN1trS4Ny0vKaGffrW08qpqsqfn+i/vgcAAElMXBwucmqAwW9/tTxLhnlpapWZwXljaJmSt6ufwlEnKWtfYn9zfnBsfayYrzpSo7ynw3xobYRnbbuZsNa5u/P0+cm2vaZnZPTJyunV2HFviE5LZXdWULu4zcO1x5zUTlAAAAD3dFJOUwBlDFRv/YcCBk7lGr+hvu1fPNny0Csm6OXp76/t1U2mj9G+noCoyMzHF/z///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////48FiQQAAADa0lEQVQ4y2NggAN2bk42Hi4uHjZmbnYGTMDOKeR8KPhM1pngGWXOXMwc6PKCwi57fE6fO/dh1qxZ0xP3JzlzompXcN7zdPvpfZmd06cfyMvLOxAf7CyPZAi7osumR36bMjM7W1oeb90aH5+YmBebxA9XwS50yG/7lCkTgAa0rHd3d4+PilrXmtjqwg9zq7LLBD8zHyDweAKU9/UFysfGprXGJilB3TfNzM/MrM/Dy9vb17fDt6cnKystbUf//h3B05jBFjhPhch7ebd7d/RkpfXv3X3w4Ixjxw7PKJsGsoSzzAwk2dHe/vzC1Kn9wXt3H2Y9dZO1BghONbAAFQhfmFDZ12dWufnlqyXvJr6d+Cb1yPuP58/PnTv3yrzr39gZNBsqpyxaVLm5dvbEbW3+pdmTAopLSz99mXf58rxbV643iDFw3pxdW1s7e1tqsk1KQH6yY6qjTbFdacj841+vXr1zp4GRgW1yfX19XZhNgqmpqUlCimfMLjtbu/yCOXPmz7/98/4vXgaeJU7l5d076+tMbBMszf39uyZlF4SElgTlVF27dvvefREGyd8rXLvLz5ab+FtaGtvG+NtmVFVVAxUUZ1RXhSy4Jc4geXaFtaGhq3WjkYGxLdAZ6SEl2XN6Q0NPVFdULF1+V5xBY9EKV1dXw+5up0Yjc/PkoJD07F3pIdVHFi9funj54nsiDGxL4gzBwNppjZtjga2dnV1v+qTjJwoqFlQs+HFXlYHzpJWTNRA4OdmvWZgfE+hYYpcT8uxFbldQxcWLl76zMHDf2BJnDwJrwo0TElJMQntzTE0jm5o35s68NHPmDVEG9m87HcLjwoEA6MzAhGTH/Jxim8jVTc3NQRtff3YBxpbASQd9Kzc3Nysg0DcKKywO2JBqYgJUkpHRtUwFFN3RD7Xd9KFAz6DQ1DzM0tjUJDLSMWJDEjjVya3VddC3AAM9XVMDBx1dAyNLyxiTiIi1LJAkxbdK28FCDwp0dCwMjI2NLE0jHqyShSVamSJtTwuQnI6Oro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XQ2q7C2SwmKEA+QbpqIWE6Ind1fVpFOdaSUairsqmkoa2ZirWeizEqLMmmfZSes5BgOcirqP729LuMhryvo9bCws6hmNCLT9qyq8OusjsaDJNrW9OQTaqHiXY3CrpoEqqMkca7vnp6hHGCnKZgIrOGYruijvLy/uLf74OBirm3u6KMiWgjAGAkAJpOD6F/cQ0DArx0NLeLbN/m9Hh/jcHH08Cbf7l16zYAAADydFJOUwAdjf3rMSb0FKDO3Y4cCJDrNiTW+Q5RuPm6lqnjyvJm4PTe+cB5fYisaWP6U6PMTrn////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+A16tJQAAA3ZJREFUOMtjYIADUTEecW52dm5xHjEOBkzAyMRiM3nqyYkTZ0+dbMPOI4Qur8bMPNFrx6RJh6oOVe0uqqixYUKR5lCxubfn2cs9Bw7s3z+zZNruqmkTbbiQDGFkuX3rzv1KIHi4ffujmV5eXiWHPCezC8L1s9SUrClcW1hYuLY9O7ulJbupyXNlT38iOyNUAVdGRG5WDhAE+vlFRBRH3chd6Vnk2d8jwQ2RV7WZfsM6KysQCCIiIkGguMirxctruScz2KWiNrNuWFsHBQU1REd3NizO8vPzC8wuvuHp6VlVbgOyhL/GOsja2jq6rf3qlcuXgoIWN3SUT+/MjY+Pn9uTKM3AwKc9K/KwdVtb+/XmVQX5XRc3Lly470L38g6QkjfWNhwM+jXl00913D3avL7Au6s0fNEityWxOx2rZ/Q2REf1z02UZ+D/c+rz+43rV/3yzm9eZu8RUF9fH+BgYunY1/26ePrcWboMBrP3TTlbsM5767opcelpYbah/h4mDg4OJg6O2+bM+/tPj0Hh//FfR454L2tdEZOelupma2Xn7u/iY2lp6eCQ4PhzngCD4tGz3rtK41bEONmnhYEVhLq7hxr5OAQAlRjOASr4/T1uQ16MU7q9vT1YgZWVnV1marKxqYOlpWGSBIPCj69Om518nZycfO3D7X19w8Nqa8N9W8N8gl3NHQzPCDBIfjlo7xSTl1eW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AZFg2TTLcgFwcwENZgVcDIvIwiYuo6olxconJsYiwy2PI3g5oFt66IiBk3SvYHAMhQKfbuGHJuAAAAAElFTkSuQmCC"
    sipIcon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAAWCAYAAACPHL/WAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAZNJREFUeNpi/P//P8NwAkwMwwyMemjUQ6QBVSBeBMRvgBiUuV8C8WwglifWAMZBVCg4A/FGIOYA4l1AfBuINYHYBYg/ALEXEJ8YKh4SgXrgGxB7APFlJDkzIN4GxL+AWA2Iv1CS5MqhUQ/Cu4HYGEluFVTcGItaZD2CRHgoHYgFgDgOzTMgcAoqLwmVJzsPhQJxBxDPAsUkEFcAcRoRjquAqp8FTS7E6LEG4mdAvBeH/AYg/gzENoQMYsEjpwSl30Pps9CQIhbsgXqGmBiSA+KPQKyAR80nYgoHfB5aDU1G5dBkBfLMPSI9I4gUM2eJUK8Npe8TUCdNSZIDOd4V6iBQ0rlLZPIBJdN30BhOhwbMoKmHQJ4xgeYLEJgJ9RwxeUgZmo/IAaC8xA3ES2hVsXYiOc6YDgH9HVqEf6emh2D5hwHNI3vo4CFRKC1LTQ91QvMBrE6B1Rdn6eCh61D6CqkaB0tL4QFakfwKiJ9DY0oKSfwhgaJ90DROU6COhQExINbH4pmUodQ4He0PjXpoKAKAAAMAAa9dFTSK6FoAAAAASUVORK5CYII="

    gCollapseDivId=0
    gPageNavLinks=""
    gBootloadersTextbuildString=""
    gMasterDumpFolder="$passedDirToRead"
    gHtmlDumpFile="$gMasterDumpFolder"/" DarwinDump.htm"
    gCssDumpFile="$gMasterDumpFolder"/CssDumpFile.htm
    gJsDumpFile="$gMasterDumpFolder"/JsDumpFile.js

    # Get state of any dumps that would have been affected by SIP
    if [ "$gSipStr" != "" ]; then
        gCsrBits=$( echo "$gSipStr" | tr -d ',' )
    else
        gCsrBits="111111"
    fi

    if [ "$gLoadedKextsString" != "" ]; then   
        gLdDrvBits=$( echo "$gLoadedKextsString" | tr -d ',' )
    else
        gLdDrvBits="11111"
    fi
}

# ---------------------------------------------------------------------------------------
CheckRoot()
{
    if [ "`whoami`" != "root" ]; then
        echo "Running this requires you to be root."
        sudo "$0"
        exit 0
    fi
}

#
# =======================================================================================
# WRITE HTML, CSS, JAVASCRIPT & RELATED CODE ROUTINES
# =======================================================================================
#

# ---------------------------------------------------------------------------------------
CloseHtmlFile()
{
    echo "Closing HTML"
    WriteHtmlCssOverrideForTextutil
    WriteHtmlClearLineToFile
    WriteHtmlFooterToFile
    WriteHtmlCloseBodyDivToFile
    WriteHtmlCloseSectionCollapseExpandDivToFile
}

# ---------------------------------------------------------------------------------------
CloseCssFile()
{
    echo "Closing CSS"
    echo "</style>" >> "$gCssDumpFile"
}

# ---------------------------------------------------------------------------------------
CombineCssJsAndHtmlFiles()
{
    echo "Appending Javascript to CSS file"
    cat "$gJsDumpFile" >> "$gCssDumpFile"
    rm "$gJsDumpFile"
    echo "Appending HTML to Javascript and CSS file"
    cat "$gHtmlDumpFile" >> "$gCssDumpFile"
    rm "$gHtmlDumpFile"
    echo "Renaming CSS file to HTML file"
    mv "$gCssDumpFile" "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteHtmlHeaderToFile()
{
    local passedDirToRead="$1"

    echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta name=\"description\" content=\"DarwinDumper Report of macOS System\" />
<meta name=\"author\" content=\"Trauma, JrCs, sonotone, phcoder, STLVNUB, blackosx\" />
<meta name=\"keywords\" content=\"osx, system dump, acpi tables, device properties, disk util, disk partitions, bootloaders, memory map, ioreg, kernel dmesg log, kexts, lspci, rtc, smbios, SIP, smc, systemprofiler, video bios\" />
<meta name=\"copyright\" content=\"Copyright 2010-2013 org.darwinx86.app. All rights reserved.\">
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />
<title>$passedDirToRead</title>" >> "$gCssDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteCssToFile()
{
    echo "<style type=\"text/css\">
body { font-family: Tahoma, Lucida Grande, Lucida Sans Unicode; font-size: 11px; background-color: #666; }
#container { width: 1100px; padding:0; margin:0 auto; background: #FFF; box-shadow: 0px 3px 20px rgba(0, 0, 0, 0.75); }
#overview_container_outer { width: 100%; margin: 0; padding: 0; border: 0; }
#overview_container_inner { width: auto; height: 140px; padding: 20px; }
#overview_topBand { width: 100%; height:190px; background-color:#293840; } /* #1BA4C5; } */
#overview_panel_logo{ width: 148px; float: left; background-repeat: no-repeat; background-position: center center; height: 148px; background-image: url($gLogoDD);}
#overview_panel_title{ width: 55%; float: left; margin: 20px 10px 6px; }
#overview_panel_date{ width: 25%; float: right; margin: 27px 10px 6px; text-align: right; }
#overview_panel_one{ width: 320px; float: left; height: 74px; margin: 10px; border-right-width: 1px; border-right-style: solid; border-right-color: #999; color: #DDD; }
#overview_panel_two{ width: 340px; float: left; height: 84px; margin: 10px 10px 10px 30px; border-right-width: 1px; border-right-style: solid; border-right-color: #999; color: #DDD; overflow:auto; }
#overview_panel_three{ float: right; margin: 10px; height: 64px; margin: 10px 10px 10px 5px; text-align: right; color: #DDD; }
#overview_logo_cat{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoCat); }
#overview_logo_moj{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoMoj); }
#overview_logo_hsierra{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoHSierra); }
#overview_logo_sierra{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoSierra); }
#overview_logo_cap{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoCap); }
#overview_logo_yos{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoYos); }
#overview_logo_mav{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoMav); }
#overview_logo_ml{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoML); }
#overview_logo_lion{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoLion); }
#overview_logo_sl{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoSL); }
#overview_logo_leo{ width: 32px; float: left; height: 32px; margin: 10px; background-image: url($gLogoLeo); }
#clear_Line { clear: both; height: 20px; background-color: #FFF; width: auto; }
#dump_container { width: 1060px; margin:0 auto; }
#bootargs { padding: 8px; background-color: #1d282e; } 
#note { padding: 8px; background-color: #bad0d4; } /* #5ea33b; } */

td { word-wrap: break-word; }
tr { font-family: Menlo; font-size: 10px; }

#dump_section_inner_table_header2 { background-color: #666; width: auto; height: 26px; border: 1px solid #555; border-bottom-width: 0px; }
#dump_section_inner_table_header2 a:link, #dump_section_inner_table_header2 a:visited { color: #00FFFF;  text-decoration: none; }
#dump_section_inner_table_header2 a:hover { text-decoration: underline; }
#dump_section_inner_table_subheader_info { background-color: #CCC; width: auto; padding: 3px 0px 3px 10px; border-right: 1px solid #666; border-left: 1px solid #666; }
#dump_section_inner_table_content_container { background-color: #EEE; width: auto; padding: 5px 0px 5px 10px; border: 1px solid #7B7B7B; border-top: 0px; }
#dump_section_inner_table_content_container_scroll { background-color: #EEE; width: auto; padding: 5px 0px 5px 10px; border-left:1px solid #7B7B7B; border-right:1px solid #7B7B7B; height: 400px; overflow: auto; }
#footer { background-color: #d3d7d9; width: auto; height: 50px; padding: 10px; text-align: center; }

.text_medium_section_inner_title { font-size: 12px; font-weight: bold; color: #FFF; position: relative; left: 10px; top: 5px; }
.text_small_section_inner_title { font-size: 12px; font-family: Tahoma; font-weight: normal; color: #000; }
.text_small_section_inner_title a:link, .text_small_section_inner_title a:visited { color: #1F76B3; text-decoration: none;  }
.text_small_section_inner_title a:hover { text-decoration: underline; }
.text_overview_heading { font-size: 20px; font-weight: bold; color: #FFF; }
.text_overview_version { font-size: 12px; line-height: 18px; color: #AAA; }
.text_overview_device { font-size: 10px; line-height: 18px; color: #AAA; }
.text_overview_body { font-size: 12px; line-height: 18px; }

#overview_container_inner a:link, #overview_container_inner a:visited { color: #60bed6; text-decoration: none; }
#overview_container_inner a:hover { text-decoration: underline; }
#footer a:link, #footer a:visited { color: #1f76b3; text-decoration: none; }
#footer a:hover { text-decoration: underline; }

.text_table_heading { font-family: Menlo, Monaco, Courier New; font-size: 10px; font-weight: bold; }
.text_table { font-family: Menlo, Monaco, Courier New; font-size: 10px; }
.text_note { font-family: Tahoma, Geneva, sans-serif; font-size: 12px; text-align: center; color: #444; }
.text_bootargs { font-family: Tahoma, Geneva, sans-serif; font-size: 11px; text-align: center; color: #CCC; }
.text_footer { font-family: Tahoma, Geneva, sans-serif; font-size: 10px; line-height:14px; }
.state { display: none; }
a.make_div_clickable { display: block; height: 100%; width: 100%; }

/*p { font-family: Menlo; font-size: 10px; line-height: 7px; }*/
" >> "$gCssDumpFile"

cat "$JQUERYUISTRUCTURE" >> "$gCssDumpFile"
cat "$JQUERYUITHEMEREPORT" >> "$gCssDumpFile"

# remove safari's focus ring
echo "
:focus {
    outline: none;
}" >> "$gCssDumpFile"


echo "
/* Overrides for jqueryUI theme */

.ui-accordion .ui-accordion-header {
  margin-top: 0;
  border-bottom: none;
}

.ui-accordion .ui-accordion-content {
    padding: 0; /* remove default padding to increase overall space */
}

.ui-tabs {
    padding: 0; /* remove default padding to increase overall space */
    border: none;
}

.ui-tabs .ui-tabs-nav .ui-tabs-anchor { /* Style the tabs */
    font-size: 11px;
    padding: 4px 8px 4px 8px;
}

.ui-tabs .ui-tabs-panel {
    padding: 0; /* remove default padding to increase overall space */
}

ul.ui-tabs-nav li.ui-state-default {
    border: none; /* Remove border around tabs */
}

.ui-tabs-anchor:focus { /* Target the focus of the currently selected tab */
    outline-width: 0px; /* Safari's user agent stylesheet add's a border - here we remove that border */
}

.ui-icon-triangle-1-s, .ui-icon-triangle-1-e {
    display: none; /* As we're not using the image file, then hide arrows at left of section headings */
}

h3 {
    padding-left: 10px !important; /* close the space left for the arrow images that we're not using */
}

/* For highlighting dumps affected by SIP */
h4 {
    padding-left: 10px !important; /* close the space left for the arrow images that we're not using */
    background-image: url($sipIcon) !important;
    background-repeat: no-repeat !important;
    background-position: right center !important;
}" >> "$gCssDumpFile"

}

# ---------------------------------------------------------------------------------------
WriteDiskPartitionCssToFile()
{
    echo "/* disk partition view items */

/* Top bar to hold disk name, size, partition table etc. */
#diskView_inner_table_subheader_info { background-color: #444; width: auto; padding: 3px 0px 3px 10px; border: 1px solid #666; border-top: 0px; border-bottom: 0px; }
.text_small_section_inner_title_White { font-size: 12px; font-weight: normal; color: #FFF; line-height: 18px; font-family: Tahoma; }

/* Main grey box for the Disk page */
#diskView_dd_frame { width: $gMasterFrameWidth; background-color: #555; margin: 0 auto 0 auto; padding: 0px 0px 5px 0px; overflow:hidden; height:1%; }

/* Left side box to hold the partition table */
#diskViewTable { width: 620px; min-height:676px; height: 98%; background-color: #3a3a3a; padding: 0px 0px 5px 0px; border: 1px solid #222; float:left; }

/* table */
.t             { display: table; border-spacing: 0px; width: 620px; }

/* table row */
.tr            { display: table-row; font-family: Menlo; font-size: 10px; color: #FFF; }

/* table cells - GPT */
.gpt_tc_Start_lba  { width: 60px;  display:table-cell; padding: 5px 10px 0px 0px; vertical-align: top;    text-align: right; }
.gpt_tc_Active     { width: 5px;   display:table-cell; padding: 0px  0px 0px 0px; vertical-align: middle; }
.gpt_tc_Mbr_Pe     { width: 114px; display:table-cell; padding: 0px  0px 0px 0px; vertical-align: middle; text-align: center; }
.gpt_tc_Type       { width: 220px; display:table-cell; padding: 0px  0px 0px 0px; vertical-align: middle; text-align: center; }
.gpt_tc_Loader     { width: 100px;  display:table-cell; padding: 0px  0px 0px 0px; vertical-align: middle; text-align: center; }

/* table cells - MBR */
.mbr_tc_Start_lba  { width: 60px;  display:table-cell; padding: 5px 10px 0px 0px; vertical-align: top;    text-align: right; }
.mbr_tc_Active     { width: 5px;   display:table-cell; padding: 0px  0px 0px 0px; vertical-align: middle; }
.mbr_tc_Type       { width: 314px; display:table-cell; padding: 0px  0px 0px 0px; vertical-align: middle; text-align: center; }
.mbr_tc_Loader     { width: 80px;  display:table-cell; padding: 0px  0px 0px 0px; vertical-align: middle; text-align: center; }

/* fill for Header Bar */
#headerBar                             { background-color: #272727; height:26px; color: #FFF; }

/* fills for partition types */
/* Note: I've made all FAT partition types the same colour as Windows Basic Data (see http://en.wikipedia.org/wiki/Basic_data_partition) */
#fillMBR                               { background-color: #6a8034; border-top-color: #8d9f62; border-bottom-color: #45551f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillMBR:hover                         { background-color: #92a952; border-top-color: #b7c88a; border-bottom-color: #65783a; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillEBR                               { background-color: #6a8034; border-top-color: #8d9f62; border-bottom-color: #45551f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillEBR:hover                         { background-color: #92a952; border-top-color: #b7c88a; border-bottom-color: #65783a; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillPrimaryGPTHeader                  { background-color: #6f6342; border-top-color: #918a6e; border-bottom-color: #49432b; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillPrimaryGPTHeader:hover            { background-color: #978964; border-top-color: #bab295; border-bottom-color: #6a6246; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillPrimaryGPTHeaderTop               { background-color: #6f6342; border-top-color: #918a6e; border-bottom-color: #6e6440; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillPrimaryGPTHeaderMid               { background-color: #6f6342; border-top-color: #6e6440; border-bottom-color: #6e6440; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; line-height: 6px; }
#fillPrimaryGPTHeaderBot               { background-color: #6f6342; border-top-color: #6e6440; border-bottom-color: #49432b; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillPrimaryGPTTable                   { background-color: #5b4e27; border-top-color: #837a5a; border-bottom-color: #5b4f25; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillPrimaryGPTTable:hover             { background-color: #827240; border-top-color: #ada280; border-bottom-color: #6c6447; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillBackupGPTHeader                   { background-color: #6f6443; border-top-color: #918a6e; border-bottom-color: #49432b; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillBackupGPTHeader:hover             { background-color: #958c6a; border-top-color: #b2ac95; border-bottom-color: #736d52; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillBackupGPTTable                    { background-color: #5b4e27; border-top-color: #837a5a; border-bottom-color: #5b4f25; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillBackupGPTTable:hover              { background-color: #84794b; border-top-color: #a79f83; border-bottom-color: #675e3a; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillEFISystemPartition                { background-color: #9e8f5e; border-top-color: #b6ab84; border-bottom-color: #6a603d; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillEFISystemPartition:hover          { background-color: #bdb185; border-top-color: #cec6a8; border-bottom-color: #928967; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillFAT12                             { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillFAT12:hover                       { background-color: #8087bc; border-top-color: #a4a8ce; border-bottom-color: #626991; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillFAT16                             { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillFAT16:hover                       { background-color: #8087bc; border-top-color: #a4a8ce; border-bottom-color: #626991; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillFAT16LBA                          { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillFAT16LBA:hover                    { background-color: #8087bc; border-top-color: #a4a8ce; border-bottom-color: #626991; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillFAT32                             { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillFAT32:hover                       { background-color: #8087bc; border-top-color: #a4a8ce; border-bottom-color: #626991; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillFAT32LBA                          { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillFAT32LBA:hover                    { background-color: #8087bc; border-top-color: #a4a8ce; border-bottom-color: #626991; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillNTFS                              { background-color: #198abf; border-top-color: #51a6cf; border-bottom-color: #115c7f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNTFS:hover                        { background-color: #3aacd4; border-top-color: #7bc2df; border-bottom-color: #2c85a4; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillMicrosoftReservedPartition        { background-color: #8f8f8f; border-top-color: #c9c9c9; border-bottom-color: #5f5f5f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillMicrosoftReservedPartition:hover  { background-color: #81a5ab; border-top-color: #a5bec1; border-bottom-color: #648084; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillWindowsBasicData                  { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillWindowsBasicData:hover            { background-color: #8087bc; border-top-color: #a4a8ce; border-bottom-color: #626991; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillWindowsRecoveryEnvironment        { background-color: #299889; border-top-color: #5db1a6; border-bottom-color: #1b655b; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillWindowsRecoveryEnvironment:hover  { background-color: #3dcec0; border-top-color: #8be1d9; border-bottom-color: #289688; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillHFS                               { background-color: #a735a7; border-top-color: #bc65be; border-bottom-color: #702370; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillHFS:hover                         { background-color: #d253d2; border-top-color: #e78bea; border-bottom-color: #983b98; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillAPFS                              { background-color: #d72a95; border-top-color: #e359b1; border-bottom-color: #9a236d; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillAPFS:hover                        { background-color: #ff45bf; border-top-color: #ff7edc; border-bottom-color: #c43b94; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillOSXBoot                           { background-color: #a13b66; border-top-color: #b86b8b; border-bottom-color: #6b2744; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillOSXBoot:hover                     { background-color: #be648e; border-top-color: #cf93ad; border-bottom-color: #934d6e; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillCoreStorage                       { background-color: #8649a0; border-top-color: #a375b7; border-bottom-color: #59316b; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillCoreStorage:hover                 { background-color: #a973be; border-top-color: #c09bce; border-bottom-color: #825993; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillAppleRAID                         { background-color: #d363d3; border-top-color: #de89de; border-bottom-color: #8d428d; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillAppleRAID:hover                   { background-color: #e28ce2; border-top-color: #e9ace9; border-bottom-color: #af6caf; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillAppleKernelCoreDump               { background-color: #ac6295; border-top-color: #b980a9; border-bottom-color: #744265; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillAppleKernelCoreDump:hover         { background-color: #d184ba; border-top-color: #d7a4c7; border-bottom-color: #976086; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillLinux                             { background-color: #bb841a; border-top-color: #cca252; border-bottom-color: #7d5811; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillLinux:hover                       { background-color: #d1a83c; border-top-color: #ddbf7c; border-bottom-color: #a2812c; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillLinuxSwap                         { background-color: #af5e22; border-top-color: #c28558; border-bottom-color: #753f17; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillLinuxSwap:hover                   { background-color: #c98747; border-top-color: #d6a881; border-bottom-color: #9b6937; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillUFS                               { background-color: #7515e1; border-top-color: #974ee8; border-bottom-color: #4e0e96; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillUFS:hover                         { background-color: #8a38e5; border-top-color: #a668eb; border-bottom-color: #6832a6; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillZFS                               { background-color: #e40bd7; border-top-color: #eb46e1; border-bottom-color: #98078f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillZFS:hover                         { background-color: #e82fdc; border-top-color: #ee62e5; border-bottom-color: #a72c9f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillFreeBSD                           { background-color: #410e54; border-top-color: #6f497e; border-bottom-color: #2b0938; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillFreeBSD:hover                     { background-color: #6b257e; border-top-color: #9673a3; border-bottom-color: #521961; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillOpenBSD                           { background-color: #2f0e54; border-top-color: #62497e; border-bottom-color: #1f0938; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillOpenBSD:hover                     { background-color: #57257e; border-top-color: #8b73a3; border-bottom-color: #431961; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillNetBSD                            { background-color: #540e43; border-top-color: #7e4971; border-bottom-color: #38092d; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNetBSD:hover                      { background-color: #7e256d; border-top-color: #a37398; border-bottom-color: #611954; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }

#fillSyncError                         { background-color: #d11212; border-top-color: #dc4c4c; border-bottom-color: #8b0c0c; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillSpace                             { background-color: #565656; border-top-color: #424242; border-bottom-color: #565656; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; line-height: 6px; }
#fillBlank                             { background-color: #3a3a3a; border-top-color: #3a3a3a; border-bottom-color: #3a3a3a; border-left-color: #3a3a3a; border-right-color: #3a3a3a; border-width: 1px; border-style: solid; line-height: 6px; }

/* fills for partition types (as above) without hover */
#fillNoHoverMBR                        { background-color: #68802f; border-top-color: #8d9f62; border-bottom-color: #45551f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverEBR                        { background-color: #68802f; border-top-color: #8d9f62; border-bottom-color: #45551f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverFAT12                      { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverFAT16                      { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverFAT16LBA                   { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverFAT32                      { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverFAT32LBA                   { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverNTFS                       { background-color: #198abf; border-top-color: #51a6cf; border-bottom-color: #115c7f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverMicrosoftReservedPartition { background-color: #8f8f8f; border-top-color: #c9c9c9; border-bottom-color: #5f5f5f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverWindowsBasicData           { background-color: #565e9e; border-top-color: #7f85b6; border-bottom-color: #393f69; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverHFS                        { background-color: #a92ea9; border-top-color: #be61be; border-bottom-color: #711f71; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverOSXBoot                    { background-color: #a13b66; border-top-color: #b86b8b; border-bottom-color: #6b2744; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverCoreStorage                { background-color: #8649a0; border-top-color: #a375b7; border-bottom-color: #59316b; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverAppleRAID                  { background-color: #d363d3; border-top-color: #de89de; border-bottom-color: #8d428d; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverLinux                      { background-color: #bb841a; border-top-color: #cca252; border-bottom-color: #7d5811; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverLinuxSwap                  { background-color: #af5e22; border-top-color: #c28558; border-bottom-color: #753f17; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverUFS                        { background-color: #7515e1; border-top-color: #974ee8; border-bottom-color: #4e0e96; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverZFS                        { background-color: #e40bd7; border-top-color: #eb46e1; border-bottom-color: #98078f; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverSyncError                  { background-color: #d11212; border-top-color: #dc4c4c; border-bottom-color: #8b0c0c; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; padding: 2px 0 2px 0; }
#fillNoHoverSpace                      { background-color: #565656; border-top-color: #424242; border-bottom-color: #565656; border-left-color: #333; border-right-color: #333; border-width: 1px; border-style: solid; line-height: 6px; }
#fillNoHoverBlank                      { background-color: #3a3a3a; border-top-color: #3a3a3a; border-bottom-color: #3a3a3a; border-left-color: #3a3a3a; border-right-color: #3a3a3a; border-width: 1px; border-style: solid; line-height: 6px; }
#fillNoHoverxx                         { background-color: #222222; border-top-color: #222222; border-bottom-color: #222222; border-left-color: #3a3a3a; border-right-color: #3a3a3a; border-width: 1px; border-style: solid; line-height: 6px; }

/* fills for loader and active partition */
#loader                                { background-color: #86c205; border-top-color: #add655; border-bottom-color: #598103; border-top-width: 1px; border-top-style: solid; border-bottom-width: 1px; border-bottom-style: solid; padding: 2px 0 2px 0; font-size: 8px; color: #000; }
/* #loader:hover                          { background-color: #a9d60e; border-top-color: #c7e47f; border-bottom-color: #82a509; border-top-width: 2px; border-top-style: solid; border-bottom-width: 2px; border-bottom-style: solid; padding: 2px 0 2px 0; font-size: 8px; color: #000; } */
#activePart                            { background-color: #edea0d; border-top-color: #f3f15b; border-bottom-color: #9e9c09; border-top-width: 1px; border-top-style: solid; border-bottom-width: 1px; border-bottom-style: solid; padding: 2px 0 2px 0; }

/* Right Side */
#diskInfoHexTableBox { height: 438px; width: 420px; background-color: #3a3a3a; margin-top: 0px; padding: 0px 5px 5px 5px; border: 1px solid #222; float:right; font-family: Menlo; font-size: 10px; color: #FFF; overflow-y:auto;}
#diskInfoDetailsBox  { width: 420px; background-color: #3a3a3a; margin-top: 5px; padding: 0px 5px 5px 5px; border: 1px solid #222; float:right; font-family: Menlo; font-size: 10px; color: #FFF; overflow-y:auto; }

/* Right Side Header Text */
.rsText_Body      { font-size: 12px; color: #FFF; line-height: 5px; }
.rsText_BodyBold  { font-size: 12px; font-weight: bold; color: #FC3; line-height: 10px; }
.rsText_HexTable  { font-size: 12px; color: #FFF; line-height: 12px; }

/* Tooltip - from http://stackoverflow.com/a/25813336 */
[tooltip]:before { content: attr(tooltip); position: absolute; opacity: 0; /* customizable */ transition: all 0.35s ease; padding: 8px; color: #000; border-radius: 6px; border: 1px solid #000; }
[tooltip]:hover:before { /* needed - do not touch */ opacity: 1; /* customizable */ background: #FFF; margin-top: -10px; margin-left: -100px; }
[tooltip]:not([tooltip-persistent]):before { pointer-events: none; }

/* end disk partition view items */
" >> "$gCssDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteIECssToFile()
{
    echo "<!--[if IE]>
<style type=\"text/css\">
  #nav ul { margin-left:0px;}
  .text_table { font-family: \"Courier New\", Courier, monospace; font-size: 11px; }
  .text_large_section_outer_title { font-family:Arial; font-size:14px; font-weight:bold; }
  .text_medium_section_inner_title { font-family:Arial; }
  .text_small_section_inner_title_White { font-family:Arial; }
  #diskInfoHexTableBox { font-family: \"Courier New\", Courier, monospace; font-size: 10px; }
  #diskInfoDetailsBox  { font-family: \"Courier New\", Courier, monospace; font-size: 11px; }
  .rsText_Body      { font-size: 14px; line-height: 10px; }
  .rsText_BodyBold  { font-size: 14px; line-height: 10px; padding-top: 8px; }
  .rsText_HexTable  { font-size: 14px; line-height: 12px; }
</style>
<![endif]-->" >> "$gCssDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteJavaScriptToFile()
{
    # Add jQuery min from file
    echo "
<script type=\"text/javascript\">" >> "$gJsDumpFile"
    cat "$JQUERYMIN" >> "$gJsDumpFile"
    echo "
</script>" >> "$gJsDumpFile"

    # Add jQueryUI min from file
    echo "
<script>" >> "$gJsDumpFile"
    cat "$JQUERYUIMIN" >> "$gJsDumpFile"
    echo "
</script>" >> "$gJsDumpFile"

    echo "

<script type=\"text/javascript\">
\$(function() {
  \$( \"#accordion\" ).accordion({
      heightStyle: \"content\",
      active: false,
      collapsible: true,
      animate: {
        duration: 150
    }
  });
});
function navShowHeaderBar(divID, state)
{
    var table = document.getElementById(divID);
    table.style.display = 'block';
}
function headerBarToggleShowHide(divID, state)
{
    var table = document.getElementById(divID);
    table.style.display = table.style.display == 'none' ? 'block' : 'none';
}
</script>" >> "$gJsDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteJavaScriptJqueryUITabToFile()
{
    local passedTabName="$1"
    echo "<script type=\"text/javascript\">
\$(function() {
  \$( \"#tabs_$passedTabName\" ).tabs();
});
</script>
" >> "$gJsDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteHtmlCssOverrideForTextutil()
{
    echo "<head>
  <style type=\"text/css\">
    p.p1 { font-family: Menlo; font-size: 10px; line-height: 18px;}
    p.p2 { font-family: Menlo; font-size: 10px; line-height: 18px;}
  </style>
</head>" >> "$gHtmlDumpFile"
}


# ---------------------------------------------------------------------------------------
WriteHtmlClearLineToFile()
{
    echo "<div id=\"clear_Line\"></div>" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteHtmlFooterToFile()
{
    echo "<div id=footer> <span class=\"text_footer\"><a href=\"https://bitbucket.org/blackosx/darwindumper\" target=\"_blank\">DarwinDumper</a> is licensed under <a href=\"http://opensource.org/licenses/GPL-3.0\" target=\"_blank\">GPL v3</a>. The individual programs used to collect and decode some of the data each come under <a href=\"http://bit.ly/1ksKSGY\" target=\"_blank\">their own respective licences</a>.<br />DarwinDumper is built upon <a href=\"https://github.com/MacGapProject/MacGap2\" target=\"_blank\">MacGap2</a> for it's user interface.</span></div>" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
CalculateTableWidths()
{
    local passedOutputType="$1"

    # This uses the gMasterFrameWidth set at the head of this file.
    local gContainerWidth=${gMasterFrameWidth%px*}
    gTableBoxWidth=$((gContainerWidth-20))
    gTableTextBoxWidth=$((gTableBoxWidth-6))

    # Calculate percentage widths of table columns, then add 100.
    if [ "$passedOutputType" == "DiskDump" ]; then
        # Original design pixel widths were 53, 66, 142, 181, 58, 146, 90, 204
        # New design pixel widths are 35, 60, 165, 162, 47, 130, 186, 161
        # To fit UEFI revisions, let's try widths of 30, 57, 160, 157, 45, 125, 180, 180
        # Latest squeeze to fit better, let's try widths of 7, 56, 139, 163, 50, 120, 214, 205
        local gColOnePcToUse=$(bc <<< 'scale=3; 7 / '$gTableTextBoxWidth' * 100 + 100')
        local gCoTwoPcToUse=$(bc <<< 'scale=3; 56 / '$gTableTextBoxWidth' * 100 + 100')
        local gColThreePcToUse=$(bc <<< 'scale=3; 139 / '$gTableTextBoxWidth' * 100 + 100')
        local gColFourPcToUse=$(bc <<< 'scale=3; 163 / '$gTableTextBoxWidth' * 100 + 100')
        local gColFivePcToUse=$(bc <<< 'scale=3; 50 / '$gTableTextBoxWidth' * 100 + 100')
        local gColSixPcToUse=$(bc <<< 'scale=3; 120 / '$gTableTextBoxWidth' * 100 + 100')
        local gColSevenPcToUse=$(bc <<< 'scale=3; 214 / '$gTableTextBoxWidth' * 100 + 100')
        local gColEightPcToUse=$(bc <<< 'scale=3; 205 / '$gTableTextBoxWidth' * 100 + 100')
    fi

    if [ "$passedOutputType" == "KextDump" ]; then
        # Original design pixel widths were 34, 34, 108, 68, 68, 341, 89, 170
        local gColOnePcToUse=$(bc <<< 'scale=3; 32 / '$gTableTextBoxWidth' * 100 + 100')
        local gCoTwoPcToUse=$(bc <<< 'scale=3; 32 / '$gTableTextBoxWidth' * 100 + 100')
        local gColThreePcToUse=$(bc <<< 'scale=3; 108 / '$gTableTextBoxWidth' * 100 + 100')
        local gColFourPcToUse=$(bc <<< 'scale=3; 66 / '$gTableTextBoxWidth' * 100 + 100')
        local gColFivePcToUse=$(bc <<< 'scale=3; 66 / '$gTableTextBoxWidth' * 100 + 100')
        local gColSixPcToUse=$(bc <<< 'scale=3; 349 / '$gTableTextBoxWidth' * 100 + 100')
        local gColSevenPcToUse=$(bc <<< 'scale=3; 89 / '$gTableTextBoxWidth' * 100 + 100')
        local gColEightPcToUse=$(bc <<< 'scale=3; 170 / '$gTableTextBoxWidth' * 100 + 100')
    fi

    # Calculate pixel width to use based on percentage of total width.
    gColOne=$(bc <<< 'scale=3; '$gTableTextBoxWidth' / 100 * '$gColOnePcToUse' - '$gTableTextBoxWidth' ')
    gColTwo=$(bc <<< 'scale=3; '$gTableTextBoxWidth' / 100 * '$gCoTwoPcToUse' - '$gTableTextBoxWidth' ')
    gColThree=$(bc <<< 'scale=3; '$gTableTextBoxWidth' / 100 * '$gColThreePcToUse' - '$gTableTextBoxWidth' ')
    gColFour=$(bc <<< 'scale=3; '$gTableTextBoxWidth' / 100 * '$gColFourPcToUse' - '$gTableTextBoxWidth' ')
    gColFive=$(bc <<< 'scale=3; '$gTableTextBoxWidth' / 100 * '$gColFivePcToUse' - '$gTableTextBoxWidth' ')
    gColSix=$(bc <<< 'scale=3; '$gTableTextBoxWidth' / 100 * '$gColSixPcToUse' - '$gTableTextBoxWidth' ')
    gColSeven=$(bc <<< 'scale=3; '$gTableTextBoxWidth' / 100 * '$gColSevenPcToUse' - '$gTableTextBoxWidth' ')
    gColEight=$(bc <<< 'scale=3; '$gTableTextBoxWidth' / 100 * '$gColEightPcToUse' - '$gTableTextBoxWidth' ')
}

# ---------------------------------------------------------------------------------------
WriteHtmlCloseHeadToFile()
{
    echo "</head>" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteHtmlOpenBodyOpenDivToFile()
{
    if [ -d "$gDumpFolderIoreg/IORegViewer/Resources/dataFiles" ]; then
        echo "<body bgcolor=\"#666\">
<div id=\"container\">" >> "$gHtmlDumpFile"
    else
        echo "<body bgcolor=\"#666\">
<div id=\"container\">" >> "$gHtmlDumpFile"
    fi
}

# ---------------------------------------------------------------------------------------
WriteHtmlCloseBodyDivToFile()
{
    echo "</div> <!-- End container -->
</body>
</html>" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteHtmlSectionAnchorToFile()
{
    local passedAnchor="$1"

    echo "<a name=\"$passedAnchor\"></a>" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteHtmlSectionHeadingToFile()
{
    local passedSectionHeading="$1"

    echo "<span class=\"text_large_section_outer_title\">$passedSectionHeading</span>" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteOuterH3()
{
    local passeOuterHeading="$1" # Used for the table title.
    echo "<h3>$passeOuterHeading</h3>
<div>" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteOuterH4()
{
    local passeOuterHeading="$1" # Used for the table title.
    echo "<h4>$passeOuterHeading</h4>
<div>" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteEndingH3()
{
    echo "</div> <!-- End h3 -->" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteHtmlCloseSectionOuterDivToFile()
{
    echo "</div> <!-- End sectionname -->" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteHtmlCloseSectionCollapseExpandDivToFile()
{
    echo "</div> <!-- End Outer Section Collapse/Expand div-->" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
# The dark grey header bar under the main (coloured) section bar - Non Collapsable
WriteHtmlTableHeaderToFile()
{
    local passedTableHeading="$1"

    echo "<div id=\"dump_section_inner_table_header2\">
  <span class=\"text_medium_section_inner_title\">$passedTableHeading</span>
</div>" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
ReadDirCreateTabsAddFileData()
{
    local passedDirToRead="$1"
    local tabname="$2"
    local finalDestination="$3"
    local files=()
    local filesExtensionRemoved=()
    local count=0
    local tmp
    local infoString=""

    WriteJavaScriptJqueryUITabToFile "$tabname"

    # Check if Directory is not empty.
    if [ "$(ls -A "${passedDirToRead}")" ]; then

        # Build list of file names
        for file in "$passedDirToRead"/*
        do
            # skip any directories
            if [[ -f $file ]]; then
              # Check for, and exclude, files we don't want to include in the report (for example, .rom)
              local lastFour=$( echo -n "$file" | tail -c 4 )
              if [ ! "$lastFour" == ".rom" ]; then
                  files+=("${file##*/}")
                  tmp="${files[$count]%.txt*}"
                  tmp="${tmp%.dsl*}"
                  filesExtensionRemoved+=("$tmp")
                  ((count++))
              fi
            fi
        done

        if [ $count -gt 0 ]; then
            # Write tabs to file
            echo "<div id=\"tabs_${tabname}\">
  <ul>" >> "$gHtmlDumpFile"
            for (( n=0; n<$count; n++ ))
            do
                echo "    <li><a href=\"#tabs_${tabname}-$((n+1))\">${filesExtensionRemoved[$n]}</a></li>" >> "$gHtmlDumpFile"
            done
            echo  "</ul>" >> "$gHtmlDumpFile"

            # Write html to file
            for (( n=0; n<$count; n++ ))
            do

                # Match details for printing about the tool/dump.
                # Include all tables names from iasl -ht and also other sources.
                case "$tabname" in
                    "acpitableinfo") case ${filesExtensionRemoved[$n]} in
                                         AAFT) infoString="ASRock OEM AAFT Table" ;;
                                         APIC) infoString="Multiple APIC Description Table" ;;
                                         APIC*) infoString="Multiple APIC Description Table" ;;
                                         ASF!) infoString="Alert Standard Format Table" ;;
                                         BERT) infoString="Boot Error Record Table" ;;
                                         BGRT) infoString="Boot Graphics Resource Table" ;;
                                         BOOT) infoString="Simple Boot Flag Table" ;;
                                         CPEP) infoString="Corrected Platform Error Polling Table" ;;
                                         CSRT) infoString="Core System Resources Table" ;;
                                         DBG2) infoString="Debug Port Table 2" ;;
                                         DBGP) infoString="Debug Port Table" ;;
                                         DMAR) infoString="DMA Remapping Table" ;;
                                         DRTM) infoString="Dynamic Root of Trust for Measurement table" ;;
                                         DSDT) infoString="Differentiated System Description Table" ;;
                                         ECDT) infoString="Embedded Controller Boot Table" ;;
                                         EINJ) infoString="Error Injection Table" ;;
                                         ERST) infoString="Error Record Serialization Table" ;;
                                         ETDT) infoString="Event Timer Description Table (Obsolete)" ;;
                                         FACP) infoString="Fixed ACPI Description Table" ;;
                                         FACS) infoString="Firmware ACPI Control Structure" ;;
                                         FADT) infoString="Fixed ACPI Description Table" ;;
                                         FPDT) infoString="Firmware Performance Data Table" ;;
                                         GTDT) infoString="Generic Timer Description Table" ;;
                                         HEST) infoString="Hardware Error Source Table" ;;
                                         HMAT) infoString="Heterogeneous Memory Attributes Table" ;;
                                         HPET) infoString="High Precision Event Timer Table" ;;
                                         IBFT) infoString="iSCSI Boot Firmware Table" ;;
                                         IORT) infoString="IO Remapping Table" ;;
                                         IVRS) infoString="I/O Virtualization Reporting Structure" ;;
                                         LPIT) infoString="Low Power Idle Table" ;;
                                         MADT) infoString="Multiple APIC Description Table" ;;
                                         MCFG) infoString="PCI Express memory mapped configuration space base address Description Table" ;;
                                         MCHI) infoString="Management Controller Host Interface Table" ;;
                                         MPST) infoString="Memory Power State Table" ;;
                                         MSCT) infoString="Maximum System Characteristics Table" ;;
                                         MSDM) infoString="Microsoft Data Management Table" ;;
                                         MTMR) infoString="MID Timer Table" ;;
                                         NFIT) infoString="NVDIMM Firmware Interface Table" ;;
                                         OEM*) infoString="OEM Specific Information Tables" ;;
                                         PCCT) infoString="Platform Communications Channel Table" ;;
                                         PDTT) infoString="Platform Debug Trigger Table" ;;
                                         PMTT) infoString="Platform Memory Topology Table" ;;
                                         PPTT) infoString="Processor Properties Topology Table" ;;
                                         PSDT) infoString="Persistent System Description Table" ;;
                                         RASF) infoString="ACPI RAS Feature Table" ;;
                                         RSDP) infoString="Root System Description Pointer" ;;
                                         RSDT) infoString="Root System Description Table" ;;
                                         S3PT) infoString="S3 Performance Table" ;;
                                         SBST) infoString="Smart Battery Specification Table" ;;
                                         SDEI) infoString="Software Delegated Exception Interface Table" ;;
                                         SDEV) infoString="Secure Devices table" ;;
                                         SLIC) infoString="Microsoft Software Licensing Table Specification" ;;
                                         SLIT) infoString="System Locality Distance Information Table" ;;
                                         SPCR) infoString="Serial Port Console Redirection Table" ;;
                                         SPMI) infoString=" Server Platform Management Interface Table" ;;
                                         SRAT) infoString="System Resource Affinity Table" ;;
                                         SSDT) infoString="Secondary System Description Table" ;;
                                         SSDT*) infoString="Secondary System Description Table" ;;
                                         STAO) infoString="Status Override table" ;;
                                         TCPA) infoString="Trusted Computing Platform Alliance Capabilities Table" ;;
                                         TPM2) infoString="Trusted Platform Module 2 Table" ;;
                                         UEFI) infoString="UEFI ACPI Data Table" ;;
                                         VRTC) infoString="Virtual Real-Time Clock Table" ;;
                                         WAET) infoString="Windows ACPI Eemulated Devices Table" ;;
                                         WDAT) infoString="Watchdog Action Table" ;;
                                         WDDT) infoString="Watchdog Description Table" ;;
                                         WDRT) infoString="Watchdog Resource Table" ;;
                                         WPBT) infoString="Windows Platform Binary Table" ;;
                                         WSMT) infoString="Windows SMM Security Mitigations Table" ;;
                                         XENV) infoString="Xen Environment table" ;;
                                         XSDT) infoString="Extended System Description" ;;
                                         *) infoString="Unknown table description."
                                     esac ;;
                    "audio")      if [ "${filesExtensionRemoved[$n]}" == "AudioCodecID" ]; then
                                      infoString="Dumped using <a href=\"https://github.com/Gengik84/getcodecid/\" target=\"_blank\">getcodecid</a> v2.4. Originally by Andy Vandijck. Further developed by InsanelyDeepak, ErmaC, Micky1979, Foskvs and Gengik84"
                                  elif [ "${filesExtensionRemoved[$n]}" == "VoodooHDAGetdump" ]; then
                                      infoString="Dumped using <a href=\"https://sourceforge.net/projects/voodoohda/\" target=\"_blank\">VoodooHDA</a> v2.9.2 combined with <a href=\"https://sourceforge.net/projects/voodoohda/files/\" target=\"_blank\">VoodooHDA's getdump tool</a>"
                                  fi ;;
                    "biosVideo")  infoString="Decoded using <a href=\"https://www.dropbox.com/s/5drpckxlmaot732/RadeonPCI.zip?dl=0\" target=\"_blank\">Andy Vandijck's</a> updated version of dong's radeon_bios_decode tool" ;;
                    "cpuinfo")    if [ "${filesExtensionRemoved[$n]}" == "cpuinfo" ]; then
                                      infoString="Dumped using <a href=\"https://github.com/CloverHackyColor/x86info\" target=\"_blank\">x86info v1.31pre</a>. Written to succeed CPUID by Phil Karn (KA9Q). Compiled by Slice."
                                  elif [ "${filesExtensionRemoved[$n]}" == "AppleIntelInfo" ]; then
                                      # Get version of AppleIntelInfo.kext
                                      versionStr="0.0"
                                      if [ -f "$DRIVERS_DIR"/AppleIntelInfo.kext/Contents/Info.plist ]; then
                                          versionStr=$( /usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$DRIVERS_DIR"/AppleIntelInfo.kext/Contents/Info.plist )
                                      fi
                                      infoString="Dumped using <a href=\"https://github.com/Piker-Alpha/AppleIntelInfo\" target=\"_blank\">Piker-Alpha's AppleIntelInfo</a> v$versionStr"
                                  fi ;;
                    "lspciinfo")  if [ "${filesExtensionRemoved[$n]}" == "lspci (nnvv)" ]; then
                                      infoString="Numbers & names view. Dumped using <a href=\"https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git\" target=\"_blank\">lspci (from pciutils 3.6.4)</a>. This version compiled by blackosx."
                                  elif [ "${filesExtensionRemoved[$n]}" == "lspci detailed (nnvvbxxxx)" ]; then
                                      infoString="Bus centric view - Extended hex dump. Dumped using <a href=\"https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git\" target=\"_blank\">lspci (from pciutils 3.6.4)</a>. This version compiled by blackosx."
                                  elif [ "${filesExtensionRemoved[$n]}" == "lspci tree (nnvvt)" ]; then
                                      infoString="Tree view. Dumped using <a href=\"https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git\" target=\"_blank\">lspci (from pciutils 3.6.4)</a>. This version compiled by blackosx."
                                  elif [ "${filesExtensionRemoved[$n]}" == "lspci map (M)" ]; then
                                      infoString="Map view. Dumped using <a href=\"https://git.kernel.org/pub/scm/utils/pciutils/pciutils.git\" target=\"_blank\">lspci (from pciutils 3.6.4)</a>. This version compiled by blackosx."
                                  fi ;;
                    "memory")     if [ "${filesExtensionRemoved[$n]}" == "IntelGraphics_00000000_00000fff" ]; then
                                      infoString="VGA and VGA Extended Registers"
                                  elif  [ "${filesExtensionRemoved[$n]}" == "IntelGraphics_00002000_00002fff" ]; then
                                      infoString="Primary CS Instruction and Interrupt Control Registers"
                                  elif  [ "${filesExtensionRemoved[$n]}" == "IntelGraphics_00003000_000031ff" ]; then
                                      infoString="FENCE & Per-Process GTT Control Registers"
                                  elif  [ "${filesExtensionRemoved[$n]}" == "IntelGraphics_00003200_00003fff" ]; then
                                      infoString="Frame Buffer Compression Registers"
                                  elif  [ "${filesExtensionRemoved[$n]}" == "IntelGraphics_0000a000_0000afff" ]; then
                                      infoString="Display Palette Registers"
                                  fi
                                  ;;
                    "kernelinfo") if [ ${filesExtensionRemoved[$n]} == "kernel_version" ]; then
                                      infoString="Dumped using uname -v"
                                  elif [ ${filesExtensionRemoved[$n]} == "sysctl_cpu" ]; then
                                      infoString="Dumped using /usr/sbin/sysctl -a | grep cpu"
                                  elif [ ${filesExtensionRemoved[$n]} == "sysctl_hw" ]; then
                                      infoString="Dumped using /usr/sbin/sysctl -a | grep hw"
                                  elif [ ${filesExtensionRemoved[$n]} == "sysctl_machdep_xcpm" ]; then
                                      infoString="Dumped using /usr/sbin/sysctl -a machdep.xcpm (Thanks Pike)."
                                  fi ;;
                     "nvraminfo") if [ ${filesExtensionRemoved[$n]} == "nvram.plist" ]; then
                                      infoString="Dumped using nvram -x -p"
                                  elif [ ${filesExtensionRemoved[$n]} == "nvram_hexdump" ]; then
                                      infoString="Dumped with nvram -hp using an <a href=\"https://bitbucket.org/blackosx/nvram\" target=\"_blank\">amended version of Apple's nvram tool.</a>"
                                  elif [ ${filesExtensionRemoved[$n]} == "uefi_firmware_vars" ]; then
                                      infoString="Dumped with nvram -ha using an <a href=\"https://bitbucket.org/blackosx/nvram\" target=\"_blank\">amended version of Apple's nvram tool.</a>"
                                  fi ;;
                     "power")     if [ ${filesExtensionRemoved[$n]} == "pm_log" ]; then
                                      infoString="Dumped using the command line: pmset -g log"
                                  elif [ ${filesExtensionRemoved[$n]} == "pm_settings" ]; then
                                      infoString="Dumped using the command line: pmset -g"
                                  elif [ ${filesExtensionRemoved[$n]} == "pm_assertions" ]; then
                                      infoString="Dumped using the command line: pmset -g assertions"
                                  fi ;;
                          "smc") infoString="Dumped keys using <a href=\"https://www.dropbox.com/s/0dgvexijx4oewfr/smcutil.zip?dl=0\" target=\"_blank\">smcutil</a>, and fans using <a href=\"https://www.dropbox.com/s/ra9h6gbjj6yhgol/SMC_util_FansOnly.zip?dl=0\" target=\"_blank\">SMC_util_FansOnly</a> (Amended version of SMC_util3 by usr-sse2)" ;;
                              *)  infoString="${filesExtensionRemoved[$n]}" ;;
                esac

                echo "<div id=\"tabs_${tabname}-$((n+1))\">" >> "$gHtmlDumpFile"
                ReadFileAndWriteSubSectionToHtml "$passedDirToRead/${files[$n]}"\
                                                 "$infoString"\
                                                 "<a href=\"$finalDestination/${files[$n]}\" target=\"_blank\">View File ${files[$n]}</a>"\
                                                 "${filesExtensionRemoved[$n]}"\
                                                 ""\
                                                 ""\
                                                 "$tabname"
                echo "</div> <!-- End tabs_${tabname}-$((n+1)) -->" >> "$gHtmlDumpFile"
            done
            echo "</div> <!-- Close tabs_${tabname} -->" >> "$gHtmlDumpFile"
        fi
    fi
}

# ---------------------------------------------------------------------------------------
# The dark grey header bar under the main (coloured) section bar - Collapsable
WriteHtmlTableHeaderWithCollapseToFile()
{
    local passedTableHeading="$1"
    local passedCollapseDivId="$2"
    local passedState="$3"
    local whichArrow=$(SelectArrow)

    if [ "$passedCollapseDivId" == "" ]; then
        passedCollapseDivId=collapseID_$gCollapseDivId
    fi

    # Remove any exclamation marks from collapseID.
    if [[ "$passedCollapseDivId" == *!* ]]; then
        passedCollapseDivId=$( echo "$passedCollapseDivId" | sed 's/\!//g' )
    fi

    echo "<div id=\"dump_section_inner_table_header2\">
<a class="make_div_clickable" style=\"cursor:pointer;\" onClick=\"javascript:headerBarToggleShowHide('$passedCollapseDivId', this)\"> <span class=\"text_medium_section_inner_title\"> $passedTableHeading</span></a></td></tr></table>
</div> <!-- End dump_section_inner_table_header2 -->
<div id=\"$passedCollapseDivId\" style=\"display:${passedState};\">" >> "$gHtmlDumpFile"

    echo "#$passedCollapseDivId { display: $passedState; }" >> "$gCssDumpFile"
    ((gCollapseDivId++))
}

# ---------------------------------------------------------------------------------------
# The light grey sub header bar under the dark grey header bar.
WriteHtmlTableSubHeaderToFile()
{
    local passedType="$1"
    local passedDevice="$2"
    local passedSize="$3"
    local passedContent="$4"
    local passedMbrBootCode="$5"
    local finalDestination="$6"

    if [ "$passedType" == "Disk" ]; then
        if [ "$passedMbrBootCode" == "" ] || [ "$passedMbrBootCode" == " " ]; then
            passedMbrBootCode=""
        else
            passedMbrBootCode="| MBR boot code detected: $passedMbrBootCode"
        fi
        echo "<div id=\"dump_section_inner_table_subheader_info\">
<table><tr><td class=\"text_small_section_inner_title\">$passedDevice | $passedSize | $passedContent $passedMbrBootCode | <a href=\"$finalDestination\" target=\"_blank\">View Disk Sectors</a></td></tr></table>
</div>" >> "$gHtmlDumpFile"
    else
        echo "<div id=\"dump_section_inner_table_subheader_info\">
<table><tr class=\"text_small_section_inner_title\"><td>$passedDevice</td></tr></table>
</div>" >> "$gHtmlDumpFile"
    fi
}

# ---------------------------------------------------------------------------------------
# The very light grey main section content panel, under the light grey sub header bar.
WriteHtmlTableTextHeadingToFile()
{
    local tableType="$1"
    # These tables have text headings
    if [ "$tableType" == "diskutil" ]; then
        echo "<div id=\"dump_section_inner_table_content_container\">
<table style=\"table-layout: fixed; width: 100%\" width=\"$gTableBoxWidth\" border=\"0\">
  <tr class=\"text_table_heading\"><td width=\"$gColOne\"></td><td width=\"$gColTwo\">DEVICE</td><td width=\"$gColThree\">TYPE</td><td width=\"$gColFour\">NAME</td><td width=\"$gColFive\">SIZE</td><td width=\"$gColSix\">PBR (Stage1)</td><td width=\"$gColSeven\">BootFile (Stage 2)</td><td width=\"$gColEight\">UEFI BootFile</td></tr>" >> "$gHtmlDumpFile"
    elif [ "$tableType" == "NonAppleKexts" ]; then
        echo "<div id=\"dump_section_inner_table_content_container\">
<table style=\"table-layout: fixed; width: 100%\" width=\"$gTableBoxWidth\" border=\"0\">
  <tr class=\"text_table_heading\"><td width=\"$gColOne\">IDX</td><td width=\"$gColTwo\">REFS</td><td width=\"$gColThree\">ADDRESS</td><td width=\"$gColFour\">SIZE</td><td width=\"$gColFive\">WIRED</td><td width=\"$gColSix\">NAME</td><td width=\"$gColSeven\">VERSION</td><td width=\"$gColEight\">LINKED AGAINST</td></tr>" >> "$gHtmlDumpFile"
    elif [ "$tableType" == "AppleKexts" ]; then
        echo "<div id=\"dump_section_inner_table_content_container_scroll\">
<table style=\"table-layout: fixed; width: 100%\" width=\"$gTableBoxWidth\" border=\"0\">
  <tr class=\"text_table_heading\"><td width=\"$gColOne\">IDX</td><td width=\"$gColTwo\">REFS</td><td width=\"$gColThree\">ADDRESS</td><td width=\"$gColFour\">SIZE</td><td width=\"$gColFive\">WIRED</td><td width=\"$gColSix\">NAME</td><td width=\"$gColSeven\">VERSION</td><td width=\"$gColEight\">LINKED AGAINST</td></tr>" >> "$gHtmlDumpFile"

    # Don't print a text table header for the others.
    # These tables don't use scrollable boxes
    elif [ "$tableType" == "dmitables" ] || [ "$tableType" == "rcLocal" ]; then
        echo "<div id=\"dump_section_inner_table_content_container\">
<table style=\"table-layout: fixed; width: 100%\" width=\"$gTableBoxWidth\" border=\"0\">" >> "$gHtmlDumpFile"

    # These tables use scrollable boxes
    else
        echo "<div id=\"dump_section_inner_table_content_container_scroll\">
<table style=\"table-layout: fixed; width: 100%\" width=\"$gTableBoxWidth\" border=\"0\">" >> "$gHtmlDumpFile"
    fi
}

# ---------------------------------------------------------------------------------------
# The masthead of the page.
WriteHtmlOverviewToFile()
{
    local passedTimeStamp="$1"
    local passedOsVersion="$2"
    local passedMacModel="$3"
    local passedCpu="$4"
    local passedGraphics="$5"
    local passedMemory="$6"
    local passedCodecID="$7"
    local passedSic="$8"

    local buildFile=""
    local osLogo=""
    local osVersion=$(CheckOsVersion)
    local osName=$(GetOsName)

    case "${osVersion}" in
         9) osLogo="overview_logo_leo" ;;
        10) osLogo="overview_logo_sl" ;;
        11) osLogo="overview_logo_lion" ;;
        12) osLogo="overview_logo_ml" ;;
        13) osLogo="overview_logo_mav" ;;
        14) osLogo="overview_logo_yos" ;;
        15) osLogo="overview_logo_cap" ;;
        16) osLogo="overview_logo_sierra" ;;
        17) osLogo="overview_logo_hsierra" ;;
        18) osLogo="overview_logo_moj" ;;
        19) osLogo="overview_logo_cat" ;;
    esac

    buildFile="<div id=\"overview_container_outer\">
  <div id=\"overview_topBand\">
    <div id=\"overview_container_inner\">
      <div id=\"overview_panel_logo\"><div id=\"ddlogo\"></div></div>"

    if [ "$gPrivateState" == "Private" ]; then
        buildFile="$buildFile
      <div id=\"overview_panel_title\" class=\"text_overview_heading\">$APP_DIR_NAME Report&nbsp;<img alt=\"\" width=\"52\" height=\"22\" align=\"top\" src=\"${privateStamp}\"/><span class=\"text_overview_body\">&nbsp;&nbsp;Version: ${DD_VER}</span></div>"
    else
       buildFile="$buildFile
      <div id=\"overview_panel_title\" class=\"text_overview_heading\">$APP_DIR_NAME Report<span class=\"text_overview_version\">&nbsp;&nbsp;Version: ${DD_VER}</span></div>"
    fi

    if [ "$passedSic" != "" ]; then
        passedSic="SIP:&nbsp;${passedSic}"
    fi

    buildFile="$buildFile
      <div id=\"overview_panel_date\" class=\"text_overview_version\">${passedTimeStamp}</div>
      <div id=\"overview_panel_one\" class=\"text_overview_body\">Mac Model: <a href=\"http://www.everymac.com/ultimate-mac-lookup/?search_keywords=${passedMacModel}\" target=\"_blank\">${passedMacModel}</a><br />CPU: ${passedCpu}<br />Memory: ${passedMemory}</div>
      <div id=\"overview_panel_two\" class=\"text_overview_body\">${passedGraphics}<br />${passedCodecID}</div>
      <div id=\"overview_panel_three\"><div id=\"${osLogo}\"></div><span class=\"text_overview_body\">Operating System<br /><strong>${osName}</strong><br />$passedOsVersion<br />${passedSic}</span></div>
    </div> <!-- End overview_container_inner -->
  </div> <!-- End overview_topBand -->
</div> <!-- End overview_container_outer -->"
    echo "${buildFile}" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteHtmlTableTextToFile()
{
    case "$#" in
        1) printf "%s\n" "<tr><td>$1</td></tr>" >> "$gHtmlDumpFile" ;;
        2) printf "%s\n" "<tr><td>$1</td><td>$2</td></tr>" >> "$gHtmlDumpFile" ;;
        3) printf "%s\n" "<tr><td>$1</td><td>$2</td><td>$3</td></tr>" >> "$gHtmlDumpFile" ;;
        4) printf "%s\n" "<tr><td>$1</td><td>$2</td><td>$3</td><td>$4</td></tr>" >> "$gHtmlDumpFile" ;;
        5) printf "%s\n" "<tr><td>$1</td><td>$2</td><td>$3</td><td>$4</td><td>$5</td</tr>" >> "$gHtmlDumpFile" ;;
        6) printf "%s\n" "<tr><td>$1</td><td>$2</td><td>$3</td><td>$4</td><td>$5</td><td>$6</td></tr>" >> "$gHtmlDumpFile" ;;
        7) printf "%s\n" "<tr><td>$1</td><td>$2</td><td>$3</td><td>$4</td><td>$5</td><td>$6</td><td>$7</td></tr>" >> "$gHtmlDumpFile" ;;
        8) printf "%s\n" "<tr><td>$1</td><td>$2</td><td>$3</td><td>$4</td><td>$5</td><td>$6</td><td>$7</td><td>$8</td></tr>" >> "$gHtmlDumpFile" ;;
    esac
}

# ---------------------------------------------------------------------------------------
WriteHtmlTableTextEndingToFile()
{
    echo "</table>
</div> <!-- End table_container ( also closes End table_container_scroll ) -->" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
InsertInternalSeparatorHTMLToFile()
{
    local passedTitle="$1"

    echo "" >> "$gHtmlDumpFile"
    echo "<!-- ====================================================================================================================================================== -->" >> "$gHtmlDumpFile"
    echo "<!--                                                     SECTION FOR: $passedTitle                                        -->" >> "$gHtmlDumpFile"
    echo "<!-- ====================================================================================================================================================== -->" >> "$gHtmlDumpFile"
    echo "" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
SelectArrow()
{
    local whichArrow=""
    if [ "$gTableState" == "block" ]; then
        whichArrow="${gArrowClosed}"
    else
        whichArrow="${gArrowOpen}"
    fi
    echo "$whichArrow" # This line acts as a return to the caller.
}

# ---------------------------------------------------------------------------------------
SetHtmlNonBreakingSpace()
{
    local passedFile="$1"

    LANG=C expand "$passedFile" > "$passedFile_spaces.txt" # Convert tabs to spaces
    LANG=C sed -i.bak 's/ /\&nbsp\;/g' "$passedFile_spaces.txt" # Convert spaces to html non-breaking space &nbsp

    echo "$passedFile_spaces.txt" # This line acts as a return to the caller.
}


# ---------------------------------------------------------------------------------------
FixHtmlLessThanGreaterThan()
{
    local passedFile="$1"

    LANG=C sed -i.bak 's/</\&lt\;/g' "$passedFile" # Convert < to &lt
    LANG=C sed -i.bak 's/>/\&gt\;/g' "$passedFile" # Convert > to &gt

    echo "$passedFile" # This line acts as a return to the caller.
}

# ---------------------------------------------------------------------------------------
RemoveHtmlNonBreakingSpaceFiles()
{
    local passedFile="$1"

    rm "$passedFile_spaces.txt"
    rm "$passedFile_spaces.txt.bak"
}

# ---------------------------------------------------------------------------------------
ReadFileAndWriteCompleteSectionToHtml()
{
    local passedFile="$1"
    local passedSectionHeading="$2"
    local passedTableHeading="$3"
    local passedSubHeader="$4"
    local passedTextHeading="$5"
    local passedAnchor="$6"
    local passedWarning="$7"
    local passedColllapseDivId="$8"
    local passedSipAllowed="$9"
    local lineRead

    if [ "$passedSipAllowed" == "N" ]; then
        WriteOuterH4 "$passedSectionHeading"
    else
        WriteOuterH3 "$passedSectionHeading"
    fi
    WriteHtmlTableHeaderToFile "$passedTableHeading"
    WriteHtmlTableSubHeaderToFile "" "$passedSubHeader"
    WriteHtmlTableTextHeadingToFile "$passedTextHeading"
    /usr/bin/textutil -convert html "$passedFile" -stdout >> "$gHtmlDumpFile"
    WriteHtmlTableTextEndingToFile
    WriteEndingH3
}

# ---------------------------------------------------------------------------------------
ReadFileAndWriteSubSectionToHtml()
{
    local passedFile="$1"
    local passedTableHeading="$2"   # Dark gray bar under main section heading.
    local passedSubHeader="$3"      # Contents of light gray bar under dark gray bar.
    local passedTextHeading="$4"    # Certain tables, for example Kexts, had special headings. These can be set from here.
    local passedCollapseID="$5"     # ID Value for collapse or empty string.
    local passedState="$6"          # String of either 'none' or 'block' (only used if passedCollapseID is not empty).
    local tabName="$7"
    local lineRead

    if [ "$passedState" == "" ]; then
        passedState="$gTableState"
    fi

    if [ "$passedCollapseID" == "" ]; then
        WriteHtmlTableHeaderToFile "$passedTableHeading"
    else
        WriteHtmlTableHeaderWithCollapseToFile "$passedTableHeading" "$passedCollapseID" "$passedState"
    fi

    if [ ! "$passedTextHeading" == "dmitables" ]; then
        WriteHtmlTableSubHeaderToFile "" "$passedSubHeader"
    fi
    WriteHtmlTableTextHeadingToFile "$passedTextHeading"
    if [ "$tabName" == "memory" ]; then
        xxd -c32 -g1 "$passedFile" > "$TEMPDIR"/"${passedFile##*/}"_hex
        /usr/bin/textutil -convert html "$TEMPDIR"/"${passedFile##*/}"_hex -stdout >> "$gHtmlDumpFile"
    else
        /usr/bin/textutil -convert html "$passedFile" -stdout >> "$gHtmlDumpFile"
    fi
    WriteHtmlTableTextEndingToFile
}

# ---------------------------------------------------------------------------------------
CreateAndInitialiseHtmlFile()
{
    WriteToLog "Creating HTML report..."
    echo "Creating HTML report"
    WriteHtmlHeaderToFile "$APP_DIR_NAME"
    WriteCssToFile
    WriteJavaScriptToFile
    WriteHtmlCloseHeadToFile
    WriteHtmlOpenBodyOpenDivToFile
    DumpSystemOverview
    WriteBootargs
    WriteNote
    WriteHtmlClearLineToFile
    WriteDumpContainerOpen
}

#
# =======================================================================================
# READ DUMP FILES & CALL HTML WRITE ROUTINES
# =======================================================================================
#

# ---------------------------------------------------------------------------------------
DumpSystemOverview()
{
    local systemVersion=$(CheckOsVersion)

    oIFS="$IFS"; IFS=$'\r\n'
    tmpChispetArr=()
    tmpVendorArr=()
    tmpDeviceArr=()
    tmpRevisionArr=()
    tmpChipsetArr=( $( /usr/sbin/system_profiler SPDisplaysDataType | grep "Chipset Model:" ))
    tmpVendorArr=( $( /usr/sbin/system_profiler SPDisplaysDataType | grep "Vendor:" ))
    tmpDeviceArr=( $( /usr/sbin/system_profiler SPDisplaysDataType | grep "Device ID:" ))
    tmpRevisionArr=( $( /usr/sbin/system_profiler SPDisplaysDataType | grep "Revision ID:" ))
    # Read tmp array for video and compile in to am html string for the report overview.
    if [ ${#tmpChipsetArr[@]} -gt 0 ]; then
        for (( c=0; c<${#tmpChipsetArr[@]}; c++ ))
        do
            tmpChipset="${tmpChipsetArr[$c]##*: }"
            tmpVendor="${tmpVendorArr[$c]##*(0x}"; tmpVendor="${tmpVendor%*)}"
            tmpDevice="${tmpDeviceArr[$c]##* 0x}"
            tmpRevision="${tmpRevisionArr[$c]##*0x}"
            [[ c -gt 0 ]] && macGraphics="${macGraphics}<br />"
            macGraphics="${macGraphics}"$( printf '%s\n\r' "Video: ${tmpChipset} <span class=\"text_overview_device\">[${tmpVendor}:${tmpDevice}] Rev.[${tmpRevision}]</span>" )
        done
    else
        macGraphics="${tmp[@]}"
    fi
    IFS="$oIFS"

    local macModel=$( /usr/sbin/system_profiler SPHardwareDataType 2>/dev/null | grep "Model Identifier:" )
    macModel="${macModel##*: }"
    
    #local macOsVer=$( /usr/sbin/system_profiler SPSoftwareDataType | grep "System Version" )
    #if [[ "$macOsVer" == *macOS* ]]; then
    #  macOsVer="${macOsVer##*OS }"
    #else
    #  macOsVer="${macOsVer##*X }"
    #fi
    
    local macMemory=$( /usr/sbin/system_profiler SPHardwareDataType 2>/dev/null | grep "Memory:" )
    macMemory="${macMemory##*: }"

    # Get memory type and speed.
    local memType=$( /usr/sbin/system_profiler SPMemoryDataType | grep Type | grep -v 'Empty' | tail -n1 )
    memType="${memType##*: }"
    local memSpeed=$( /usr/sbin/system_profiler SPMemoryDataType | grep Speed | grep -v 'Empty' | tail -n1 )
    memSpeed="${memSpeed##*: }"

    if [ $systemVersion -eq 8 ] || [ $systemVersion -eq 9 ]; then
        if [ -f "$gDumpFolderSysProf/System-Profiler.txt" ]; then
            macCpu=$( fgrep "Processor Name:" "$gDumpFolderSysProf/System-Profiler.txt" )
        else
            macCpu=$( sysctl -a | grep "cpu.brand_string" )
        fi
    else
        macCpu=$( sysctl -a | grep "cpu.brand_string" )
    fi
    local macCpu="${macCpu##*: }"
    local timeStamp=$( date +"%A %d %B %Y" )

    # There's only space for 4 lines in the report header for audio and graphics
    # Sometimes the AudioCodec can report more than one line.
    # For Example:
    # Cirrus Logic CS4206
    # ATI R6xx HDMI
    #
    # So, in the case of multiple devices remove the line breaks and add a slash to separate them.
    #gCodecID=$( echo "$gCodecID" | tr "\n" "/"  | sed 's/.$//' )
    #macGraphics=$( echo "$macGraphics" | tr "\n" "/"  | sed 's/.$//' )

    WriteHtmlSectionAnchorToFile "aTop"
    WriteHtmlOverviewToFile "$timeStamp" "$OSPRODUCTVERSION ($OSBUILDVERSION)" "$macModel" "$macCpu" "$macGraphics" "${macMemory} ${memSpeed} ${memType}" "$gCodecID" "$gSic"
}

# ---------------------------------------------------------------------------------------
WriteBootargs()
{
    tmp=$( sysctl -n kern.bootargs )
    if [ -n "$tmp" ]; then
      echo "<div id=\"bootargs\" class=\"text_bootargs\">bootargs: $tmp</div>" >> "$gHtmlDumpFile"
    fi
}

# ---------------------------------------------------------------------------------------
WriteNote()
{
    echo "<div id=\"note\" class=\"text_note\">Note: A complete dump contains more information than shown in this .htm report. If submitting a report for help then please supply the containing directory, not just this file.</div>" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteAccordionOpen()
{
    echo "<div id=\"accordion\">" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteAccordionClose()
{
    echo "</div> <!-- Close Accordion -->" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteDumpContainerOpen()
{
    echo "<div id=\"dump_container\">" >> "$gHtmlDumpFile"
}

# ---------------------------------------------------------------------------------------
WriteDumpContainerClose()
{
    echo "</div> <!-- Close dump_container -->" >> "$gHtmlDumpFile"
}


# ---------------------------------------------------------------------------------------
DumpHtmlAcpiTables()
{
    local finalDestination=""
    local checkFileExistence=$( find "$gDumpFolderAcpiDsl" -type f -name *.dsl -print 2>/dev/null )
    if [ ! "$checkFileExistence" == "" ]; then
        SendToUI "@DS@Processing ACPI Tables:Report@"
        finalDestination="${gDumpFolderAcpi##*/}/${gDumpFolderAcpiDsl##*/}"

        # Check size of DSL directory and only process is no larger than 2MB
        local dslDirSize=$( du -k -d0 "$gDumpFolderAcpiDsl" | cut -f1 )
        if [ $dslDirSize -le 2048 ]; then
            WriteToLog "${gLogIndent}adding ACPI tables"
            InsertInternalSeparatorHTMLToFile "ACPI Tables"
            WriteOuterH3 "ACPI Tables"
            ReadDirCreateTabsAddFileData "$gDumpFolderAcpiDsl" "acpitableinfo" "$finalDestination"
            WriteEndingH3
        else
            WriteToLog "${gLogIndent}ACPI tables: Note - DSL dir size of [${dslDirSize}Kb] is too large to include in this report."
            InsertInternalSeparatorHTMLToFile "ACPI Tables"
            ls -l "$gDumpFolderAcpiDsl" | tail -n +2 | awk 'BEGIN {print "ACPI Tables (Decompiled)\n------------------------"} {print $9,"[",$5," bytes ]"}' >> "$TEMPDIR"/fileList.txt
            ReadFileAndWriteCompleteSectionToHtml "${TEMPDIR}/fileList.txt" "ACPI Tables" "Total size of decompiled files [${dslDirSize}Kb] is deemed too large to include in this report. The files and their sizes are.." "" "AcpiTables" "aAcpiTables" "Warning: Balls" "collapseID_AcpiTables" "$sipAllow"
        fi
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlAudio()
{
    local finalDestination="${gDumpFolderAudio##*/}"
    if [ -f "$gDumpFolderAudio/VoodooHDAGetdump.txt" ] || [ -f "$gDumpFolderAudio/AudioCodecID.txt" ]; then
        SendToUI "@DS@Processing Audio:Report@"
        WriteToLog "${gLogIndent}adding VoodooHDAGetdump.txt"
        InsertInternalSeparatorHTMLToFile "Audio Voodoo Dump"
        WriteJavaScriptJqueryUITabToFile "Audio Info"

        # Did SIP block this dump?
        if [ "${gCsrBits:7:1}" == "0" ] && [ "${gLdDrvBits:3:1}" == "0" ]; then
            WriteOuterH4 "Audio"
        else
            WriteOuterH3 "Audio"
        fi

        ReadDirCreateTabsAddFileData "$gDumpFolderAudio" "audio" "$finalDestination"
        WriteEndingH3

        local checkLog=$( grep "if AppleHDA is disabled." "${logFile}" )
        if [ ! "$checkLog" == "" ]; then
            local message="&nbsp;&nbsp;Note: VoodooHDA's getdump may produce more info if AppleHDA is disabled."
        fi
        #ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderAudio/VoodooHDAGetdump.txt" "Audio" "Dumped using <a href=\"http://www.projectosx.com/forum/index.php?showtopic=355\" target=\"_blank\">VoodooHDA's getdump tool</a>$message" "<a href=\"$finalDestination/VoodooHDAGetdump.txt\" target=\"_blank\">View VoodooHDAGetdump.txt File</a>" "Audio" "aAudio" "" "collapseID_Audio"
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlBiosSystem()
{
    local finalDestination="${gDumpFolderBios##*/}/${gDumpFolderBiosSystem##*/}"
    if [ -f "$gDumpFolderBiosSystem/flashrom_log.txt" ]; then
        SendToUI "@DS@Processing System BIOS:Report@"
        WriteToLog "${gLogIndent}adding BIOS flashrom_log.txt"
        InsertInternalSeparatorHTMLToFile "BIOS System Dump"

        # Did SIP block this dump?
        local sipAllow="Y"
        if [ "${gCsrBits:7:1}" == "0" ] && [ "${gLdDrvBits:0:1}" == "0" ]; then
            sipAllow="N"
        fi

        ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderBiosSystem/flashrom_log.txt" "BIOS - System: Flashrom Log" "Dumped using Flashrom Darwin Port, v0.9.7 r1786. <a href=\"https://www.dropbox.com/s/gfmqx2t7lvofs1v/flashrom.zip?dl=0\" target=\"_blank\">macOS port by THe KiNG.</a>." "<a href=\"$finalDestination/flashrom_log.txt\" target=\"_blank\">View flashrom_log.txt File</a>" "BiosSystem" "aBiosSystem" "" "collapseID_BiosSystem" "$sipAllow"
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlBiosVideo()
{
    local finalDestination="${gDumpFolderBios##*/}/${gDumpFolderBiosVideo##*/}"
    local checkFileExistence=$( find "$gDumpFolderBiosVideo" -type f -name "*.txt" 2>/dev/null )
    if [ ! "$checkFileExistence" == "" ]; then
        SendToUI "@DS@Processing Video BIOS:Report@"
        WriteToLog "${gLogIndent}adding BIOS Video decoded text file"
        InsertInternalSeparatorHTMLToFile "BIOS Video Dump"

        # Did SIP block this dump?
        if [ "${gCsrBits:7:1}" == "0" ] && [ "${gLdDrvBits:2:1}" == "0" ]; then
            WriteOuterH4 "BIOS Video"
        else
            WriteOuterH3 "BIOS Video"
        fi

        ReadDirCreateTabsAddFileData "$gDumpFolderBiosVideo" "biosVideo" "$finalDestination"
      WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlCpuInfo()
{
    local finalDestination="${gDumpFolderCPU##*/}"
    if [ -f "$gDumpFolderCPU/cpuinfo.txt" ] || [ -f "$gDumpFolderCPU/AppleIntelInfo.txt" ]; then
        SendToUI "@DS@Processing CPU:Report@"
        WriteToLog "${gLogIndent}adding CPU Information"
        InsertInternalSeparatorHTMLToFile "CPU Information"
        WriteJavaScriptJqueryUITabToFile "CPU Info"

        # Did SIP block this dump?
        if [ "${gCsrBits:7:1}" == "0" ] && [ "${gLdDrvBits:4:1}" == "0" ] && [ -f "$gDumpFolderCPU/AppleIntelInfo.txt" ]; then
            WriteOuterH4 "CPU"
        else
            WriteOuterH3 "CPU"
        fi

        ReadDirCreateTabsAddFileData "$gDumpFolderCPU" "cpuinfo" "$finalDestination"
        WriteEndingH3

    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlDeviceProperties()
{
    local finalDestination="${gDumpFolderDevProps##*/}"
    if [ -f "$gDumpFolderDevProps/device-properties.plist" ]; then
        SendToUI "@DS@Processing Device Properties:Report@"
        WriteToLog "${gLogIndent}adding device properties"
        InsertInternalSeparatorHTMLToFile "Device Properties"
        ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderDevProps/device-properties.plist" "Device Properties" "Dumped using <a href=\"https://github.com/acidanthera/gfxutil\" target=\"_blank\">gfxutil</a> v1.80b from acidanthera" "<a href=\"$finalDestination/device-properties.plist\" target=\"_blank\">View device-properties.plist File</a>" "DeviceProperties" "aDeviceProps" "" "collapseID_DevProps"
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlBootLoaderAndBootSectors()
{
    local finalDestination=""
    local checkFileExistence=$( find "$gDumpFolderBootLoader" -type f -name *.txt -print 2>/dev/null )

    if [ ! "$checkFileExistence" == "" ]; then
        SendToUI "@DS@Processing Bootloader & Boot Sectors:Report@"
        finalDestination="${gDumpFolderBootLoader##*/}"

        WriteToLog "${gLogIndent}adding Bootloader & Boot Sectors"
        InsertInternalSeparatorHTMLToFile "Bootloader & Boot Sectors"
        WriteOuterH3 "Bootloader & Boot Sectors"
        ReadDirCreateTabsAddFileData "$gDumpFolderBootLoader" "Bootloaders" "$finalDestination"

        WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlDiskUUIDs()
{
    local finalDestination="${gDumpFolderDisks##*/}"
    if [ -f "$gDumpFolderDisks/UIDs.txt" ]; then
        SendToUI "@DS@Processing Disk UUIDs:Report@"
        WriteToLog "${gLogIndent}adding disk & volume UIDs"
        InsertInternalSeparatorHTMLToFile "Disk & Volume UIDs"
        ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderDisks/UIDs.txt" "Disk & Volume UIDs" "UUID's grabbed from diskutil info. Unique partition GUID's dumped from IOreg." "<a href=\"$finalDestination/UIDs.txt\" target=\"_blank\">View UIDs.txt File</a>" "UIDs" "aUIDs" "" "collapseID_UIDs"
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlDisks()
{
    #------------------------
    AppendTableData()
    {
        diskTableData="$diskTableData"$(printf "$1\n")
    }

    #------------------------
    AppendHexDetailsData()
    {
        hexDetailsData="$hexDetailsData"$(printf "$1\n")
    }

    #------------------------
    AppendCssInitBlocks()
    {
        if [ $1 -eq 0 ]; then
            cssInitBlock="$cssInitBlock"$(printf "#diskPartitionCollapseID_${diskToRead}_$1 { display: block; }\n")
        else
            cssInitBlock="$cssInitBlock"$(printf "#diskPartitionCollapseID_${diskToRead}_$1 { display: none; }\n")
        fi
    }

    #------------------------
    AppendJsBlock()
    {
        jsBlock="$jsBlock"$(printf "    diskPartitionCollapseID_${diskToRead}_${1}.style.display = 'none';\n")
    }

    local finalDestination="${gDumpFolderDisks##*/}"

    # Name of the folder in "$gDumpFolderDisks" that contains the partition table dumps
    gDumpFolderName="${gDumpFolderDiskPartitionInfo}/Partition bdisk Scan"

    if [ -d "$gDumpFolderName" ]; then
        SendToUI "@DS@Processing Disk Partitions:Report@"
        #echo "${gLogIndent}adding partition table info" >> "${gLogFile}"
        WriteToLog "${gLogIndent}adding partition table info"
        InsertInternalSeparatorHTMLToFile "Disk Partition Tables"
        local tabname="DiskPartInfo"
        local diskTabCount=1
        WriteJavaScriptJqueryUITabToFile "$tabname"

        # Did SIP block this dump?
        if [ "${gCsrBits:8:1}" == "0" ]; then
            WriteOuterH4 "Disk Partition Tables"
        else
            WriteOuterH3 "Disk Partition Tables"
        fi


        # Build list of disks and write tabs to file
        local disks=()
        local count=0
        for file in "$TEMPDIR"/html_build_file_disk*
        do
            local tmp="${file##*_}"
            disks+=("${tmp%.txt}")
            ((count++))
        done
        if [ $count -gt 0 ]; then
            echo "<div id=\"tabs_${tabname}\">
  <ul>" >> "$gHtmlDumpFile"
            for (( n=0; n<$count; n++ ))
            do
                echo "    <li><a href=\"#tabs_${tabname}-$((n+1))\">${disks[$n]}</a></li>" >> "$gHtmlDumpFile"
            done
            echo  "</ul>" >> "$gHtmlDumpFile"
        fi

        #local cdir="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
        #cd "$cdir"; cd ..; cd ..
        #local resourcesDir="$( pwd )"/Resources
        #local dataDir="$resourcesDir"/Data

        # Add specific css for the disk partitions
        WriteDiskPartitionCssToFile

        for file in "$TEMPDIR"/html_build_file_disk*.txt
        do
            local fileFound="${file##*/}"
            fileToProcess="$TEMPDIR"/"$fileFound"
            diskToRead="${fileFound##*_}"
            diskToRead="${diskToRead%.*}"
            gDumpFolderHex="${gDumpFolderName}/${diskToRead}/hex"
            gDumpFolderDecoded="${gDumpFolderName}/${diskToRead}/decoded"

            #htmlFile="${gDumpFolderDisks}/Partition_${diskToRead}.html"

            diskTableData=""
            hexDetailsData=""
            jsBlock=""
            diskInfoToInsert=""

            #local fileToRead="$gTmpHtmlParseFile"

            # Set Javascript Function Name
            jsFuncName="ShowHideDiskPartitionHexDetails_${diskToRead}"

            if [ -f "$fileToProcess" ]; then

                InsertInternalSeparatorHTMLToFile "Disk Partition Table: ${diskToRead}"

                diskInfoToInsert=""
                diskInfoToInsert2=""
                unset cssInitBlocks
                local collapseCount=0
                local foundGPT=0
                local tmpTableType="gpt"

                while read -r lineRead
                do
                        codeRead="${lineRead%%@*}"
                        detailsRead="${lineRead#*@}"

                        if [ "$detailsRead" == "" ]; then
                            detailsRead=" "
                        fi

                        case "$codeRead" in

                            "Title")       # lines beginning with Title are joined together to print in the subheader title bar

                                           diskInfoToInsert="${diskInfoToInsert}${detailsRead}&nbsp;&nbsp;|&nbsp;&nbsp;"
                                           ;;

                            "Title2")      # lines beginning with Title2 are joined together to print the 2nd line of the subheader title bar

                                           diskInfoToInsert2="${diskInfoToInsert2}${detailsRead}&nbsp;&nbsp;|&nbsp;&nbsp;"

                                           # Make a note if HTML table type is MBR or GPT.
                                           # We can use this to decide which table to produce (ie. number of columns)
                                           if [ "${detailsRead}" == "MBR Partition Table" ]; then
                                               tmpTableType="mbr"
                                           fi
                                           ;;

                            "TableHgt")    # lines beginning with TableHgt indicate the height in pixels that this table row will be.
                                           # Finding this line also indicates the beginning of a partition description.

                                           ((collapseCount++))
                                           AppendTableData "        <div class=\"t\">"
                                           AppendTableData "            <div class=\"tr\" style=\"height:${detailsRead}px;\">"
                                           ;;

                            "TableLba")    # lines beginning with TableLba indicate the starting LBA of this entry.

                                           # Add the html code for the starting LBA table column and include the LBA number.
                                           AppendTableData "                <div class=\"${tmpTableType}_tc_Start_lba\">${detailsRead}</div>"

                                           # Remember the startingLBA for later.
                                           local tmpLba=${detailsRead}
                                           ;;

                            "TableAct")    # lines beginning with TableAct indicate if this entry is active.

                                           if [ "$detailsRead" == "" ] || [ "$detailsRead" == " " ]; then

                                               # If the data is blank, then add the html code for a blank active table column.
                                               AppendTableData "                <div class=\"${tmpTableType}_tc_Active\">&nbsp;</div>"
                                           else
                                               # If the data is not blank, then add the html code for an active table column with ID set to active.
                                               AppendTableData "                <div class=\"${tmpTableType}_tc_Active\" id=\"activePart\">&nbsp;</div>"
                                           fi
                                           ;;

                            "TablePeTyp")  # lines beginning with TablePeTyp indicate a partition entry type.
                                           # Data for this can be either a boot record type: MBR or EBR
                                           # or a GUID partition type. For example, Primary GPT Header / EFI System Partition / HFS

                                           # For now, remember this for using later.
                                           tmpPeType="$detailsRead" ;;

                            "TablePeVal")  # lines beginning with TablePeVal indicate a partition entry value.
                                           # Data for this will be a hex byte, though it may be blank.

                                           # Check to see if the data is blank.
                                           if [ "$detailsRead" == "" ] || [ "$detailsRead" == " " ]; then

                                               # Have we already added html code for a GPT entry to the MBR Partition Map table column?
                                               #if [ $foundGPT -eq 0 ]; then

                                                   # first occurrence of EE will have already had html code added (Top). So we add html code for the Mid section
                                                   #AppendTableData "                <div class=\"gpt_tc_Mbr_Pe\" id=\"fillPrimaryGPTHeaderMid\">${detailsRead}</div>"
                                               #else

                                                   # If reading LBA 0 and we have a GPT disk, add html code for an MBR fill to the MBR Partition Map table column.
                                                   if [ "$tmpLba" == "0" ]; then
                                                       if [ "$tmpTableType" == "gpt" ]; then
                                                           AppendTableData "                <div class=\"gpt_tc_Mbr_Pe\" id=\"fillNoHoverMBR\">&nbsp;</div>"
                                                       fi
                                                   else
                                                       # We are not reading LBA 0. So if this is a GPT disk then add html code for a blank fill in the MBR Partition Map table column.
                                                       if [ "$tmpTableType" == "gpt" ]; then
                                                           AppendTableData "                <div class=\"${tmpTableType}_tc_Mbr_Pe\" id=\"fillBlank\">&nbsp;</div>"
                                                       fi
                                                   fi
                                              # fi
                                           else # The data is not blank

                                               # Is the hex byte ee for a GPT partition?
                                               if [ "$detailsRead" == "ee" ]; then

                                                   # Is this the first time we've read hex byte ee ?
                                                   if [ $foundGPT -eq 0 ]; then

                                                       # remember we've found hex byte ee
                                                       foundGPT=1

                                                       # First time EE will be printed - So add html code for the Top section of the MBR Partition Map table column.
                                                       AppendTableData "                <div class=\"gpt_tc_Mbr_Pe\" id=\"fillPrimaryGPTHeaderTop\">EFI Protective (ee)</div>"
                                                   else
                                                       #AppendTableData "                <div class=\"gpt_tc_Mbr_Pe\" id=\"fillPrimaryGPTHeaderMid\">${detailsRead}</div>"
                                                       AppendTableData "                <div class=\"gpt_tc_Mbr_Pe\" id=\"fillPrimaryGPTHeaderMid\">&nbsp;</div>"
                                                   fi

                                               else # the hex byte is not a GPT partition ID of ee

                                                   # Have we already discovered a GPT and currently reading a GPT ?
                                                   if [ $foundGPT -eq 1 ]; then

                                                       # We are reading a hybrid table.
                                                       # Data for a hybrid will have been passed as: Name (id)  For example, HFS+ (af)

                                                       # Take the first item before a space followed by an opening parenthesis
                                                       local tmp=$( echo "${detailsRead% (*}" | tr -d '()' )

                                                       # Remove all non-alphanumeric chars (for example HFS+ to HFS)
                                                       tmp=$( echo "$tmp" | sed 's/[^a-zA-Z0-9]//g' )

                                                       # add html code for the partition entry in to the MBR Partition Map table column.
                                                       # Check first for code (xx) that represents an unprotected area of MBR for a GPT/MBR hybrid.
                                                       if [ "$detailsRead" == "xx" ]; then
                                                           AppendTableData "                <div class=\"gpt_tc_Mbr_Pe\" id=\"fillNoHover${tmp}\">&nbsp;</div>"
                                                       else
                                                           AppendTableData "                <div class=\"gpt_tc_Mbr_Pe\" id=\"fillNoHover${tmp}\">${detailsRead}</div>"
                                                       fi

                                                   else # A partition type of EFI Protective (ee) is not currently open (being written to the MBR Partition Map table column) for this disk.

                                                       # Check the partition table this disk is using.
                                                       if [ "$tmpTableType" == "gpt" ]; then

                                                           # add html code for the partition entry type in to the MBR Partition Map table column.
                                                           AppendTableData "                <div class=\"gpt_tc_Mbr_Pe\" id=\"fill${tmpPeType}\">${detailsRead}</div>"
                                                       fi
                                                   fi
                                               fi
                                           fi
                                           ;;

                            "TableTyp")    # lines beginning with TableTyp indicate the GUID partition type. For example: Primary GPT Header / EFI System Partition / HFS

                                           tmpType="$detailsRead"
                                           ;;

                            "TableNme")    # lines beginning with TableNme indicate the GUID partition name.

                                           # Check if the name needs printing in the html table, then remember the name for later.
                                           if [ "$tmpType" == "Space" ]; then
                                               if [ ! "$detailsRead" == "Unused" ]; then
                                                   local tmpName="&nbsp;"
                                               else
                                                   local tmpName="$detailsRead"
                                               fi

                                           else # Not Space

                                               # Remember name for later.
                                               local tmpName="$detailsRead"

                                               # As this entry is not a space, use the LBA as the collapse_show ID.
                                               cssInitBlocks+=("${tmpLba}")
                                               AppendCssInitBlocks "${tmpLba}"
                                               AppendJsBlock "${tmpLba}"
                                           fi
                                           ;;

                            "TableSze")    # lines beginning with TableSze indicate the size of the partition as human readable. For example 160.0 GB

                                           # Check if the type is a Space and if so, is it a large unused space (>=1GB) worth displaying
                                           if [ "$tmpType" == "Space" ]; then
                                               if [ "$tmpName" == "Unused" ]; then

                                                   # add html code for a table cell with a space ID and include the name Unused and the Size.
                                                   AppendTableData "                <div class=\"${tmpTableType}_tc_Type\" id=\"fillSpace\">${tmpName} ${detailsRead}</div>"
                                               else
                                                   # add html code for a blank table cell with a space ID.
                                                   AppendTableData "                <div class=\"${tmpTableType}_tc_Type\" id=\"fillSpace\">&nbsp;</div>"
                                               fi

                                           else # Not a Space

                                               if [ "$detailsRead" == "" ] || [ "$detailsRead" == " " ]; then

                                                   # add html code for a clickable partition type without a size label. For example, Primary GPT Header
                                                   AppendTableData "                <div class=\"${tmpTableType}_tc_Type\" id=\"fill${tmpType}\" style=\"cursor:pointer;\" onClick=\"javascript:${jsFuncName}('diskPartitionCollapseID_${diskToRead}_${tmpLba}', this)\">${tmpName}</div>"
                                               else
                                                   # add html code for a clickable partition type with a size label. For example, Macintosh HD (160.0GB)
                                                   AppendTableData "                <div class=\"${tmpTableType}_tc_Type\" id=\"fill${tmpType}\" tooltip=\"${tmpType}\" style=\"cursor:pointer;\" onClick=\"javascript:${jsFuncName}('diskPartitionCollapseID_${diskToRead}_${tmpLba}', this)\">${tmpName} ${detailsRead}</div>"
                                               fi
                                           fi
                                           ;;

                            "TableLdr")    # lines beginning with TableLdr indicate identified boot code in the partition sector.
                                           # Finding this line also indicates the end of a partition description on the parse file.

                                           if [ "$detailsRead" == "" ] || [ "$detailsRead" == " " ]; then

                                               # add html code to include a space in the Loader table column as no data was found.
                                               AppendTableData "                <div class=\"${tmpTableType}_tc_Loader\">&nbsp;</div>"
                                           else
                                               # add html code to include the loader title in the Loader table column.
                                               AppendTableData "                <div class=\"${tmpTableType}_tc_Loader\" id=\"loader\">${detailsRead}</div>"
                                           fi

                                           # add html code to complete the div table section.
                                           AppendTableData "            </div>"
                                           AppendTableData "        </div>"
                                           ;;

                            "SyncErrorLba")    # lines beginning with SyncErrorLba indicate a hybrid GPT has an MBR partition entry out of sync.
                                               # Finding this line shows we have to create an extra table row.

                                               AppendTableData "        <div class=\"t\">"
                                               AppendTableData "            <div class=\"tr\" style=\"height:10px;\">"
                                               AppendTableData "                <div class=\"${tmpTableType}_tc_Start_lba\">${detailsRead}</div>"
                                               ;;

                            "SyncErrorAct")    # lines beginning with SyncErrorAct indicate the active partition

                                               if [ "$detailsRead" == "" ] || [ "$detailsRead" == " " ]; then

                                                   # If the data is blank, then add the html code for a blank active table column.
                                                   AppendTableData "                <div class=\"${tmpTableType}_tc_Active\">&nbsp;</div>"
                                               else
                                                   # If the data is not blank, then add the html code for an active table column with ID set to active.
                                                   AppendTableData "                <div class=\"${tmpTableType}_tc_Active\" id=\"activePart\">&nbsp;</div>"
                                               fi
                                               ;;

                            "SyncErrorTyp")    # lines beginning with SyncErrorTyp indicate the partition type

                                               # add html code for the partition entry type.
                                               AppendTableData "                <div class=\"gpt_tc_Mbr_Pe\" id=\"fillSyncError\">${detailsRead}</div>"
                                               ;;

                            "SyncErrorSze")    # lines beginning with SyncErrorSze indicate the partition size

                                               # add html code for the partition entry size
                                               AppendTableData "                <div class=\"gpt_tc_Type\" id=\"fillSyncError\">Sync Error (${detailsRead})</div>"

                                               # add html code for a blank field in the loader column
                                               AppendTableData "                <div class=\"${tmpTableType}_tc_Loader\">&nbsp;</div>"

                                               # add html code to complete the div table section.
                                               AppendTableData "            </div>"
                                               AppendTableData "        </div>"
                                               ;;

                        esac
                done < "$fileToProcess"

                # Remove the ending pipe from diskInfoToInsert and diskInfoToInsert2.
                diskInfoToInsert="${diskInfoToInsert%|*}"
                diskInfoToInsert2="${diskInfoToInsert2%|*}"

                # Build Hex and Details HTML for inserting in to HTML template.
                for (( c=0; c<${#cssInitBlocks[@]}; c++ ))
                do

                    AppendHexDetailsData "        <div id=\"diskPartitionCollapseID_${diskToRead}_${cssInitBlocks[$c]}\">"
                    AppendHexDetailsData "            <div id=\"diskInfoHexTableBox\" class=\"rsText_HexTable\">"
                    AppendHexDetailsData "                <p class=\"rsText_BodyBold\">LBA ${cssInitBlocks[$c]}</p>"

                    # Include the hex which would have been saved to file earlier.
                    # Read only the first 64 lines of the hex file (which should equate to 1024 bytes)
                    if [ -f "${gDumpFolderHex}/LBA${cssInitBlocks[$c]}_Hex.txt" ]; then
                        fileToInclude=$( head -n 64 < "${gDumpFolderHex}/LBA${cssInitBlocks[$c]}_Hex.txt" )
                        while read -r line; do

                            # Escape any ampersands.
                            # Repeat any percentage characters otherwise printf complains.
                            # Escape any forward slashes.
                            # Convert any spaces to html non breaking space $nbsp;.
                            line=$( echo "$line" | sed 's/&/\\&/g;s/%/%%/g;s/\//\\/g;s/ /\&nbsp\;/g' )
                            AppendHexDetailsData "${line}</br>"
                        done <<< "$fileToInclude"
                    else
                        AppendHexDetailsData "</br>"
                    fi

                    AppendHexDetailsData "            </div>"
                    AppendHexDetailsData "            <div id=\"diskInfoDetailsBox\" class=\"rsText_HexTable\">"
                    AppendHexDetailsData "                <p class=\"rsText_BodyBold\">Details</p>"

                    # Include the decoded hex details which would have been saved to file earlier.
                    # Read only the first 128 lines of the hex file (which should equate to 2048 bytes)
                    if [ -f "${gDumpFolderDecoded}/LBA${cssInitBlocks[$c]}_Details.txt" ]; then
                        fileToInclude=$( head -n 128 < "${gDumpFolderDecoded}/LBA${cssInitBlocks[$c]}_Details.txt" )
                        while read -r line; do
                            AppendHexDetailsData "${line}</br>"
                        done <<< "$fileToInclude"
                    else
                        AppendHexDetailsData "</br>"
                    fi

                    AppendHexDetailsData "            </div>"
                    AppendHexDetailsData "        </div>"
                done

                #-----------------------------
                # Write all details to file.
                #-----------------------------

                # Insert the javascript block
                echo "<script type=\"text/javascript\">
function ${jsFuncName}(divID, state)
{
    var table = document.getElementById(divID);
${jsBlock}
    table.style.display = 'block';
}
</script>" >> "$gHtmlDumpFile"

                #WriteHtmlTableHeaderWithCollapseToFile "/dev/${diskToRead}"
                echo "<div id=\"tabs_${tabname}-${diskTabCount}\">" >> "$gHtmlDumpFile"

                #-----------------------------
                # Write sub title bar header.
                #-----------------------------

                # Insert the header data
                 echo "    <div id=\"diskView_inner_table_subheader_info\">
                <table width=\"\" border=\"0\"><tr><td width=\"\" class=\"text_small_section_inner_title_White\">${diskInfoToInsert}<br>${diskInfoToInsert2}</td></tr></table>
            </div> <!-- End dump_section_inner_table_subheader_info -->" >> "$gHtmlDumpFile"

                #-----------------------------
                # Write table header.
                #-----------------------------

                # TABLE HEADER BAR - Part 1
                echo "    <div id=\"diskView_dd_frame\">

        <!----------------------------------------  LEFT SIDE DISK TABLE ---------------------------------------->

        <div id=\"diskViewTable\">

            <!-- Header Bar -->

            <div class=\"t\">
                <div class=\"tr\" id=\"headerBar\">" >> "$gHtmlDumpFile"

                # TABLE HEADER BAR - Part 2 - Different contents for different partition type.
                if [ "$tmpTableType" == "gpt" ]; then
                    # Insert the partition table data
                    echo "
                    <div class=\"gpt_tc_Start_lba\" style=\"padding: 0px 10px 0px 0px; vertical-align: middle;\">Start LBA</div>
                    <div class=\"gpt_tc_Active\">A</div>
                    <div class=\"gpt_tc_Mbr_Pe\">MBR Partition Map</div>
                    <div class=\"gpt_tc_Type\">GPT Partition Map</div>
                    <div class=\"gpt_tc_Loader\">Loader</div>" >> "$gHtmlDumpFile"
                else
                    # Insert the partition table data
                    echo "
                    <div class=\"mbr_tc_Start_lba\" style=\"padding: 0px 10px 0px 0px; vertical-align: middle;\">Start LBA</div>
                    <div class=\"mbr_tc_Active\">A</div>
                    <div class=\"mbr_tc_Type\">MBR Partition Map</div>
                    <div class=\"mbr_tc_Loader\">Loader</div>" >> "$gHtmlDumpFile"
                fi

                # TABLE HEADER BAR - Part 3
                echo "                </div>
            </div>

            <!-- Partition Table -->

$diskTableData

    </div> <!-- End diskViewTable -->
" >> "$gHtmlDumpFile"

                # Insert the hex and details data
                echo "    <!----------------------------------------  RIGHT SIDE DETAILS ---------------------------------------->

$hexDetailsData

    </div><!-- End diskView_dd_frame -->" >> "$gHtmlDumpFile"

               echo "</div> <!-- End tabs_${tabname}-${diskTabCount} -->" >> "$gHtmlDumpFile"
               ((diskTabCount++))

                # Remove the temporary parse file
                if [ -f "$fileToProcess" ]; then       
                    rm "$fileToProcess"
                fi
            fi

        done # End of for loop.

        # Write the css collapse init block
        echo "#$cssInitBlock" >> "$gCssDumpFile"

        echo "</div> <!-- End div section for device id & set state -->" >> "$gHtmlDumpFile"

      WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlBootloaderConfigs()
{
    # Note - the config files are dumped by the diskutil and loader routine.

    local plistFiles=()
    local plistName=""
    local finalDestination="${gDumpFolderBootLoader##*/}/${gDumpFolderBootLoaderConfigs##*/}"
    local fileLocation=""
    local fileType=""
    local oIFS="$IFS"
    local tabname="BootloaderConfigs"
    local count=0
    local lastEntry=""

    # ---------------------------------------------------------------------------------------
    getConfigType()
    {
        local passedTextLine="$1"
        local fileType=""
        local pathWithoutFileName=""
        local containingDirName=""

        if [ ! "$passedTextLine" == "" ]; then

            local fileName=$(basename "$passedTextLine")

            case "$fileName" in
                "org.chameleon.Boot.plist") fileType="<span style=\"color:#99CC33\">Chameleon</span>" ;;
                "SMBIOS.plist") fileType="<span style=\"color:#99CC33\">Chameleon</span>" ;;
                "com.apple.Boot.plist") fileType="<span style=\"color:#DDDDDD\">Apple</span>" ;;
                "config.plist") 

                    # Both Clover and Opencore use a config.plist
                    # Try to determine which this is.

                    pathWithoutFileName="${passedTextLine%%/$fileName*}"
                    containingDirName=$(basename "$pathWithoutFileName")

                    if [ "$containingDirName" == "CLOVER" ] || [[ "$containingDirName" == CLOVER* ]]; then
                      fileType="<span style=\"color:#FFFF66\">Clover</span>"
                    elif [ "$containingDirName" == "OC" ] || [[ "$containingDirName" == OC* ]]; then
                      fileType="<span style=\"color:#75cbd3\">OpenCore</span>"
                    fi

                    # if not determined then check file for existence of <key>ProtocolOverrides</key> which appears in OpenCore config.plist

                    if [ "$fileType" == "" ]; then
                      local check=$( grep "<key>ProtocolOverrides</key>" "$passedTextLine" )
                      if [ ! "$check" == "" ]; then
                        fileType="<span style=\"color:#75cbd3\">OpenCore</span>"
                      fi
                    fi

                    # if not determined then check file for existence of <key>Protocol</key> which appears in older OpenCore config.plist

                    if [ "$fileType" == "" ]; then
                      local check=$( grep "<key>Protocol</key>" "$passedTextLine" )
                      if [ ! "$check" == "" ]; then
                        fileType="<span style=\"color:#75cbd3\">OpenCore</span>"
                      fi
                    fi

                    # if not determined then check file for existence of <key>IgnoreInvalidFlexRatio</key> which appears in OpenCore config.plist

                    if [ "$fileType" == "" ]; then
                      local check=$( grep "<key>IgnoreInvalidFlexRatio</key>" "$passedTextLine" )
                      if [ ! "$check" == "" ]; then
                        fileType="<span style=\"color:#75cbd3\">OpenCore</span>"
                      fi
                    fi

                    # Default to Clover

                    if [ "$fileType" == "" ]; then
                      fileType="<span style=\"color:#FFFF66\">Clover</span>"
                    fi

                ;;
                "CurrentCloverBootedConfig.plist") fileType="<span style=\"color:#FFFF66\">Clover</span>" ;;
                "nvram.plist") 

                    # Both Clover and Opencore can use an nvram.plist
                    # Try to determine which this is.

                    local check=$( grep "<key>Add</key>" "$passedTextLine" )
                    if [ ! "$check" == "" ]; then
                      fileType="<span style=\"color:#75cbd3\">OpenCore</span>"
                    else
                      fileType="<span style=\"color:#FFFF66\">Clover</span>"
                    fi

                ;;
                "settings.plist") fileType="<span style=\"color:#db940c\">XPC</span>" ;;
                "Defaults.plist") fileType="<span style=\"color:#fb6f6f\">Ozmosis</span>" ;;
            esac
            echo "$fileType" # This line acts as a return to the caller.
        fi
    }

    if [ -d "$gDumpFolderBootLoaderConfigs" ]; then
        SendToUI "@DS@Processing Bootloader Configs:Report@"
        WriteToLog "${gLogIndent}adding Bootloader config files"
        InsertInternalSeparatorHTMLToFile "Bootloader Config .plist files"
        WriteJavaScriptJqueryUITabToFile "$tabname"
        WriteOuterH3 "Bootloader Configuration Files"
        IFS=$'\n'

        # Build list of files
        plistFiles=( $(find "$gDumpFolderBootLoaderConfigs" -type f -name "*.plist") )
        for (( c=0; c<${#plistFiles[@]}; c++ ))
        do
            stripVolumeA="${plistFiles[$c]##*Configuration Files/}"
            stripVolumeB="${stripVolumeA%-*}"
            fileDeviceID+=("$stripVolumeB")
            ((count++))
        done

        # Build tabs
        if [ $count -gt 0 ]; then
            echo "<div id=\"tabs_${tabname}\">
  <ul>" >> "$gHtmlDumpFile"
            local tabCount=1
            for (( n=0; n<$count; n++ ))
            do
                if [ ! "${fileDeviceID[$n]}" == "$lastEntry" ]; then
                    echo "    <li><a href=\"#tabs_${tabname}-${tabCount}\">${fileDeviceID[$n]}</a></li>" >> "$gHtmlDumpFile"
                    lastEntry="${fileDeviceID[$n]}"
                    ((tabCount++))
                fi
            done
            echo  "</ul>" >> "$gHtmlDumpFile"
        fi

        tabCount=1
        echo "<div id=\"tabs_${tabname}-${tabCount}\">" >> "$gHtmlDumpFile"
        lastEntry="${fileDeviceID[0]}"

        for (( p=0; p<${#plistFiles[@]}; p++ ))
        do
            if [ -f "${plistFiles[$p]}" ]; then

                if [ ! "${fileDeviceID[$p]}" == "$lastEntry" ]; then
                    echo "</div> <!-- End tabs_${tabname}-${tabCount} -->" >> "$gHtmlDumpFile"
                    ((tabCount++))
                    echo "<div id=\"tabs_${tabname}-${tabCount}\">" >> "$gHtmlDumpFile"
                fi

                fileLocation="${plistFiles[$p]##*$gDumpFolderBootLoaderConfigs/}"
                fileType=$(getConfigType "${plistFiles[$p]}")
                ReadFileAndWriteSubSectionToHtml "${plistFiles[$p]}"\
                                                 "/$fileLocation : $fileType"\
                                                 "<a href=\"$finalDestination/$fileLocation\" target=\"_blank\">View ${plistFiles[$p]##*/}</a>"\
                                                 ""\
                                                 "collapseID_BootLoaderConfigs$p"\
                                                 "none"
                echo "</div> <!-- End div section for device id & set state -->" >> "$gHtmlDumpFile"

                lastEntry="${fileDeviceID[$p]}"
            fi
        done
        IFS="$oIFS"

        echo "</div> <!-- End tabs_${tabname}-${tabCount} -->" >> "$gHtmlDumpFile"
        echo "</div> <!-- Close tabs_${tabname} -->" >> "$gHtmlDumpFile"
        WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlDiskUtils()
{
    if [[ -f "${gDumpFolderDisks}/diskutil_ap_list.txt" ]] && [[ -f "${gDumpFolderDisks}/diskutil_ar_list.txt" ]] && [[ -f "${gDumpFolderDisks}/diskutil_cs_list.txt" ]] && [[ -f "${gDumpFolderDisks}/diskutil_list.txt" ]]; then

        SendToUI "@DS@Processing Diskutil Lists:Report@"

        local finalDestination="${gDumpFolderDisks##*/}"
        local tabname="DiskutilLists"
    
        InsertInternalSeparatorHTMLToFile "Diskutil Lists"
        WriteOuterH3 "Diskutil Lists"
        WriteJavaScriptJqueryUITabToFile "$tabname"

        echo "<div id=\"tabs_${tabname}\">
  <ul>" >> "$gHtmlDumpFile"
        echo "    <li><a href=\"#tabs_${tabname}-1\">List</a></li>" >> "$gHtmlDumpFile"
        echo "    <li><a href=\"#tabs_${tabname}-2\">List APFS</a></li>" >> "$gHtmlDumpFile"
        echo "    <li><a href=\"#tabs_${tabname}-3\">List Apple RAID</a></li>" >> "$gHtmlDumpFile"
        echo "    <li><a href=\"#tabs_${tabname}-4\">List Core Storage</a></li>" >> "$gHtmlDumpFile"
        echo  "</ul>" >> "$gHtmlDumpFile"

        echo "<div id=\"tabs_${tabname}-1\">" >> "$gHtmlDumpFile"
        ReadFileAndWriteSubSectionToHtml "${gDumpFolderDisks}/diskutil_list.txt"\
                                             "List of whole disks and their partitions. Dumped using diskutil list"\
                                             "<a href=\"$finalDestination/diskutil_list.txt\" target=\"_blank\">View File diskutil_list.txt</a>"\
                                             "diskutil_list.txt"\
                                             ""\
                                             ""\
                                             "$tabname"   
        echo "</div> <!-- End tabs_${tabname}-$((n+1)) -->" >> "$gHtmlDumpFile"

        echo "<div id=\"tabs_${tabname}-2\">" >> "$gHtmlDumpFile"
        ReadFileAndWriteSubSectionToHtml "${gDumpFolderDisks}/diskutil_ap_list.txt"\
                                             "List APFS objects of currently attached containers as a tree. Dumped using diskutil ap list"\
                                             "<a href=\"$finalDestination/diskutil_ap_list.txt\" target=\"_blank\">View File diskutil_ap_list.txt</a>"\
                                             "diskutil_ap_list.txt"\
                                             ""\
                                             ""\
                                             "$tabname"     
        echo "</div> <!-- End tabs_${tabname}-$((n+1)) -->" >> "$gHtmlDumpFile"

        echo "<div id=\"tabs_${tabname}-3\">" >> "$gHtmlDumpFile"
        ReadFileAndWriteSubSectionToHtml "${gDumpFolderDisks}/diskutil_ar_list.txt"\
                                             "List AppleRaid volumes with current status and associated member disks. Dumped using diskutil ar list"\
                                             "<a href=\"$finalDestination/diskutil_ar_list.txt\" target=\"_blank\">View File diskutil_ar_list.txt</a>"\
                                             "diskutil_ar_list.txt"\
                                             ""\
                                             ""\
                                             "$tabname"     
        echo "</div> <!-- End tabs_${tabname}-$((n+1)) -->" >> "$gHtmlDumpFile"

        echo "<div id=\"tabs_${tabname}-4\">" >> "$gHtmlDumpFile"
        ReadFileAndWriteSubSectionToHtml "${gDumpFolderDisks}/diskutil_cs_list.txt"\
                                             "Tree view of the CoreStorage world for all current logical volume groups with member disks. Dumped using diskutil cs list"\
                                             "<a href=\"$finalDestination/diskutil_cs_list.txt\" target=\"_blank\">View File diskutil_cs_list.txt</a>"\
                                             "diskutil_cs_list.txt"\
                                             ""\
                                             ""\
                                             "$tabname"   
        echo "</div> <!-- End tabs_${tabname}-$((n+1)) -->" >> "$gHtmlDumpFile"

        echo "</div> <!-- Close tabs_${tabname} -->" >> "$gHtmlDumpFile"
        WriteEndingH3
    
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlBootLogF()
{
    local finalDestination="${gDumpFolderBootLogF##*/}"
    if [ -d "$gDumpFolderBootLogF" ]; then
        SendToUI "@DS@Processing Bootlog Firmware:Report@"
        WriteToLog "${gLogIndent}adding boot log - firmware"
        InsertInternalSeparatorHTMLToFile "Boot Log - Firmware"
        local dumpedFile=$( ls "$gDumpFolderBootLogF" )
        if [ -n "$dumpedFile" ]; then
            if [[ "$dumpedFile" == Clover*BootLog.txt ]]; then
                message="Dumped using the <a href=\"http://sourceforge.net/p/cloverefiboot/code/1905/tree/CloverPackage/utils/bdmesg/bdmesg.c\" target=\"_blank\">bdmesg tool</a>. Created by Kabyl, modified by JrCs from an idea by STLVNUB"
            elif [ "$dumpedFile" == "OpenCore_Data_Hub_Log.txt" ]; then
                message="Dumped from ioreg using command in OpenCore manual"
            elif [ "$dumpedFile" == "OpenCore_UEFI_Var_Log.txt" ]; then
                message="Dumped from UEFI variable using command in OpenCore manual"
            elif [[ "$dumpedFile" == opencore-*.txt ]]; then
                message="Saved from ESP"
            fi

            ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderBootLogF/$dumpedFile" "Boot Log - Firmware" "$message" "<a href=\"$finalDestination/$dumpedFile\" target=\"_blank\">View $dumpedFile File</a>" "BootlogF" "aBootlogF" "" "collapseID_BootlogF" "$sipAllow"
        fi
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlBootLogK()
{
    local finalDestination="${gDumpFolderBootLogK##*/}"
    if [ -d "$gDumpFolderBootLogK" ]; then
        SendToUI "@DS@Processing Bootlog Kernel:Report@"
        WriteToLog "${gLogIndent}adding boot log - kernel messages"
        InsertInternalSeparatorHTMLToFile "Boot Log - Kernel Messages"
        local dumpedFile=$( ls -p "$gDumpFolderBootLogK" | grep -v / )

        local systemVersion=$(CheckOsVersion)
        if [ $systemVersion -le 15 ]; then
            local message="Dumped from the log file in /var/log/asl/ created last time this system was booted."
        else
            local message="Log extracted using log command-line tool."
        fi

        ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderBootLogK/$dumpedFile" "Boot Log - Kernel Messages" "$message" "<a href=\"$finalDestination/$dumpedFile\" target=\"_blank\">View $dumpedFile File</a>" "BootlogK" "aBootlogK" "" "collapseID_BootlogK" "$sipAllow"

    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlFirmwareMemoryMap()
{
    local finalDestination="${gDumpFolderMemory##*/}"
    if [ -f "$gDumpFolderMemory/FirmwareMemoryMap.txt" ]; then
        SendToUI "@DS@Processing Firmware Memory Map:Report@"
        WriteToLog "${gLogIndent}adding firmware memory map"
        InsertInternalSeparatorHTMLToFile "Firmware Memory Map"

        # Did SIP block this dump?
        local sipAllow="Y"
        if [ "${gCsrBits:4:1}" == "0" ]; then
            sipAllow="N"
        fi

        ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderMemory/FirmwareMemoryMap.txt" "Firmware Memory Map" "Script: FirmwareMemoryMap (formerly showbootermemorymap) by Amit Singh. Revised by bcc9, then by dmazar." "<a href=\"$finalDestination/FirmwareMemoryMap.txt\" target=\"_blank\">View FirmwareMemoryMap.txt File</a>" "FirmwareMemoryMap" "aFirmwareMemoryMap" "" "CollapseID_FirmMemMap" "$sipAllow"
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlIoreg()
{
    local finalDestination="${gDumpFolderIoreg##*/}"
    if [ -d "$gDumpFolderIoreg/IORegViewer/Resources/dataFiles" ]; then
        SendToUI "@DS@Processing IO Registry:Report@"
        WriteToLog "${gLogIndent}adding IORegistry Viewer"
        InsertInternalSeparatorHTMLToFile "I/O Kit Registry"
        WriteOuterH3 "I/O Kit Registry"
        WriteHtmlTableHeaderToFile "This is best viewed in a separate browser window/tab. <a href=\"$finalDestination/IORegViewer/IORegFileViewer.html\" target=\"_blank\">Click here to load it.</a>"
        WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlKernelInfo()
{
    local finalDestination="${gDumpFolderKernelInfo##*/}"
    if [ -d "$gDumpFolderKernelInfo" ]; then
        SendToUI "@DS@Processing Kernel Info:Report@"
        WriteToLog "${gLogIndent}adding kernel info"
        InsertInternalSeparatorHTMLToFile "Kernel Info"
        WriteOuterH3 "Kernel Info"
        ReadDirCreateTabsAddFileData "$gDumpFolderKernelInfo" "kernelinfo" "$finalDestination"
        WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlKextLists()
{
    local finalDestination="${gDumpFolderKexts##*/}"

    # Only run if the text files exist
    if [ -f "$gDumpFolderKexts/loaded_non_apple_kexts.txt" ] || [ -f "$gDumpFolderKexts/loaded_apple_kexts.txt" ]; then
        SendToUI "@DS@Processing Kext Lists:Report@"
        WriteToLog "${gLogIndent}adding kext dumps"
        InsertInternalSeparatorHTMLToFile "Kext Dumps"

        # For ref: Kextstat returns 8 output fields. Index, Refs, Address, Size, Wired, Name, Version, Linked Against
        declare -a ksIndex
        declare -a ksRefs
        declare -a ksAddress
        declare -a ksSize
        declare -a ksWired
        declare -a ksName
        declare -a ksVer
        declare -a ksLinked

        # ---------------------------------------------------------------------------------------
        WriteHtml()
        {
            local passedAnchor="$1"
            local passedHeading="$2"
            local passedCount="$3"
            local passedSubHeader="$4"
            local passedTableTextHeading="$5"

            CalculateTableWidths "KextDump"
            WriteHtmlTableHeaderToFile "Dumped using: $passedSubHeader"
            WriteHtmlTableSubHeaderToFile "" "$passedHeading : $passedCount"
            WriteHtmlTableTextHeadingToFile "$passedTableTextHeading"
        }

        # ---------------------------------------------------------------------------------------
        readKextInfoInToStrings()
        {
            local fileToRead="$1"
            local kextCount=0
            ksIndex=(); ksRefs=(); ksAddress=(); ksSize=(); ksWired=(); ksName=(); ksVer=(); ksLinked=()
            firstLinked=0
            if [ -f "$fileToRead" ]; then
                oIFS="$IFS"; IFS=$'\n'
                inFile=( $(cat "$fileToRead") )
                # start at 1 to skip first header line
                for (( n=1; n<${#inFile[@]}; n++ ))
                do
                    (( kextCount++ ))
                    ksIndex+=($(echo "${inFile[$n]}" | awk '{print $1}'))
                    ksRefs+=($(echo "${inFile[$n]}" | awk '{print $2}'))
                    ksAddress+=($(echo "${inFile[$n]}" | awk '{print $3}'))
                    ksSize+=($(echo "${inFile[$n]}" | awk '{print $4}'))
                    ksWired+=($(echo "${inFile[$n]}" | awk '{print $5}'))
                    ksName+=($(echo "${inFile[$n]}" | awk '{print $6}'))
                    ksVer+=($(echo "${inFile[$n]}" | awk '{print $7}'))
                    ksLinked+=($(echo "${inFile[$n]}" | awk 'BEGIN { FS = "<" } ; {print $2}'))
                    if [[ "${inFile[$n]}" =~ "<" ]] && [ $firstLinked -eq 0 ]; then
                        firstLinked=$kextCount
                    fi
                done
                IFS="$oIFS"
            fi
        }

        local tabname="Kexts"
        WriteJavaScriptJqueryUITabToFile "$tabname"
        WriteOuterH3 "$tabname"

        echo "<div id=\"tabs_${tabname}\">
  <ul>" >> "$gHtmlDumpFile"
        [[ -f "$gDumpFolderKexts/loaded_apple_kexts.txt" ]] && echo "    <li><a href=\"#tabs_${tabname}-1\">Loaded Apple Kexts</a></li>" >> "$gHtmlDumpFile"
        [[ -f "$gDumpFolderKexts/loaded_non_apple_kexts.txt" ]] && echo "    <li><a href=\"#tabs_${tabname}-2\">Loaded Non-Apple Kexts</a></li>" >> "$gHtmlDumpFile"
        [[ -f "$gDumpFolderKexts/prelinked_kexts_list_simple.txt" ]] && echo "    <li><a href=\"#tabs_${tabname}-3\">Kexts in Prelinked Kernel (Simple)</a></li>" >> "$gHtmlDumpFile"
        [[ -f "$gDumpFolderKexts/prelinked_kexts_list_detailed.txt" ]] && echo "    <li><a href=\"#tabs_${tabname}-4\">Kexts in Prelinked Kernel (Detailed)</a></li>" >> "$gHtmlDumpFile"
        echo  "</ul>" >> "$gHtmlDumpFile"


        if [ -f "$gDumpFolderKexts/loaded_apple_kexts.txt" ]; then
            echo "<div id=\"tabs_${tabname}-1\">" >> "$gHtmlDumpFile"
            readKextInfoInToStrings "$gDumpFolderKexts/loaded_apple_kexts.txt"
            local totalCount=${#ksIndex[@]}
            # Note: some kexts at beginning of list aren't linked.
            (( firstLinked-- )) # adjust for zero based array.
            WriteHtml "aAppleKexts" "Apple Kexts" "$totalCount" "kextstat -l | egrep \"com.apple\"" "AppleKexts"
            for (( n=0; n<$firstLinked; n++ )) # print first lines which are not linked
            do
                WriteHtmlTableTextToFile "${ksIndex[$n]}" "${ksRefs[$n]}" "${ksAddress[$n]}" "${ksSize[$n]}" "${ksWired[$n]}" "${ksName[$n]}" "${ksVer[$n]}"
            done
            for (( n=$firstLinked; n<$totalCount; n++ )) # print remaining lines which are linked
            do
                WriteHtmlTableTextToFile "${ksIndex[$n]}" "${ksRefs[$n]}" "${ksAddress[$n]}" "${ksSize[$n]}" "${ksWired[$n]}" "${ksName[$n]}" "${ksVer[$n]}" "<${ksLinked[$n-$firstLinked]}"
            done

            WriteHtmlTableTextEndingToFile
            echo "</div> <!-- End tabs_${tabname}-1 -->" >> "$gHtmlDumpFile"
        fi

        if [ -f "$gDumpFolderKexts/loaded_non_apple_kexts.txt" ]; then
            echo "<div id=\"tabs_${tabname}-2\">" >> "$gHtmlDumpFile"
            readKextInfoInToStrings "$gDumpFolderKexts/loaded_non_apple_kexts.txt"
            local totalCount=${#ksIndex[@]}
            WriteHtml "aNonAppleKexts" "Non Apple Kexts" "$totalCount" "kextstat -l | egrep -v \"com.apple\"" "NonAppleKexts"
            for (( n=0; n<$totalCount; n++ ))
            do
                WriteHtmlTableTextToFile "${ksIndex[$n]}" "${ksRefs[$n]}" "${ksAddress[$n]}" "${ksSize[$n]}" "${ksWired[$n]}" "${ksName[$n]}" "${ksVer[$n]}" "<${ksLinked[$n]}"
            done
            WriteHtmlTableTextEndingToFile
            echo "</div> <!-- End tabs_${tabname}-2 -->" >> "$gHtmlDumpFile"
        fi

        if [ -f "$gDumpFolderKexts/prelinked_kexts_list_simple.txt" ]; then
            echo "<div id=\"tabs_${tabname}-3\">" >> "$gHtmlDumpFile"
            ReadFileAndWriteSubSectionToHtml "$gDumpFolderKexts/prelinked_kexts_list_simple.txt"\
                                                 "Simple list of prelinked kexts from Pike's <a href=\"https://github.com/Piker-Alpha/LZVN\" target=\"_blank\">lzvn</a>"\
                                                 "<a href=\"$gDumpFolderKexts/prelinked_kexts_list_simple.txt\" target=\"_blank\">View File prelinked_kexts_list_simple.txt</a>"\
                                                 "PrelinkedKextList"\
                                                 ""\
                                                 ""\
                                                 "$tabs_${tabname}-3"   
            echo "</div> <!-- End tabs_${tabname}-3 -->" >> "$gHtmlDumpFile" 
        fi

        if [ -f "$gDumpFolderKexts/prelinked_kexts_list_detailed.txt" ]; then
            echo "<div id=\"tabs_${tabname}-4\">" >> "$gHtmlDumpFile"
            ReadFileAndWriteSubSectionToHtml "$gDumpFolderKexts/prelinked_kexts_list_detailed.txt"\
                                                 "Detailed list of prelinked kexts from Pike's <a href=\"https://github.com/Piker-Alpha/LZVN\" target=\"_blank\">lzvn</a>"\
                                                 "<a href=\"$gDumpFolderKexts/prelinked_kexts_list_detailed.txt\" target=\"_blank\">View File prelinked_kexts_list_detailed.txt</a>"\
                                                 "PrelinkedKextList"\
                                                 ""\
                                                 ""\
                                                 "$tabs_${tabname}-4"   
            echo "</div> <!-- End tabs_${tabname}-4 -->" >> "$gHtmlDumpFile" 
        fi

        echo "</div> <!-- Close tabs_${tabname} -->" >> "$gHtmlDumpFile"
        WriteEndingH3
    fi

}

# ---------------------------------------------------------------------------------------
DumpHtmlLspci()
{
    local finalDestination="${gDumpFolderLspci##*/}"

    if [ -d "$gDumpFolderLspci" ]; then
        SendToUI "@DS@Processing LSPCI:Report@"
        WriteToLog "${gLogIndent}adding LSPCI dumps"
        InsertInternalSeparatorHTMLToFile "LSPCI"

        # Did SIP block this dump?
        if [ "${gCsrBits:7:1}" == "0" ] && [ "${gLdDrvBits:0:1}" == "0" ]; then
            WriteOuterH4 "LSPCI"
        else
            WriteOuterH3 "LSPCI"
        fi

        ReadDirCreateTabsAddFileData "$gDumpFolderLspci" "lspciinfo" "$finalDestination"
        WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlMemoryIntelGraphics()
{
    local finalDestination="${gDumpFolderMemoryRegions%/*}"
    finalDestination="${finalDestination}/Regions"

    if [ -d "$gDumpFolderMemoryRegions" ]; then
        SendToUI "@DS@Processing Memory Intel Registers:Report@"
        WriteToLog "${gLogIndent}adding Intel Graphics Register dumps"
        InsertInternalSeparatorHTMLToFile "Memory - Intel Graphics Registers"
        WriteOuterH3 "Memory - Intel Graphics Registers"
        ReadDirCreateTabsAddFileData "$gDumpFolderMemoryRegions" "memory" "$finalDestination"
        WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlMemoryInfo()
{
    if [[ -f "${gDumpFolderMemory}/pmem_info_meta.txt" ]] && [[ -f "${gDumpFolderMemory}/pmem_map_efi_range.txt" ]] && [[ -f "${gDumpFolderMemory}/pmem_map_pci_range.txt" ]]; then
        SendToUI "@DS@Processing Memory Info:Report@"
        local finalDestination="${gDumpFolderMemory##*/}"
        local tabname="MemoryCollectedInformation"
    
        InsertInternalSeparatorHTMLToFile "Memory - Collected Information"
        WriteOuterH3 "Memory - Collected Information"
        WriteJavaScriptJqueryUITabToFile "$tabname"

        echo "<div id=\"tabs_${tabname}\">
  <ul>" >> "$gHtmlDumpFile"
        echo "    <li><a href=\"#tabs_${tabname}-1\">Meta</a></li>" >> "$gHtmlDumpFile"
        echo "    <li><a href=\"#tabs_${tabname}-2\">Memory Map - EFI Ranges</a></li>" >> "$gHtmlDumpFile"
        echo "    <li><a href=\"#tabs_${tabname}-3\">Memory Map - PCI Ranges</a></li>" >> "$gHtmlDumpFile"
        echo  "</ul>" >> "$gHtmlDumpFile"

        echo "<div id=\"tabs_${tabname}-1\">" >> "$gHtmlDumpFile"
        ReadFileAndWriteSubSectionToHtml "${gDumpFolderMemory}/pmem_info_meta.txt"\
                                             "Meta information, such as kernel slide, dumped using <a href=\"https://github.com/google/rekall/tree/master/tools/osx/MacPmem\" target=\"_blank\">MacPmem driver</a>"\
                                             "<a href=\"$finalDestination/pmem_info.txt\" target=\"_blank\">View File pmem_info.txt</a>"\
                                             "pmem_info.txt"\
                                             ""\
                                             ""\
                                             "$tabname"     
        echo "</div> <!-- End tabs_${tabname}-$((n+1)) -->" >> "$gHtmlDumpFile"
    
        echo "<div id=\"tabs_${tabname}-2\">" >> "$gHtmlDumpFile"
        ReadFileAndWriteSubSectionToHtml "${gDumpFolderMemory}/pmem_map_efi_range.txt"\
                                             "Further information, such as EFI ranges, dumped using <a href=\"https://github.com/google/rekall/tree/master/tools/osx/MacPmem\" target=\"_blank\">MacPmem driver</a>"\
                                             "<a href=\"$finalDestination/pmem_map_efi_range.txt\" target=\"_blank\">View File pmem_map_efi_range.txt</a>"\
                                             "pmem_map_efi_range.txt"\
                                             ""\
                                             ""\
                                             "$tabname"   
        echo "</div> <!-- End tabs_${tabname}-$((n+1)) -->" >> "$gHtmlDumpFile"
        
        echo "<div id=\"tabs_${tabname}-3\">" >> "$gHtmlDumpFile"
        ReadFileAndWriteSubSectionToHtml "${gDumpFolderMemory}/pmem_map_pci_range.txt"\
                                             "Further information, such as EFI ranges, dumped using <a href=\"https://github.com/google/rekall/tree/master/tools/osx/MacPmem\" target=\"_blank\">MacPmem driver</a>"\
                                             "<a href=\"$finalDestination/pmem_map_pci_range.txt\" target=\"_blank\">View File pmem_map_pci_range.txt</a>"\
                                             "pmem_map_pci_range.txt"\
                                             ""\
                                             ""\
                                             "$tabname"   
        echo "</div> <!-- End tabs_${tabname}-$((n+1)) -->" >> "$gHtmlDumpFile"
        
        echo "</div> <!-- Close tabs_${tabname} -->" >> "$gHtmlDumpFile"
        WriteEndingH3
    
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlOpenCL()
{
    local finalDestination="${gDumpFolderOpenCl##*/}"
    if [ -f "$gDumpFolderOpenCl/openCLinfo.txt" ]; then
        SendToUI "@DS@Processing OpenCL:Report@"
        WriteToLog "${gLogIndent}adding OpenCL dump"
        InsertInternalSeparatorHTMLToFile "OpenCL"
        ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderOpenCl/openCLinfo.txt" "OpenCL" "Dumped using opencl by cmf from 2009" "<a href=\"$finalDestination/openCLinfo.txt\" target=\"_blank\">View openCLinfo.txt File</a>" "OpenCL" "aOpenCL" "" "collapseID_OpenCL"
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlPower()
{
    local finalDestination="${gDumpFolderPower##*/}"
    if [ -d "$gDumpFolderPower" ]; then
        SendToUI "@DS@Processing Power:Report@"
        WriteToLog "${gLogIndent}adding power dumps"
        InsertInternalSeparatorHTMLToFile "Power"
        WriteOuterH3 "Power (Sleep/Hibernate)"
        ReadDirCreateTabsAddFileData "$gDumpFolderPower" "power" "$finalDestination"
      WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlRtc()
{
    local finalDestination="${gDumpFolderRtc##*/}"
    if [ -f "$gDumpFolderRtc/RTCDump${rtclength}.txt" ]; then
        SendToUI "@DS@Processing RTC:Report@"
        WriteToLog "${gLogIndent}adding RTC dump"
        InsertInternalSeparatorHTMLToFile "RTC"
        ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderRtc/RTCDump${rtclength}.txt" "RTC" "Dumped using <a href=\"https://www.dropbox.com/s/bg1q0yho6g7u3xn/cmosDumperForOsxV0.1.zip?dl=0\" target=\"_blank\">cmosDumperForOsx</a> by rafirafi, revised extensively by STLVNUB" "<a href=\"$finalDestination/RTCDump${rtclength}.txt\" target=\"_blank\">View RTCDump${rtclength}.txt File</a>" "RTC" "aRTC" "" "collapseID_RTC"
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlDmiTables()
{
    local warningMessage=()
    local checkMessage=""
    local finalDestination="${gDumpFolderDmi##*/}"
    local tabName="dmi"
    local outfileTableDir="${TEMPDIR}/dmi_split_files/"
    local outfileTableName="dmi_table_type_"
    local currentType=""
    local currentHandle=""
    local infoString=""
    declare -a tableType
    declare -a tableTypeSorted
    declare -a findFiles

    #warningMessage[0]="Wrong DMI structures"
    #warningMessage[1]="DMI table is broken"

    if [ -f "$gDumpFolderDmi/SMBIOS.txt" ]; then
        SendToUI "@DS@Processing DMI Tables:Report@"
        WriteToLog "${gLogIndent}adding DMI dump"
        InsertInternalSeparatorHTMLToFile "DMI Tables"
        WriteOuterH3 "DMI Tables"
        WriteJavaScriptJqueryUITabToFile "$tabName"

        oIFS="$IFS"; IFS=$'\n'

        echo "<div id=\"tabs_$tabName\">
  <ul>" >> "$gHtmlDumpFile"

        if [ ! -d "$outfileTableDir" ]; then
            mkdir "$outfileTableDir"
        fi

        # Split SMBIOS.txt file in to individual handle files.
        while read -r lineRead
        do
            if [[ "$lineRead" == *"DMI type"* ]]; then
                currentType="${lineRead##*type }";
                currentType="${currentType%,*}"

                # Is number already in array?
                match=0
                for type in "${tableType[@]}"
                do
                    if [[ $type = "$currentType" ]]; then
                        match=1
                        break
                    fi
                done
                if [[ $match = 0 ]]; then
                    tableType+=($currentType)
                fi
                currentHandle="${lineRead%%,*}";
                currentHandle="${currentHandle##* }"
            else
                echo "$lineRead" >> "${outfileTableDir}${outfileTableName}${currentType}_${currentHandle}".txt
            fi
        done < "$gDumpFolderDmi/SMBIOS.txt"

        # Sort type array
        tableTypeSorted=($(sort -g <<<"${tableType[*]}"))

        # Print tab entries to main html file.
        for ((s=0; s<${#tableTypeSorted[@]}; s++))
        do
            echo "    <li><a href=\"#tabs_$tabName-$s\">${tableTypeSorted[$s]}</a></li>" >> "$gHtmlDumpFile"
        done

        echo "</ul>" >> "$gHtmlDumpFile"

        # Insert each table under it's subsequent tab
        for ((s=0; s<${#tableTypeSorted[@]}; s++))
        do
            echo "<div id=\"tabs_$tabName-$s\">" >> "$gHtmlDumpFile"
            findFiles=( $(find "$outfileTableDir" -type f -name "${outfileTableName}${tableTypeSorted[$s]}_0x*.txt") )
            for (( x=0; x<${#findFiles[@]}; x++ ))
            do
                handle=$( echo "${findFiles[$x]##*_}" | tr -d '.txt' )

                # Add a description for the table type
                case "${tableTypeSorted[$s]}" in
                    0) infoString="DMI Type 0: BIOS" ;;
                    1) infoString="DMI Type 1: System" ;;
                    2) infoString="DMI Type 2: Base Board" ;;
                    3) infoString="DMI Type 3: Chassis" ;;
                    4) infoString="DMI Type 4: Processor" ;;
                    5) infoString="DMI Type 5: Memory Controller" ;;
                    6) infoString="DMI Type 6: Memory Module" ;;
                    7) infoString="DMI Type 7: Cache" ;;
                    8) infoString="DMI Type 8: Port Connector" ;;
                    9) infoString="DMI Type 9: System Slots" ;;
                    10) infoString="DMI Type 10: On Board Devices" ;;
                    11) infoString="DMI Type 11: OEM Strings" ;;
                    12) infoString="DMI Type 12: System Configuration Options" ;;
                    13) infoString="DMI Type 13: BIOS Language" ;;
                    14) infoString="DMI Type 14: Group Associations" ;;
                    15) infoString="DMI Type 15: System Event Log" ;;
                    16) infoString="DMI Type 16: Physical Memory Array" ;;
                    17) infoString="DMI Type 17: Memory Device" ;;
                    18) infoString="DMI Type 18: 32-bit Memory Error" ;;
                    19) infoString="DMI Type 19: Memory Array Mapped Address" ;;
                    20) infoString="DMI Type 20: Memory Device Mapped Address" ;;
                    21) infoString="DMI Type 21: Built-in Pointing Device" ;;
                    22) infoString="DMI Type 22: Portable Battery" ;;
                    23) infoString="DMI Type 23: System Reset" ;;
                    24) infoString="DMI Type 24: Hardware Security" ;;
                    25) infoString="DMI Type 25: System Power Controls" ;;
                    26) infoString="DMI Type 26: Voltage Probe" ;;
                    27) infoString="DMI Type 27: Cooling Device" ;;
                    28) infoString="DMI Type 28: Temperature Probe" ;;
                    29) infoString="DMI Type 29: Electrical Current Probe" ;;
                    30) infoString="DMI Type 30: Out-of-band Remote Access" ;;
                    31) infoString="DMI Type 31: Boot Integrity Services" ;;
                    32) infoString="DMI Type 32: System Boot" ;;
                    33) infoString="DMI Type 33: 64-bit Memory Error" ;;
                    34) infoString="DMI Type 34: Management Device" ;;
                    35) infoString="DMI Type 35: Management Device Component" ;;
                    36) infoString="DMI Type 36: Management Device Threshold Data" ;;
                    37) infoString="DMI Type 37: Memory Channel" ;;
                    38) infoString="DMI Type 38: IPMI Device" ;;
                    39) infoString="DMI Type 39: Power Supply" ;;
                    40) infoString="DMI Type 40: Additional Information" ;;
                    41) infoString="DMI Type 41: Onboard Device" ;;
                    42) infoString="DMI Type 42: Management Controller Host Interface" ;;
    4[3-9]|1[0-2][0-5]) infoString="DMI Type ${tableTypeSorted[$s]}: Unknown Table Type" ;;
                    126) infoString="DMI Type 126: Disabled Entry" ;;
                    127) infoString="DMI Type 127: End of Table Marker" ;;
                    128) infoString="DMI Type 128: OEM Table - Apple FirmwareVolume" ;;
                    130) infoString="DMI Type 130: OEM Table - Apple Memory SPD" ;;
                    131) infoString="DMI Type 131: OEM Table - Apple Processor Type" ;;
                    132) infoString="DMI Type 132: OEM Table - Apple Processor Interconnect Speed" ;;
                    133) infoString="DMI Type 133: OEM Table - Apple - Unknown Table Type" ;;
                      *) infoString="DMI Type ${tableTypeSorted[$s]}: OEM Table - Unknown Table Type" ;;
                esac

                # To have the sub tables collapsed by default, use these two lines.
                ReadFileAndWriteSubSectionToHtml "${findFiles[$x]}"\
                                                 "${infoString}&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#CCC\">Handle:$handle</span>"\
                                                 "<a href=\"$finalDestination/$fileLocation\" target=\"_blank\">View ${plistFiles[$p]##*/}</a>"\
                                                 "dmitables"\
                                                 "collapseID_DMITables_${s}_${x}"\
                                                 "block"
                # To have the sub tables open/un-collapsed for the dmi tables, use this instead of the code above.
                #ReadFileAndWriteSubSectionToHtml "${findFiles[$x]}" "${infoString}&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:#CCC\">Handle:$handle</span>" "<a href=\"$finalDestination/$fileLocation\"target=\"_blank\">View SMBIOS.txt File</a>" "dmitables" "" "" "none"
                echo "</div> <!-- End div section for device id & set state -->" >> "$gHtmlDumpFile"
            done
            echo "</div> <!-- End tabs_$tabName-$s -->" >> "$gHtmlDumpFile"
        done

        echo "</div> <!-- Close tabs_rcscripts -->" >> "$gHtmlDumpFile"
        WriteEndingH3

        # Clean up
        if [ -d "$outfileTableDir" ]; then
            rm "$outfileTableDir"/*
            rmdir "$outfileTableDir"
        fi

        # Check for a couple of warnings
        #for (( n=0; n<${#warningMessage[@]}; n++ ))
        #do
        #    checkMessage=`fgrep "${warningMessage[$n]}" "$gDumpFolderDmi/SMBIOS.txt"`
        #    if [ ! "$checkMessage" == "" ]; then
        #        ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderDmi/SMBIOS.txt" "SMBIOS" "Dumped using smbios-reader & <a href=\"http://www.nongnu.org/dmidecode/\">dmidecode</a> v2.12. dmidecode <a href=\"http://www.projectosx.com/forum/index.php?showtopic=2208\">compiled for macOS</a> by Slice." "<a href=\"$finalDestination/SMBIOS.txt\" target=\"_blank\">View SMBIOS.txt File</a>" "SMBIOS" "aSMBIOS" "Warning: $checkMessage" "collapseID_SMBIOS"
        #        break
        #    fi
        #done

        #if [ "$checkMessage" == "" ]; then
        #    ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderDmi/SMBIOS.txt" "SMBIOS" "Dumped using smbios-reader & <a href=\"http://www.nongnu.org/dmidecode/\">dmidecode</a> v2.12. dmidecode <a href=\"http://www.projectosx.com/forum/index.php?showtopic=2208\">compiled for macOS</a> by Slice." "<a href=\"$finalDestination/SMBIOS.txt\" target=\"_blank\">View SMBIOS.txt File</a>" "SMBIOS" "aSMBIOS" "" "collapseID_SMBIOS"
        #fi
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlSip()
{
    local finalDestination="${gDumpFolderSip##*/}"
    if [ -f "$gDumpFolderSip/SIP_status.txt" ]; then
        SendToUI "@DS@Processing SIP:Report@"
        WriteToLog "${gLogIndent}adding SIP dump"
        InsertInternalSeparatorHTMLToFile "SIP"
        ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderSip/SIP_status.txt" "Security Integrity Protection (SIP)" "Dumped using <a href=\"https://github.com/Piker-Alpha/csrstat\" target=\"_blank\">csrstat</a> by Piker-Alpha" "<a href=\"$finalDestination/SIP_status.txt\" target=\"_blank\">View SIP_status.txt File</a>" "SIP" "aSIP" "" "collapseID_SIP"
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlSmcKeys()
{
    local finalDestination="${gDumpFolderSmc##*/}"
    if [ -d "$gDumpFolderSmc" ]; then
        SendToUI "@DS@Processing SMC:Report@"
        WriteToLog "${gLogIndent}adding SMC dumps"
        InsertInternalSeparatorHTMLToFile "SMC"
        WriteOuterH3 "SMC"
        ReadDirCreateTabsAddFileData "$gDumpFolderSmc" "smc" "$finalDestination"
      WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlSytemProfiler()
{
    local finalDestination="${gDumpFolderSysProf##*/}"
    if [ -f "$gDumpFolderSysProf/System-Profiler.txt" ]; then
        SendToUI "@DS@Processing System Profiler:Report@"
        WriteToLog "${gLogIndent}adding System Profiler dump"
        InsertInternalSeparatorHTMLToFile "System Profiler"
        ReadFileAndWriteCompleteSectionToHtml "$gDumpFolderSysProf/System-Profiler.txt" "System Profiler" "Dumped using /usr/sbin/system_profiler -detailLevel mini" "<a href=\"$finalDestination/System-Profiler.txt\" target=\"_blank\">View System-Profiler.txt File</a>" "SystemProfiler" "aSystemProfiler" "" "collapseID_SysProf"
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlRcScripts()
{
    local finalDestination="${gDumpFolderRcScripts##*/}"
    declare -a readScriptFiles

    # ---------------------------------------------------------------------------------------
    BuildTabs()
    {
        if [ ${#readScriptFiles[@]} -gt 0 ]; then

            echo "<div id=\"tabs_rcscripts\">
  <ul>" >> "$gHtmlDumpFile"

            for (( x=0; x<${#readScriptFiles[@]}; x++ ))
            do
                if [ -f "${readScriptFiles[$x]}" ]; then
                    fileLocation="${readScriptFiles[$x]##*$gDumpFolderRcScripts/}"
                    echo "
    <li><a href=\"#tabs_rcscripts-(($x+1))\">/etc/${fileLocation}</a></li>" >> "$gHtmlDumpFile"
                fi
            done
            echo "</ul>" >> "$gHtmlDumpFile"
        fi
    }

    # ---------------------------------------------------------------------------------------
    AddScriptsDumps()
    {
        if [ ${#readScriptFiles[@]} -gt 0 ]; then
            WriteToLog "${gLogIndent}adding RC Startup and Shutdown scripts"
            finalDestination="RC Scripts"
            for (( x=0; x<${#readScriptFiles[@]}; x++ ))
            do
                if [ -f "${readScriptFiles[$x]}" ]; then
                    fileLocation="${readScriptFiles[$x]##*$gDumpFolderRcScripts/}"
                    echo "<div id=\"tabs_rcscripts-(($x+1))\">" >> "$gHtmlDumpFile"
                    ReadFileAndWriteSubSectionToHtml "${readScriptFiles[$x]}"\
                                                     "Found from searching /etc/rc*"\
                                                     "<a href=\"$finalDestination/$fileLocation\">View ${readScriptFiles[$x]##*/} file</a>"\
                                                     "RCScripts"\
                                                     ""\
                                                     "none"
                    echo "</div> <!-- Endtabs_rcscripts-(($x+1)) -->" >> "$gHtmlDumpFile"
                fi
            done
        fi
    }

    if [ -d "$gDumpFolderRcScripts" ]; then
        SendToUI "@DS@Processing RC Scripts:Report@"
        InsertInternalSeparatorHTMLToFile "RC Startup and Shutdown scripts"
        WriteOuterH3 "RC Startup and Shutdown scripts"
        WriteJavaScriptJqueryUITabToFile "rcscripts"

        local oIFS="$IFS"
        IFS=$'\n'
        readScriptFiles=( $(find "$gDumpFolderRcScripts" -type f -not -path '*svn*') )
        IFS="$oIFS"

        BuildTabs
        AddScriptsDumps

        echo "</div> <!-- Close tabs_rcscripts -->" >> "$gHtmlDumpFile"
        WriteEndingH3
    fi
}

# ---------------------------------------------------------------------------------------
DumpHtmlNvram()
{
    local finalDestination="${gDumpFolderNvram##*/}"
    if [ -d "$gDumpFolderNvram" ]; then
        SendToUI "@DS@Processing NVRAM:Report@"
        WriteToLog "${gLogIndent}adding nvram info"
        InsertInternalSeparatorHTMLToFile "NVRAM"
      WriteOuterH3 "NVRAM"
      ReadDirCreateTabsAddFileData "$gDumpFolderNvram" "nvraminfo" "$finalDestination"
      WriteEndingH3
    fi
}


# ---------------------------------------------------------------------------------------
DumpHtmlEdid()
{
    local finalDestination="${gDumpFolderEdid##*/}"
    local tabname="edid"
    local edidFileName=""
    local edidFileNameExtensionRemoved=""

    if [ -d "$gDumpFolderEdid" ]; then

        SendToUI "@DS@Processing EDID:Report@"

        # Build list of files
        local oIFS="$IFS"
        IFS=$'\n'
        local edidFiles=( $(find "$gDumpFolderEdid" -type f -name "EDI*.txt") )
        IFS="$oIFS"

        if [ ${#edidFiles[@]} -gt 1 ]; then
            InsertInternalSeparatorHTMLToFile "EDID"
            WriteOuterH3 "EDID"
            WriteJavaScriptJqueryUITabToFile "$tabname"

            # Build tabs
            echo "<div id=\"tabs_${tabname}\">
  <ul>" >> "$gHtmlDumpFile"
            for (( n=0; n<${#edidFiles[@]}; n++ ))
            do
                echo "    <li><a href=\"#tabs_${tabname}-${n}\">${edidFiles[$n]##*/}</a></li>" >> "$gHtmlDumpFile"
            done
            echo  "</ul>" >> "$gHtmlDumpFile"

            # Read file and add contents in to each tab
            for (( n=0; n<${#edidFiles[@]}; n++ ))
            do
                edidFileName="${edidFiles[$n]##*/}"
                WriteToLog "${gLogIndent}adding $edidFileName"
                edidFileNameExtensionRemoved="${edidFileName%.txt*}"
                echo "<div id=\"tabs_${tabname}-${n}\">" >> "$gHtmlDumpFile"
                ReadFileAndWriteSubSectionToHtml "${gDumpFolderEdid}/${edidFileName}"\
                                                  "${edidFileNameExtensionRemoved}"\
                                                  "Dumped IODisplayEDID from ioreg and decoded using <a href=\"http://cgit.freedesktop.org/xorg/app/edid-decode/\" target=\"_blank\">edid-decode</a> by Adam Jackson. <a href=\"$finalDestination/${edidFileName}\" target=\"_blank\">View ${edidFileName} File</a>"\
                                                  "${edidFileName}"\
                                                  ""\
                                                  ""
                echo "</div> <!-- End tabs_${tabname}-${n} -->" >> "$gHtmlDumpFile"
            done
            echo "</div> <!-- Close tabs_edid -->" >> "$gHtmlDumpFile"
          WriteEndingH3

        else
            # Only one file to read
            if [ -f "$gDumpFolderEdid/EDID.txt" ]; then
                WriteToLog "${gLogIndent}adding EDID.txt"
                InsertInternalSeparatorHTMLToFile "EDID"
                ReadFileAndWriteCompleteSectionToHtml "${gDumpFolderEdid}/EDID.txt" "EDID" "Dumped IODisplayEDID from ioreg and decoded using <a href=\"http://cgit.freedesktop.org/xorg/app/edid-decode/\" target=\"_blank\">edid-decode</a> by Adam Jackson. Updated by Andy Vandijck." "<a href=\"$finalDestination/EDID.txt\" target=\"_blank\">View EDID.txt File</a>" "EDID" "aEDID" "" "collapseID_EDID" "block"
            fi
        fi
    fi
}

CleanUp()
{
    checkDir="${DATA_DIR%/*}"
    checkDir="${checkDir%/*}"
    [[ -f .txt ]] && rm .txt
    [[ -f .txt.bak ]] && rm .txt.bak
}

#
# =======================================================================================
# MAIN
# =======================================================================================
#

# get the absolute path of the executable
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")
source "${SELF_PATH%/*}"/shared.sh

#CheckRoot
Initialise "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
SendToUI "@DS@Initialising:Report@"
CreateAndInitialiseHtmlFile
WriteAccordionOpen
DumpHtmlAcpiTables
DumpHtmlAudio
DumpHtmlBiosSystem
DumpHtmlBiosVideo
DumpHtmlBootLoaderAndBootSectors
DumpHtmlBootloaderConfigs
DumpHtmlBootLogF
DumpHtmlBootLogK
DumpHtmlCpuInfo
DumpHtmlDeviceProperties
DumpHtmlDisks
DumpHtmlDiskUtils
DumpHtmlDiskUUIDs
DumpHtmlDmiTables
DumpHtmlEdid
DumpHtmlFirmwareMemoryMap
DumpHtmlIoreg
DumpHtmlKernelInfo
DumpHtmlKextLists
DumpHtmlLspci
DumpHtmlMemoryIntelGraphics
DumpHtmlMemoryInfo
DumpHtmlNvram
DumpHtmlOpenCL
DumpHtmlPower
DumpHtmlRcScripts
DumpHtmlRtc
DumpHtmlSip
DumpHtmlSmcKeys
DumpHtmlSytemProfiler
SendToUI "@DS@Finishing up:Report@"
WriteAccordionClose
WriteDumpContainerClose
CloseCssFile
CloseHtmlFile
WriteIECssToFile
CombineCssJsAndHtmlFiles
CleanUp
echo "Done."