Posting Reactions
2 posters
Page 1 of 1
Posting Reactions
My forum is trying to use something that can post random images from my selection after a certain post. Though the dice generator is too limited for what I need it for. Is there any code that can make a randomization program work with the posting system?
MasterofChaos- Forumember
- Posts : 43
Reputation : 1
Language : english
Re: Posting Reactions
Hello MasterofChaos,
You could probably do something through JavaScript to enter a random object into the editor. It would probably take a bit of editing on your part, though. If that's not a problem with you, I can write a small draft.
You could probably do something through JavaScript to enter a random object into the editor. It would probably take a bit of editing on your part, though. If that's not a problem with you, I can write a small draft.
Re: Posting Reactions
editing wont really be a problem i just no idea how to start the code lol
MasterofChaos- Forumember
- Posts : 43
Reputation : 1
Language : english
Re: Posting Reactions
Okay give this a try ^^
Administration panel > Modules > JavaScript codes management > Create a new script
Title : Your choice
Placement : in all the pages
Paste the code below :
At the beginning we have the variable buttonImage here you can change the icon that is displayed on the button by replacing the current URL with another. Next is n, n holds a number value which will be the amount of random results we want. Currently it is set to 5. Using Math.random() we'll add n + 1 = 0-6; our result is the occurrence of 0, 1, 2, 3, 4, or 5, but we exclude 0 to less confuse things.
Now the last thing you need to modify is the conditions. A condition is simple : If a certain condition is met, let's say n is exactly equal to 5, then we'll display a popup saying "You win !". In this case we'll be using strings(text), see below our current conditions :
Simply put, all you need to do is replace the values between the single quotes with your own, and if you increase the value of n add another condition. So if n is equal to 20 we'll have 20 conditions, make sure to change the number in the condition too ! ex : if (rand === 20)
In your case you're adding images correct ? This is how it would look :
Administration panel > Modules > JavaScript codes management > Create a new script
Title : Your choice
Placement : in all the pages
Paste the code below :
- Code:
$(function(){$(function() {
var buttonImage = 'http://2img.net/i/rs3/58/frm/SCEditor/src/themes/icons/src/famfamfam/faspoiler.png';
var n = 5;
$('.sceditor-button-source').before('<a class="sceditor-button sceditor-button-randomI"><div style="background-image:url('+buttonImage+');"></div></a>');
$('.sceditor-button-randomI').click(function() {
var rand = Math.floor( Math.random() * n + 1 );
if (rand === 1) var content = '1';
if (rand === 2) var content = '2';
if (rand === 3) var content = '3';
if (rand === 4) var content = '4';
if (rand === 5) var content = '5';
$('#text_editor_textarea').sceditor('instance').insertText('',content);
});
})});
At the beginning we have the variable buttonImage here you can change the icon that is displayed on the button by replacing the current URL with another. Next is n, n holds a number value which will be the amount of random results we want. Currently it is set to 5. Using Math.random() we'll add n + 1 = 0-6; our result is the occurrence of 0, 1, 2, 3, 4, or 5, but we exclude 0 to less confuse things.
Now the last thing you need to modify is the conditions. A condition is simple : If a certain condition is met, let's say n is exactly equal to 5, then we'll display a popup saying "You win !". In this case we'll be using strings(text), see below our current conditions :
- Code:
if (rand === 1) var content = '1'; // if rand contains the value 1, then this will be the resulting text
if (rand === 2) var content = '2'; // read the comment above but replace 1 w/ 2
if (rand === 3) var content = '3'; // I'll be entered into the editor if rand loves m-- I mean is 3
if (rand === 4) var content = '4';
if (rand === 5) var content = '5';
Simply put, all you need to do is replace the values between the single quotes with your own, and if you increase the value of n add another condition. So if n is equal to 20 we'll have 20 conditions, make sure to change the number in the condition too ! ex : if (rand === 20)
In your case you're adding images correct ? This is how it would look :
- Code:
$(function(){$(function() {
var buttonImage = 'http://2img.net/i/rs3/58/frm/SCEditor/src/themes/icons/src/famfamfam/faspoiler.png';
var n = 5;
$('.sceditor-button-source').before('<a class="sceditor-button sceditor-button-randomI"><div style="background-image:url('+buttonImage+');"></div></a>');
$('.sceditor-button-randomI').click(function() {
var rand = Math.floor( Math.random() * n + 1 );
if (rand === 1) var content = '[img]/myimage.gif[/img]';
if (rand === 2) var content = '[img]/myimage.gif[/img]';
if (rand === 3) var content = '[img]/myimage.gif[/img]';
if (rand === 4) var content = '[img]/myimage.gif[/img]';
if (rand === 5) var content = '[img]/myimage.gif[/img]';
$('#text_editor_textarea').sceditor('instance').insertText('',content);
});
})});
Re: Posting Reactions
thanks ill let you know how it goes
MasterofChaos- Forumember
- Posts : 43
Reputation : 1
Language : english
Re: Posting Reactions
so far it seems to be working thanks
MasterofChaos- Forumember
- Posts : 43
Reputation : 1
Language : english
Re: Posting Reactions
Very good, you're welcome.
Topic archived
If you encounter any bugs you can let me know, or create a new topic.
Topic archived
If you encounter any bugs you can let me know, or create a new topic.
Similar topics
» A dream about reactions
» How to remove information after reply posting and new posting?
» Posting problems posting GIFs in my mobile app
» Posting problems posting GIFs in my mobile app
» Need help with posting
» How to remove information after reply posting and new posting?
» Posting problems posting GIFs in my mobile app
» Posting problems posting GIFs in my mobile app
» Need help with posting
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum