forked from Qortal/qortal
Removed unnecessary javascript navigation code.
This commit is contained in:
parent
ccf8773b18
commit
553de5a873
@ -26,35 +26,6 @@ public class HTMLParser {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject javascript used for back/forward navigation, and other system-level features
|
||||
*/
|
||||
public void injectJavascript() {
|
||||
String script = "<script>\n" +
|
||||
" window.addEventListener('message', (event) => {\n" +
|
||||
" if (event.data != null && event.data.action != null) {\n" +
|
||||
" if (event.data.action === 'nav_back') {\n" +
|
||||
" window.history.back();\n" +
|
||||
" }\n" +
|
||||
" if (event.data.action === 'nav_forward') {\n" +
|
||||
" window.history.forward();\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }, false);\n" +
|
||||
"</script>\n";
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
// FUTURE: we may want to add it to the <head>, and maybe put the js itself into an external file
|
||||
outputStream.write(script.getBytes());
|
||||
outputStream.write(this.data);
|
||||
this.data = outputStream.toByteArray();
|
||||
|
||||
} catch (IOException e) {
|
||||
LOGGER.info("Unable to inject javascript: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find relative links and prefix them with the resource ID, using Jsoup
|
||||
* @param path
|
||||
|
@ -94,7 +94,6 @@ public class ArbitraryDataRenderer {
|
||||
// HTML file - needs to be parsed
|
||||
byte[] data = Files.readAllBytes(Paths.get(filePath)); // TODO: limit file size that can be read into memory
|
||||
HTMLParser htmlParser = new HTMLParser(resourceId, inPath, prefix, usePrefix, data);
|
||||
htmlParser.injectJavascript();
|
||||
htmlParser.replaceRelativeLinks(filename);
|
||||
response.setContentType(context.getMimeType(filename));
|
||||
response.setContentLength(data.length);
|
||||
|
Loading…
Reference in New Issue
Block a user