Please turn on javascript in your browser to play chess.
Developers Forum

Developers Forum

  1. Standard member gregoftheweb
    The Great Gonzo
    31 Jul '03 16:21
    In your method for displaying the forum post body, do you have any means of regex'ing the string?

    This of course is a leading question, but could provide some very neat added functionality.

    if you are able to apply a regex to the string then you could do something like this

    sPostBodyString.replace(/[gn]($1)[/gn]/gi,<a href=\javascript:LaunchGame('$1';\>$1</a>

    Or something very like that.

    Where the user could insert the [gn]12345[/gn] directly into his/her post and the javascript function LaunchGame would navigate to or open a new window simply pointing to the gamehistory.php page for that game.

    Just a thought.

  2. Subscriber Crowley
    Not Aleister
    31 Jul '03 22:39
    Hmmm, good idea, could also work for citing other threads...
  3. Standard member gregoftheweb
    The Great Gonzo
    31 Jul '03 22:57 / 1 edit
    My regex is incorrect, it should read:

    sPostBodyString.replace(/[gn]($1)[\/gn]/gi,<a href=\"javascript:LaunchGame('$1';\>$1</a>" ) ;

    I forgot the escaping backslash in the [/gn] tag and the quote before javascript.

    And yes in theory this could be extended for many things.
  4. Subscriber Russ
    RHP Code Monkey
    05 Aug '03 20:07
    Originally posted by gregoftheweb
    My regex is incorrect, it should read:

    sPostBodyString.replace(/[gn]($1)[\/gn]/gi,<a href=\"javascript:LaunchGame('$1';\>$1</a>" ) ;

    I forgot the escaping backslash in the [/gn] tag and the quote before javascript.

    And yes in theory this could be extended for many things.
    A nice idea.

    I may well do this.

    -Russ

  5. Standard member gregoftheweb
    The Great Gonzo
    05 Aug '03 22:34
    my regex is still not quite right I think you are going to need to escape the []'s

    like so \[gn\] but you'll figure it out.

    g