mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-27 20:27:37 +00:00
Javascript support
This commit is contained in:
parent
88103cefc2
commit
a89948f76d
@ -147,4 +147,9 @@ public class Module_help extends TFM_HTTPD_Module
|
||||
{
|
||||
return ".commandName{font-weight:bold;}.commandDescription{padding-left:15px;}li{margin:.15em;padding:.15em;}";
|
||||
}
|
||||
@Override
|
||||
public String getScript()
|
||||
{
|
||||
return "$(document).ready(function(){console.log(\"Ready\");});";
|
||||
}
|
||||
}
|
||||
|
@ -22,21 +22,26 @@ public abstract class TFM_HTTPD_Module
|
||||
|
||||
public String getBody()
|
||||
{
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getStyle()
|
||||
{
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getScript()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Response getResponse()
|
||||
{
|
||||
return new TFM_HTTPD_PageBuilder(getBody(), getTitle(), getStyle()).getResponse();
|
||||
return new TFM_HTTPD_PageBuilder(getBody(), getTitle(), getStyle(), getScript()).getResponse();
|
||||
}
|
||||
}
|
||||
|
@ -10,24 +10,32 @@ public class TFM_HTTPD_PageBuilder
|
||||
+ "<head>\r\n"
|
||||
+ "<title>{$TITLE}</title>\r\n"
|
||||
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n"
|
||||
+ "<style type=\"text/css\">{$STYLE}</style>\r\n"
|
||||
+ "{$STYLE}"
|
||||
+ "{$SCRIPT}"
|
||||
+ "</head>\r\n"
|
||||
+ "<body>{$BODY}</body>\r\n"
|
||||
+ "<body>\r\n{$BODY}</body>\r\n"
|
||||
+ "</html>\r\n";
|
||||
private static final String STYLE = "<style type=\"text/css\">{$STYLE}</style>\r\n";
|
||||
private static final String SCRIPT =
|
||||
"<script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js\"></script>\r\n"
|
||||
+ "<script src=\"//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js\"></script>\r\n"
|
||||
+ "<script>\r\n{$SCRIPT}\r\n</script>\r\n";
|
||||
//
|
||||
private String body = "";
|
||||
private String title = "";
|
||||
private String style = "";
|
||||
private String body = null;
|
||||
private String title = null;
|
||||
private String style = null;
|
||||
private String script = null;
|
||||
|
||||
public TFM_HTTPD_PageBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
public TFM_HTTPD_PageBuilder(String body, String title, String style)
|
||||
public TFM_HTTPD_PageBuilder(String body, String title, String style, String script)
|
||||
{
|
||||
this.body = body;
|
||||
this.title = title;
|
||||
this.style = style;
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
public void setBody(String body)
|
||||
@ -45,6 +53,11 @@ public class TFM_HTTPD_PageBuilder
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public void setScript(String script)
|
||||
{
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
public Response getResponse()
|
||||
{
|
||||
return new Response(this.toString());
|
||||
@ -53,6 +66,10 @@ public class TFM_HTTPD_PageBuilder
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return TEMPLATE.replace("{$BODY}", body).replace("{$TITLE}", title).replace("{$STYLE}", style);
|
||||
return TEMPLATE
|
||||
.replace("{$BODY}", this.body == null ? "" : this.body)
|
||||
.replace("{$TITLE}", this.title == null ? "" : this.title)
|
||||
.replace("{$STYLE}", this.style == null ? "" : STYLE.replace("{$STYLE}", this.style))
|
||||
.replace("{$SCRIPT}", this.script == null ? "" : SCRIPT.replace("{$SCRIPT}", this.script));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user