package seedu.address.ui;

import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.image.Image;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.web.WebView;
import javafx.stage.Modality;
import javafx.stage.Stage;


/**
 * Controller for a help page
 */
public class HelpWindow {

    private static final String ICON = "/images/help_icon.png";
    private static final String FXML = "/view/HelpWindow.fxml";
    private static final String USERGUIDE_URL =
            "https://github.com/se-edu/addressbook-level4/blob/master/docs/UserGuide.md";

    @FXML
    private WebView webView;

    public HelpWindow() {

        Alert helpBox = new Alert(javafx.scene.control.Alert.AlertType.NONE);
        helpBox.initModality(Modality.NONE);

        //add icon
        Stage stage = (Stage) helpBox.getDialogPane().getScene().getWindow();
        stage.getIcons().add(new Image(ICON));

        //set help box to be on top even when command tray is in focus
        stage.setAlwaysOnTop(true);
        helpBox.initModality(Modality.NONE);

        //set contents
        helpBox.setTitle("HELP");
        helpBox.setHeaderText("Press <ESC> to close");
        helpBox.setContentText("");

        //press escape to close
        stage.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
            @Override
            public void handle(KeyEvent keyEvent) {
                if (keyEvent.getCode().equals(KeyCode.ESCAPE)) {
                    stage.close();
                    keyEvent.consume();
                }
            }
        });

        helpBox.showAndWait();
    }
}

@@ -371,24 +371,1059 @@
 lpWindow %7B%0A%0A
+    private static final String HELPBOX_CONTENT =%0A              %22Add Floating Task         %7C add %5C%22FLOATING_TASK_NAME%5C%22  %5Bp-PRIORITY%5D%5Cn%22%0A            + %22Add Deadline Task         %7C add %5C%22DEADLINE_NAME%5C%22 %3CDATE%3E %3CTIME%3E%5Cn%22%0A            + %22Add Events                %7C add %5C%22EVENT_NAME%5C%22 %3CSTARTING_DATE%3E %3CSTARTING_TIME%3E to %3CENDING_DATE%3E %3CENDING_TIME%3E%5Cn%22%0A            + %22Delete                    %7C del %3CINDEX%3E%5Cn%22%0A            + %22Edit Floating Tasks       %7C edit %3CINDEX%3E %5Bn-NEW_NAME%5D %5Bp-PRIORITY%5D%5Cn%22%0A            + %22Edit Deadline             %7C edit %3CINDEX%3E %5Bdd-DUE_DATE%5D %5Bdt-DUE_TIME%5D %5Bn-NEW_NAME%5D%5Cn%22%0A            + %22Mark task as finished     %7C fin %3CINDEX%3E%5Cn%22%0A            + %22Mark a task as unfinished %7C unfin %3CINDEX%3E%5Cn%22%0A            + %22Search for keywords       %7C search KEYWORD%5Cn%22%0A            + %22Undo                      %7C undo%5Cn%22%0A            + %22Redo                      %7C redo%5Cn%22%0A            + %22Clear                     %7C clear%5Cn%22%0A            + %22Exit                      %7C exit%5Cn%22%0A            + %22Hide and show Task Tracker%7C Ctrl + SPACE%5Cn%22;%0A%0A
     private 
@@ -1474,16 +1474,16 @@
 n.png%22;%0A
-
     priv
@@ -2027,67 +2027,22 @@
   //
-set help box to be on top even when command tray is in focu
+window setting
 s%0A  
@@ -2111,32 +2111,207 @@
 (Modality.NONE);
+%0A        helpBox.setResizable(true);%0A        helpBox.setWidth(500.0);%0A        helpBox.setHeight(500.0);%0A        //helpBox.getDialogPane().getScene().getWindow().sizeToScene();
 %0A%0A        //set 
@@ -2443,10 +2443,23 @@
 ext(
-%22%22
+HELPBOX_CONTENT
 );%0A%0A

add contents for help box