Last active
August 5, 2021 08:57
-
-
Save M-tower/3b8bfbc7438d827431b3f5acf654af84 to your computer and use it in GitHub Desktop.
les fonctions utililes pour dev
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
/** | |
* Coupe le texte 'data' dont la longueur dépasse 'lng_max' | |
* @param {string} data Texte à couper | |
* @param {number} lng_max Longueur maximale | |
*/ | |
function couperTexte (data, lng_max=37) { | |
return data.length > lng_max ? | |
'<span title="'+data+'">'+data.substr( 0, (lng_max - 3) )+'...</span>' : | |
data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment