summaryrefslogtreecommitdiff
path: root/site-media/js/jquery.webstart.js
blob: 80761c5997a14e4c0021cf8d47e73c36a65621e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * jQuery.webstart
 * 
 * Written by Leif Johansson (leifj@nordu.net)
 * 
 * Licensed under BSD
 * Requires http://java.com/js/deployJava.js
 */

String.prototype.startsWith = function(str) {return (this.match("^"+str)==str)}

jQuery.fn.webstart = function(options) {
	if (typeof(options.minVersion) == "undefined")
		options.minVersion = "1.6.0";
	
	this.each(function() {
		var jnlp = options.jnlp;
		if (!jnlp.startsWith("http")) {
			var dir = location.href.substring(0,location.href.lastIndexOf('/')+1);
	 	    jnlp = dir+jnlp
		}
		
		if (deployJava.returnPage == null) {
		       deployJava.returnPage = jnlp;
		}
		
		$(this).click(function() {
	    	if (!deployJava.isWebStartInstalled(options.minVersion)) {
	    	   if (deployJava.installLatestJRE()) {
	    	      if (deployJava.launch(jnlp)) {}
	    	   }
	    	} else {
	    	   if (deployJava.launch(jnlp)) {}
	    	}
	    });
	});
}