Skip to content

Instantly share code, notes, and snippets.

View icodealot's full-sized avatar

Justin Biard icodealot

View GitHub Profile
var Base64 = Java.type("java.util.Base64");
var encoder = Base64.encoder;
var decoder = {
decode : function (str) {
return new java.lang.String(Base64.decoder.decode(str));
}
}
var message = "Hello, World!";
// This is a minimal Base64 encode/decode utility for Nashorn -> JavaScript
// Add error checking for data types as needed within encode or decode
var Base64 = {
decode: function (str) {
return new java.lang.String(java.util.Base64.decoder.decode(str));
},
encode: function (str) {
return java.util.Base64.encoder.encodeToString(str.bytes);
}
};
// Trick QUnit into exporting QUnit reference since 1.19+ no
// longer export a global reference to QUnit. (or just revert
// back to using QUnit 1.18.0) Don't actually know if this is
// a good idea or not but it works.
var exports = this;
load("https://code.jquery.com/qunit/qunit-2.4.0.js");
with(QUnit) {
log(function(d) {
// This is a minimal JavaFX web browser written in JavaScript
// for Nashorn. Requires Java 1.8+ and I recommend JJS[.exe]
//
// Usage:
// jjs browse.js -- [URL or File.html]
// Declare class references from Java packages
var Application = Java.type("javafx.application.Application");
var Scene = Java.type("javafx.scene.Scene");