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

Update paul.js

- simplifiaction murl variable
- IE11 code-compatibility (String.indexOf instead of String.includes)
- new edited "kurs löschen"-code
- new IE11-redirect-code
parent f6390e05
<script type="text/javascript">
// // // // //
// Version 2019/10/17 by Wema
// Version 2019/11/06 by Wema
// // // // //
var headers1 = document.getElementsByTagName('h1');
var headers2 = document.getElementsByTagName('h2');
var links = document.getElementsByTagName("a");
var murl = location.href.includes("anna") ? "https://paul.zhdk.ch/anna/" : "https://paul.zhdk.ch/";
var mfaq = location.href.includes("anna") ?
murl+"mod/glossary/showentry.php?courseid=3&eid=1&idnumber=" :
murl+"mod/glossary/showentry.php?courseid=3&eid=129&displayformat=dictionary&idnumber=";
var murl = window.location.origin;
var mfaq = "/mod/glossary/showentry.php?courseid=3&eid=129&displayformat=dictionary&idnumber=";
function isCoursePage(){
return location.href.includes(murl+"course/view.php?id=") || location.href.includes(murl+"course/view.php?idnumber=");
return location.href.indexOf(murl+"/course/view.php?id=")>=0 || location.href.indexOf(murl+"/course/view.php?idnumber=")>=0;
}
// Funktioniert nur auf der Kurs-Startseite
......@@ -34,6 +32,7 @@ function insertAfter(referenceNode, newNode) {
}
/* Voma Start: Verbergen des Blogs auf der Startseite */
/* Wird mit neuer Startseite nicht mehr benötigt */
if(location.href == murl){
for (i=0; i<headers2.length; i++) {
if (headers2[i].innerHTML == "Blog"){
......@@ -41,17 +40,20 @@ if(location.href == murl){
}
}
}
/* Voma Ende: Verbergen des Blogs auf der Startseite */
/* Voma Start: Persönlichen Blog verlinken */
var userid = 1; // guest
for (var i=0; i<links.length; i++) {
if (links[i].href.includes(murl+"user/profile.php?id=")){
userid = links[i].href.split("=")[1];
if (links[i].href.indexOf(murl+"/user/profile.php?id=")>=0){
userid = links[i].href.split("=")[1]; break;
}
else if (links[i].href == murl+"blog/"){
links[i].href = murl+"blog/index.php?userid=" + userid; break;
}
for (var i=0; i<links.length; i++) {
if (links[i].href == murl+"/blog/"){
links[i].href = murl+"/blog/index.php?userid=" + userid; break;
}
}
/* Voma Ende: Persönlichen Blog verlinken */
......@@ -59,19 +61,19 @@ for (var i=0; i<links.length; i++) {
/* Voma Start: Einträge im Nutzermenü auf Englisch ändern */
if(document.documentElement.lang == "en"){
for(var i=0; i<links.length; i++) {
if(links[i].href == murl+"course/edit.php?category=1"){
if(links[i].href == murl+"/course/edit.php?category=1"){
links[i].innerHTML = links[i].innerHTML.replace(/Neuen Kurs anlegen/g, "Create new course");
}
else if (links[i].href == murl+"course/management.php?categoryid=1"){
else if (links[i].href == murl+"/course/management.php?categoryid=1"){
links[i].innerHTML = links[i].innerHTML.replace(/Kurse verwalten/g, "Manage course");
}
else if (links[i].href == murl+"user/editadvanced.php?id=-1"){
else if (links[i].href == murl+"/user/editadvanced.php?id=-1"){
links[i].innerHTML = links[i].innerHTML.replace(/Accounts für Externe/g, "Accounts for externals");
}
else if (links[i].href == murl+"user/preferences.php"){
else if (links[i].href == murl+"/user/preferences.php"){
links[i].innerHTML = links[i].innerHTML.replace(/Einstellungen/g, "Settings");
}
else if(links[i].href.includes(murl+"login/logout.php")){
else if(links[i].href.indexOf(murl+"/login/logout.php")>=0){
break;
}
}
......@@ -79,19 +81,19 @@ if(document.documentElement.lang == "en"){
/* Voma Ende: Einträge im Nutzermenü auf Englisch ändern */
/* Voma Start: Authentifizierung deaktivieren (Nutzer/in anlegen) */
if(location.href == murl+"user/editadvanced.php?id=-1"){
if(location.href == murl+"/user/editadvanced.php?id=-1"){
document.getElementById('id_auth').disabled=true;
}
/* Voma Ende: Authentifizierung deaktivieren (Nutzer/in anlegen) */
/* Voma Start: Aufklappbare Themenblöcke: (De) Aktivitäten -> Inhalte; (En) Activities -> Contents */
/* Überholt? Falls ja, entfernen!
if(location.href.includes("#module-206")){ // &section=1#module-206
if(location.href.indexOf("#module-206")>=0){ // &section=1#module-206
for(var i=0; i<links.length; i++) {
if(links[i].innerHTML.includes('Aktivitäten<i class="fa-angle-up float-right"></i>')){
if(links[i].innerHTML.indexOf('Aktivitäten<i class="fa-angle-up float-right"></i>')>=0){
links[i].innerHTML = links[i].innerHTML.replace(/Aktivitäten/g, "Inhalte"); break;
}
if(links[i].innerHTML.includes('Activities<i class="fa-angle-up float-right"></i>')){
if(links[i].innerHTML.indexOf('Activities<i class="fa-angle-up float-right"></i>')>=0){
links[i].innerHTML = links[i].innerHTML.replace(/Activities/g, "Contents"); break;
}
}
......@@ -121,7 +123,7 @@ if(isCoursePage()){ // &section=1#module-206
/* Voma Start: Anzeigen, dass Kurs verborgen ist */
/* Voma Start: Fehlermeldung nach dem Erstellen eines Accounts überschreiben / verbergen */
if(location.href == murl+"admin/user.php"){
if(location.href == murl+"/admin/user.php"){
var para = document.getElementsByTagName("p");
if(para[0].className == "errormessage"){
if(para[0].innerHTML == "Access denied"){
......@@ -136,10 +138,10 @@ if(location.href == murl+"admin/user.php"){
/* Voma Ende: Fehlermeldung nach dem Erstellen eines Accounts überschreiben / verbergen */
/* Voma Start: Grösse von Vimeo beim Einbetten anpassen */
if(location.href.includes(murl+"mod/url/view.php?id=")){
if(location.href.indexOf(murl+"/mod/url/view.php?id=")>=0){
var iframe = document.getElementsByTagName("iframe");
for(var i=0; i<iframe.length; i++) {
if(iframe[i].src.includes("https://player.vimeo.com/video/")){
if(iframe[i].src.indexOf("https://player.vimeo.com/video/")>=0){
iframe[i].width = iframe[i].parentElement.clientWidth;
iframe[i].height = Math.round(0.5625*iframe[i].width);
}
......@@ -152,20 +154,20 @@ if(location.href.includes(murl+"mod/url/view.php?id=")){
var divs = document.getElementsByTagName('div');
setTimeout(function(){
var imgs = new Array();
imgs[imgs.length] = murl+"pluginfile.php/66/course/summary/0.png";
imgs[imgs.length] = murl+"pluginfile.php/66/course/summary/1.png";
imgs[imgs.length] = murl+"pluginfile.php/66/course/summary/2.png";
imgs[imgs.length] = murl+"/pluginfile.php/66/course/summary/0.png";
imgs[imgs.length] = murl+"/pluginfile.php/66/course/summary/1.png";
imgs[imgs.length] = murl+"/pluginfile.php/66/course/summary/2.png";
divs = document.getElementsByTagName('div');
var placeholder0 = murl+"theme/image.php/remui/theme/";
var placeholder0 = murl+"/theme/image.php/remui/theme/";
var placeholder1 = "1522760156"; // Zeitstempel ändert öfters
var placeholder2 = "/placeholder";
for (var i in divs) {
if (typeof divs[i].style !== 'undefined'){
if (typeof divs[i].style.backgroundImage !== 'undefined'){
if (divs[i].style.backgroundImage.includes(placeholder2)){
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);
divs[i].style.backgroundImage = divs[i].style.backgroundImage.replace(placeholder0+placeholder1+placeholder2, imgs[rand]);
......@@ -178,12 +180,12 @@ setTimeout(function(){
/* Voma Ende: Zufälliges Bild in Kursbeschreibung zeigen */
/* Voma Start: Gibt es diese idnumber nicht? Weiterleitung zur Erstellung */
if(location.href.includes("view.php?idnumber=")){
if(location.href.indexOf("view.php?idnumber=")>=0){
for (var i in divs) {
if(divs[i].dataset.rel == "fatalerror"){
var idnumber = parseInt(getSearchParam("idnumber"));
var mac = getSearchParam("mac");
var abra = murl+"abra/?usr=2&zid="+idnumber+"&mac="+mac;
var abra = murl+"/abra/?usr=2&zid="+idnumber+"&mac="+mac;
// var jasc = 'onclick="window.location=this.href; this.parentNode.parentNode.innerHTML=\'<h1>⏳</h1>\';return false;"';
var jasc = 'onclick="window.location=this.href; this.parentNode.parentNode.innerHTML=\'<img src=https://paul.zhdk.ch/pluginfile.php/66/course/summary/paul-wartend.gif />\'; return false;"';
mfaq = mfaq+idnumber;
......@@ -210,14 +212,14 @@ if(location.href.includes("view.php?idnumber=")){
/* Voma Start: Gibt es diese idnumber nicht? Weiterleitung zur Erstellung */
/* Voma Start: Kurs-ID in FAQ ersetzten */
if(location.href.includes("idnumber=")){
if(location.href.indexOf("idnumber=")>=0){
var idnumber = parseInt(getSearchParam("idnumber"));
document.body.innerHTML = document.body.innerHTML.replace(/XXXXXX/g, idnumber);
}
/* Voma Ende: Kurs-ID in FAQ ersetzten */
/* Voma Start: Eintragen von Id ins Formular für neuen Kurs */
/* if(location.href.includes("edit.php?category=1&idnumber=")){
/* if(location.href.indexOf("edit.php?category=1&idnumber=")>=0){
var idnumber = parseInt(getSearchParam("idnumber"));
document.getElementById("id_idnumber").value = idnumber;
} */
......@@ -258,14 +260,14 @@ forms[forms.length] = document.getElementById("coursesearch2") || null;
forms[forms.length] = document.getElementById("coursesearchnavbar") || null;
for (var i in forms) {
if(forms[i]) {
forms[i].action = murl+"course/search.php";
forms[i].action = murl+"/course/search.php";
}
}
*/
/* Voma Ende: Kurs-Suche von RemUI flicken */
/* Voma Start: Nutzer/innen (Evento) synchronisieren */
if(location.href.includes("user/index.php?")){
if(location.href.indexOf("user/index.php?")>=0){
var enrol = "Nutzer/innen einschreiben";
var userrole = "Teilnehmer/innen @Evento";
var userrolesingular = "Teilnehmer/in @Evento";
......@@ -284,7 +286,7 @@ if(location.href.includes("user/index.php?")){
el.className = input[i].className;
el.type = "button";
var id = parseInt(getSearchParam("id"));
el.onclick = function() {location.href=murl+"abra/?usr=2&mid="+id;};
el.onclick = function() {location.href=murl+"/abra/?usr=2&mid="+id;};
insertAfter(input[i], el);
el = document.createElement("span");
el.innerHTML = " ";
......@@ -297,6 +299,31 @@ if(location.href.includes("user/index.php?")){
}
/* Voma Ende: Nutzer/innen (Evento) synchronisieren */
/* Voma Start: Kurs-Administration > Kurs löschen (Version 2019/09/19) */
if(location.href.indexOf('admin.php?courseid=')>=0){
var deletecourse = 'Kurs löschen';
if(document.documentElement.lang == 'en'){
deletecourse = 'Delete course';
}
var courseid = getSearchParam('courseid');
var node = document.createElement('li');
node.innerHTML = '<a href="'+murl+'/course/delete.php?id='+courseid+'">'+deletecourse+'</a>';
document.getElementsByClassName('list-unstyled')[0].appendChild(node);
}
/* Voma Ende: Kurs-Administration > Kurs löschen */
/* Voma Start: Kurslöschung beantragen (Version 2019/11/06 edit by Wema) */
if(location.href.indexOf('course/delete.php?id=')>=0){
var node = document.getElementsByClassName('errorcode')[0].firstChild;
node.text = 'Klicke auf diesen Link und wir löschen den Kurs für dich.';
var courseid = getSearchParam('id');
node.href = 'mailto:support.elearning@zhdk.ch?subject=Löschanfrage PAUL-Kurs&body=Bitte löscht für mich den Kurs mit folgenden Angaben: %0D%0A%0D%0AKurs-ID: '+courseid+'%0D%0AUsername: «'+document.getElementsByClassName('username')[0].innerHTML+'»%0D%0AUser-ID: '+userid+'%0D%0A%0D%0ABesten Dank%0D%0A';
if(document.documentElement.lang == "en"){
node.text = "Click this link and we'll delete the course for you.";
}
}
/* Voma Ende: Kurs-Administration > Kurs löschen */
/* Wema Start: Maintenance-Info */
/*document.getElementById('site-navbar-collapse').insertAdjacentHTML('beforeend','<div style="font-size: 9px; color: #D71964; padding-top: 1.5715rem;"><strong>Wartungsfenster: </strong>Heute Abend wird PAUL aktualisiert. Dabei kann es kurzfristig zu Unterbrechungen kommen. LG, PAUL</div>');*/
/* Wema Ende: Maintenance-Info */
......@@ -329,4 +356,12 @@ 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 */
</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