Problème avec le script "Mentionner dans un message"

3 participants

Voir le sujet précédent Voir le sujet suivant Aller en bas

Résolu Problème avec le script "Mentionner dans un message"

Message par Lany_13 Ven 05 Juin 2020, 14:39

Détails techniques


Version du forum : phpBB2
Poste occupé : Fondateur
Navigateur(s) concerné(s) : Mozilla Firefox
Capture d'écran du problème :
Voir l'image:

Personnes concernées par le problème : Tous les utilisateurs
Lien du forum : (lien masqué, vous devez poster pour le voir)

Description du problème

Bonjour ! Je viens vous voir car je rencontre un souci avec le tutoriel "Mentionner dans un message": le bouton "Taguer" n'apparaît pas. Auparavant, le script fonctionnait, mais le template viewtopic_body a été modifié, alors je pense que le souci vient de là.

Je vous laisse ci-dessous le script ainsi que le template :

Code:
/* FORUM VERSIONS
    * 0 = PHPBB2
    * 1 = PHPBB3
    * 2 = PUNBB
    * 3 = INVISION
    * 4 = MODERNBB
    */
    $(function() {
      var version = 0,
          image = 'https://www.zupimages.net/up/20/23/v1v6.png';
     
      if (/mode=reply/.test(window.location.search) && my_getcookie('fa_mention')) {
        document.post.message.value += '@"' + my_getcookie('fa_mention') + '" ';
        my_setcookie('fa_mention',''); 
      } if (!/\/t\d+/.test(window.location.pathname)) return;
     
      for (var a = $(['.post-options', '.profile-icons', '.post-options', '.posting-icons', '.profile-icons'][version]), b, c, d = ['.name a', '.author a', '.username a', '.author a', '.postprofile-name a'][version], e, i = 0, j = a.length, t = document.getElementById('text_editor_textarea'), l = version == 1 || version == 3 || version == 4; i<j; i++) {
        b = document.createElement('IMG');
        b.src = image;
        b.alt = 'Mentionner';
        b.title = 'Mentionner ' + $(a[i]).closest('.post').find(d + ':not(.fa-mention)').text();
        b.className = 'i_icon_mention';
        b.onclick = function() {
          var n = this.title.replace(/^.*?\s/,'');
         
          if ($.sceditor) t.insertText('@"' + n + '" ');
          else {
            my_setcookie('fa_mention', n);
            window.location.href = '/post?t=' + window.location.pathname.replace(/\/t(\d+)-.*/,'$1') + '&mode=reply';
          }
        };
   
        if (l) {
          c = document.createElement('LI');
          c.appendChild(b);
        }
       
        a[i].insertBefore(l ? c : b, a[i].firstChild);
      }
     
      $(function(){
        if (!$.sceditor) return;
        t=$(t).sceditor('instance');
      });
    });

Code:
<script type="text/javascript">
//<![CDATA[
var multiquote_img_off = '{JS_MULTIQUOTE_IMG_OFF}', multiquote_img_on = '{JS_MULTIQUOTE_IMG_ON}', _atr = '{JS_DIR}addthis/', _ati = '{PATH_IMG_FA}addthis/'{ADDTHIS_LANG}, addthis_localize = { share_caption: "{L_SHARE_CAPTION}", email: "{L_EMAIL}", email_caption: "{L_EMAIL_CAPTION}", favorites: "{L_SHARE_BOOKMARKS}", print: "{L_PRINT}", more: "{L_MORE}" };
$(function(){
    if(typeof(_atc) == "undefined") {
        _atc = {  };
    }
});

