Go Back   vb.org Archive > vBulletin Modifications > vBulletin 3.8 Modifications > vBulletin 3.8 Add-ons
Shuffle Text BB Code (Randomizes text) (BBCode) Details »»
Shuffle Text BB Code (Randomizes text) (BBCode)
Version: 1.00, by BirdOPrey5 (Senior Member) BirdOPrey5 is offline
Developer Last Online: Aug 2023 Show Printable Version Email this Page

Category: BB Code Enhancements - Version: 3.8.x Rating:
Released: 08-07-2010 Last Update: Never Installs: 7
Supported
Re-useable Code  

This BB Code uses Javascript to shuffle the alpha-numeric and some special characters in a block of text. This can be used to create 'puzzles' for your members or perhaps provide answers to questions that aren't immediately apparent should someone accidentally glance at them. The use is of course up to you.

I found this Javascrpt already created on the web and have left the copyright info in tact. I made minor changes to adapt it to a BB Code.

Demo: here.

Add a new BBCode

Title: Random (Shuffle) Text
BB Code Tag Name: ran
Replacement:
Code:
<script type="text/javascript">
function str_shuffle (str) {
    // Shuffles string. One permutation of all possible is created  
    // 
    // version: 1006.1915
    // discuss at: http://phpjs.org/functions/str_shuffle
    // +   original by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: shuffled = str_shuffle("abcdef");
    // *     results 1: shuffled.length == 6
    
    if (str == undefined) {
        throw 'Wrong parameter count for str_shuffle()';
    }
    
    var getRandomInt = function (max) {
        return Math.floor(Math.random() * (max + 1));
    }
    var newStr = '', rand = 0;
    
    while (str.length) {
        rand = getRandomInt(str.length-1);
        newStr += str.charAt(rand);
        str = str.substring(0, rand)+str.substr(rand+1);
    }
    
    return newStr;
}
</script> 
<script>
document.write(str_shuffle("{param}"));
</script>
Example: [ran]This is a random test[/ran].
Description: This code shuffles text. Do not use the following characters: " {}[]<>&
Use Option: No
Button Image: (optional)
Remove Tag If Empty: Yes
All Disable Options: Yes

The following special characters do not work: " {}[]<>& (There may be others)
The following special characters do work: .,!?$()

Please mark as installed if you use this.
View My Profile for more BB Code Enhancements- they work on all versions.

Example:
[b][ran]A bold example[/ran].[/b] =
ex adlmopbl eA.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 08-08-2010, 05:52 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Note- this will randomize the letters each time you load the page... If you want to keep the same persistent order each time the page is loaded change the line in the replacement code:

Code:
 return Math.floor(Math.random() * (max + 1));
Replace Math.random() with a number between zero and 1, DO NOT MAKE IT = 1!!!

An example is:

Code:
 return Math.floor(0.5 * (max + 1));
Reply With Quote
  #3  
Old 08-08-2010, 07:45 PM
MagicThemeParks's Avatar
MagicThemeParks MagicThemeParks is offline
 
Join Date: Sep 2009
Posts: 850
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for this sir!

I was wondering though....could this randomize the letters of each word rather than randomize the entire sentence or phrase?

For example......

THIS IS WHAT I WANT = hsit si hwta i ntaw

....instead of doing the entire phrase, it would give folks an actual clue to "solve the game" with only the actual letters of each word scrambled.

Can this be done?

EDITED: Just thinking about it....I can actually put the code around each word as a 'workaround'.

But, do you know if it could be done automatically to save some time?
Reply With Quote
  #4  
Old 08-08-2010, 10:19 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well anything is possible... let me work on this for a bit and see if I can figure it out... I'm thinking I can split the strings based on spaces and randomize each array that way...
Reply With Quote
  #5  
Old 08-08-2010, 10:22 PM
MagicThemeParks's Avatar
MagicThemeParks MagicThemeParks is offline
 
Join Date: Sep 2009
Posts: 850
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That would be great! :up:
Reply With Quote
  #6  
Old 08-11-2010, 05:53 PM
y2krazy y2krazy is offline
 
Join Date: Jun 2003
Location: Houston, Texas
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MagicThemeParks View Post
THIS IS WHAT I WANT = hsit si hwta i ntaw

....instead of doing the entire phrase, it would give folks an actual clue to "solve the game" with only the actual letters of each word scrambled.

Can this be done?
I would love to have this be the case, but how many queries would this add per post on showthread? if it was a paragraph with, let's say 200 words, would it add 200 queries for that one post?

Tagging this Mod, but curious how it will be handled with the potential for so many queries.
Reply With Quote
  #7  
Old 08-11-2010, 07:04 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

JavaScript doesn't run queries... it's all handled by the user's browser, not the server, there are no performance issues.
Reply With Quote
  #8  
Old 08-12-2010, 01:12 AM
MagicThemeParks's Avatar
MagicThemeParks MagicThemeParks is offline
 
Join Date: Sep 2009
Posts: 850
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
Well anything is possible... let me work on this for a bit and see if I can figure it out... I'm thinking I can split the strings based on spaces and randomize each array that way...
Were you able to figure it out?
Reply With Quote
  #9  
Old 08-12-2010, 01:24 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not yet... ran into some issues... will try and look at it again soon. Will let you know as soon as I have something.
Reply With Quote
  #10  
Old 08-12-2010, 02:06 AM
MagicThemeParks's Avatar
MagicThemeParks MagicThemeParks is offline
 
Join Date: Sep 2009
Posts: 850
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sounds great! Thanks :up:
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:59 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04929 seconds
  • Memory Usage 2,307KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete