package com.github.xpenatan.gdx.backends.dragome.dom;

import org.w3c.dom.Document;
import com.dragome.commons.javascript.ScriptHelper;
import com.dragome.web.enhancers.jsdelegate.JsCast;
import com.dragome.web.html.dom.Window;
import com.github.xpenatan.gdx.backend.web.dom.DocumentWrapper;
import com.github.xpenatan.gdx.backend.web.dom.LocationWrapper;
import com.github.xpenatan.gdx.backend.web.dom.WindowWrapper;

/**
 * @author xpenatan
 */
public class DragomeWindow implements WindowWrapper {

	Window window;

	WindowWrapper wrapper;

	public DragomeWindow() {
		window = Window.getInstance();
		Object windowObj = ScriptHelper.eval("window", null);
		wrapper = JsCast.castTo(windowObj, WindowWrapper.class);
	}

	@Override
	public DocumentWrapper getDocument() {
		Document document = Window.getDocument();
		DocumentWrapper document2 = JsCast.castTo(document, DocumentWrapper.class);
		return document2;
	}

	@Override
	public void requestAnimationFrame(Runnable runnable) {
		window.requestAnimationFrame(runnable);
	}

	@Override
	public int setTimeout(Runnable run, int delay) {
		//TODO needs to impl
		ScriptHelper.put("timeoutDelay", delay, this);
		int retValue = ScriptHelper.evalInt("wrapper.node.timeout(function() {ra.$run$void();}, timeoutDelay)", this);
		return retValue;
	}

	@Override
	public LocationWrapper getLocation () {
		LocationWrapper location = wrapper.getLocation();
		return location;
	}
}

@@ -341,32 +341,93 @@
 ocationWrapper;%0A
+import com.github.xpenatan.gdx.backend.web.dom.TimerWrapper;%0A
 import com.githu
@@ -1109,277 +1109,8 @@
 lic 
-int setTimeout(Runnable run, int delay) %7B%0A%09%09//TODO needs to impl%0A%09%09ScriptHelper.put(%22timeoutDelay%22, delay, this);%0A%09%09int retValue = ScriptHelper.evalInt(%22wrapper.node.timeout(function() %7Bra.$run$void();%7D, timeoutDelay)%22, this);%0A%09%09return retValue;%0A%09%7D%0A%0A%09@Override%0A%09public 
 Loca
@@ -1207,15 +1207,117 @@
 location
+;%0A%09%7D%0A%0A%09@Override%0A%09public TimerWrapper getTimer () %7B%0A%09%09// TODO Auto-generated method stub%0A%09%09return null
 ;%0A%09%7D%0A%7D%0A

Add dragome todo timer