Permlink Replies: 59 - Pages: 4 [ Previous | 1 2 3 4 | Next ] - Last Post: 19 Nov 14, 14:46 Last Post By: davidekholm Threads: [ Previous | Next ]
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: jAlbum 12.3 with JavaScript support
Posted: 24 Sep 14, 15:01   in response to: JeffTucker in response to: JeffTucker
  Click to reply to this thread Reply
Thanks for the update!
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: jAlbum 12.3 with JavaScript support
Posted: 24 Sep 14, 15:06   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Another little oddity. Scripting errors aren't being output to the system console. So, if I introduce a scripting error, I get the popup window that says, "An unexpected error occurred," and I get the familiar stack trace dump. I can copy it to the clipboard. I get the yellow triangle warning in the lower right. But the system console remains empty.
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: jAlbum 12.3 with JavaScript support
Posted: 25 Sep 14, 21:30   in response to: JeffTucker in response to: JeffTucker
  Click to reply to this thread Reply
jGromit wrote:
Another little oddity. Scripting errors aren't being output to the system console. So, if I introduce a scripting error, I get the popup window that says, "An unexpected error occurred," and I get the familiar stack trace dump. I can copy it to the clipboard. I get the yellow triangle warning in the lower right. But the system console remains empty.

Ok. Thanks for spotting. Will be fixed in the next update.
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: jAlbum 12.3 with JavaScript support
Posted: 30 Sep 14, 10:42   in response to: JeffTucker in response to: JeffTucker
  Click to reply to this thread Reply
jGromit wrote:
davidekholm wrote:
Should work in this JavaScript engine too.

Well yeah, it does, but only if it immediately follows the opening of the scriptlet. So:

<%= a %> Good

<% =a %> No good

But of course print('hi'); is easier :-)

I was astonished when I stumbled onto that!


Ah, well the syntax really is <%= and not <% =
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: jAlbum 12.3 with JavaScript support
Posted: 30 Sep 14, 15:31   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Attachment MinimalJS.jaskin (109.2 KB)
FYI: There is now an auto update to jAlbum 2.2.1 which fixes three issues:
  • Shaky response to excluding/including files
  • Deletion of linked files having non web conformant characters
  • Not all URLs could be opened in external browser from within the embedded browser's toolbar button

I've now incorporated these bug fixes in jAlbum 12.3 b5 which is available in the ordinary beta location.

New in jAlbum 12.3 b5:
  • Fully working JavaScript engine as alternative to BeanShell. Just name your init file "init.js" instead of "init.bsh". Now all interpretation of <% scriptlets %> will be done by JavaScript
  • User interfaces can now be designed without any coding: Automatic loading of user interface designed using the free Scene Builder tool . Just drop a "ui.fxml" file inside the skin's folder and delete any existing onload.* file. Now jAlbum will auto-load the ui from this file.

I've attached a small tweak to the MinimalJS skin that demonstrates three ways to make a UI:
  • The "no code way". Just rename any existing onload file to onload-disabled or whatever. Keep the "ui.fxml" file.
  • The mixed approach, which gives you more control, but saves coding: Rename the "onload-fxml.bsh" file to "onload.bsh". The "onload.bsh" file reads the "ui.fxml" file manually and specifies a "Controller" that handles such things that can't be done from the visual builder tool.
  • The plain code approach: Use the "onload.js" file only. It demonstrates making a small, (but not working with the Minimal skin) UI in plain JavaScript.

See this as work in progress. I'm still exploring different ways to design user interfaces. I personally like the JavaScript syntax for skin design. I has a very neat syntax, don't you think? Check out the inside of "onload.js" and "onload-fxml.bsh"
ctwist

Posts: 474
Registered: 27-Sep-2003
Re: jAlbum 12.3 with JavaScript support
Posted: 1 Oct 14, 19:02   in response to: JeffTucker in response to: JeffTucker
  Click to reply to this thread Reply
jGromit wrote:
Another area in which existing scripts will need considerable rewriting is in checks for data types. Many skins are loaded with statements like:
if(someVar != void && someVar != null) do something;
That won't fly in Javascript! I suspect that will end up looking something like this:
if(typeof someVar != "undefined" && someVar != null) do something;
The simplest way to do this in JavaScript is
if(someVar) do something;
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: jAlbum 12.3 with JavaScript support
Posted: 1 Oct 14, 19:06   in response to: ctwist in response to: ctwist
  Click to reply to this thread Reply
ctwist wrote:
The simplest way to do this in JavaScript is
if(someVar) do something;

I'll have to do some more playing with that later, but just running JS in the system console, that throws an error if someVar isn't defined (just as it does in Java).
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: jAlbum 12.3 with JavaScript support
Posted: 1 Oct 14, 22:21   in response to: JeffTucker in response to: JeffTucker
  Click to reply to this thread Reply
jGromit wrote:
ctwist wrote:
The simplest way to do this in JavaScript is
if(someVar) do something;

