Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jQuery dependency #17

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ docs/dist
node_modules
npm-debug.log
*.map
package-lock.json
149 changes: 80 additions & 69 deletions dist/rmbtws.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
* @returns {}
*/

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RMBTTest = RMBTTest;

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

function RMBTTest(rmbtTestConfig, rmbtControlServer) {
var _server_override = "wss://developv4-rmbtws.netztest.at:19002";

Expand Down Expand Up @@ -155,7 +162,7 @@ function RMBTTest(rmbtTestConfig, rmbtControlServer) {
//@TODO: Nicer
//if there is testVisualization, make use of it!
if (TestEnvironment.getTestVisualization() !== null) {
TestEnvironment.getTestVisualization().updateInfo(response.test_server_name, response.client_remote_ip, response.provider, response.test_uuid);
TestEnvironment.getTestVisualization().updateInfo(response.test_server_name, response.client_remote_ip, response.provider, response.test_uuid, response.open_test_uuid);
}

var continuation = function continuation() {
Expand Down Expand Up @@ -271,6 +278,7 @@ function RMBTTest(rmbtTestConfig, rmbtControlServer) {
if (_rmbtTestResult !== null) {
if (_intermediateResult.status === TestState.PING || _intermediateResult.status === TestState.DOWN) {
_intermediateResult.pingNano = _rmbtTestResult.ping_server_median;
_intermediateResult.pings = _rmbtTestResult.pings;
}

if (_intermediateResult.status === TestState.DOWN || _intermediateResult.status == TestState.INIT_UP) {
Expand Down Expand Up @@ -684,6 +692,7 @@ function RMBTTest(rmbtTestConfig, rmbtControlServer) {

var onsuccess = function onsuccess(pingResult) {
thread.result.pings.push(pingResult);
_rmbtTestResult.pings = [].concat(_toConsumableArray(thread.result.pings));

//use first two pings to do a better approximation of the remaining time
if (pingsRemaining === _rmbtTestConfig.numPings - 1) {
Expand Down Expand Up @@ -1352,8 +1361,11 @@ if (typeof window.setCookie === 'undefined') {
document.cookie = cookie_name + "=" + c_value + " path=/;";
};
}
"use strict";
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* Handles the communication with the ControlServer
* @param rmbtTestConfig RMBT Test Configuratio
Expand All @@ -1362,13 +1374,14 @@ if (typeof window.setCookie === 'undefined') {
* 'submit': Function to be called after result submission: function(event)
* @returns Object
*/
var RMBTControlServerCommunication = function RMBTControlServerCommunication(rmbtTestConfig, options) {
var RMBTControlServerCommunication = exports.RMBTControlServerCommunication = function RMBTControlServerCommunication(rmbtTestConfig, options) {
var _rmbtTestConfig = rmbtTestConfig;
var _logger = log.getLogger("rmbtws");

options = options || {};
var _registrationCallback = options.register || null;
var _submissionCallback = options.submit || null;
var headers = options.headers || {
'Content-Type': 'application/json'
};

return {
/**
Expand All @@ -1394,30 +1407,28 @@ var RMBTControlServerCommunication = function RMBTControlServerCommunication(rmb
json_data['prefer_server'] = UserConf.preferredServer;
json_data['user_server_selection'] = userServerSelection;
}

var response = void 0;
$.ajax({
url: _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerRegistrationResource,
type: "post",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(json_data),
success: function success(data) {
response = data;
var config = new RMBTControlServerRegistrationResponse(data);
onsuccess(config);
},
error: function error(data) {
response = data;
_logger.error("error getting testID");
onerror();
},
complete: function complete() {
if (_registrationCallback != null && typeof _registrationCallback === 'function') {
_registrationCallback({
response: response,
request: json_data
});
}
fetch(_rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerRegistrationResource, {
method: 'POST',
headers: headers,
body: JSON.stringify(json_data)
}).then(function (res) {
return res.json();
}).then(function (data) {
response = data;
var config = new RMBTControlServerRegistrationResponse(data);
onsuccess(config);
}).catch(function (reason) {
response = reason;
_logger.error("error getting testID");
onerror();
}).finally(function () {
if (_registrationCallback != null && typeof _registrationCallback === 'function') {
_registrationCallback({
response: response,
request: json_data
});
}
});
},
Expand All @@ -1427,20 +1438,17 @@ var RMBTControlServerCommunication = function RMBTControlServerCommunication(rmb
*
*/
getDataCollectorInfo: function getDataCollectorInfo() {
$.ajax({
url: _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerDataCollectorResource,
type: "get",
dataType: "json",
contentType: "application/json",
success: function success(data) {
_rmbtTestConfig.product = data.agent.substring(0, Math.min(150, data.agent.length));
_rmbtTestConfig.model = data.product;
//_rmbtTestConfig.platform = data.product;
_rmbtTestConfig.os_version = data.version;
},
error: function error(data) {
_logger.error("error getting data collection response");
}
fetch(_rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerDataCollectorResource, {
method: 'GET',
headers: headers
}).then(function (res) {
return res.json();
}).then(function (data) {
_rmbtTestConfig.product = data.agent.substring(0, Math.min(150, data.agent.length));
_rmbtTestConfig.model = data.product;
_rmbtTestConfig.os_version = data.version;
}).catch(function () {
_logger.error("error getting data collection response");
});
},

Expand All @@ -1456,39 +1464,39 @@ var RMBTControlServerCommunication = function RMBTControlServerCommunication(rmb

var json = JSON.stringify(json_data);
_logger.debug("Submit size: " + json.length);

var response = void 0;
$.ajax({
url: _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerResultResource,
type: "post",
dataType: "json",
contentType: "application/json",
data: json,
success: function success(data) {
response = data;
_logger.debug("https://develop.netztest.at/en/Verlauf?" + json_data.test_uuid);
//window.location.href = "https://develop.netztest.at/en/Verlauf?" + data.test_uuid;
onsuccess(true);
},
error: function error(data) {
response = data;
_logger.error("error submitting results");
onerror(false);
},
complete: function complete() {
if (_submissionCallback !== null && typeof _submissionCallback === 'function') {
_submissionCallback({
response: response,
request: json_data
});
}
fetch(_rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerResultResource, {
method: 'POST',
headers: headers,
body: json
}).then(function (res) {
return res.json();
}).then(function (data) {
response = data;
_logger.debug(json_data.test_uuid);
onsuccess(true);
}).catch(function (reason) {
response = reason;
_logger.error("error submitting results");
onerror(false);
}).finally(function () {
if (_submissionCallback !== null && typeof _submissionCallback === 'function') {
_submissionCallback({
response: response,
request: json_data
});
}
});
}
};
};
"use strict";

var TestEnvironment = function () {
Object.defineProperty(exports, "__esModule", {
value: true
});
var TestEnvironment = exports.TestEnvironment = function () {
var testVisualization = null;
var geoTracker = null;

Expand Down Expand Up @@ -1595,7 +1603,7 @@ var TestVisualization = function () {
* @param providerName
* @param testUUID
*/
TestVisualization.prototype.updateInfo = function (serverName, remoteIp, providerName, testUUID) {};
TestVisualization.prototype.updateInfo = function (serverName, remoteIp, providerName, testUUID, openTestUUID) {};

/**
* Will be called from Websockettest as soon as the current status changes
Expand Down Expand Up @@ -1634,7 +1642,10 @@ var TestVisualization = function () {
}();
"use strict";

var RMBTTestConfig = function () {
Object.defineProperty(exports, "__esModule", {
value: true
});
var RMBTTestConfig = exports.RMBTTestConfig = function () {
RMBTTestConfig.prototype.version = "0.3"; //minimal version compatible with the test
RMBTTestConfig.prototype.language;
RMBTTestConfig.prototype.uuid = "";
Expand Down
Loading