Package netscape.javascript

Examples of netscape.javascript.JSObject


    if (nodeId == null)
      return null;
    // Retrieve Node ...
    // First try to find by ID
    Object[] idArgs = { nodeId };
    JSObject tryNode = null;
    try {
      JSObject jsoWindow = JSObject.getWindow(appletWrapper);
      JSObject jsoDocument = (JSObject) jsoWindow.getMember("document");
      tryNode = (JSObject) jsoDocument.call("getElementById", idArgs);

      // But that relies on a well-formed CML DTD specifying ID search.
      // Otherwise, search all cml:cml nodes.
      if (tryNode == null) {
        Object[] searchArgs = { "http://www.xml-cml.org/schema/cml2/core",
            "cml" };
        JSObject tryNodeList = (JSObject) jsoDocument.call(
            "getElementsByTagNameNS", searchArgs);
        if (tryNodeList != null) {
          for (int i = 0; i < ((Number) tryNodeList.getMember("length"))
              .intValue(); i++) {
            tryNode = (JSObject) tryNodeList.getSlot(i);
            Object[] idArg = { "id" };
            String idValue = (String) tryNode.call("getAttribute", idArg);
            if (nodeId.equals(idValue))
              break;
            tryNode = null;
View Full Code Here


        return;
      }
      if (!doCallback || !mayScript)
        return;
      try {
        JSObject jsoWindow = JSObject.getWindow(appletWrapper);
        if (callback.equals("alert"))
          jsoWindow.call(callback, new Object[] { strInfo });
        else if (callback.length() > 0)
          jsoWindow.call(callback, data);
      } catch (Exception e) {
        if (!haveNotifiedError)
          if (Logger.debugging) {
            Logger.debug(JmolConstants.getCallbackName(type)
                + " call error to " + callback + ": " + e);
View Full Code Here

    private String notifySync(String info, String appletName) {
      String syncCallback = callbacks[JmolConstants.CALLBACK_SYNC];
      if (!mayScript || syncCallback == null)
        return info;
      try {
        JSObject jsoWindow = JSObject.getWindow(appletWrapper);
        if (syncCallback.length() > 0)
          return "" + jsoWindow.call(syncCallback, new Object[] { htmlName,
              info, appletName });
      } catch (Exception e) {
        if (!haveNotifiedError)
          if (Logger.debugging) {
            Logger.debug("syncCallback call error to " + syncCallback + ": "
View Full Code Here

      if (pt >= 0)
        return sendScript(strEval.substring(pt + 1), strEval.substring(0, pt),
            false, false);
      if (!haveDocumentAccess)
        return "NO EVAL ALLOWED";
      JSObject jsoWindow = null;
      JSObject jsoDocument = null;
      try {
        jsoWindow = JSObject.getWindow(appletWrapper);
        jsoDocument = (JSObject) jsoWindow.getMember("document");
      } catch (Exception e) {
        if (Logger.debugging)
          Logger.debug(" error setting jsoWindow or jsoDocument:" + jsoWindow
              + ", " + jsoDocument);
        return "NO EVAL ALLOWED";
      }
      if (callbacks[JmolConstants.CALLBACK_EVAL] != null) {
        notifyCallback(JmolConstants.CALLBACK_EVAL, new Object[] { null,
            strEval });
        return "";
      }
      try {
        //System.out.println(jsoDocument.eval("!!_jmol.noEval"));
        if (!haveDocumentAccess
            || ((Boolean) jsoDocument.eval("!!_jmol.noEval")).booleanValue())
          return "NO EVAL ALLOWED";
      } catch (Exception e) {
        Logger
            .error("# no _jmol in evaluating " + strEval + ":" + e.toString());
        return "";
      }
      try {
        return "" + jsoDocument.eval(strEval);
      } catch (Exception e) {
        Logger.error("# error evaluating " + strEval + ":" + e.toString());
      }
      return "";
    }
View Full Code Here

      //System.out.println("functionXY" + nX + " " + nY  + " " + functionName);
      float[][] fxy = new float[Math.abs(nX)][Math.abs(nY)];
      if (!mayScript || nX == 0 || nY == 0)
        return fxy;
      try {
        JSObject jsoWindow = JSObject.getWindow(appletWrapper);
        if (nX > 0 && nY > 0) { // fill with individual function calls (slow)
          for (int i = 0; i < nX; i++)
            for (int j = 0; j < nY; j++) {
              fxy[i][j] = ((Double) jsoWindow.call(functionName, new Object[] {
                  htmlName, new Integer(i), new Integer(j) })).floatValue();
            }
        } else if (nY > 0) { // fill with parsed values from a string (pretty fast)
          String data = (String) jsoWindow.call(functionName, new Object[] {
              htmlName, new Integer(nX), new Integer(nY) });
          //System.out.println(data);
          nX = Math.abs(nX);
          float[] fdata = new float[nX * nY];
          Parser.parseStringInfestedFloatArray(data, null, fdata);
          for (int i = 0, ipt = 0; i < nX; i++) {
            for (int j = 0; j < nY; j++, ipt++) {
              fxy[i][j] = fdata[ipt];
            }
          }
        } else { // fill float[][] directly using JavaScript
          jsoWindow.call(functionName, new Object[] { htmlName,
              new Integer(nX), new Integer(nY), fxy });
        }
      } catch (Exception e) {
        Logger.error("Exception " + e.getMessage() + " with nX, nY: " + nX
            + " " + nY);
View Full Code Here

    public float[][][] functionXYZ(String functionName, int nX, int nY, int nZ) {
      float[][][] fxyz = new float[Math.abs(nX)][Math.abs(nY)][Math.abs(nZ)];
      if (!mayScript || nX == 0 || nY == 0 || nZ == 0)
        return fxyz;
      try {
        JSObject jsoWindow = JSObject.getWindow(appletWrapper);
       jsoWindow.call(functionName, new Object[] { htmlName,
              new Integer(nX), new Integer(nY), new Integer(nZ), fxyz });
      } catch (Exception e) {
        Logger.error("Exception " + e.getMessage() + " for " + functionName + " with nX, nY, nZ: " + nX
            + " " + nY + " " + nZ);
      }
View Full Code Here

    super(element, data, dataPath);

                                // fill the optionList value with the various
    optionList = new Vector()// OPTIONs that are a part of this SELECT tag.
    formOptions = (JSObject) element.getMember("options");
    JSObject option;
    int numOptions = NSFieldManager.intValue(formOptions.getMember("length"));
    for (int optIdx = 0;   optIdx < numOptions;   optIdx++)
      optionList.addElement(getOptionValue(formOptions, optIdx));

    if (variantValue != null) paint();
View Full Code Here

    return (String) optionList.elementAt(idx);
  }

  private static String getOptionValue(JSObject formOptions, int idx) {
    JSObject option = (JSObject) formOptions.getSlot(idx);
    String result = (String) option.getMember("value");
    if (result == null || result.trim().length() == 0) {
      result = (String) option.getMember("text");
      if (result != null) result = result.trim();
    }

    return result;
  }
View Full Code Here

    this.data = data;
    this.dataPath = dataPath;

    debug("get document...");
    JSObject document = (JSObject) window.getMember("document");
    debug("get forms...");
    JSObject formList = (JSObject) document.getMember("forms");

    // Build an internal list of all the elements on the form. (This
    // is necessary because otherwise Netscape 6 has a nasty habit of
    // reordering the list of elements in the form as we initialize
    // them.)
    Vector allElements = new Vector();
    if (formList != null) {
      debug("get forms.length...");
      int numForms = intValue(formList.getMember("length"));
      for (int formIdx = 0;   formIdx < numForms; formIdx++) {
        debug("get a form...");
        JSObject form = (JSObject) formList.getSlot(formIdx);
        debug("get elements...");
        JSObject elementList = (JSObject) form.getMember("elements");
        debug("get elements.length...");
        int numElements = intValue(elementList.getMember("length"));
        for (int elementIdx = 0;  elementIdx < numElements;  elementIdx++) {
          if (!isRunning) return; // abort if we have been terminated
          debug("add an element...");
          allElements.addElement(elementList.getSlot(elementIdx));
        }
      }
    }

      // Discard any previous input listeners
View Full Code Here

    this.data = data;
    this.dataPath = dataPath;

    debug("get document...");
    JSObject document = (JSObject) window.getMember("document");
    debug("get forms...");
    JSObject formList = (JSObject) document.getMember("forms");

    // Build an internal list of all the elements on the form. (This
    // is necessary because otherwise Netscape 6 has a nasty habit of
    // reordering the list of elements in the form as we initialize
    // them.)
    Vector allElements = new Vector();
    if (formList != null) {
      debug("get forms.length...");
      int numForms = intValue(formList.getMember("length"));
      for (int formIdx = 0;   formIdx < numForms; formIdx++) {
        debug("get a form...");
        JSObject form = (JSObject) formList.getSlot(formIdx);
        debug("get elements...");
        JSObject elementList = (JSObject) form.getMember("elements");
        debug("get elements.length...");
        int numElements = intValue(elementList.getMember("length"));
        for (int elementIdx = 0;  elementIdx < numElements;  elementIdx++) {
          if (!isRunning) return; // abort if we have been terminated
          debug("add an element...");
          allElements.addElement(elementList.getSlot(elementIdx));
        }
      }
    }

      // Discard any previous input listeners
View Full Code Here

TOP

Related Classes of netscape.javascript.JSObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.