MyBB Community Forums

Full Version: Place post author name into quick reply form after click on avatar
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
Trying to realize that simple thing, but, as I novice, got some troubles.
changed postbit_avatar:
<div class="author_avatar"><a href="javascript:void(0);" onclick="javascript:{document.getElementsByName('quick_reply_form')[0].getElementsByTagName('TextArea')[1].value = {$post['username']};}"><img src="{$useravatar['image']}" alt="" {$useravatar['width_height']} /></a></div>


Clicking on post avatar gets error :
Uncaught ReferenceError: someuser is not defined

Thanks for any hint, sorry for silly question

managed eventually
javascript function^
// JavaScript Document
var jp = {
 init: function()
 {
 $(document).ready(function(){
 });
 },
 insertUsr: function(usr)
 {
 var toFind = 'uid='+usr+'"';
 var myList = document.getElementsByClassName('largetext');
 for (i = 0; i < myList.length; i++) { 
     
 if ( myList[i].innerHTML.indexOf(toFind)> 0 ){
 document.getElementsByName('quick_reply_form')[0].getElementsByTagName('TextArea')[1].value += '[b]' + myList[i].innerText  + '[/b]'+ ', ';
 return true;
 }
                            ;            
 
 
                }
 
 
  return true;
 }
  
  };
  jp.init();

into headerinclude:
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/jp.js?ver=1800"></script>

into postbit_author_user:
<br />{$post['username']}:&nbsp;<a href="javascript:void(0)" onClick="javascript:jp.insertUsr({$post['uid']})">Into reply</a>

thats all.

instead of postbit_author_user you may use postbit_avatar
<div class="author_avatar"><a href="javascript:void(0)" onClick="javascript:jp.insertUsr({$post['uid']})"><img src="{$useravatar['image']}" alt="" {$useravatar['width_height']} /></a></div>