Commit 15c93119 authored by Mathijs den Burger's avatar Mathijs den Burger

CMS7-8442: check JavaScript with jslint

The circular dependency of functions connect -> onClose -> reconnect is valid, so added 'reconnect' as a global to the jslint config to make it happy.
parent 0665840d
......@@ -43,6 +43,7 @@
<commons-io.version>1.4</commons-io.version>
<commons-lang.version>2.6</commons-lang.version>
<easymock.version>3.0</easymock.version>
<jslint.plugin.version>1.0.1</jslint.plugin.version>
<junit.version>4.11</junit.version>
</properties>
......@@ -124,4 +125,29 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jslint-maven-plugin</artifactId>
<version>${jslint.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>jslint</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceJsFolder>${basedir}/src/main/resources</sourceJsFolder>
<predefinedVars>
console,
reconnect, <!-- ignore valid circular function dependency: connect -> onClose -> reconnect -->
window
</predefinedVars>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -25,6 +25,10 @@
reconnectAttempts = 0,
websocket;
function serverUrl() {
return "ws://" + document.location.host + CONTEXT_PATH + AUTO_RELOAD_PATH;
}
function reloadPage() {
window.document.location.reload();
}
......@@ -63,6 +67,12 @@
}
}
function onClose(event) {
if (!isReloadingPage && hasBeenConnected) {
reconnect();
}
}
function connect() {
log("connecting...");
websocket = new window.WebSocket(serverUrl());
......@@ -91,16 +101,6 @@
}
}
function onClose(event) {
if (!isReloadingPage && hasBeenConnected) {
reconnect();
}
}
function serverUrl() {
return "ws://" + document.location.host + CONTEXT_PATH + AUTO_RELOAD_PATH;
}
if (window.addEventListener && window.WebSocket) {
window.addEventListener("load", connect);
window.addEventListener("beforeunload", disconnect);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment