Advertisement
NecromancerCoding

Pronombres de usuario

Aug 5th, 2023
1,778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.98 KB | None | 0 0
  1. $(function(){
  2. /* Editable */
  3. var campoPerfil = '.psfield';
  4. var campoPerfilLabel = '.psflabel';
  5. var campoPerfilContent = '.psfcontent';
  6. var welcomeMessage = '.welcome-message';
  7. var pronouns = 'Pronombres';
  8. var masc = 'Masculinos';
  9. var fem = 'Femeninos';
  10. var neut = 'Neutros';
  11. var mascPronouns = 'o';
  12. var femPronouns = 'a';
  13. var neutPronouns = 'e';
  14. var nullPronouns = '@';
  15.  
  16. /* No edites a partir de aquí */
  17.  
  18. $(welcomeMessage).each(function(){
  19. var self = $(this);
  20. $.get('/u'+_userdata.user_id, function(data) {
  21. var selected = $(data).find(campoPerfilLabel+':contains('+pronouns+')').parents(campoPerfil).find(campoPerfilContent+' .field_uneditable').text();
  22. if (selected === masc) {
  23. var pronounsSelected = mascPronouns;
  24. } else if (selected === fem) {
  25. var pronounsSelected = femPronouns;
  26. } else if (selected === neut) {
  27. var pronounsSelected = neutPronouns;
  28. } else {
  29. var pronounsSelected = nullPronouns;
  30. }
  31. $(self).attr('style','--pronoun:"'+pronounsSelected+'";');
  32. });
  33.  
  34. });
  35.  
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement