package net.eaglerforge;

import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.minecraft.client.Minecraft;
import org.teavm.jso.JSBody;
import org.teavm.jso.browser.Window;
import org.teavm.jso.dom.html.HTMLBodyElement;
import org.teavm.jso.dom.html.HTMLElement;
import org.teavm.jso.dom.html.HTMLImageElement;

import static net.minecraft.client.Minecraft.mojangLogo;


public class EaglerForge {
    private static Minecraft mc;
    public static final Logger log = LogManager.getLogger();
    @JSBody(params = { "message" }, script = "alert(message)")
    public static native void jsalert(String message);

    @JSBody(params = { "message" }, script = "console.log(message)")
    public static native void jsconsolelog(String message);

    @JSBody(params = { "message" }, script = "prompt(message)")
    public static native void jsprompt(String message);
    @JSBody(params = { "message", "default_text" }, script = "prompt(message, default_text)")
    public static native void jspromptdt(String message, String default_text);
    
    public static void displayanvil() {
    	HTMLImageElement img = (HTMLImageElement) Window.current().getDocument().createElement("img");
        img.setAttribute("id", "anvil");
        img.setSrc(src);
        img.setAttribute("draggable", "false");
        img.getStyle().setProperty("position", "fixed");
        img.getStyle().setProperty("bottom", "0");
        img.getStyle().setProperty("right", "0");
        img.getStyle().setProperty("width", "200px");
        img.getStyle().setProperty("height", "auto");
        
        HTMLBodyElement body = (HTMLBodyElement) Window.current().getDocument().getBody();
        body.appendChild(img);
    }
    
    public static void removeanvil() {
    	HTMLElement element = Window.current().getDocument().getElementById("anvil");
    	
    	if (element != null) {
            element.getParentNode().removeChild(element);
        }
    }

    public static void init() {
        log.info("Starting EaglerForge!");
        displayanvil();
        log.info("Loading Mods...");
    }
    
    public static String src = "data:image/gif;base64,[encoded data, 65120 characters]";
    
}