var hiddenMsgLabel = { visible:'{JS_HIDE_HIDDEN_MESSAGE}', hidden:'{JS_SHOW_HIDDEN_MESSAGE}' };
showHiddenMessage = function(id)
{
    try
    {
        var regId = parseInt(id, 10);
        if( isNaN(regId) ) { regId = 0; }
       
        if( regId > 0)
        {
            $('.post--' + id).toggle(0, function()
 {
 if( $(this).is(":visible") )
 {
 $('#hidden-title--' + id).html(hiddenMsgLabel.visible);
 }
 else
 {
 $('#hidden-title--' + id).html(hiddenMsgLabel.hidden);
 }
 });
        }
    }
    catch(e) { }
   
 return false;
};

//]]>
</script>

<table width="100%" border="0" cellspacing="2" cellpadding="0">
 <tr>
 <td align="left" valign="middle" nowrap="nowrap">
 <span class="browse-arrows">
                        <!-- BEGIN switch_isconnect -->
                        <a href="{U_VIEW_OLDER_TOPIC}">{L_VIEW_PREVIOUS_TOPIC}</a> <a href="{U_VIEW_NEWER_TOPIC}">{L_VIEW_NEXT_TOPIC}</a>
                        <!-- END switch_isconnect -->
                        <a href="#bottom">{L_GOTO_DOWN}</a>
                    </span>
 </td>
 
 <td align="right" valign="bottom" nowrap="nowrap" width="100%">
 <!-- BEGIN switch_twitter_btn -->
 <span id="twitter_btn" style="margin-left: 6px; ">
                <a href="https://twitter.com/share" class="twitter-share-button" data-via="{TWITTER}">Tweet</a>
                <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
 </span>
 <!-- END switch_twitter_btn -->
 
 <!-- BEGIN switch_fb_likebtn -->
 <script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "https://connect.facebook.net/{LANGUAGE}/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
 }(document, 'script', 'facebook-jssdk'));</script>
 <div class="fb-like" data-href="{FORUM_URL}{TOPIC_URL}" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
 <!-- END switch_fb_likebtn -->

 <span class="gensmall bold">
 <a class="addthis_button" href="#">{L_SHARE}</a>
 <!-- BEGIN switch_plus_menu -->
  |
 <script type="text/javascript">//<![CDATA[
 var url_favourite = '{U_FAVOURITE_JS_PLUS_MENU}';
 var url_newposts = '{U_NEWPOSTS_JS_PLUS_MENU}';
 var url_egosearch = '{U_EGOSEARCH_JS_PLUS_MENU}';
 var url_unanswered = '{U_UNANSWERED_JS_PLUS_MENU}';
 var url_watchsearch = '{U_WATCHSEARCH_JS_PLUS_MENU}';
 insert_plus_menu('f{FORUM_ID}&t={TOPIC_ID}','{JS_SESSION_ID}', {JS_AUTH_FAVOURITES});
 //]]>
 </script>
 <!-- END switch_plus_menu -->
 </span>
 </td>
 </tr>
</table>

