Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently May 18th, 2024, 5:52 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Array variable with Multiple Pages export [HTML5]
PostPosted: April 1st, 2014, 8:31 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've been developing my project as an One page export with hash tag. Because of the size I wanted to export it with Multiple pages.

What happens: book variables are remembered unless it is an array variable. When moving from page to page array variable is always cleared when entering a page.
Can you advice me how I should store an array between pages using Opus? May be to use some way of the Web Storage (http://www.w3.org/TR/2009/WD-webstorage-20091222/)?

Ota


For this message ovo has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Array variable with Multiple Pages export [HTML5]
PostPosted: April 1st, 2014, 10:29 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
I'd hazard a guess that this is a bug and contact DW.

However;

localStorage requires the data to be in string format and therefore you'll need to convert your data back and forth. Opus already has an action for session storage, so you simply need to convert the array to a string and use the action to save and then load on the next page and convert back to an array.

If you're looking for a simple method look at using Array.join and String.split to convert the data - if your data is more advanced you can use window.JSON functions from within Opus.

Mack

_________________
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: Array variable with Multiple Pages export [HTML5]
PostPosted: April 2nd, 2014, 8:11 am 
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
Thanks you saved me time with string information. I'll send it to support.
I have been using an array to a string for storing a cookies from Opus so I can use it for an array between pages.

Algorithm for keeping a pair of information in a string (values separated by coma) I've found on the Internet. It can be useful for others:

Code:
function getArray(str, type)//str e.g.: "Page_1_,completed,Page_2_,visited,Page_3_,completed"
{
    var pages = [];
    var status = [];
    for (var i=0;i<str.length;i++)
    {
        if ((i+2)%2==0) {
            pages.push(str[i]);
        }
        else {
            status.push(str[i]);
        }
    }
    if(type == "pages")
    {
        console.log(pages);
        return pages;
    }
    else
    {
        console.log(status);
        return status;
    }
}


in Opus I can fill an array with variables and then use it in text fields:
Code:
var_COMPLETED_PAGES = window.getArray(strArr, "status")
var_URL_PAGES = window.getArray(strArr, "pages")


For this message ovo has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Array variable with Multiple Pages export [HTML5]
PostPosted: April 10th, 2014, 8:13 am 
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
Thanks again Mack. JSON works within Opus and is super easy to use.
Code:
var_BOOK_TOOLTIPS_VISIBLE_str = window.JSON.stringify(var_BOOK_TOOLTIPS_VISIBLE);
var_BOOK_TOOLTIPS_VISIBLE =  window.JSON.parse(var_BOOK_TOOLTIPS_VISIBLE_str);


Ota


For this message ovo has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Array variable with Multiple Pages export [HTML5]
PostPosted: July 5th, 2016, 10:01 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
Hi All,

I started a new Windows EXE publication and I need to pull a JSON from online into multiple variables. It is my understanding I can do this in Opus V9 via OpusScript, can someone describe the process for doing this? Previously I manually parsed the returned HTML and split out the JSON via OpusScript, but there must be an easier way.

I am using the Post Web Data action to get the HTML and JSON into a variable in Opus to manipulate it from there, I believe this is not the correct way of doing it. Any advice is greatly welcome.

Thanks, Luke

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Array variable with Multiple Pages export [HTML5]
PostPosted: July 6th, 2016, 7:35 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
No, I think you misunderstand.

JSON is a JavaScript function and therefore available to the browser and thus HTML5 Opus publications.

Such functions can be accessed within OpusScript by accessing the window object and therefore the results made available to objects of the _DWPub. In the example above, this principle is used to assign the results of a JavaScript function (JSON) to a property of the Opus _DWPub Object (AKA a variable).

For Windows EXE Applications, a JSON string could be parsed using PHP on a server and echoed to the Opus Application as an object for use.

</mack>

_________________
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


For this message mackavi has been thanked by : lmc


Top
 Profile Visit website  
 
 Post subject: Re: Array variable with Multiple Pages export [HTML5]
PostPosted: July 6th, 2016, 10:42 am 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
Thank you Mack,

Ah ok, that's what I thought the issue might be. Ok I will dig up my old JSON parser I created a while back and see if I can get it to work. I wrote the code in 2011 so I cannot remember if it is dynamic or if I built it for a specific JSON I was expecting, I'll check and post the OpusScript here if dynamic.

When you say parse it in PHP and give it to Opus as an object, is that it being pulled into Opus via the Post Web Data? Some more information on this would be greatly appreciated.

Thanks, Luke

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Array variable with Multiple Pages export [HTML5]
PostPosted: July 6th, 2016, 12:02 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Yes, using POSTWEBDATA.

A simple PHP example:

Code:
<?php
$json = '{
    "title": "Secrets of the JavaScript Ninja",
    "author": "John Resig",
    "publisher":"Manning"
}';

$book = json_decode($json);

echo "title=".$book->title."&author=".$book->author."&publisher=".$book->publisher;
?>


Then you just set the receive tab as multiple fields and match the parameters in the echo string to your variables.

</mack>

_________________
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


For this message mackavi has been thanked by : AtakSport, lmc


Top
 Profile Visit website  
 
 Post subject: Re: Array variable with Multiple Pages export [HTML5]
PostPosted: July 6th, 2016, 1:46 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
Fantastic, that's much easier. I really did go to town on parsing a JSON via OpusScript.

Thanks as always Mack, I appreciate your quick response.

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group