// https://www.webswing.org/docs/23.2/configure/applet.html // https://www.webswing.org/docs/23.2/configure/swing.html // https://www.webswing.org/docs/23.2/integrate/javascript-api?_h=customArgs%2Cargs#usage-with-customization-and-options // https://www.webswing.org/docs/23.2/integrate/embed.html // https://www.webswing.org/docs/20.1/integrate/urlparams.html // https://www.webswing.org/docs/23.2/integrate/urlparams.html // https://www.webswing.org/docs/20.1/integrate/customize.html // https://www.webswing.org/docs/2.7/integrate/embed.html var webswingInstance0 = { options: { autoStart: true, //appletParams: getParam('appletParams'), //appletParams: {"collection":"smallbea", "library":"library"}, connectionUrl:'/webswing-server/collage', customization: function(injector) { injector.services.base.handleActionEvent = function(actionName, data, binaryData) { //console.log("WebSwing actionEvent callback handler: called with actionName = " + actionName); if (actionName === "openURL") { var url = data; // check if a target tab/window name has been specified // TODO: Any better way of passing > 1 string between Java and JavaScript? var index = url.indexOf(" - "); if (index !== -1) { var target = url.substring(index+3); // skip past " - " to get target name url = url.substring(0, index); // Note that target window name is not the same as target window title // https://stackoverflow.com/questions/8051811/how-to-show-window-title-using-window-open window.open(url, target); } else { window.open(url, '_blank'); } } else if (actionName == "javaToWebswingJSConsoleLog") { console.log("Got message from java:\n" + data); } } } } }; // The applet jar files can just remain in web/applet where they are compiled up if(!webswingInstance0.options.args) { webswingInstance0.options.args=""; } //https://stackoverflow.com/questions/25203124/how-to-get-base-url-with-jquery-or-javascript var baseURL = window.location.origin+window.location.pathname; // webswingInstance0.options.args += "\"" + baseURL+ "?a=a&rt=d&s=GsdlCollageApplet&c=smallbea\""; var servlet_index = baseURL.indexOf("/"+gs.xsltParams.library_name); if(servlet_index > 0) { baseURL = baseURL.substring(0, servlet_index+1); } var baseClassifier = "CL3"; //var gs3CollImgPath = gs.xsltParams.library_name + "/sites/" + gs.xsltParams.site_name + "/collect/" + gs.cgiParams.c; var gs3CollBrowsePath = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/browse/" + baseClassifier; webswingInstance0.options.args += "--baseurl \"" + baseURL + "\""; //webswingInstance0.options.args += " --gsdlversion 3"; webswingInstance0.options.args += " --collection " + gs.cgiParams.c; webswingInstance0.options.args += " --library " + gs.xsltParams.library_name; webswingInstance0.options.args += " --documentroot greenstone3"; webswingInstance0.options.args += " --hrefMustHave " + gs3CollBrowsePath; webswingInstance0.options.args += " --imageMustNotHave \"interfaces/\""; webswingInstance0.options.args += " --verbosity " + 3; webswingInstance0.options.args += " --imageType " + "\".jpg%.png\""; webswingInstance0.options.args += " --classifier \"" + baseClassifier + ".1\""; // "CL3.1" webswingInstance0.options.args += " --maxDepth 500 --maxDisplay 25 --refreshDelay 1500 --bgcolor \"#96c29a\""; // Control the width and height of the Java application launched with webswing // by passing width and height params set to the attributes of the webswing element // https://stackoverflow.com/questions/21851633/get-height-from-style-attribute var w = document.getElementById("webswing-collage").style.width; var suffixIndex = 0; if(w) { suffixIndex = w.indexOf("px"); if(suffixIndex>0) { w = w.substring(0, suffixIndex); } webswingInstance0.options.args += " --width " + w; } var h = document.getElementById("webswing-collage").style.height; if(h) { suffixIndex = h.indexOf("px"); if(suffixIndex>0) { h = h.substring(0, suffixIndex); } webswingInstance0.options.args += " --height " + h; } //console.log("args: " + webswingInstance0.options.args); // Allow sending user events to swing application // https://www.webswing.org/docs/20.2/integrate/embed.html //webswingInstance0.setControl(true); function getParam(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var results = new RegExp("[\\?&]" + name + "=([^&#]*)").exec(location.href); return results == null ? null : decodeURIComponent(results[1]); }