<table class="forumline" width="100%" border="0" cellspacing="0" cellpadding="0" >
 <tr align="right">
 <div class="suj_header">
 <h1 class="cattitle"> {TOPIC_TITLE}</h1>

 <div class="nav" valign="middle" width="100%"><a class="nav" href="{U_INDEX}"><span>{L_INDEX}</span></a>
              <!--{NAV_SEP}<a class="nav" href="{U_ALBUM}"><span>{L_ALBUM}</span></a>-->
              {NAV_CAT_DESC_SECOND}</div>
                 
        </div>
 </tr>
 
        <tr>
            <td align="left">
 <!-- BEGIN switch_user_authpost -->
 <a href="{U_POST_NEW_TOPIC}" rel="nofollow"><img src="{POST_IMG}" id="{POST_IMG_ID}one" alt="{L_POST_NEW_TOPIC}" align="middle" border="0" /></a> 
 <!-- END switch_user_authpost -->
 <!-- BEGIN switch_user_authreply -->
 <a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" id="i_reply" alt="{L_POST_REPLY_TOPIC}" align="middle" border="0" /></a>
 <!-- END switch_user_authreply -->
            </td>
            <!-- BEGIN topicpagination -->
            <td align="right"><span class="gensmall">{PAGINATION}</span></td>
          <!-- END topicpagination -->
 </tr>
 {POLL_DISPLAY}
 <!-- BEGIN postrow -->
 <!-- BEGIN hidden -->
 <tr>
 <td class="postdetails {postrow.hidden.ROW_CLASS}" colspan="2" align="center">{postrow.hidden.MESSAGE}</td>
 </tr>
 <!-- END hidden -->
 <!-- BEGIN displayed -->
 <tr class="post post--{postrow.displayed.U_POST_ID}" id="p{postrow.displayed.U_POST_ID}" style="{postrow.displayed.DISPLAYABLE_STATE}">
          <tr height="30"></tr>
          <td {postrow.displayed.THANK_BGCOLOR} valign="top">
            <div class="suj_bloc_avatar">
 {postrow.displayed.POSTER_AVATAR}
            </div>
           
            <div class="suj_bloc_profil" id="profil">
 <!-- BEGIN profile_field -->
 {postrow.displayed.profile_field.LABEL} {postrow.displayed.profile_field.CONTENT}{postrow.displayed.profile_field.SEPARATOR}
 <!-- END profile_field -->
                               
                          <div class="rang">{postrow.displayed.RANK_IMAGE}</div><br />
                          {postrow.displayed.POSTER_RPG}<br />
 
              <img src="https://2img.net/i/fa/empty.gif" alt="" style="width:150px;height:1px" />
             
 <div class="browse-arrows"{postrow.displayed.THANK_BGCOLOR} align="center" valign="middle">
 <a href="#top">{L_BACK_TO_TOP}</a> <a href="#bottom">{L_GOTO_DOWN}</a>
 </div>
             
            </div>
            {postrow.displayed.ONLINE_IMG}
  </td>
         
 <td {postrow.displayed.THANK_BGCOLOR} valign="top" width="100%" height="28">
                 
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
 
                          <tr class="suj_conteneur_pseudo">
  <td align="left" class="pseudo_groupe" style="padding: 5px">
                                    <span class="name"><a name="{postrow.displayed.U_POST_ID}" style="position: relative; top: -30px; width: 1px;" id="{postrow.displayed.U_POST_ID}"></a>
                                      <strong>{postrow.displayed.POSTER_NAME}</strong></span> - {postrow.displayed.POSTER_RANK}
                                  </td>
                                 
                                  <td align="right" style="padding: 5px">
                                    <span class="postdetails"><img src="{postrow.displayed.MINI_POST_IMG}" alt="{postrow.displayed.L_MINI_POST_ALT}" title="{postrow.displayed.L_MINI_POST_ALT}" border="0" />
                                    {L_POST_SUBJECT}: {postrow.displayed.POST_SUBJECT}    [ <img src="{postrow.displayed.MINI_TIME_IMG}" alt="" border="0" />{postrow.displayed.POST_DATE} ]
                                    </span>
                                  </td>
  </tr>
                         
 <tr>
 <td colspan="2">
 <!-- BEGIN switch_vote_active -->
 <div class="vote gensmall">
 <!-- BEGIN switch_vote -->
 <div class="vote-button"><a href="{postrow.displayed.switch_vote_active.switch_vote.U_VOTE_PLUS}">+</a></div>
 <!-- END switch_vote -->

 <!-- BEGIN switch_bar -->
 <div class="vote-bar" title="{postrow.displayed.switch_vote_active.L_VOTE_TITLE}">
 <!-- BEGIN switch_vote_plus -->
 <div class="vote-bar-plus" style="height:{postrow.displayed.switch_vote_active.switch_bar.switch_vote_plus.HEIGHT_PLUS}px;"></div>
 <!-- END switch_vote_plus -->

 <!-- BEGIN switch_vote_minus -->
 <div class="vote-bar-minus" style="height:{postrow.displayed.switch_vote_active.switch_bar.switch_vote_minus.HEIGHT_MINUS}px;"></div>
 <!-- END switch_vote_minus -->
 </div>
 <!-- END switch_bar -->

 <!-- BEGIN switch_no_bar -->
 <div title="{postrow.displayed.switch_vote_active.L_VOTE_TITLE}" class="vote-no-bar">----</div>
 <!-- END switch_no_bar -->

 <!-- BEGIN switch_vote -->
 <div class="vote-button"><a href="{postrow.displayed.switch_vote_active.switch_vote.U_VOTE_MINUS}">-</a></div>
 <!-- END switch_vote -->
 </div>
 <!-- END switch_vote_active -->

 <div class="postbody">
 <div class="suj_bloc_msg">
                                                          <div class="suj_message">{postrow.displayed.MESSAGE}</div>
                                                  </div>
                                                  <!-- BEGIN switch_signature -->
 <div class="signature_div">
 {postrow.displayed.SIGNATURE}
 </div>
 <!-- END switch_signature -->
                                                  <tr>
                                                    <td align="left" style="padding: 5px 0px 0px 25px ">
 {postrow.displayed.PROFILE_IMG} {postrow.displayed.PM_IMG} {postrow.displayed.EMAIL_IMG}<!-- BEGIN contact_field --> {postrow.displayed.contact_field.CONTENT}<!-- END contact_field -->
                                                      </td>
                                                   
                                                    <td align="right" style="padding: 5px 10px 0px 0px">
                                                    {postrow.displayed.THANK_IMG} {postrow.displayed.MULTIQUOTE_IMG} {postrow.displayed.QUOTE_IMG} {postrow.displayed.EDIT_IMG} {postrow.displayed.DELETE_IMG} {postrow.displayed.IP_IMG} {postrow.displayed.REPORT_IMG}
                                                   

                                                    </td>
                                                   
                                                  </tr>
                                                 

 <!-- BEGIN switch_attachments -->
 <dl class="attachbox">
 <dt>{postrow.displayed.switch_attachments.L_ATTACHMENTS}</dt>
 <dd>
 <!-- BEGIN switch_post_attachments -->
 <dl class="file">
 <dt>
 <img src="{postrow.displayed.switch_attachments.switch_post_attachments.U_IMG}" alt="" />

 <!-- BEGIN switch_dl_att -->
 <a class="postlink" href="{postrow.displayed.switch_attachments.switch_post_attachments.switch_dl_att.U_ATTACHMENT}">{postrow.displayed.switch_attachments.switch_post_attachments.switch_dl_att.ATTACHMENT}</a> {postrow.displayed.switch_attachments.switch_post_attachments.switch_dl_att.ATTACHMENT_DEL}
 <!-- END switch_dl_att -->

 <!-- BEGIN switch_no_dl_att -->
 {postrow.displayed.switch_attachments.switch_post_attachments.switch_no_dl_att.ATTACHMENT} {postrow.displayed.switch_attachments.switch_post_attachments.switch_no_dl_att.ATTACHMENT_DEL}
 <!-- END switch_no_dl_att -->
 </dt>

 <!-- BEGIN switch_no_comment -->
 <dd>
 <em>{postrow.displayed.switch_attachments.switch_post_attachments.switch_no_comment.ATTACHMENT_COMMENT}</em>
 </dd>
 <!-- END switch_no_comment -->

 <!-- BEGIN switch_no_dl_att -->
 <dd>
 <em><strong>{postrow.displayed.switch_attachments.switch_post_attachments.switch_no_dl_att.TEXT_NO_DL}</strong></em>
 </dd>
 <!-- END switch_no_dl_att -->

 <dd>({postrow.displayed.switch_attachments.switch_post_attachments.FILE_SIZE}) {postrow.displayed.switch_attachments.switch_post_attachments.NB_DL}</dd>
 </dl>
 <!-- END switch_post_attachments -->
 </dd>
 </dl>
 <!-- END switch_attachments -->
                                                  <div class="clear"></div>
 </div>
                                       
 </td>
 </tr>
 </table>
 </td>
         
  </tr>

 <!-- BEGIN first_post_br -->
</table>
<hr />
<table class="forumline" width="100%" border="0" cellspacing="1" cellpadding="0">
 <!-- END first_post_br -->
 <!-- END displayed -->
 <!-- END postrow -->
 <!-- BEGIN no_post -->
 <tr align="center">
 <td class="row1" colspan="2" height="28">
 <span class="genmed">{no_post.L_NO_POST}</span>
 </td>
 </tr>
 <!-- END no_post -->
 
</table>

<table class="pagination">
 <td class="row2" valign="top" {COLSPAN_PAGINATION} width="150"><span class="gensmall">{PAGE_NUMBER}</span></td>
 <!-- BEGIN topicpagination -->
 <td class="row1" align="right" valign="top" ><span class="gensmall">{PAGINATION}</span></td>
 <!-- END topicpagination -->
</table>

<!-- BEGIN switch_forum_rules -->
<table id="forum_rules" class="forumline" width="100%" border="0" cellspacing="0" cellpadding="0" style="margin: 1px 0px 1px 0px">
 <tbody>
 <tr>
 <td class="catBottom">
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tbody>
 <tr>
 <td valign="top">
 <div class="cattitle"> {L_FORUM_RULES}</div>
 </td>
 </tr>
 </tbody>
 </table>
 </td>
 </tr>
 <tr>
 <td class="row1 clearfix">
 <table>
 <tr>
 <!-- BEGIN switch_forum_rule_image -->
 <td class="logo">
 <img src="{RULE_IMG_URL}" alt="" />
 </td>
 <!-- END switch_forum_rule_image -->
 <td class="rules postbody">
 {RULE_MSG}
 </td>
 </tr>
 </table>
 </td>
 </tr>
 </tbody>
