Created
June 10, 2017 14:11
-
-
Save iamtracy/6892ff799b90698c25c779c304a4068b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//req url - https://vts.inxpo.com/scripts/Server.nxp?LASCmd=AI:1;F:LBSEXPORT!JSON&SQLID=16010&ImageLib=9 | |
//Filter Polyfill for IE | |
if (!Array.prototype.filter) { | |
Array.prototype.filter = function(fun) { | |
var len = this.length >>> 0; | |
if (typeof fun != "function") | |
throw new TypeError(); | |
var res = []; | |
var thisp = arguments[1]; | |
for (var i = 0; i < len; i++) { | |
if (i in this) { | |
var val = this[i]; // in case fun mutates this | |
if (fun.call(thisp, val, i, this)) | |
res.push(val); | |
} | |
} | |
return res; | |
}; | |
} | |
function InitData() { | |
formatTabs(data); | |
} | |
function formatTabs(tabs) { | |
var tabsArray = removeDuplicates(tabs, "SubjectCategoryKey"); | |
var newTabsArray = tabsArray.sort(function(a, b) { | |
return a.DisplayOrder - b.DisplayOrder; | |
}); | |
buildTabs(newTabsArray); | |
} | |
function buildTabs(item) { | |
var g_oTabContent = document.getElementById('tabs'); | |
var g_cTabHtmlString = ''; | |
g_cTabHtmlString += '<div class="list-group">'; | |
item.forEach(function(item) { | |
var cat = item.SubjectCategoryKey; | |
g_cTabHtmlString += '<a href="#' + cat + '" class="list-group-item list-group-item-action"'; | |
g_cTabHtmlString += 'title="Click to view the ' + item.Description + ' section">'; | |
g_cTabHtmlString += item.Description; | |
g_cTabHtmlString += '</a>'; | |
var itemsArray = g_aItemData.filter(function(item) { | |
return item.SubjectCategoryKey == cat; | |
}); | |
buildListItem(itemsArray, item.Description, item.SubjectCategoryKey); | |
}); | |
g_cTabHtmlString += '</div>'; | |
g_oTabContent.innerHTML = g_cTabHtmlString; | |
} | |
function buildListItem(item, title, id) { | |
var g_oContent = document.getElementById('content'); | |
g_cListHtmlString += '<h3 id="' + id + '">' + title + '</h3>' | |
g_cListHtmlString += '<div class="list-group mb-3">'; | |
item.forEach(function(item) { | |
var itemLogo = getIconType(item.ItemName); | |
g_cListHtmlString += '<a href="https://vts.inxpo.com/scripts/Server.nxp?LASCmd=AI:1;S:41008;F:LBSATTACH!V&AttachmentKey=' + item.ItemKey + '"'; | |
g_cListHtmlString += 'class="list-group-item list-group-item-action" target="_blank" title="' + item.ItemTitle + '" title="' + itemLogo.srContent + '">'; | |
g_cListHtmlString += (itemLogo.status ? '<i class="fa ' + itemLogo.icon + ' mr-3" aria-hidden="true"></i>' : '<i class="fa fa-link mr-3" aria-hidden="true" title="' + itemLogo.srContent + '"></i>'); | |
g_cListHtmlString += item.ItemTitle + '</a>'; | |
}); | |
g_cListHtmlString += '</div>'; | |
g_oContent.innerHTML = g_cListHtmlString; | |
setShowContHeight(); | |
} | |
function removeDuplicates(arr, prop) { | |
var newArray = []; | |
var lookup = {}; | |
for (var i in arr) { | |
lookup[arr[i][prop]] = arr[i]; | |
} | |
for (i in lookup) { | |
newArray.push(lookup[i]); | |
} | |
return newArray; | |
} | |
function getIconType(item) { | |
var fileType = item.slice((item.lastIndexOf(".") - 1) + 2).substring(0, 3); | |
if (fileType === 'doc') { | |
return { | |
icon: 'fa-file-o', | |
srContent: 'Link to a word document', | |
status: true | |
} | |
} else if (fileType === 'pdf') { | |
return { | |
icon: 'fa-file-pdf-o', | |
srContent: 'Link to a pdf document', | |
status: true | |
} | |
} else if (fileType === 'com' || fileType === 'htm' || fileType === 'asp' || fileType === 'jsp') { | |
return { | |
icon: 'fa-internet-explorer', | |
srContent: 'Link to a website', | |
status: true | |
} | |
} else if (fileType === 'mp4' || fileType === 'mp3') { | |
return { | |
icon: 'fa-file-video-o', | |
srContent: 'Link to a video', | |
status: true | |
} | |
} else if (fileType === 'ppt') { | |
return { | |
icon: 'fa-file-powerpoint-o', | |
srContent: 'Link to a video', | |
status: true | |
} | |
} else { | |
return { | |
srContent: 'Link to a resource', | |
status: false | |
} | |
} | |
} | |
function scrollToTop() { | |
var timeOut; | |
if (document.body.scrollTop != 0 || document.documentElement.scrollTop != 0) { | |
window.scrollBy(0, -50); | |
timeOut = setTimeout('scrollToTop()', 10); | |
} else clearTimeout(timeOut); | |
} | |
//document.addEventListener('DOMContentLoaded', setConfigOptions); | |
function setConfigOptions() { | |
var oTitleElem = document.getElementsByTagName('title')[0]; | |
var oLeftList = document.getElementById('leftList'); | |
var oRightList = document.getElementById('rightList'); | |
var cSetLeftList = GetURLParamValue('leftListText'); | |
var cSetRightList = GetURLParamValue('rightListText'); | |
var cSetTitle = GetURLParamValue('title'); | |
oLeftList.innerHTML = decodeURIComponent(cSetLeftList) || 'Table of Contents'; | |
oRightList.innerHTML = decodeURIComponent(cSetRightList) || 'Upcoming Shows'; | |
oTitleElem.innerHTML = decodeURIComponent(cSetTitle) || 'Screen Reader'; | |
} | |
setConfigOptions(); | |
document.addEventListener('DOMContentLoaded', setShowContHeight); | |
function InitTheaterData() { | |
var oResponse = InxpoAJAXEvalJSON(g_oAjaxObjTheater.m_oXMLHTTPReqObj.responseText); | |
var aTheaterData = oResponse.ResultSet[0]; | |
buildShows(aTheaterData); | |
} | |
function buildShows(data) { | |
var oTheaterContent = document.getElementById('theater'); | |
if (data.length > 0) { | |
data.forEach(function(item) { | |
var target = (item.LaunchNewWindow == 1 ? '_blank' : '_parent'); | |
g_cTheaterHTML += '<div class="card">'; | |
g_cTheaterHTML += '<div class="card-block">'; | |
g_cTheaterHTML += '<p class="card-title" title="' + item.Description + '">' + item.Description + '</p>'; | |
g_cTheaterHTML += '<p class ="card-text" title="' + item.Abstract + '">' + item.Abstract + '</p>'; | |
g_cTheaterHTML += '<a href="Server.nxp?LASCmd=AI:1;F:SF!42000&EventKey=' + item.EventKey + '"'; | |
g_cTheaterHTML += 'class="btn btn-primary" title="Launch presentation titled ' + item.Description + '" target="' + target + '">Launch Presentation</a>'; | |
g_cTheaterHTML += '</div></div>'; | |
}); | |
} else { | |
g_cTheaterHTML += '<a href="#" class="list-group-item list-group-item-action" title="There are no shows to display">There are no shows to display</a>'; | |
} | |
oTheaterContent.innerHTML = g_cTheaterHTML; | |
} | |
function setShowContHeight() { | |
var oTabHeight = document.getElementById('tabs').clientHeight.toString(); | |
var oTheaterElem = document.getElementById('theater'); | |
oTheaterElem.style.overflowY = "scroll"; | |
if (oTabHeight >= 400) { | |
oTheaterElem.style.maxHeight = oTabHeight + 'px'; | |
oTheaterElem.style.borderBottom = '1px solid rgba(0,0,0,.125)'; | |
oTheaterElem.style.borderRadius = '.25rem'; | |
} else { | |
oTheaterElem.style.maxHeight = '600' + 'px'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment