JavaScript insertion on dita files

<oXygen/> general issues.
jmanier
Posts: 35

JavaScript insertion on dita files

Wed Sep 19, 2018 5:32 pm

Hi,

I would like to insert a javascript code in my dita file but, even after reading oxygen documentation, I don't really understand. It would be for webhelp output responsive content.

The object looks like this in the HTML page of our platform :

Code: Select all

    <script type="text/javascript">
        function generate() {
            var login = document.getElementById('login').value;
            var password = document.getElementById('password').value;
            var tokenField = document.getElementById('token');

            var token = 'Basic ' + btoa(login+':'+password);
            tokenField.value = token;
            return false;
        }
    </script>
</head>
<body>
<h1>
    <table>
        <tr>
            <td><img style="margin-top:10px" src="/img/logo.png"/>
            </td>
            <td>APIs Authentication</td>
        </tr>
    </table>
</h1>

<div class="section">Token generation</div>
    <p>The token value is "Basic " + base64encode(login + ":" + password)</p>
    <form onsubmit="return generate()">
        <table>
            <tr>
                <td>Login</td><td><input type="text" id="login" /></td>
            </tr>
            <tr>
                <td>Password</td><td><input type="password" id="password" /></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" value="Generate" /></td>
            </tr>
            <tr>
                <td>Token</td>
                <td><input type="text" id="token"></td>
            </tr>
        </table>


    </form>

<div class="section">More infos</div>
    <p>Wikipedia description</p>
    <a class="gray" href="https://en.wikipedia.org/wiki/Basic_access_authentication#Client_side">https://en.wikipedia.org/wiki/Basic_access_authentication#Client_side</a>


How could I be able to insert that script on author, directly form my dita page? I have created a js file on the output for webhelp responsive.

Plus, I'm not able to use the <script> tag.

Thanks in advance.

Regards,

Jeremy
Radu
Posts: 5751

Re: JavaScript insertion on dita files

Thu Sep 20, 2018 11:09 am

Hi Jeremy,

Maybe this topic will help:

https://www.oxygenxml.com/doc/versions/20.1/ug-editor/topics/dita-embed-html-x-modes2.html

the embedded HTML content (which may contain Javascript) will appear in the HTML <body> section though.
If you want to embed the Javscript content in any HTML file generated from any DITA file and you generate WebHelp responsive from DITA you may want to use the "webhelp.fragment.head" parameter:

https://www.oxygenxml.com/doc/versions/20.1/ug-editor/topics/webhelp-responsive-plugin-additional-parameters.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
jmanier
Posts: 35

Re: JavaScript insertion on dita files

Fri Sep 21, 2018 10:23 am

Hi Radu,

Thanks for your answer. It's not working for the moment but I need to look further.
I'll get back to you if necessary.

Regards,

Jeremy

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 1 guest