Permalink
Browse files

Add mising protocol to user-entered URLs

  • Loading branch information...
alexanderte committed Apr 8, 2013
1 parent 6e5c88d commit fb0b8e1c41ee19de9e453751ba8178031e744d13
Showing with 11 additions and 3 deletions.
  1. +1 −1 frontend/index.html
  2. +8 −0 frontend/models/test-run.coffee
  3. +1 −1 frontend/views/home.coffee
  4. +1 −1 frontend/views/navbar.coffee
View
@@ -41,7 +41,7 @@
<h1>User Testing Tool</h1>
<p class="lead">The User Testing Tool (UTT) is a research demonstrator to combine user testing with automated testing services to improve the accessibility and usability of web sites.</p>
<p class="lead">
- To get started, enter the URL of a web page to test.
+ To get started, enter a web page to test.
</p>
<form class="form-inline" onsubmit="return false;">
<fieldset>
@@ -41,4 +41,12 @@ define ['backbone', 'socketio', 'collections/tests'], (Backbone, io, Tests) ->
this.get('currentTest') == 0
setAnswer: (answer) ->
this.verifyTests()[this.get('currentTest')].set('answer', answer)
+ setWebPage: (url) ->
+ addProtocol = (url) ->
+ if url.substring(0, 6) isnt 'http://' or url.substring(0, 7) isnt 'https://'
+ 'http://' + url
+ else
+ url
+
+ this.set 'webPage', addProtocol(url)
}
@@ -37,5 +37,5 @@ define ['backbone', 'underscore', 'jquery'], (Backbone, _, $) ->
if this.model.get('webPage') == $('#web-page-2').val()
this.options.router.navigate 'test', true
else
- this.model.set('webPage', $('#web-page-2').val())
+ this.model.setWebPage($('#web-page-2').val())
}
@@ -43,5 +43,5 @@ define ['jquery', 'underscore', 'backbone'], ($, _, Backbone) ->
this.$el.html(_.template($('#navbar-template').html(), { webPage: this.model.get('webPage') }))
events: { 'click button#set-web-page': 'setWebPage' }
setWebPage: () ->
- this.model.set('webPage', $('#web-page').val())
+ this.model.setWebPage($('#web-page').val())
}

0 comments on commit fb0b8e1

Please sign in to comment.