diff --git a/core/main/client/dom.js b/core/main/client/dom.js
index 6c9709b85..56d45549d 100644
--- a/core/main/client/dom.js
+++ b/core/main/client/dom.js
@@ -16,7 +16,7 @@
/*!
* @literal object: beef.dom
*
- * Provides functionalities to manipulate the DOM.
+ * Provides functionality to manipulate the DOM.
*/
beef.dom = {
@@ -191,37 +191,78 @@ beef.dom = {
},
/**
+ * Given an array of objects (key/value), return a string of param tags ready to append in applet/object/embed
+ * @params: {Array} an array of params for the applet, ex.: [{'argc':'5', 'arg0':'ReverseTCP'}]
+ * @return: {String} the parameters as a string ready to append to applet/embed/object tags (ex.: ).
+ */
+ parseAppletParams: function(params){
+ var result = '';
+ for (i in params){
+ var param = params[i];
+ for(key in param){
+ result += "";
+ }
+ }
+ return result;
+ },
+
+ /**
+ * 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} 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', 'SuperMario3D.class', 'http://127.0.0.1:3000/ui/media/images/target.jar');
+ * beef.dom.attachApplet('appletId', 'appletName', 'SuperMario3D.class', 'http://127.0.0.1:3000/ui/media/images/target.jar', [{'param1':'1', 'param2':'2'}]);
*/
- attachApplet: function(id, code, archive){
+ attachApplet: function(id, name, code, archive, params) {
var content = null;
- if(beef.browser.isIE()){
- content = "" +
- "";
- }else{ // if the hooked browser is not IE, then use the embed tag
- content = "" +
+ if (beef.browser.isIE()) {
+ content = "" + // the classid means 'use the latest JRE available to launch the applet'
+ "";
+ }
+ if (beef.browser.isC() || beef.browser.isS() || beef.browser.isO()) {
+ content = "" +
+ "";
+ }
+ if (beef.browser.isFF()) {
+ content = "" +
"";
+ "type='application/x-java-applet' archive='" + archive + "' " +
+ "height='0' width='0' name='" + name + "'>";
+
+ if (params != null) {
+ content += beef.dom.parseAppletParams(params);
+ }
+ content += "";
}
$j('body').append(content);
},
/**
+ * Given an id, remove the applet from the DOM.
* @params: {String} id: reference identifier to the applet.
*/
detachApplet: function(id){
$j('#' + id + '').detach();
}
+
+
};