mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
jso apis: improve support of XMLHttpRequest
This commit is contained in:
parent
27713b78f8
commit
a4b2199142
30
jso/apis/src/main/java/org/teavm/jso/ajax/ProgressEvent.java
Normal file
30
jso/apis/src/main/java/org/teavm/jso/ajax/ProgressEvent.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright 2023 ihromant.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.jso.ajax;
|
||||
|
||||
import org.teavm.jso.JSProperty;
|
||||
import org.teavm.jso.dom.events.Event;
|
||||
|
||||
public interface ProgressEvent extends Event {
|
||||
@JSProperty
|
||||
boolean isLengthComputable();
|
||||
|
||||
@JSProperty
|
||||
int getLoaded();
|
||||
|
||||
@JSProperty
|
||||
int getTotal();
|
||||
}
|
|
@ -18,9 +18,12 @@ package org.teavm.jso.ajax;
|
|||
import org.teavm.jso.JSBody;
|
||||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.JSProperty;
|
||||
import org.teavm.jso.dom.events.Event;
|
||||
import org.teavm.jso.dom.events.EventListener;
|
||||
import org.teavm.jso.dom.events.EventTarget;
|
||||
import org.teavm.jso.dom.xml.Document;
|
||||
|
||||
public abstract class XMLHttpRequest implements JSObject {
|
||||
public abstract class XMLHttpRequest implements JSObject, EventTarget {
|
||||
public static final int UNSET = 0;
|
||||
|
||||
public static final int OPENED = 1;
|
||||
|
@ -54,6 +57,30 @@ public abstract class XMLHttpRequest implements JSObject {
|
|||
@JSProperty("onreadystatechange")
|
||||
public abstract void setOnReadyStateChange(ReadyStateChangeHandler handler);
|
||||
|
||||
@JSProperty("onreadystatechange")
|
||||
public abstract void setOnReadyStateChange(EventListener<Event> handler);
|
||||
|
||||
@JSProperty("onabort")
|
||||
public abstract void onAbort(EventListener<ProgressEvent> eventListener);
|
||||
|
||||
@JSProperty("onerror")
|
||||
public abstract void onError(EventListener<ProgressEvent> eventListener);
|
||||
|
||||
@JSProperty("onload")
|
||||
public abstract void onLoad(EventListener<ProgressEvent> eventListener);
|
||||
|
||||
@JSProperty("onloadstart")
|
||||
public abstract void onLoadStart(EventListener<ProgressEvent> eventListener);
|
||||
|
||||
@JSProperty("onloadend")
|
||||
public abstract void onLoadEnd(EventListener<ProgressEvent> eventListener);
|
||||
|
||||
@JSProperty("onprogress")
|
||||
public abstract void onProgress(EventListener<ProgressEvent> eventListener);
|
||||
|
||||
@JSProperty("ontimeout")
|
||||
public abstract void onTimeout(EventListener<ProgressEvent> eventListener);
|
||||
|
||||
public final void onComplete(Runnable runnable) {
|
||||
setOnReadyStateChange(() -> {
|
||||
if (getReadyState() == DONE) {
|
||||
|
|
|
@ -35,7 +35,7 @@ public abstract class WebSocket implements JSObject {
|
|||
public abstract void onMessage(EventListener<MessageEvent> eventListener);
|
||||
|
||||
@JSProperty("onopen")
|
||||
public abstract void onOpen(EventListener<MessageEvent> eventListener);
|
||||
public abstract void onOpen(EventListener<Event> eventListener);
|
||||
|
||||
@JSBody(params = "url", script = "return new WebSocket(url);")
|
||||
public static native WebSocket create(String url);
|
||||
|
|
Loading…
Reference in New Issue
Block a user