</table>
<!-- END switch_forum_rules -->

<table class="forumline noprint" width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
 <td class="row2" colspan="2" align="center" style="padding:0px">
 <!-- BEGIN switch_user_logged_in -->
 <a name="quickreply"></a>
 {QUICK_REPLY_FORM}<br />
 <!-- END switch_user_logged_in -->
 </td>
 </tr>
</table>

<table class="noprint" width="100%" border="0" cellspacing="2" cellpadding="0" align="center">
 <tr>
<td align="left" valign="middle" nowrap="nowrap" {WIDTH_GALLERY}>
 <span class="nav">
 <!-- BEGIN switch_user_authpost -->
 <a href="{U_POST_NEW_TOPIC}" rel="nofollow"><img src="{POST_IMG}" id="{POST_IMG_ID}Newtopic" alt="{L_POST_NEW_TOPIC}" align="middle" border="0" /></a> 
 <!-- END switch_user_authpost -->
 <!-- BEGIN switch_user_authreply -->
 <a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" alt="{L_POST_REPLY_TOPIC}" align="middle" border="0" /></a>
 <!-- END switch_user_authreply -->
 </span>
 </td>
         
          <td align="right">
            <!-- BEGIN switch_user_logged_in -->
           
 <!-- BEGIN watchtopic -->
            <div class="surveiller"><span class="gensmall">{S_WATCH_TOPIC}</span></div> 
 <!-- END watchtopic -->
           
            <!-- END switch_user_logged_in -->
          </td>
  </tr>
  </table>

    <div class="suj_nav_bottom"> <a class="nav" href="{U_INDEX}">{L_INDEX}</a>{NAV_SEP}<a class="nav" href="{U_ALBUM}">{L_ALBUM}</a>{NAV_CAT_DESC_SECOND}</div>
 
          <table width="100%"><tr>
            <td align="left">
 <!-- BEGIN moderation_panel -->
 <span class="gensmall">{moderation_panel.U_YOUR_PERSONAL_MODERATE}</span>
 <span class="gensmall"> </span>
 <!-- END moderation_panel -->
            </td>
