Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 6:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: OpusPro with javascript
PostPosted: February 5th, 2014, 9:18 pm 
Offline

Joined: January 28th, 2014, 4:38 pm
Posts: 54
Location: Czech Republic
Opus: OpusPro 9.75 - HTML5 exports, Evolution
OS: Win 7 x64 CZ
System: FUJITSU
I'd like to share a few things I've found out when discovering HTML5 export possibilities from Opus Pro 9.03. It might be obvious for other users but it took me a few hours to find it. Opus help says you can extend the application for javascript but not how.

1) Calling an alert("alert") from OpusScript.
2) Adding a link to an external javascript file.
3) Get Opus variable from javascript.

1) To call an alert("alert") message in browser from OpusScript you need to use syntax:
Code:
window.alert("message written in OpusScript")
.

2) How to link a javascript file to exported project? I haven't found a way how to automatically link an external javascript file. Adding a reference to a javascript file (after loading a master page) works. You need to copy myFunctions.js file manually to the project.

Code:
var sElement = document.createElement("script");
sElement.type = "text/javascript"; sElement.async = true;
sElement.src = "myFunctions.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(sElement, s);

Now you can access your function in myFunctions.js:
Code:
function jsTest()
{
alert("action from myFunctions.js.");
}

To call jsTest() use "window.jsTest();" from the script e.g. on the button in Opus.

3) Do you need to access a variable which is created in OpusPro? Use syntax
Code:
alert(DWVariables.instance().getValue("variableName"));
from your external javascript file.

Comments are welcomed.
Ota


For this message ovo has been thanked by : Graham Baglin, mackavi


Last edited by ovo on February 10th, 2014, 10:59 pm, edited 1 time in total.

Top
 Profile Visit website  
 
 Post subject: Re: OpusPro with javascript
PostPosted: February 6th, 2014, 1:58 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
console.log is a better choice than alert. Opus will also use the standard Debug.trace if you enable it at publish - this has another advantage that it can be easily turned off.

Mack
https://twitter.com/imsmackavi

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: OpusPro with javascript
PostPosted: February 8th, 2014, 3:18 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Ota,
Thanks for sharing your work and your discoveries on what works.
And thanks Mack for rounding-out the discussion with some options and best practice methods.

Larry

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: OpusPro with javascript
PostPosted: February 13th, 2014, 2:37 pm 
Offline

Joined: November 25th, 2004, 2:23 pm
Posts: 24
Location: Wiltshire, UK
Opus: 9.03
OS: Win7 x64
System: ACER i7 4GB RAM
Keep it coming Ota, Mack & Lar

Although I only comprehend the gist of your posts, it's great to have sight of new possibilities to experiment with - even if it does make me realise how far away I am from achieving 'Godlike' on my forum profile....

_________________
Glen


For this message Glen Burn has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: OpusPro with javascript
PostPosted: May 29th, 2015, 1:14 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
What I did was I put something like:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

Under the Advanced tab on the Publish Settings - HTML 5 dialog place in HTML <head> Additions field.

On a page I can use Bootstrap "stuff" by using an HTML object and then putting in something like:
<div class="panel-group" id="accordion" style="font-size:12pt">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">1. What is HTML?</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in">
<div class="panel-body">
<p>HTML stands for HyperText Markup Language. HTML is the main markup language for describing the structure of Web pages. <a href="http://www.tutorialrepublic.com/html-tutorial/" target="_blank">Learn more.</a></p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">2. What is Bootstrap?</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
<p>Bootstrap is a powerful front-end framework for faster and easier web development. It is a collection of CSS and HTML conventions. <a href="http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/" target="_blank">Learn more.</a></p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">3. What is CSS?</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body">
<p>CSS stands for Cascading Style Sheet. CSS allows you to specify various style properties for a given HTML element such as colors, backgrounds, fonts etc. <a href="http://www.tutorialrepublic.com/css-tutorial/" target="_blank">Learn more.</a></p>
</div>
</div>
</div>
</div>

When published I get a nice Bootstrap accordion. Not sure exactly how to size it, but it's kind of cool. That means I'd have Bootstrap stuff to be able to use and JQuery stuff to be able to use as well.

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


For this message bwpatric has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: OpusPro with javascript
PostPosted: May 29th, 2015, 1:30 pm 
Offline

Joined: January 28th, 2014, 4:38 pm
Posts: 54
Location: Czech Republic
Opus: OpusPro 9.75 - HTML5 exports, Evolution
OS: Win 7 x64 CZ
System: FUJITSU
Advanced - Export - <Head> is available since Opus version 9.5. Now it is easier to extend the page functionality with own .js files.


For this message ovo has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group