--- /dev/null
+// This is a sample config file. Copy to config.js if you need to fiddle with the
+// configuration of the client.
+
+window.TrivabbleConf = {
+ // The amount of time to wait after a connection failure
+ POLLING_DELAY: 2000,
+
+ // Whether WebSockets should be used, if possible
+ ENABLE_WEBSOCKETS: true,
+
+ // Whether Server Sent Events should be used, if available
+ ENABLE_EVENT_SOURCE: true,
+
+ // Max consecutive tries before blacklisting WebSockets for the current session
+ MAX_WEBSOCKET_ERRORS": 1,
+
+ // I don't like trailing commas, here is a nice message for you reading this file :-)
+ HAVE_FUN: true
+};
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
+ <script src="config.js"></script>
<script src="l10n.js"></script>
<script src="alert.js"></script>
<script src="touch2click.js"></script>
"use strict";
const VERSION = 202004121400;
- const POLLING_DELAY = 2000;
- const ENABLE_WEBSOCKETS = true;
- const ENABLE_EVENT_SOURCE = true;
- const MAX_WEBSOCKET_ERRORS = 1;
+
+ const Conf = window.TrivabbleConf || {};
+
+ function setConf(parameterName, defaultValue) {
+ if (typeof Conf[parameterName] === "undefined") {
+ Conf[parameterName] = defaultValue;
+ }
+ }
+
+ setConf("POLLING_DELAY", 2000);
+ setConf("ENABLE_WEBSOCKETS", true);
+ setConf("ENABLE_EVENT_SOURCE", true);
+ setConf("MAX_WEBSOCKET_ERRORS", 1);
const _ = (window.libD && libD.l10n) ? libD.l10n() : function (s) {return s;};
startConnection();
retryPollingTimeout = 0;
},
- delay || POLLING_DELAY
+ delay || Conf.POLLING_DELAY
);
} else {
retriedImmediately = true;
} else {
webSocketErrors++;
- if (webSocketErrors > MAX_WEBSOCKET_ERRORS) {
+ if (webSocketErrors > Conf.MAX_WEBSOCKET_ERRORS) {
blacklistWebsockets = true;
}
}
}
function pollServerWithEventSource() {
- if (canConnect() && ENABLE_EVENT_SOURCE && window.EventSource) {
+ if (canConnect() && Conf.ENABLE_EVENT_SOURCE && window.EventSource) {
closeConnections();
pollingServer = true;
}
function pollServerWithWebSocket() {
- if (canConnect() && ENABLE_WEBSOCKETS && !blacklistWebsockets && window.WebSocket) {
+ if (canConnect() && Conf.ENABLE_WEBSOCKETS && !blacklistWebsockets && window.WebSocket) {
closeConnections();
pollingServer = true;
xhrRequest(cmdsWithContext(cmds), function (xhr) {
if (xhr.readyState === 4) {
if (xhr.status === 0 || xhr.status >= 300) {
- setTimeout(sendCmds.bind(null, cmds), POLLING_DELAY);
+ setTimeout(sendCmds.bind(null, cmds), Conf.POLLING_DELAY);
return;
}
if (!pollingReady) {
startConnection();
- setTimeout(sendCmds, POLLING_DELAY, cmds);
+ setTimeout(sendCmds, Conf.POLLING_DELAY, cmds);
return;
}