Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 12:45 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 11th, 2016, 7:49 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Still working on using math formulas in an HTML5 pub. Ran into a problem with parseInt which is in the formula being used. Firebug shows the following on the page where parseInt is used:

Code:
TypeError: Score_Page.parseInt is not a function


The part of the math formula that would benefit from a work around is:

Code:
for (var i=0;i<hS.length;i=i+2){
bA[Math.floor(i/2)]= parseInt(hS.substring(i,i+2),16);
}
return bA;


So far, not sure if a work around can be created? Any help appreciated.

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 12th, 2016, 8:22 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Don't need a work around just an understanding of OOP. parseInt is a window method - so just call that object first.

Code:
window.parseInt();

</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: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 12th, 2016, 12:20 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Mack,

I've got this long math formula in a page script object, not a JavaScript object. Adding the window. prefix to this single function didn't work.

Since the JavaScript has many, many functions (probably a hundred lines-AES Crypto formula for example, http://www.fourmilab.ch/javascrypt/index.html to encrypt/decrypt health-sensitive data), I'm wondering if the entire formula needs to be put into an external JS file, attached to Opus in the advanced publishing dialog through src, then calling the key functions to run it? Probably would need to re-write/prefix every function (25+) with window(.function)?

Interestingly, since its pure JS, it does work in Opus, in a standard page script object, if the Opus pub is an EXE, but not if it is published in Opus to HTML5.

So, even though watched YouTube video, still not quite sure how to do this?

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 12th, 2016, 3:02 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Yes, the different scopes and contexts involved in adding vanilla JavaScript to Opus-converted-to-JavaScript can cause advanced code to become easily confused.

Placing it in an external JS file makes it much easier to work out what is running from where. If practical terms, I would recommend passing all values needed by the function as parameters and then returning the result to a publication variable.

</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: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 12th, 2016, 3:55 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Played some more, but not getting this to work. Too complicated for me, so will try another approach to securing the few pieces of data.

Much thanks again.

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 12th, 2016, 4:21 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Working example:

http://www.live.interaktiv.co.uk/?secti ... evine.info

</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: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 12th, 2016, 5:25 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Mack,

OK, got the sample to work.

So, maybe I can just "dump" the (multi-line, multi-function) JavaScript for the crypto into a JS external file, try to run it similarly? This JavaScript does contain parseInt in one of the functions.

I will try it.

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 12th, 2016, 5:34 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
You did include the interaktiv.js file with the published files?

</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: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 12th, 2016, 5:46 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Must have crossed paths in cyberspace. Yes, forgot to put the external JS in the export folder. Once done, worked fine.

But did try what I mentioned in last posting: dumped the crypto JS into an external JS file, set up (for my project) the Publishing>Advanced>Head addition the same (src...) and when viewed after publishing, got a black screen.

At this point, after struggling for a couple of days, am thinking it may be easier (though not as secure, would prfer AES 128 or higher) to find online a XOR basic JS (the data are both words and numbers, so word only substitution won't work) to encode/obfuscate the data, decode it back to plain text and numbers, as needed. Did some searching but so far haven't found a really simple XOR in JS like this.

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 12th, 2016, 9:31 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
It's the same principle as all the other examples:

Opus HTML: http://www.live.interaktiv.co.uk/?secti ... evine.info

Source: http://cryptojs.altervista.org/api/#AES

</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 : Stephen


Top
 Profile Visit website  
 
 Post subject: Re: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: October 12th, 2016, 11:45 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Thank you very much! I had seen mention of Google's (?) crypto.js but had steered away because I suspected (without actually looking at it :oops: ) that it would be way beyond my capability.

From your sample IMP, actually pretty straightforward implementation. Potentially helpful to secure user-generated health-sensitive data they choose to save or share.

Again, thank you.

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: November 14th, 2016, 12:31 pm 
Offline

Joined: May 24th, 2007, 11:02 am
Posts: 132
Location: UK - Wales - Ceredigion
Opus: illuminatus > Evolution
OS: Windows 10 Pro
System: i7 8GB RAM
mackavi wrote:
It's the same principle as all the other examples:

Opus HTML: http://www.live.interaktiv.co.uk/?secti ... evine.info

Source: http://cryptojs.altervista.org/api/#AES

</mack>


Thanks for sharing, but is there a way to still get this file? It seems to be broken at the moment.


For this message jezjones29 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: November 16th, 2016, 9:28 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Jez,

Interaktiv have recently moved hosting providers and due to technical issues, some of the website features are currently unavailable. The issue is being looked into.

Regards,

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: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: November 16th, 2016, 10:36 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Okay, it seems that if something needs doing, don't ring hosting support, do it your self :-)

I think I've fixed it. Downloads should now work. I still need to check other parts of the site - so let me know if anything else is missing.

</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: JavaScript parseInt in Math Formula-HTML5 pub
PostPosted: November 16th, 2016, 1:14 pm 
Offline

Joined: May 24th, 2007, 11:02 am
Posts: 132
Location: UK - Wales - Ceredigion
Opus: illuminatus > Evolution
OS: Windows 10 Pro
System: i7 8GB RAM
Thanks Mack, I've been able to download your file now.


For this message jezjones29 has been thanked by : mackavi


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 26 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