Commit f8d7a3c8 authored by weibel manuel - mweibel's avatar weibel manuel - mweibel
Browse files

Update paul.js

IE 11 fixes
parent 7cd9d9e3
<script type="text/javascript">
// // // // //
// Version 2019/11/14 by Wema
// Version 2020/01/15 by Wema
// // // // //
var headers1 = document.getElementsByTagName('h1');
var headers2 = document.getElementsByTagName('h2');
......@@ -22,10 +22,20 @@ function getCourseHome(){
}
}
}
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var urlParams = getUrlVars();
function getSearchParam(param){
var myurl = new URL(location.href);
return (myurl.searchParams.get(param) === null) ? 0 : myurl.searchParams.get(param);
return typeof urlParams[param] !== "undefined" ? urlParams[param] : 0;
}
// https://stackoverflow.com/questions/4793604/how-to-insert-an-element-after-another-element-in-javascript-without-using-a-lib
function insertAfter(referenceNode, newNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
......@@ -165,8 +175,8 @@ setTimeout(function(){
var placeholder2 = "/placeholder";
for (var i in divs) {
if (typeof divs[i].style !== 'undefined'){
if (typeof divs[i].style.backgroundImage !== 'undefined'){
if (typeof divs[i].style !== "undefined"){
if (typeof divs[i].style.backgroundImage !== "undefined"){
if (divs[i].style.backgroundImage.indexOf(placeholder2)>=0){
placeholder1 = parseInt(divs[i].style.backgroundImage.split(placeholder0)[1]);
var rand = Math.floor(Math.random() * imgs.length);
......@@ -181,9 +191,8 @@ setTimeout(function(){
/* Voma Start: Gibt es diese idnumber nicht? Weiterleitung zur Erstellung */
if(location.href.indexOf("view.php?idnumber=")>=0){
var divs = document.getElementsByTagName('div');
for (var i in divs) {
if(divs[i].dataset.rel == "fatalerror"){
var errorDiv = document.querySelector("[data-rel='fatalerror']");
if(errorDiv!=null) {
var idnumber = parseInt(getSearchParam("idnumber"));
var mac = getSearchParam("mac");
var abra = murl+"/abra/?usr=2&zid="+idnumber+"&mac="+mac;
......@@ -200,7 +209,7 @@ if(location.href.indexOf("view.php?idnumber=")>=0){
btn1 = 'Continue'; btn2 = 'Cancel';
document.title = 'Create / connect a new PAUL course';
}
divs[i].innerHTML = msg;
errorDiv.innerHTML = msg;
var input = document.getElementsByTagName("button");
for (var i in input) {
if(input[i].innerHTML == btn1){
......@@ -208,7 +217,6 @@ if(location.href.indexOf("view.php?idnumber=")>=0){
}
}
}
}
}
/* Voma Start: Gibt es diese idnumber nicht? Weiterleitung zur Erstellung */
......@@ -241,7 +249,7 @@ setTimeout(function(){
var enrolmenticons = document.getElementsByClassName("enrolmenticons");
for (var i in enrolmenticons) {
if (typeof enrolmenticons[i].innerHTML !== 'undefined'){
if (typeof enrolmenticons[i].innerHTML !== "undefined"){
if(enrolmenticons[i].innerHTML.trim() == ""){
if(document.documentElement.lang == "en"){
enrolmenticons[i].innerHTML = '<i class="card-text">Manual enrolments (restricted)</i>';
......@@ -358,15 +366,6 @@ if (document.body.id == 'page-course-view-remuiformat') {
}
/* Wema Ende: Expand collapsible course-sections by url (from Edwiser) */
/* Wema Start: IE11 Redirect */
var isIE11 = !!navigator.userAgent.match(/Trident.*rv\:11\./);
var faqPage = '/mod/glossary/showentry.php?courseid=3&eid=271&displayformat=dictionary';
if(isIE11 && (window.location.pathname + window.location.search + window.location.hash)!=faqPage) {
window.location.href = murl + faqPage;
}
/* Wema Ende: IE11 Redirect */
/* Wema Start: Remove link from group-icon in edit mode */
if(isCoursePage()){
var icoTitle = {
......@@ -383,14 +382,22 @@ if(isCoursePage()){
en: 'No groups'
}
};
for (var icoClassName of Object.keys(icoTitle)) {
Object.keys(icoTitle).forEach(function (icoClassName, icoClassIndex) {
var nodeAnchor = document.getElementsByClassName(icoClassName+' menu-action cm-edit-action');
if(nodeAnchor.length>0) {
for(var j=nodeAnchor.length; j>0; j--) {
nodeAnchor[j-1].outerHTML = nodeAnchor[j-1].innerHTML.replace('class=', 'title="'+icoTitle[icoClassName][document.documentElement.lang]+'" class=');
}
}
}
});
}
/* Wema Ende: Remove link from group-icon in edit mode */
/* Wema Start: IE11 Redirect */
var isIE11 = !!navigator.userAgent.match(/Trident.*rv\:11\./);
var faqPage = '/mod/glossary/showentry.php?courseid=3&eid=271&displayformat=dictionary';
if(isIE11 && (window.location.pathname + window.location.search + window.location.hash)!=faqPage) {
window.location.href = murl + faqPage;
}
/* Wema Ende: IE11 Redirect */
</script>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment