Skip to content

Commit

Permalink
Merge pull request #296 from webaissance/region
Browse files Browse the repository at this point in the history
#283 iframe page for embedding in 3rd party websites
  • Loading branch information
webaissance authored Apr 20, 2022
2 parents ce021da + 784ca1e commit 0a9c411
Show file tree
Hide file tree
Showing 39 changed files with 785 additions and 250 deletions.
31 changes: 21 additions & 10 deletions app/assets/region-javascripts/region.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ disable_form_inputs = ->
$('#form-container .form-fields input').prop('disabled', true)

set_coords = (accuracy, latitude, longitude) ->
$('#submission_latitude').attr 'value', latitude
$('#submission_longitude').attr 'value', longitude
$("input[name='submission[accuracy]']").attr 'value', accuracy
$('#region_submission_latitude').attr 'value', latitude
$('#region_submission_longitude').attr 'value', longitude
$("input[name='region_submission[accuracy]']").attr 'value', accuracy

location_finished()

Expand Down Expand Up @@ -70,7 +70,7 @@ enable_speed_test = ->
$('#testing_speed').modal('show');

setTimeout (->
console.log('starting ndt test...');
console.log('starting regional ndt test...');
$('#region_start_ndt_test').click()
), 200

Expand Down Expand Up @@ -141,6 +141,10 @@ places_autocomplete = ->
if eventResult
latlng = eventResult.suggestion.latlng
set_coords(50, latlng.lat, latlng.lng)
$('#region_submission_address').attr 'value', eventResult.suggestion.value
$('#region_submission_zip_code').attr 'value',eventResult.suggestion.postcode
#console.log('address:'+eventResult.suggestion.value)
#console.log('zip:'+eventResult.suggestion.postcode)
placesAutocomplete

# This function only works on the region page
Expand Down Expand Up @@ -225,6 +229,13 @@ location_finished = ->
if $('#address-input').prop('value', 'true')
$('#testbutton-div').removeClass('hide')
$('#test-speed-btn').removeClass('button-disabled')
#$('#region_submission_address').attr 'value', $('#address-input').val();
#console.log('address-input val:' + $('#address-input').val());
#console.log('address-input prop val:' + $('#address-input').prop('value'));
#console.log('address-input placeholder:' + $('#address-input').attr('placeholder'));
#console.log('address-input textContent:' + $('#address-input').textContent);



#$("#address-input").on 'change', ->
#if $('#address-input').prop('value', 'true')
Expand All @@ -246,7 +257,7 @@ $ ->
#set_error_for_invalid_fields()
places_autocomplete()
ajax_interactions()
$(".checkboxes-container input[name='submission[location]']").each ->
$(".checkboxes-container input[name='region_submission[location]']").each ->
$(this).prop('checked', false)

# Start the test when the user clicks either the button or the nav link
Expand All @@ -259,7 +270,7 @@ $ ->

$('[rel="tooltip"]').tooltip({'placement': 'top'});
$('#testing_for_button').attr('disabled', true)
$(".checkboxes-container input[name='submission[testing_for]']").prop('checked', false)
$(".checkboxes-container input[name='region_submission[testing_for]']").prop('checked', false)

$('#location_button').on 'click', ->
$('#location_button').prop('innerHTML', 'Loading...')
Expand All @@ -286,14 +297,14 @@ $ ->
if $('#location_disabled').prop('checked')
show_step_one()

$(".checkboxes-container input[name='submission[testing_for]']").on 'change', ->
$(".checkboxes-container input[name='submission[testing_for]']").each ->
$(".checkboxes-container input[name='region_submission[testing_for]']").on 'change', ->
$(".checkboxes-container input[name='region_submission[testing_for]']").each ->
$(this).prop('checked', false)
$(this).prop('checked', true)
$('#testing_for_button').attr('disabled', !$(".checkboxes-container input[name='submission[testing_for]']").is(':checked'));
$('#testing_for_button').attr('disabled', !$(".checkboxes-container input[name='region_submission[testing_for]']").is(':checked'));

$('#testing_for_button').on 'click', ->
testing_for = $(".checkboxes-container input[name='submission[testing_for]']:checked").data('target')
testing_for = $(".checkboxes-container input[name='region_submission[testing_for]']:checked").data('target')
$(testing_for).removeClass('hide')
$(testing_for + ' input').prop('disabled', false)
$(testing_for + ' select').prop('disabled', false)
Expand Down
34 changes: 17 additions & 17 deletions app/assets/region-javascripts/region_ndt_d3.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

function RegionNDTmeter(body_element) {
function NDTmeter(body_element) {
this.meter = undefined;
this.arc = undefined;
this.state = undefined;
Expand Down Expand Up @@ -37,13 +37,13 @@ function RegionNDTmeter(body_element) {
this.create();
}

RegionNDTmeter.prototype.update_display = function (status, information) {
NDTmeter.prototype.update_display = function (status, information) {
d3.select('#ndt-status').text(status);
d3.select('text.information').text(information);
return;
};

RegionNDTmeter.prototype.create = function () {
NDTmeter.prototype.create = function () {

var ndtDiv = d3.select('#ndt-div');
var width = $('#ndt-div').data('width');
Expand Down Expand Up @@ -99,7 +99,7 @@ RegionNDTmeter.prototype.create = function () {
return;
};

RegionNDTmeter.prototype.onstart = function (server) {
NDTmeter.prototype.onstart = function (server) {
var that = this;
var meter_movement = function () {
that.meter_movement();
Expand All @@ -112,13 +112,13 @@ RegionNDTmeter.prototype.onstart = function (server) {
d3.timer(meter_movement);
};

RegionNDTmeter.prototype.onstatechange = function (returned_message) {
NDTmeter.prototype.onstatechange = function (returned_message) {
this.state = returned_message;
this.time_switched = new Date().getTime();
this.update_display(this.NDT_STATUS_LABELS[returned_message], '...');
};

RegionNDTmeter.prototype.onprogress = function (returned_message, passedResults) {
NDTmeter.prototype.onprogress = function (returned_message, passedResults) {
var throughputRate;
var progress_label = this.NDT_STATUS_LABELS[this.state];

Expand All @@ -130,7 +130,7 @@ RegionNDTmeter.prototype.onprogress = function (returned_message, passedResults)
}
};

RegionNDTmeter.prototype.onfinish = function (passed_results) {
NDTmeter.prototype.onfinish = function (passed_results) {
console.log(passed_results)
var resultString,
dy_current,
Expand All @@ -149,26 +149,26 @@ RegionNDTmeter.prototype.onfinish = function (passed_results) {
passed_results.hasOwnProperty(metric_name)) {
if (metric_name == 'MinRTT') {
resultString = Number(passed_results[metric_name]).toFixed(2);
if (document.getElementById('submission_ping'))
if (document.getElementById('region_submission_ping'))
{
document.getElementById('submission_ping').value = resultString;
document.getElementById('region_submission_ping').value = resultString;
}

} else {
resultString = Number(passed_results[metric_name] /
1000).toFixed(2);
if (metric_name == 's2cRate') {
if (document.getElementById('submission_actual_down_speed'))
if (document.getElementById('region_submission_actual_down_speed'))
{
document.getElementById('submission_actual_down_speed').value = resultString;
document.getElementById('region_submission_actual_down_speed').value = resultString;
}


}
if (metric_name == 'c2sRate') {
if (document.getElementById('submission_actual_upload_speed'))
if (document.getElementById('region_submission_actual_upload_speed'))
{
document.getElementById('submission_actual_upload_speed').value = resultString;
document.getElementById('region_submission_actual_upload_speed').value = resultString;
}

}
Expand All @@ -182,17 +182,17 @@ RegionNDTmeter.prototype.onfinish = function (passed_results) {

d3.selectAll("#progress-meter .foreground").classed("complete", true);

$('#new_submission').submit();
$('#new_region_submission').submit();
document.getElementById('ndt-div').innerHTML = '<h3>Submitting Data...</h3>';
};

RegionNDTmeter.prototype.onerror = function (error_message) {
NDTmeter.prototype.onerror = function (error_message) {
d3.timer.flush();
d3.selectAll("#progress-meter").classed("progress-error", true);
this.update_display(error_message, "!");
};

RegionNDTmeter.prototype.reset_meter = function () {
NDTmeter.prototype.reset_meter = function () {
d3.select('#s2cRate')
.text('?')
.classed('metric-value', false)
Expand All @@ -206,7 +206,7 @@ RegionNDTmeter.prototype.reset_meter = function () {
return;
};

RegionNDTmeter.prototype.meter_movement = function () {
NDTmeter.prototype.meter_movement = function () {
var end_angle,
start_angle,
progress_label,
Expand Down
8 changes: 4 additions & 4 deletions app/assets/region-javascripts/region_ndt_speed_test.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
region_bind_ndt_speed_calculation = ->
RegionNDT_meter = new RegionNDTmeter('#ndt-svg')
RegionNDT_meter = new NDTmeter('#ndt-svg')
console.log('region_bind_ndt_speed_calculation');
$('#region_start_ndt_test').on 'click', ->
# Note: rates are in kbits/s, latency is in milliseconds.
Expand Down Expand Up @@ -31,7 +31,7 @@ region_bind_ndt_speed_calculation = ->
s2cRate = data.LastClientMeasurement.MeanClientMbps * 1000
minRTT = (data.LastServerMeasurement.TCPInfo.MinRTT / 1000).toFixed(0)
RegionNDT_meter.onstatechange('finished_s2c')
console.log('Download complete: ' + s2cRate.toFixed(2) + ' Kb/s')
console.log('Regional Download complete: ' + s2cRate.toFixed(2) + ' Kb/s')
RegionNDT_meter.onstatechange('running_c2s')

uploadMeasurement: (data) ->
Expand All @@ -43,7 +43,7 @@ region_bind_ndt_speed_calculation = ->
uploadComplete: (data) ->
c2sRate = (data.LastServerMeasurement.TCPInfo.BytesReceived /
data.LastServerMeasurement.TCPInfo.ElapsedTime * 8) * 1000
console.log('Upload complete: ' + c2sRate.toFixed(2) + ' Kb/s')
console.log('Regional Upload complete: ' + c2sRate.toFixed(2) + ' Kb/s')
RegionNDT_meter.onfinish({
s2cRate: s2cRate,
c2sRate: c2sRate,
Expand All @@ -60,6 +60,6 @@ region_bind_ndt_speed_calculation = ->
window.NdtSpeedTest || (window.NdtSpeedTest = {})

NdtSpeedTest.init = ->
console.log('NdtSpeedTest.init');
console.log('RegionNdtSpeedTest.init 1');
region_bind_ndt_speed_calculation()
).call(this)
65 changes: 57 additions & 8 deletions app/assets/region-stylesheets/region-theme-all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@


$region: all;
$color1: #003399; /* primary color */
$color2: #33cccc; /* secondary color */
$bgcolor1: #EEE;
$bgcolor2: #EED;
$bgcolor3: #DEE;
$bgcolor4: #EDE;
$bgcolor5: #DED;
$bgcolor6: #222;
$bgcolor6: #222; /* secondary color */
$bgcolor7: #003399; /* primary color */
$border-radius1: 10px;
$box-shadow1: 7px 7px 7px #777777;
$text-shadow1: 5px 5px 5px #999;
$border1: 0;
$buttonbg1: #888;
$buttoncolor1: #FFFFFF;
$buttonhovercolor1: #000;
$fontsize1: 16px;
$padding1: 30px 50px 30px 50px;
$margin1: 0px auto 20px;
Expand All @@ -32,6 +34,14 @@ $bg1: #FFFFFF;

}

.region.#{$region} h1 {
color: $color2;
}

.region.#{$region} h2 {
color: $color1;
}

.region.#{$region} #region-form-step-0{
margin-bottom:200px;
}
Expand Down Expand Up @@ -116,13 +126,13 @@ $bg1: #FFFFFF;

.region.#{$region} #form-container p {
font-size: 18px;
color: $bgcolor6;
color: $color1;
line-height: 28px;
}

.region.#{$region} .checkbox label {
font-size: 18px;
color: $bgcolor6;
color: $color1;
line-height: 20px;
}

Expand Down Expand Up @@ -158,11 +168,27 @@ $bg1: #FFFFFF;
padding: 20px;
}

.region.#{$region} button#test-speed-btn {
border-radius: 20px;
transition: .5s ease-in-out;
font-size:26px;
width: 250px;
padding: 20px;
background-color:$bgcolor6;
}

.region.#{$region} button#test-speed-btn:hover {
background-color:#538b8b;
background-color:$bgcolor7;
opacity:1;
}

.region.#{$region} .export-btn {
background-color:$bgcolor6;
}

.region.#{$region} .export-btn:hover {
background-color:$bgcolor7;
}

.region.#{$region} button#enterpricebtn {
margin-top: 10px;
Expand All @@ -171,11 +197,34 @@ $bg1: #FFFFFF;
color: $buttoncolor1;
border-radius: 10px;
border: 0;
background-color: $buttonbg1;
background-color: $bgcolor6;
font-weight: 600;
transition:0.5s ease-in-out;
}

.region.#{$region} button#enterpricebtn:hover {
background-color: $buttonhovercolor1;
background-color: $bgcolor7;
}

.region.#{$region} .background-container {
background: $bgcolor1;
padding: 20px;
}

.region.#{$region} .container {
padding: 30px;
}

.region.#{$region} h3 {
color: $color1;
}

.region.#{$region} h4 {
color: $color2;
}

.region.#{$region} table.col-md-6.text-center {
float: none;
margin: auto;
width: auto;
}
Loading

0 comments on commit 0a9c411

Please sign in to comment.