The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Chat box Commands

Page 2 of 2 Previous  1, 2

View previous topic View next topic Go down

Solved Chat box Commands

Post by Royer Blaze on June 3rd 2015, 2:58 am

First topic message reminder :

I was wondering if it'd be possible to add a chat box command for a d6 dice roll instead of using the dice roll feature via posts.

*Edited* Is there possibly a JavaScript that'd allow me to add a dice roll feature to my chatbox?


Last edited by Royer Blaze on July 10th 2015, 8:10 pm; edited 2 times in total

Royer Blaze
Forumember

Male Posts : 87
Reputation : 1
Language : English

http://thegoldendarkage.motionsforum.com/

Back to top Go down


Solved Re: Chat box Commands

Post by Royer Blaze on July 7th 2015, 10:28 pm

@Ange Tuteur wrote:Hi @Royer Blaze,

I apologize for the late reply. I can't give you a definitive answer, but I can provide you with some information.

For one, any modifications to the chatbox cannot be installed through JavaScript codes management. It's not impossible though, as you CAN access the frame contents from wherever it's installed, although this can require constant polling to ensure that the added content doesn't get removed.

It's absolutely possible to create a dice rolling feature with JavaScript, although it depends on how complex you want it. This is a simple example that can be applied to an HTML page :
Code:
<script type="text/javascript">//<![CDATA[
function faRoll() {
 var result = [
  '1',
  '2',
  '3',
  '4',
  '5',
  '6'
 ];
 alert('You rolled ' + result[Math.floor(Math.random() * result.length)] + ' !');
}
//]]></script>
<input type="button" value="Roll" onclick="faRoll();" />

The same method can be applied to the Chatbox, but as I said before, it depends on how complex you want it.
Thank you @Ange Tuteur I'd love it applied to the Chatbox, and would love it as simple as possible. Just a simple D6 roll. Where would I go to apply it?

Royer Blaze
Forumember

Male Posts : 87
Reputation : 1
Language : English

http://thegoldendarkage.motionsforum.com/

Back to top Go down

Solved Re: Chat box Commands

Post by Royer Blaze on July 9th 2015, 6:33 am

Bump, please and thank you. Nearly there.

Royer Blaze
Forumember

Male Posts : 87
Reputation : 1
Language : English

http://thegoldendarkage.motionsforum.com/

Back to top Go down

Solved Re: Chat box Commands

Post by Royer Blaze on July 10th 2015, 9:46 am

Could someone tell me where to place that code so I could use it? Should I just put D6 into the equation and add it to my CSS spreadsheet or add it to my Javascripts for it to affect my chatbox?

Royer Blaze
Forumember

Male Posts : 87
Reputation : 1
Language : English

http://thegoldendarkage.motionsforum.com/

Back to top Go down

Solved Re: Chat box Commands

Post by Ange Tuteur on July 10th 2015, 11:49 am

Hi,

Sorry for the delay again, as I said in my recent message :
This is a simple example that can be applied to an HTML page :

It was an example for displaying a javascript Dice. Here's an actual button your can apply to your chatbox. Go to Modules > JS codes management and create a new script

Placement : In the homepage
Paste the following code and submit
Code:
$(function() {
  var dice = [1, 2, 3, 4, 5, 6],
  fa_chat = document.getElementById('frame_chatbox'), frame;
  if (!fa_chat) return;
 
  fa_chat.onload = function() {   
    if (fa_chat.contentDocument) frame = fa_chat.contentDocument;
    else if (fa_chat.contentWindow) frame = fa_chat.contentWindow.document;
   
    var b = document.createElement('DIV');
    b.className = 'fontbutton';
    b.innerHTML = 'D';
    b.title = 'Dice';
    b.onclick = function() {
      frame.getElementById('message').value = '[b]' + _userdata.username + ' rolled ' + dice[Math.floor(Math.random() * dice.length)] + ' ![/b]';
      frame.getElementById('submit_button').click();
    };
   
    b.style.border = '1px solid #AAA';
    b.style.borderRadius = '3px';
    b.style.height = '18px';
    b.style.width = '18px';
    b.style.lineHeight = '16px';
    b.style.textAlign = 'center';
   
    frame.getElementById('chatbox_messenger_form').firstChild.nextSibling.appendChild(b);
  }
});

When applied, go to your homepage chatbox and there should be a new button after emoticons.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Chat box Commands

Post by Royer Blaze on July 10th 2015, 7:52 pm

Works perfectly on my chatbox on my homepage thanks, was exactly what I was needing! But I can't seem to get the dice roll button to show up when I pop the chatbox up in the homepage or any other page.

I tried applying it to Every page, but that didn't work.

Royer Blaze
Forumember

Male Posts : 87
Reputation : 1
Language : English

http://thegoldendarkage.motionsforum.com/

Back to top Go down

Solved Re: Chat box Commands

Post by Ange Tuteur on July 10th 2015, 8:01 pm

@Royer Blaze wrote:Works perfectly on my chatbox on my homepage thanks, was exactly what I was needing! But I can't seem to get the dice roll button to show up when I pop the chatbox up in the homepage or any other page.

I tried applying it to Every page, but that didn't work.
Unfortunately modifications to the chatbox made via JavaScript can only affect the homepage chatbox. It cannot affect the full page chatbox.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Chat box Commands

Post by Royer Blaze on July 10th 2015, 8:09 pm

Ah, I'll just have to note that for my players.

My thanks for all of your hard work and time. I'm grateful! This can be considered completed.

Royer Blaze
Forumember

Male Posts : 87
Reputation : 1
Language : English

http://thegoldendarkage.motionsforum.com/

Back to top Go down

Solved Re: Chat box Commands

Post by SLGray on July 10th 2015, 8:31 pm

Topic solved and archived


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 36648
Reputation : 2443
Language : English
Location : United States

http://ztwds.forumotion.com/

Back to top Go down

Page 2 of 2 Previous  1, 2

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum