Skip to content

Commit

Permalink
iframe page for embedding in 3rd party websites Hack4Eugene#283
Browse files Browse the repository at this point in the history
* Scenario where no internet does not run speed test. Instead submits data to database
* 3 possible messages: a) Speed Results b) No internet - not affordable  c) No internet - no access
  • Loading branch information
Webaissance committed May 10, 2022
1 parent f4c560a commit 606374c
Show file tree
Hide file tree
Showing 32 changed files with 102 additions and 822 deletions.
78 changes: 16 additions & 62 deletions app/assets/region-javascripts/region.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ enable_speed_test = ->
), 200

enable_submit = ->
$('#submit-btn').on 'click', ->
if check_fields_validity()

setTimeout (->
console.log('starting submittal of data...');
$('#submitdatabutton').click()
), 200
# SUBMIT BUTTON
$('#submit-btn').on 'click', ->
console.log('submit-btn clicked');
setTimeout (->
console.log('starting submittal of data...');
$('#new_region_submission').submit();
), 200

numeric_field_constraint = ->
$('.numeric').keydown (e) ->
Expand All @@ -99,9 +99,6 @@ numeric_field_constraint = ->
e.preventDefault()





access_start = ->
#if $('#access_have').prop('checked')
#$('#test-speed-btn').prop('innerHTML', 'Loading...');
Expand All @@ -123,7 +120,7 @@ access_finished = ->
$("#location_success").attr 'value', true
$('#test-speed-btn').prop('disabled', false)
$('.location-warning').addClass('hide')
$('#test-speed-btn').attr('disabled', false)
#$('#test-speed-btn').attr('disabled', false)
$('#test-speed-btn').removeClass('button-disabled')

location_error = ->
Expand Down Expand Up @@ -265,14 +262,18 @@ location_finished = ->
if $('#access_have').prop('checked')
$('#testbutton-div').removeClass('hide')
$('#test-speed-btn').removeClass('button-disabled')
$('#submitbutton-div').addClass('hide')
$('#submit-btn').prop('disabled', true)
#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);
window.scrollBy(0,280)
else
$('#submitbutton-div').removeClass('hide')
$('#submit-speed-btn').removeClass('button-disabled')
$('#submit-btn').prop('disabled', false)
$('#testbutton-div').addClass('hide')
$('#test-speed-btn').addClass('button-disabled')


$ ->
Expand All @@ -286,69 +287,22 @@ $ ->

if thispathone == 'region'
enable_speed_test()
enable_submit()
#set_error_for_invalid_fields()
places_autocomplete()
ajax_interactions()
$(".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
$('#take_test, .nav-link-take-test').on 'click', region_take_the_test
# $('#take_test, .nav-link-take-test').on 'click', region_take_the_test

# Start the test if the user arrived via a link pointing to the test
# if window.location.hash == '#take_test'
window.scrollTo(0, 0)
#window.scrollTo(0, 0)
region_take_the_test()

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

$('#location_button').on 'click', ->
$('#location_button').prop('innerHTML', 'Loading...')
get_location()

$('#submit-btn').on 'click', ->



$('#test-speed-btn').on 'click', ->
if $('#location_geolocation').prop('checked')
if $("#location_success").prop('value') == 'false'
navigator.geolocation.getCurrentPosition set_coords_by_geolocation, block_callback
show_step_one()

if $('#location_address').prop('checked')
if $("#location_success").prop('value') == 'true'
show_step_one()
else
$('#address-input').addClass('error-input')
$('#test-speed-btn').attr('disabled', true)
$('#test-speed-btn').removeClass('button-disabled')

setTimeout (->
$('#address-input').removeClass('error-input');
), 2500

if $('#location_disabled').prop('checked')
show_step_one()

$(".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='region_submission[testing_for]']").is(':checked'));

$('#testing_for_button').on 'click', ->
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)
$('#form-step-1').addClass('hide')

show_step_one = ->
$('#form-step-0').addClass('hide')
$('#form-step-1').removeClass('hide')
$('#form-step-1 input').prop('disabled', false)
$('#test-speed-btn').prop('disabled', false)
$('.location-warning').addClass('hide')
1 change: 1 addition & 0 deletions app/assets/region-stylesheets/region.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ $bg1: url(https://upload.wikimedia.org/wikipedia/commons/c/cd/Central_Oregon_lan
.region .background-container {
background: $bgcolor1;
padding: 20px;
margin-top:20px;
}

.region .container {
Expand Down
12 changes: 12 additions & 0 deletions app/models/region_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ def self.create_region_submission(params)
region_submission.location = 0
#region_submission.location = POINT(longitude, latitude)

if !region_submission.actual_down_speed.present?
region_submission.actual_down_speed = 0
end
if !region_submission.actual_upload_speed.present?
region_submission.actual_upload_speed = 0
end
if !region_submission.ping.present?
region_submission.ping = 0
end

region_submission.save

#region_submission.populate_location
Expand All @@ -158,6 +168,8 @@ def self.get_all_results
def location
end

def language
end

def self.fetch_tileset_groupby(params)
providers = provider_names(params[:provider])
Expand Down
5 changes: 0 additions & 5 deletions app/views/region/_bottom_description.html.erb

This file was deleted.

37 changes: 0 additions & 37 deletions app/views/region/_error_geolocation.html.erb

This file was deleted.

33 changes: 0 additions & 33 deletions app/views/region/_error_position_unavailable.html.erb

This file was deleted.

32 changes: 0 additions & 32 deletions app/views/region/_form_step_1.html.erb

This file was deleted.

80 changes: 0 additions & 80 deletions app/views/region/_form_step_2a.html.erb

This file was deleted.

26 changes: 0 additions & 26 deletions app/views/region/_form_step_2b.html.erb

This file was deleted.

Loading

0 comments on commit 606374c

Please sign in to comment.