To get the source code move your mouse pointer into the source code section and press on the upper right side the copy button. This copies the source code to the clipboard and now it can be pasted and saved into your target.

var System = {
  log : function(text) {
    console.log(text);
  }
}

/**
 * Example how to simulate getModule method of System class with
 * Node.js.
 */

var com = {

  vmware : {

    // Module com.vmware.basic
    basic : {
      createDirectory : function(directory) {
        var file = new java.io.File(directory);
        if (!file.exists()) {
          System.log("Creating directory : '" + directory + "'");
          file.mkdirs();
          System.log("Directory '" + directory + "' created.");
        }
      },
      getFileName : function(fileName) {
        if (fileName != null)  {
          var index = fileName.lastIndexOf("/");
          return fileName.substring(index + 1, fileName.length);
        }
        return null;
      }
    },

    // Module com.vmware.constants
    constants : {
      getDefaultCompanyName : function() {
        return "VMware Inc.";
      },
      getDefaultSSHKeyPairPath : function() {
        return "/usr/lib/vco/app-server/conf/vco_key";
      }
    }

  }

}

// Simulate getModule method.
function getModule(object) {
  return Object.create(eval(object));
}

// Main
System.log(
  getModule("com.vmware.constants").getDefaultCompanyName()
);

var constants = getModule("com.vmware.constants");
System.log(constants.getDefaultCompanyName());



This site is part of blog.stschnell.de