home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 August / PCO0897.ISO / filesbbs / os2 / fp1os2.arj / OS2 / DATA / 49 / C / 0 / F_26836 / JScriptFrameObject.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-05-15  |  6.0 KB  |  282 lines

  1. public class JScriptFrameObject extends JSbxObject implements JSbxPropertyInterface {
  2.    private static final String NAME = "frame";
  3.    private static final int FRAME_ID_ALERT = 1;
  4.    private static final int FRAME_ID_CLOSE = 2;
  5.    private static final int FRAME_ID_CONFIRM = 3;
  6.    private static final int FRAME_ID_OPEN = 4;
  7.    private static final int FRAME_ID_PROMPT = 5;
  8.    private static final int FRAME_ID_SETTIMEOUT = 6;
  9.    private static final int FRAME_ID_CLEARTIMEOUT = 7;
  10.    private static final int FRAME_ID_FRAMES = 17;
  11.    private static final int FRAME_ID_LENGTH = 18;
  12.    private static final int FRAME_ID_PARENT = 19;
  13.    private static final int FRAME_ID_SELF = 20;
  14.    private static final int FRAME_ID_TOP = 21;
  15.    private static final int FRAME_ID_WINDOW = 22;
  16.    private static final int FRAME_ID_NAME = 23;
  17.    private static final int FRAME_ID_DOCUMENT = 32;
  18.    private static final int FRAME_ID_ONBLUR = 36;
  19.    private static final int FRAME_ID_ONFOCUS = 37;
  20.    JSbxObject aCacheDocument = null;
  21.  
  22.    public String GetName() {
  23.       return "frame";
  24.    }
  25.  
  26.    public JScriptFrameObject(long var1) {
  27.       super(var1, JScriptManager.GetConstructorObjectForMe("DefaultConstructor"));
  28.       this.InitFrameProps();
  29.    }
  30.  
  31.    protected void InitFrameProps() {
  32.       try {
  33.          ((JSbxObject)this).Put(new JSbxObjectProperty("close", this, this, 2, true, true));
  34.          ((JSbxObject)this).Put(new JSbxObjectProperty("open", this, this, 4, true, true));
  35.          ((JSbxObject)this).Put(new JSbxObjectProperty("alert", this, this, 1, true, true));
  36.          ((JSbxObject)this).Put(new JSbxObjectProperty("confirm", this, this, 3, true, true));
  37.          ((JSbxObject)this).Put(new JSbxObjectProperty("prompt", this, this, 5, true, true));
  38.          ((JSbxObject)this).Put(new JSbxObjectProperty("window", this, this, 22, true, true));
  39.          ((JSbxObject)this).Put(new JSbxObjectProperty("length", this, this, 18, true));
  40.          ((JSbxObject)this).Put(new JSbxObjectProperty("frames", this, this, 17, true));
  41.          ((JSbxObject)this).Put(new JSbxObjectProperty("parent", this, this, 19, true));
  42.          ((JSbxObject)this).Put(new JSbxObjectProperty("top", this, this, 21, true));
  43.          ((JSbxObject)this).Put(new JSbxObjectProperty("self", this, this, 20, true));
  44.          ((JSbxObject)this).Put(new JSbxObjectProperty("name", this, this, 23, true));
  45.          ((JSbxObject)this).Put(new JSbxObjectProperty("document", this, this, 32, true));
  46.          ((JSbxObject)this).Put(new JSbxObjectProperty("setTimeout", this, this, 6, true, true));
  47.          ((JSbxObject)this).Put(new JSbxObjectProperty("clearTimeout", this, this, 7, true, true));
  48.          ((JSbxObject)this).Put(new JSbxObjectProperty("onblur", this, this, 36, true, true));
  49.          ((JSbxObject)this).Put(new JSbxObjectProperty("onfocus", this, this, 37, true, true));
  50.       } catch (JSbxException var1) {
  51.       }
  52.    }
  53.  
  54.    public JSbxValue PropertyCallFunction(JSbxObjectProperty var1, JScriptCallParam var2) throws JSbxExceptionBase {
  55.       JSbxVector var3 = var2.GetParamVector();
  56.       int var4 = var1.GetID();
  57.       int var5 = var3 != null ? var3.GetSize() : 0;
  58.       String var6 = "";
  59.       double var7 = (double)0.0F;
  60.       JScriptFrameObject var9 = null;
  61.       boolean var10 = false;
  62.       boolean var11 = false;
  63.       boolean var12 = true;
  64.       boolean var13 = false;
  65.       boolean var14 = false;
  66.  
  67.       try {
  68.          switch (var4) {
  69.             case 1:
  70.                if (var5 > 0) {
  71.                   this.alert(JScriptWindowObject.GetStringParam(var3, 0));
  72.                } else {
  73.                   this.alert("undefined");
  74.                }
  75.                break;
  76.             case 2:
  77.                this.close();
  78.                break;
  79.             case 3:
  80.                var12 = false;
  81.                var10 = true;
  82.                if (var5 == 0) {
  83.                   var13 = this.confirm("undefined");
  84.                }
  85.  
  86.                if (var5 > 0) {
  87.                   var13 = this.confirm(JScriptWindowObject.GetStringParam(var3, 0));
  88.                }
  89.                break;
  90.             case 4:
  91.                String var15 = "";
  92.                String var16 = "";
  93.                String var17 = "";
  94.                var14 = true;
  95.                var12 = false;
  96.                if (var5 >= 1) {
  97.                   var15 = JScriptWindowObject.GetStringParam(var3, 0);
  98.                }
  99.  
  100.                if (var5 >= 2) {
  101.                   var16 = JScriptWindowObject.GetStringParam(var3, 1);
  102.                }
  103.  
  104.                if (var5 > 2) {
  105.                   var17 = JScriptWindowObject.GetStringParam(var3, 2);
  106.                }
  107.  
  108.                var9 = this.open(var15, var16, var17);
  109.                if (var9 != null && var9 instanceof JScriptWindowObject) {
  110.                   ((JScriptWindowObject)var9).SetOpener(this);
  111.                }
  112.  
  113.                if (var5 < 1) {
  114.                   throw new JSbxException(0, "bad number of arguments for open()");
  115.                }
  116.                break;
  117.             case 5:
  118.                var12 = false;
  119.                if (var5 == 0) {
  120.                   var6 = this.prompt("undefined", "undefined");
  121.                }
  122.  
  123.                if (var5 == 1) {
  124.                   var6 = this.prompt(JScriptWindowObject.GetStringParam(var3, 0), "undefined");
  125.                }
  126.  
  127.                if (var5 >= 2) {
  128.                   var6 = this.prompt(JScriptWindowObject.GetStringParam(var3, 0), JScriptWindowObject.GetStringParam(var3, 1));
  129.                }
  130.                break;
  131.             case 6:
  132.                if (var5 >= 2) {
  133.                   var12 = false;
  134.                   var11 = true;
  135.                   var7 = (double)this.SetTimeout(JScriptWindowObject.GetStringParam(var3, 0), (int)JScriptWindowObject.GetDoubleParam(var3, 1));
  136.                }
  137.                break;
  138.             case 7:
  139.                if (var5 >= 1) {
  140.                   this.ClearTimeout((int)JScriptWindowObject.GetDoubleParam(var3, 0));
  141.                }
  142.                break;
  143.             default:
  144.                throw new JSbxException(0, "no such method in frame (ID=" + var4 + ")");
  145.          }
  146.       } catch (UnsatisfiedLinkError var18) {
  147.       }
  148.  
  149.       Object var19 = null;
  150.       JSbxValue var20;
  151.       if (var12) {
  152.          var20 = new JSbxValue();
  153.       } else if (var14) {
  154.          var20 = new JSbxValue(var9);
  155.       } else if (var10) {
  156.          var20 = new JSbxValue(var13);
  157.       } else if (var11) {
  158.          var20 = new JSbxValue(var7);
  159.       } else {
  160.          var20 = new JSbxValue(var6);
  161.       }
  162.  
  163.       var2.GetRuntimeParam().SetReturnValue(var20);
  164.       return var20;
  165.    }
  166.  
  167.    public void PropertyGet(JSbxObjectProperty var1, JSbxValue var2) throws JSbxException {
  168.       int var3 = var1.GetID();
  169.  
  170.       try {
  171.          switch (var3) {
  172.             case 17:
  173.                JSbxArrayObject var4 = this.getFrames();
  174.                if (var4 != null) {
  175.                   var4.SetArrayType("Window");
  176.                }
  177.  
  178.                var2.Put(new JSbxValue(var4));
  179.                return;
  180.             case 18:
  181.                var2.Put(new JSbxValue((double)this.getLength()));
  182.                return;
  183.             case 19:
  184.                var2.Put(new JSbxValue(this.getParent()));
  185.                return;
  186.             case 20:
  187.                var2.Put(new JSbxValue(this.getSelf()));
  188.                return;
  189.             case 21:
  190.                var2.Put(new JSbxValue(this.getTop()));
  191.                return;
  192.             case 22:
  193.                var2.Put(new JSbxValue(this));
  194.                return;
  195.             case 23:
  196.                var2.Put(new JSbxValue(this.getName()));
  197.                return;
  198.             case 32:
  199.                this.aCacheDocument = this.getDocument();
  200.                var2.Put(new JSbxValue(this.aCacheDocument));
  201.                return;
  202.             case 36:
  203.                var2.Put(new JSbxValue(this.getOnBlur()));
  204.                return;
  205.             case 37:
  206.                var2.Put(new JSbxValue(this.getOnFocus()));
  207.                return;
  208.             default:
  209.                throw new JSbxException(0, "no such property in frame (ID=" + var3 + ")");
  210.          }
  211.       } catch (UnsatisfiedLinkError var5) {
  212.       }
  213.    }
  214.  
  215.    public void PropertyPut(JSbxObjectProperty var1, JSbxValue var2) throws JSbxException {
  216.       int var3 = var1.GetID();
  217.  
  218.       try {
  219.          switch (var3) {
  220.             case 23:
  221.                break;
  222.             case 36:
  223.                this.setOnBlur(var2.GetString());
  224.                return;
  225.             case 37:
  226.                this.setOnFocus(var2.GetString());
  227.                return;
  228.             default:
  229.                throw new JSbxException(0, "no such property in frame (ID=" + var3 + ")");
  230.          }
  231.       } catch (UnsatisfiedLinkError var4) {
  232.       }
  233.  
  234.    }
  235.  
  236.    public String Property_GetJScript_typeofString(JSbxObjectProperty var1) {
  237.       return "frame";
  238.    }
  239.  
  240.    public String GetJScriptString(boolean var1) {
  241.       return "[object Frame]";
  242.    }
  243.  
  244.    protected native int getLength();
  245.  
  246.    protected native String getName();
  247.  
  248.    protected native JSbxArrayObject getFrames();
  249.  
  250.    protected native JScriptFrameObject getParent();
  251.  
  252.    protected native JScriptFrameObject getTop();
  253.  
  254.    protected native JScriptFrameObject getSelf();
  255.  
  256.    protected native void alert(String var1);
  257.  
  258.    protected native boolean confirm(String var1);
  259.  
  260.    protected native String prompt(String var1, String var2);
  261.  
  262.    protected native void close();
  263.  
  264.    protected native JScriptFrameObject open(String var1, String var2, String var3);
  265.  
  266.    protected native JScriptDocumentObject getDocument();
  267.  
  268.    protected native int SetTimeout(String var1, int var2);
  269.  
  270.    protected native void ClearTimeout(int var1);
  271.  
  272.    protected native String getOnBlur();
  273.  
  274.    protected native void setOnBlur(String var1);
  275.  
  276.    protected native String getOnFocus();
  277.  
  278.    protected native void setOnFocus(String var1);
  279.  
  280.    protected native void StopAllJavaScripts();
  281. }
  282.