<td>
<!-- BEGIN viewtopic_bottom -->
 <td align="left" valign="top">{S_TOPIC_ADMIN}<br />
 <form name="action" method="get" action="{S_FORM_MOD_ACTION}">
 <input type="hidden" name="t" value="{TOPIC_ID}" />

 <!-- <input type="hidden" name="sid" value="{S_SID}" /> -->
 <input type="hidden" name="{SECURE_ID_NAME}" value="{SECURE_ID_VALUE}" />

 <span class="gen">{L_MOD_TOOLS}<br />{S_SELECT_MOD}&nbsp;<input class="liteoption" type="submit" value="{L_GO}" /></span>
 </form>
 </td>
            </td>
<!-- END viewtopic_bottom -->
           
                        <td align="right">
                <!-- BEGIN show_permissions -->
<span class="gensmall">{L_TABS_PERMISSIONS}</span> <br/>
<span class="gensmall">{S_AUTH_LIST}</span>
 <!-- END show_permissions -->
              </td>
            </tr>
            </table>

<!-- BEGIN switch_image_resize -->
<script type="text/javascript">
//<![CDATA[
$(resize_images({ 'selector' : '.postbody', 'max_width' : {switch_image_resize.IMG_RESIZE_WIDTH}, 'max_height' : {switch_image_resize.IMG_RESIZE_HEIGHT} }));
//]]>
</script>
<!-- END switch_image_resize -->
<script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=forumotion" type="text/javascript"></script>

Merci d'avance !
Lany_13

Lany_13
**

Messages : 84
Inscrit(e) le : 25/04/2019

https://forumtestdeflocon.forumactif.com
Lany_13 a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par mSyx Ven 05 Juin 2020, 17:14

Hello o/
Je ne sais pas si ça suffira, mais:

Dans ton template, trouver:
Code:
                                                    <td align="right" style="padding: 5px 10px 0px 0px">
                                                    {postrow.displayed.THANK_IMG} {postrow.displayed.MULTIQUOTE_IMG} {postrow.displayed.QUOTE_IMG} {postrow.displayed.EDIT_IMG} {postrow.displayed.DELETE_IMG} {postrow.displayed.IP_IMG} {postrow.displayed.REPORT_IMG}
                                                 

                                                    </td>

Remplacer par:
Code:
                                                    <td align="right" style="padding: 5px 10px 0px 0px" class="post-options">
                                                    {postrow.displayed.THANK_IMG} {postrow.displayed.MULTIQUOTE_IMG} {postrow.displayed.QUOTE_IMG} {postrow.displayed.EDIT_IMG} {postrow.displayed.DELETE_IMG} {postrow.displayed.IP_IMG} {postrow.displayed.REPORT_IMG}
                                                 

                                                    </td>
mSyx

mSyx
****

Masculin
Messages : 394
Inscrit(e) le : 22/09/2012

https://forum.forumactif.com/
mSyx a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Lany_13 Ven 05 Juin 2020, 22:00

Bonsoir ! Smile

Le bouton apparaît bel et bien, merci ! En revanche, en cliquant sur "taguer", la mention apparaît seulement comme ceci, sans pseudo : @""
Lany_13

Lany_13
**

Messages : 84
Inscrit(e) le : 25/04/2019

https://forumtestdeflocon.forumactif.com
Lany_13 a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Self Sam 06 Juin 2020, 19:43

Bonjour,

