Announcement

Collapse
No announcement yet.

How to use the {option} parameter in a custom BBCode

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Glenn Vergara
    replied
    Originally posted by Meestor_X View Post
    Ok, I'm very sorry about that. It DOES work when I make a proper post, just not in the BBCode manager. I was testing it in the manager. Once I went to the forum and created a post using it, it worked.

    THANK YOU so much, and sorry to take up so much of your time.
    Oh ok. I thought you were testing it in the forum. I never even knew you could test in the bbcode manager.

    Leave a comment:


  • Glenn Vergara
    replied
    You have to click the Beautify button to beautify the script. I'm not available right now to help you
    Last edited by Glenn Vergara; Sun 20 Sep '15, 10:23am.

    Leave a comment:


  • Meestor_X
    replied
    Ok, I'm very sorry about that. It DOES work when I make a proper post, just not in the BBCode manager. I was testing it in the manager. Once I went to the forum and created a post using it, it worked.

    THANK YOU so much, and sorry to take up so much of your time.

    Leave a comment:


  • Meestor_X
    replied
    Ok, thank you for verifying. I'll keep trying!

    Leave a comment:


  • Glenn Vergara
    replied
    I developed it in 4.2.2 and it worked.

    Leave a comment:


  • Meestor_X
    replied
    The jsbeautifier doesn't work, it stays as one long string, but I see the other "(" bracket after the && now. Hard to read when it's all one line! ;-)
    Were you able to try your sample code on a vbulletin installation?

    I don't know how to work the console. I can open it but it doesn't mean anything to me. I appreciate all the time you're taking on this, if you were able to simply confirm that your sample works properly on a vbulletin 4 install, then I will continue to mess with it until I get it working. My fear at the moment is that javascript is not being executed within the BBCode.
    Last edited by Meestor_X; Sun 20 Sep '15, 9:31am.

    Leave a comment:


  • Glenn Vergara
    replied
    Do you see any error in the Javascript console? If you paste the js code in http://jsbeautifier.org/ to prettify the script, you will see the matching ')'

    Leave a comment:


  • Meestor_X
    replied
    If you get a chance, give it a try and let me know if it works. It seems the javascript isn't being executed. I tried even simplifying the code and it seems to ignore it all. I also see the progress3.gif image to the right of the link, so the RemoveChild isn't working either.

    Are you certain that vBulletin doesn't just block javascript within BBCodes? I've seen more posts indicating that js IS blocked, but I can't find anything "official".
    Last edited by Meestor_X; Sun 20 Sep '15, 9:10am.

    Leave a comment:


  • Meestor_X
    replied
    Yes and Yes.
    I noticed there's an unmatched parenthesis ")" near the end of your string. I don't see the matching open parenthesis.
    .... ?action=track&trackingnumber={param}')}

    Leave a comment:


  • Glenn Vergara
    replied
    And did you set Use {option} to Yes? Review all what I mentioned in post #7

    Leave a comment:


  • Glenn Vergara
    replied
    Does the image path in the img src exist? The JavaScript will not execute if it doesn't.

    Leave a comment:


  • Meestor_X
    replied
    It doesn't seem to work for some reason. {param} becomes a link, but the link has no href. It's not a clickable link. Have you tried this?

    Leave a comment:


  • Glenn Vergara
    replied
    Originally posted by Meestor_X View Post
    Thank you very much! I'll give it a try. I can understand all of it, with the help of google, except the last part:
    (this);this.parentNode.removeChild(this);
    What is the reason for that?
    That removes the temporary img tag that was used to execute Javascript.

    Leave a comment:


  • Meestor_X
    replied
    Thank you very much! I'll give it a try. I can understand all of it, with the help of google, except the last part:
    (this);this.parentNode.removeChild(this);
    What is the reason for that?

    Leave a comment:


  • Glenn Vergara
    replied
    Try this.

    Replacement:
    Code:
    <a>{param}</a><img src="images/misc/progress3.gif" onload="!function(e){var t='{option}',r=e.previousSibling;/ups/i.test(t)?r.href='http://wwwapps.ups.com/WebTracking/processRequest?HTMLVersion=5.0&Requester=NES&AgreeToTermsAndConditions=yes&tracknum={param}':/fedex/i.test(t)&&(r.href='https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber={param}')}(this);this.parentNode.removeChild(this);" />
    Example: [track=ups]trackingid[/track]
    Use {option}: Yes
    Disable options: All Yes

    Ignore "BBCode replacement may not be properly formed" warning when saving. Replace the FedEx tracking URL in the code if needed. Make sure "images/misc/progress3.gif" exists and the path is correct. Note that changing it to a transparent 1x1 image is better. The reason why the Javascript code is in img onload is because using regular <script> tag does not work on Post Quick Reply and Edit Post as they use AJAX and the new post is rendered via innerHTML which does not execute javascript inside <script> tags.

    Leave a comment:

Related Topics

Collapse

  • Actron
    "Code" bbcode
    by Actron
    I want to create a custom bbcode like the standart "code" bbcode with no name.... so if i use the custom bbcode there will only show following without the "Code :" on top:
    Code:
    like
    ...
    Mon 7 May '18, 11:00am
Working...
X