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"> <script type="text/javascript">
// // // // // // // // // //
// Version 2019/11/14 by Wema // Version 2020/01/15 by Wema
// // // // // // // // // //
var headers1 = document.getElementsByTagName('h1'); var headers1 = document.getElementsByTagName('h1');
var headers2 = document.getElementsByTagName('h2'); var headers2 = document.getElementsByTagName('h2');
...@@ -22,10 +22,20 @@ function getCourseHome(){ ...@@ -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){ function getSearchParam(param){
var myurl = new URL(location.href); return typeof urlParams[param] !== "undefined" ? urlParams[param] : 0;
return (myurl.searchParams.get(param) === null) ? 0 : myurl.searchParams.get(param);
} }
// https://stackoverflow.com/questions/4793604/how-to-insert-an-element-after-another-element-in-javascript-without-using-a-lib // https://stackoverflow.com/questions/4793604/how-to-insert-an-element-after-another-element-in-javascript-without-using-a-lib
function insertAfter(referenceNode, newNode) { function insertAfter(referenceNode, newNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
...@@ -165,8 +175,8 @@ setTimeout(function(){ ...@@ -165,8 +175,8 @@ setTimeout(function(){
var placeholder2 = "/placeholder"; var placeholder2 = "/placeholder";
for (var i in divs) { for (var i in divs) {
if (typeof divs[i].style !== 'undefined'){ if (typeof divs[i].style !== "undefined"){
if (typeof divs[i].style.backgroundImage !== 'undefined'){ if (typeof divs[i].style.backgroundImage !== "undefined"){
if (divs[i].style.backgroundImage.indexOf(placeholder2)>=0){ if (divs[i].style.backgroundImage.indexOf(placeholder2)>=0){
placeholder1 = parseInt(divs[i].style.backgroundImage.split(placeholder0)[1]); placeholder1 = parseInt(divs[i].style.backgroundImage.split(placeholder0)[1]);
var rand = Math.floor(Math.random() * imgs.length); var rand = Math.floor(Math.random() * imgs.length);
...@@ -181,9 +191,8 @@ setTimeout(function(){ ...@@ -181,9 +191,8 @@ setTimeout(function(){
/* Voma Start: Gibt es diese idnumber nicht? Weiterleitung zur Erstellung */ /* Voma Start: Gibt es diese idnumber nicht? Weiterleitung zur Erstellung */
if(location.href.indexOf("view.php?idnumber=")>=0){ if(location.href.indexOf("view.php?idnumber=")>=0){
var divs = document.getElementsByTagName('div'); var errorDiv = document.querySelector("[data-rel='fatalerror']");
for (var i in divs) { if(errorDiv!=null) {
if(divs[i].dataset.rel == "fatalerror"){
var idnumber = parseInt(getSearchParam("idnumber")); var idnumber = parseInt(getSearchParam("idnumber"));
var mac = getSearchParam("mac"); var mac = getSearchParam("mac");
var abra = murl+"/abra/?usr=2&zid="+idnumber+"&mac="+mac; var abra = murl+"/abra/?usr=2&zid="+idnumber+"&mac="+mac;
...@@ -200,15 +209,14 @@ if(location.href.indexOf("view.php?idnumber=")>=0){ ...@@ -200,15 +209,14 @@ if(location.href.indexOf("view.php?idnumber=")>=0){
btn1 = 'Continue'; btn2 = 'Cancel'; btn1 = 'Continue'; btn2 = 'Cancel';
document.title = 'Create / connect a new PAUL course'; document.title = 'Create / connect a new PAUL course';
} }
divs[i].innerHTML = msg; errorDiv.innerHTML = msg;
var input = document.getElementsByTagName("button"); var input = document.getElementsByTagName("button");
for (var i in input) { for (var i in input) {
if(input[i].innerHTML == btn1){ if(input[i].innerHTML == btn1){
input[i].innerHTML = btn2; input[i].innerHTML = btn2;
} }
} }
} }
}
} }
/* Voma Start: Gibt es diese idnumber nicht? Weiterleitung zur Erstellung */ /* Voma Start: Gibt es diese idnumber nicht? Weiterleitung zur Erstellung */
...@@ -241,7 +249,7 @@ setTimeout(function(){ ...@@ -241,7 +249,7 @@ setTimeout(function(){
var enrolmenticons = document.getElementsByClassName("enrolmenticons"); var enrolmenticons = document.getElementsByClassName("enrolmenticons");
for (var i in enrolmenticons) { for (var i in enrolmenticons) {
if (typeof enrolmenticons[i].innerHTML !== 'undefined'){ if (typeof enrolmenticons[i].innerHTML !== "undefined"){
if(enrolmenticons[i].innerHTML.trim() == ""){ if(enrolmenticons[i].innerHTML.trim() == ""){
if(document.documentElement.lang == "en"){ if(document.documentElement.lang == "en"){
enrolmenticons[i].innerHTML = '<i class="card-text">Manual enrolments (restricted)</i>'; enrolmenticons[i].innerHTML = '<i class="card-text">Manual enrolments (restricted)</i>';
...@@ -358,15 +366,6 @@ if (document.body.id == 'page-course-view-remuiformat') { ...@@ -358,15 +366,6 @@ if (document.body.id == 'page-course-view-remuiformat') {
} }
/* Wema Ende: Expand collapsible course-sections by url (from Edwiser) */ /* 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 */ /* Wema Start: Remove link from group-icon in edit mode */
if(isCoursePage()){ if(isCoursePage()){
var icoTitle = { var icoTitle = {
...@@ -383,14 +382,22 @@ if(isCoursePage()){ ...@@ -383,14 +382,22 @@ if(isCoursePage()){
en: 'No groups' 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'); var nodeAnchor = document.getElementsByClassName(icoClassName+' menu-action cm-edit-action');
if(nodeAnchor.length>0) { if(nodeAnchor.length>0) {
for(var j=nodeAnchor.length; j>0; j--) { 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='); 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 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> </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