From 5429128a390d81e79df9bb01400be365a23ceebd Mon Sep 17 00:00:00 2001 From: Andreas Grupp Date: Sun, 13 Nov 2022 17:56:23 +0100 Subject: [PATCH] Version inconsistencies fixed. Add formal lang There were two different version strings in the code. Increased the version number in train of fixing this. Also depending on Moodle settings the first name is in field element 0, as already mentioned by TRMSC. Fixed this for our Moodle (version 4.0.4) and it's settings. Also included a way to have German formal language, with first and last name. --- individual greeting.html | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/individual greeting.html b/individual greeting.html index 6e68f29..1b00281 100644 --- a/individual greeting.html +++ b/individual greeting.html @@ -1,4 +1,4 @@ - + @@ -8,7 +8,7 @@ let jquery_load_check_interval = setInterval( function() { if ( window.jQuery ) { console.log( 'Individual Greeting: jQuery v.' + $.fn.jquery + ' loaded' ); - console.log( 'Individual Greeting: v.2.1.1' ); + console.log( 'Individual Greeting: v.2.1.3' ); setGreeting(); clearInterval( jquery_load_check_interval ); } else { @@ -17,10 +17,20 @@ }, 150); function setGreeting() { - var fstName = $('.logininfo a:first-of-type').text().split(/\s+/)[1]; /*IF THE LASTNAME WILL BE DISPLAYED TRY [0} INSTEAD OF [1] IN THIS LINE */ - var textBefore = 'Hallo '; /* THE TEXT DISPLAYED BEFORE THE USERNAME */ - var textAfter = '! Schön, dass du da bist!'; /* THE TEXT DISPLAYED AFTER THE USERNAME */ - var fullText = textBefore + fstName + textAfter; + /* SEE THE NEXT TWO CODE LINES AND ADJUST ACCORDING TO YOUR MOODLE. + DEPENDING ON YOUR MOODLE-SETTINGS THE FIRST NAME IS IN [0] OR [1] */ + var fstName = $('.logininfo a:first-of-type').text().split(/\s+/)[0]; + var lstName = $('.logininfo a:first-of-type').text().split(/\s+/)[1]; + /* THE TEXT DISPLAYED BEFORE THE USERNAME */ + var textBefore = 'Hallo '; + /* THE TEXT DISPLAYED AFTER THE USERNAME */ + var textAfterInformal = '! Schön, dass du da bist!'; + var textAfterFormal = '! Schön, dass Sie hier sind!'; + /* USE THE CODE-LINE THAT FITS BEST TO YOUR SITE + var fullText = textBefore + fstName + textAfterInformal; + var fullText = textBefore + fstName + ' ' + lstName + textAfterFormal; + */ + var fullText = textBefore + fstName + textAfterInformal; console.log('Individual Greeting: ' + fullText); $('div[role=main]').prepend('

' + fullText + '

'); }