From 8a3977ff78c018b6e71291665d847c9a43a073a0 Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Wed, 2 Nov 2011 11:04:05 +0000 Subject: [PATCH] Improved attachApplet JS API function to support codebase attribute git-svn-id: https://beef.googlecode.com/svn/trunk@1388 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- core/main/client/dom.js | 52 +++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/core/main/client/dom.js b/core/main/client/dom.js index 56d45549d..a7923c361 100644 --- a/core/main/client/dom.js +++ b/core/main/client/dom.js @@ -210,30 +210,45 @@ beef.dom = { * Attach an applet to the DOM, using the best approach for differet browsers (object/applet/embed). * @params: {String} id: reference identifier to the applet. * @params: {String} code: name of the class to be loaded. For example, beef.class. + * @params: {String} codebase: the URL of the codebase (usually used when loading a single class for an unsigned applet). * @params: {String} archive: the jar that contains the code. * @params: {String} params: an array of additional params that the applet except. - * example usage in code: - * beef.dom.attachApplet('appletId', 'appletName', 'SuperMario3D.class', 'http://127.0.0.1:3000/ui/media/images/target.jar', [{'param1':'1', 'param2':'2'}]); + * example usage in code, using a JAR archive (recommended and faster): + * beef.dom.attachApplet('appletId', 'appletName', 'SuperMario3D.class', null, 'http://127.0.0.1:3000/ui/media/images/target.jar', [{'param1':'1', 'param2':'2'}]); + * example usage in code, using codebase: + * beef.dom.attachApplet('appletId', 'appletName', 'SuperMario3D', 'http://127.0.0.1:3000/', null, null); */ - attachApplet: function(id, name, code, archive, params) { + attachApplet: function(id, name, code, codebase, archive, params) { var content = null; if (beef.browser.isIE()) { content = "" + // the classid means 'use the latest JRE available to launch the applet' " " + - "" + - ""; + ""; + if (codebase != null) { + content += "" + }else{ + content += ""; + } if (params != null) { content += beef.dom.parseAppletParams(params); } content += ""; } if (beef.browser.isC() || beef.browser.isS() || beef.browser.isO()) { - content = "" + - ""; + + if (codebase != null) { + content = "" + + ""; + } else { + content = "" + + ""; + } if (params != null) { content += beef.dom.parseAppletParams(params); @@ -241,10 +256,17 @@ beef.dom = { content += ""; } if (beef.browser.isFF()) { - content = "" + - ""; + if (codebase != null) { + content = "" + + ""; + } else { + content = "" + + ""; + } if (params != null) { content += beef.dom.parseAppletParams(params); @@ -258,8 +280,8 @@ beef.dom = { * Given an id, remove the applet from the DOM. * @params: {String} id: reference identifier to the applet. */ - detachApplet: function(id){ - $j('#' + id + '').detach(); + detachApplet: function(id) { + $j('#' + id + '').detach(); }