J'avais donné la solution ici, en adaptant à votre template et la modification que vous a demandé de faire mSyx, essayez de remplacer le javascript par celui-ci :
Code:
$(function(){
   var image = 'https://www.zupimages.net/up/20/23/v1v6.png';
   if (/mode=reply/.test(window.location.search) && my_getcookie('fa_mention')) {
      document.post.message.value += '@"' + my_getcookie('fa_mention') + '" ';
      my_setcookie('fa_mention','');
   } if (!/\/t\d+/.test(window.location.pathname)) return;
 
   $('.post').each(function(i){
      if(!$(this).find('.name strong a')) return;
      var name = $(this).find('.name strong a').text();
      $(this).find('.profile-options').prepend('<li><img class="i_icon_mention" src="'+image+'" alt="Mentionner" title="Mentionner '+name+'" /></li>');
      $(this).find('.i_icon_mention').on('click', function(){
         t = document.getElementById('textarea_content').querySelectorAll('textarea')[1];
         if (t.length != 0) t.value = t.value+' '+('@"' + name + '" ');
         else {
            my_setcookie('fa_mention', name);
            window.location.href = '/post?t=' + window.location.pathname.replace(/\/t(\d+)-.*/,'$1') + '&mode=reply';
         }
      });
   });
  
}, jQuery);


Dernière édition par Self le Sam 06 Juin 2020, 19:46, édité 1 fois
Self

Self
Membre actif

Masculin
Messages : 3853
Inscrit(e) le : 13/06/2013

https://selfback.forumactif.com/
Self a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Lany_13 Dim 07 Juin 2020, 01:11

Bonjour,
Merci pour votre message !
Malheureusement, le code ne fonctionne pas et fait disparaître la mention "taguer" Sad
Lany_13

Lany_13
**

Messages : 84
Inscrit(e) le : 25/04/2019

https://forumtestdeflocon.forumactif.com
Lany_13 a été remercié(e) par l'auteur de ce sujet.
  • 0

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Self Dim 07 Juin 2020, 01:51

Ah normal, j'ai mis la mauvaise classe What a Face !

Comme cela ?
Code:
$(function(){
  var image = 'https://www.zupimages.net/up/20/23/v1v6.png';
  if (/mode=reply/.test(window.location.search) && my_getcookie('fa_mention')) {
      document.post.message.value += '@"' + my_getcookie('fa_mention') + '" ';
      my_setcookie('fa_mention','');
  } if (!/\/t\d+/.test(window.location.pathname)) return;
 
  $('.post').each(function(i){
      if(!$(this).find('.name strong a')) return;
      var name = $(this).find('.name strong a').text();
      $(this).find('.post-options').prepend('<li><img class="i_icon_mention" src="'+image+'" alt="Mentionner" title="Mentionner '+name+'" /></li>');
      $(this).find('.i_icon_mention').on('click', function(){
        t = document.getElementById('textarea_content').querySelectorAll('textarea')[1];
        if (t.length != 0) t.value = t.value+' '+('@"' + name + '" ');
        else {
            my_setcookie('fa_mention', name);
            window.location.href = '/post?t=' + window.location.pathname.replace(/\/t(\d+)-.*/,'$1') + '&mode=reply';
        }
      });
  });
 
}, jQuery);
Self

Self
Membre actif

Masculin
Messages : 3853
Inscrit(e) le : 13/06/2013

https://selfback.forumactif.com/
Self a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Lany_13 Dim 07 Juin 2020, 10:54

Nope, ça me donne toujours le même problème Sad
Lany_13

Lany_13
**

Messages : 84
Inscrit(e) le : 25/04/2019

https://forumtestdeflocon.forumactif.com
Lany_13 a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Self Dim 07 Juin 2020, 14:22