I'll have to do some more playing with that later, but just running JS in the system console, that throws an error if someVar isn't defined (just as it does in Java).


I don't know what's the most elegant way to check variable existence in JavaScript, but I've found out that the following works
var ns = context.getBindings(javax.script.ScriptContext.ENGINE_SCOPE);
if (ns.containsKey("bar")) {
  if (bar) print('true');
}
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: jAlbum 12.3 with JavaScript support
Posted: 1 Oct 14, 22:26   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
The simplest appears to be:
if(typeof someVar != "undefined" && someVar) print("hello");
That prints "hello" if someVar is defined, and is non-null.

Very disturbing to a Java person, of course, to be doing what amounts to a Boolean test on a variable that might be a string, an integer, or even an array!
ctwist

Posts: 474
Registered: 27-Sep-2003
Re: jAlbum 12.3 with JavaScript support
Posted: 12 Nov 14, 05:20   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
I've been patiently waiting for jGromit to solve all known problems (it's easier that way), but it's not happening, so I decided to try JavaScript.
init.js is failing with this error
java.lang.NullPointerException
	at se.datadosen.jalbum.CompiledScript.updateVars(CompiledScript.java:170)
Since I can't see the jAlbum source code, I need David to tell me what is failing.
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: jAlbum 12.3 with JavaScript support
Posted: 12 Nov 14, 10:13   in response to: ctwist in response to: ctwist
  Click to reply to this thread Reply
ctwist wrote:
I've been patiently waiting for jGromit to solve all known problems (it's easier that way), but it's not happening, so I decided to try JavaScript.
init.js is failing with this error
java.lang.NullPointerException
	at se.datadosen.jalbum.CompiledScript.updateVars(CompiledScript.java:170)
Since I can't see the jAlbum source code, I need David to tell me what is failing.

It's caused by CompiledScript dereferencing the currentObject variable, which is null/missing. I guess you tried to use that Compiled outside a fileiterator or inside index.htt instead of slide.htt. That's not allowed. I've fixed this nullpointer issue though for the upcoming 12.3 version.

Also, CompiledScript is deprecated (flagged to not be used) as it isn't thread safe. The javadocs state that you should used CompiledBase instead.
ctwist

Posts: 474
Registered: 27-Sep-2003
Re: jAlbum 12.3 with JavaScript support
Posted: 12 Nov 14, 14:04   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
The statement that fails is
super.updateVars();
in a class that extends CompiledScript. This is outside fileIterator because I am initialising. I do not refer to currentObject until I am inside fileIterator.
Based on this thread http://jalbum.net/forum/thread.jspa?messageID=272380 I thought it was OK to continue using CompiledScript.
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: jAlbum 12.3 with JavaScript support
Posted: 12 Nov 14, 15:16   in response to: ctwist in response to: ctwist
  Click to reply to this thread Reply
ctwist wrote:
The statement that fails is
super.updateVars();
in a class that extends CompiledScript. This is outside fileIterator because I am initialising. I do not refer to currentObject until I am inside fileIterator.
Based on this thread http://jalbum.net/forum/thread.jspa?messageID=272380 I thought it was OK to continue using CompiledScript.

Yes, ok to use it witin a fileiterator, but as you're initializing it outside a fileiterator you bump into this issue. The best thing is still to switch to CompiledBase and to simply use get("variableName") to get the few image specific variables when you need them I think.

This said, I've updated CompiledScript to at least not give that nullpointer exception.
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: jAlbum 12.3 with JavaScript support
Posted: 13 Nov 14, 18:35   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
FYI. I've updated the beta to v9 now. Download the Windows beta or Mac beta here.

This beta is hopefully the last one before the sharp release. It has more robust file uploads but doesn't have javafx support yet. I decided to cut it from this release to still stay compatible with Java 6 for older Mac users. This is likely to be the last version supporting Java 6 though.
JeffTucker

Posts: 8,039
Registered: 31-Jan-2006
Re: jAlbum 12.3 with JavaScript support
Posted: 15 Nov 14, 15:08   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
davidekholm wrote:
...to still stay compatible with Java 6 for older Mac users. This is likely to be the last version supporting Java 6....

This always confuses me a bit. If there's a user with an older Mac, one for which Java 7 or Java 8 aren't available, what happens if he downloads and installs jAlbum with bundled Java 8? Does it fail? Or is he really running Java 8?

And on a related note, are Ubuntu users restricted in any way when it comes to Java versions?

I'm still compiling my skins to the JDK 6 source/binary format, but I'm wondering why. The skins require jAlbum 12.3 (unreleased betas of each, with context-sensitive help). I still haven't tackled the conversion from NetBeans to Nashorn (there's just a mountain of code to be messed with), but that will truly make the skins incompatible with earlier versions of jAlbum. So is there actually any reason not to compile to JDK 8? Would I actually be locking out any users?
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums