Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
canvas-header-widget/script.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
125 lines (110 sloc)
4.03 KB
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
// --------------------------------------------- | |
// Function to get URL parameters | |
// --------------------------------------------- | |
function getParameterByName(name, url) { | |
if (!url) url = window.location.href; | |
name = name.replace(/[\[\]]/g, '\\$&'); | |
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), | |
results = regex.exec(url); | |
if (!results) return null; | |
if (!results[2]) return ''; | |
return decodeURIComponent(results[2].replace(/\+/g, ' ')); | |
} | |
// Get values from URL parameters | |
var pageIndex = getParameterByName('page'); | |
//var baseURL = 'https://internet2.instructure.com'; | |
console.log(pageIndex); | |
// --------------------------------------------- | |
// Define functions to set the header values from the page array | |
// --------------------------------------------- | |
function replacePageValue(value) { | |
if (pageValue.hasOwnProperty(value)) { | |
var resultobj = pageValue[value]; | |
return resultobj | |
} | |
return value; | |
} | |
var pageObj = replacePageValue(pageIndex); | |
var course = pageObj['course']; | |
var topic = pageObj['topic']; | |
var type = pageObj['type']; | |
var usecase = pageObj['usecase']; | |
var pageTitle = pageObj['title']; | |
console.log(course); | |
console.log(topic); | |
console.log(type); | |
console.log(usecase); | |
console.log(pageTitle); | |
// --------------------------------------------- | |
// Define functions to replace values based on the configuration | |
// --------------------------------------------- | |
function replaceCourseValue(value) { | |
if (courseValues.hasOwnProperty(value)) { | |
var resultArray = courseValues[value]; | |
return resultArray | |
} | |
return value; | |
} | |
function replaceTopicValue(value) { | |
if (topicValues.hasOwnProperty(value)) { | |
return topicValues[value]; | |
} | |
return value; | |
} | |
function replaceTypeValue(value) { | |
if (typeValues.hasOwnProperty(value)) { | |
return typeValues[value]; | |
} | |
return value; | |
} | |
function replaceUsecaseValue(value) { | |
if (usecaseValues.hasOwnProperty(value)) { | |
return usecaseValues[value] | |
} | |
return value; | |
} | |
// Substitute topic and param2 with values from the external configurations | |
course = replaceCourseValue(course); | |
//baseURL = baseURL + course['path']; | |
type = replaceTypeValue(type); | |
topic = replaceTopicValue(topic); | |
usecase = replaceUsecaseValue(usecase); | |
console.log("TOPIC: ",topic); | |
console.log("TYPE: ",type); | |
console.log("USECASE: ",usecase); | |
// --------------------------------------------- | |
// Display values on the page | |
// --------------------------------------------- | |
document.addEventListener('DOMContentLoaded', function () { | |
// HOME LINK | |
/*var homeLink = document.getElementById('courseHome'); | |
homeLink.textContent = course[0]; | |
homeLink.href = baseURL;*/ | |
// TOPIC LINK | |
if (topic !== null && topic !== undefined) { | |
//document.getElementById('topic').textContent = topicObj['name']; | |
/* | |
// TOPIC MODULE LINK | |
document.getElementById('moduleHome').textContent = 'TOPIC MODULE HOME'; | |
document.getElementById('moduleHome').href = topic['moduleURL']; | |
// TOPIC EXERCISE LINK | |
document.getElementById('exerciseHome').textContent = 'TOPIC EXERCISE HOME'; | |
document.getElementById('exerciseHome').href = topic['exerciseURL']; | |
*/ | |
// TOPIC WAYFINDING IMAGE | |
document.getElementById('topic').src = topic['wayfindingWt']; | |
document.getElementById('topic').alt = topic['alt']; | |
document.getElementById('topic').height = '20'; | |
}; | |
if (type !== null && type !== undefined) { | |
document.getElementById('type').src = type['wayfindingWt']; | |
document.getElementById('type').alt = type['alt']; | |
document.getElementById('type').height = "20"; | |
}; | |
if (usecase !== null && usecase !== undefined) { | |
document.getElementById('usecase').src = usecase['wayfinding'] | |
document.getElementById('usecase').alt = usecase['alt']; | |
document.getElementById('usecase').height = "20"; | |
}; | |
if (pageTitle !== null && pageTitle !== undefined) {document.getElementById('title').textContent = pageTitle}; | |
}); |