En effet, je pensais que la classe .post englobait chaque message,
Avec le code suivant j'arrive bien à récupérer le nom :
Code:
$(function(){
   var image = 'https://www.zupimages.net/up/20/23/v1v6.png';
   if (/mode=reply/.test(window.location.search) && my_getcookie('fa_mention')) {
       document.post.message.value += '@"' + my_getcookie('fa_mention') + '" ';
       my_setcookie('fa_mention','');
   } if (!/\/t\d+/.test(window.location.pathname)) return;
 
   $('.suj_conteneur_pseudo').each(function(i){
       if(!$(this).find('.name strong a')) return;
       var name = $(this).find('.name strong a').text();
       $(this).closest('table').find('.post-options').prepend('<img class="i_icon_mention" src="'+image+'" alt="Mentionner" title="Mentionner '+name+'" />');
       $(this).closest('table').find('.i_icon_mention').on('click', function(){
           t = document.getElementById('textarea_content').querySelectorAll('textarea')[1];
           if (t.length != 0) t.value = t.value+' '+('@"' + name + '" ');
           else {
               my_setcookie('fa_mention', name);
               window.location.href = '/post?t=' + window.location.pathname.replace(/\/t(\d+)-.*/,'$1') + '&mode=reply';
           }
       });
   });
 }, jQuery);
Self

Self
Membre actif

Masculin
Messages : 3853
Inscrit(e) le : 13/06/2013

https://selfback.forumactif.com/
Self a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Lany_13 Dim 07 Juin 2020, 15:03

Merci ! Cette fois, la mention "Taguer" reste bien apparente, mais il ne se passe rien dans l'éditeur de messages quand on clique dessus :/
Lany_13

Lany_13
**

Messages : 84
Inscrit(e) le : 25/04/2019

https://forumtestdeflocon.forumactif.com
Lany_13 a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Self Dim 07 Juin 2020, 19:01

Bonjour,

J'ai essayé d'aller dans la zone invité mais on ne peux pas répondre, auriez vous un sujet où la réponse est ouverte aux invités que je puisse vous donné un code complètement fonctionnel sans avancer à l'aveugle ?
Self

Self
Membre actif

Masculin
Messages : 3853
Inscrit(e) le : 13/06/2013

https://selfback.forumactif.com/
Self a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Lany_13 Dim 07 Juin 2020, 19:22

Oups, oui désolée, la partie invités est maintenant accessible !
Lany_13

Lany_13
**

Messages : 84
Inscrit(e) le : 25/04/2019

https://forumtestdeflocon.forumactif.com
Lany_13 a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Self Dim 07 Juin 2020, 19:26

Merci Smile ! Ce code semble fonctionner :
Code:
$(function(){
   var image = 'https://www.zupimages.net/up/20/23/v1v6.png';
   if (/mode=reply/.test(window.location.search) && my_getcookie('fa_mention')) {
       document.post.message.value += '@"' + my_getcookie('fa_mention') + '" ';
       my_setcookie('fa_mention','');
   } if (!/\/t\d+/.test(window.location.pathname)) return;
 
   $('.suj_conteneur_pseudo').each(function(i){
       if(!$(this).find('.name strong a')) return;
       var name = $(this).find('.name strong a').text();
       $(this).closest('table').find('.post-options').prepend('<img class="i_icon_mention" src="'+image+'" alt="Mentionner" title="Mentionner '+name+'" />');
       $(this).closest('table').find('.i_icon_mention').on('click', function(){
           t = document.getElementById('textarea_content textarea');
           if (t) t[1].value = t[1].value+' '+('@"' + name + '" ');
           else {
               my_setcookie('fa_mention', name);
               window.location.href = '/post?t=' + window.location.pathname.replace(/\/t(\d+)-.*/,'$1') + '&mode=reply';
           }
       });
   });
 }, jQuery);
Self

Self
Membre actif

Masculin
Messages : 3853
Inscrit(e) le : 13/06/2013

https://selfback.forumactif.com/
Self a été remercié(e) par l'auteur de ce sujet.

Résolu Re: Problème avec le script "Mentionner dans un message"

Message par Lany_13 Dim 07 Juin 2020, 19:36

Oui, ça fonctionne Smile Merci beaucoup !
Lany_13

Lany_13
**

Messages : 84
Inscrit(e) le : 25/04/2019

https://forumtestdeflocon.forumactif.com
Lany_13 a été remercié(e) par l'auteur de ce sujet.

Voir le sujet précédent Voir le sujet suivant Revenir en haut

- Sujets similaires

Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum