How to Use the New Javascript

Keryth987
Keryth987

So, cna someone please explain how to use this new capability? What goes in the JavaScript Box and what goes on the webpage?

Comments

  • thaen
    thaen
    Posts: 928

    I'm copying this from nuadaria's post on the other thread ...

    https://forums.obsidianportal.com/discussion/comment/47515/#Comment_47515

     


    if(document.getElementsByClassName('wiki-edit').length < 1){
    var siblingDiv = document.getElementsByClassName('wiki-page-container');
    var div = document.createElement('div');
    div.innerHTML = '<div class="wiki-edit"><a class="button" href="'+window.location.href+'/edit">Edit This Page</a></div>';

    siblingDiv[0].parentNode.insertBefore(div, siblingDiv.nextSibling);
    }



    Copy that code exactly, and then paste it in the Campaign Settings -> Advanced -> Custom JavaScript box.

    Then click Save.

    Then go to any Wiki Page in your Campaign, and scroll down to the bottom of the main section, and you'll see the button for "Edit This Page".  You'll probably want to add some CSS to position it, but otherwise, it should work as is.

    You don't need to put anything on the Wiki Pages themselves to make this work.  Part of the power here is similar to the Custom CSS where you make change in one place (the Advanced tab) and it affects (or can affect) everything in the Campaign.

    Does that answer the question?

     

    Obsidian Portal Developer

  • Keryth987
    Keryth987
    Posts: 991

    Seems to work. So I just add things java wise there and thats it then?

  • thaen
    thaen
    Posts: 928

    Yeah, just like Custom CSS.  (Let me know if I'm not fully understanding your question?)

    Just noting, "Java" and "JavaScript" are two separate programming languages.  So, if you were googling for some "Java" code to show a popup, that code wouldn't work.  But, if you were googling for some "JavaScript" code to show a popup, that code would work.

     

    Obsidian Portal Developer

Sign In or Register to comment.

May 2022
Revenge on the Kraken's Bane

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions