Page 1 of 1

JavaScript insertion on dita files

Posted: Wed Sep 19, 2018 5:32 pm
by jmanier
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

Re: JavaScript insertion on dita files

Posted: Thu Sep 20, 2018 11:09 am
by Radu
Hi Jeremy,

Maybe this topic will help:

https://www.oxygenxml.com/doc/versions/ ... odes2.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/ ... eters.html

Regards,
Radu

Re: JavaScript insertion on dita files

Posted: Fri Sep 21, 2018 10:23 am
by jmanier
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