Skip to content

Commit

Permalink
Minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LEO-E-100 committed Aug 28, 2017
1 parent 01b2800 commit 8db306b
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 218 deletions.
206 changes: 97 additions & 109 deletions .idea/workspace.xml

Large diffs are not rendered by default.

92 changes: 46 additions & 46 deletions static/js/main.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
var rootUrl = 'http://localhost:8080/DWP-P2-DR/app/claimant'
/**
* Created by Leo on 16/07/2017.
*/

$(document)
.ready(
function() {
if (window.location.href == "http://localhost:8080/TaxCredit/tcpage1.html") {
var mess = document.getElementById('output').innerHTML;
if (!localStorage.message){
document.getElementById('output').innerHTML = "Hello and welcome to the Tax Credit Application page";
} else {
document.getElementById('output').innerHTML = localStorage.message;
}
}
});
$('#btnFindClaimantbyNino').click(function() {
findClaimantByNino();
return false;
});
function submit_feedback(){
var stars = document.getElementsByClassName('active');
var rating = stars.length;


function findClaimantByNino() {
var url = window.location.href.split('/');
var service = url[url.length - 1];
console.log(service);
var data = {dm: service, stars: rating};
console.log(data);
$.ajax({
statusCode: {
500: function() {
alert("error");
}
},
type : "POST",
url : "/firebase",
data: JSON.stringify(data),
success: function(result) {
console.log("Success!");
},
error: function(error) {
console.log(error);
}
});
// var data_1 = JSON.stringify(data);
// console.log(data_1);
window.location.replace('/pages/thankyou');
}

var nino = $('#nino').val();
localStorage.setItem("nino", nino);
// Could be global. Takes the place of all following error callbacks.
$(function() {
$.ajaxSetup({
error : function(jqXHR, exception) {
message="Incorrect National Insurance number. Please try again"
localStorage.setItem("message", message);
if (jqXHR.status === 0) {
console.log('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
console.log('404: requested page not found. [404]');
} else if (jqXHR.status == 500) {
console.log('500: internal Server Error [500].');
} else if (exception === 'parsererror') {
console.log('parsererrr: requested JSON parse failed.');
} else if (exception === 'timeout') {
console.log('timeout: time out error.');
} else if (exception === 'abort') {
console.log('abort: AJAX request aborted.');
} else {
console.log('Uncaught Error.\n' + jqXHR.responseText);
}
}
});
});
document.getElementById('submit').addEventListener('click', submit_feedback)

document.getElementById('ninoForm').submit();
var stars = document.getElementsByClassName('fa-star')
Array.prototype.forEach.call(stars, function(star){
star.addEventListener('click', choose_rating)
})

function choose_rating(event){
console.log(event.target.id)
var id = event.target.id
var stars = document.getElementsByClassName('fa-star')
Array.prototype.forEach.call(stars, function(star){
star.classList.remove("active")
if (star.id <= id){
star.classList.add("active")
}
})
}

File renamed without changes.
53 changes: 0 additions & 53 deletions static/js/main3.js

This file was deleted.

53 changes: 53 additions & 0 deletions static/js/main_deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
var rootUrl = 'http://localhost:8080/DWP-P2-DR/app/claimant'

$(document)
.ready(
function() {
if (window.location.href == "http://localhost:8080/TaxCredit/tcpage1.html") {
var mess = document.getElementById('output').innerHTML;
if (!localStorage.message){
document.getElementById('output').innerHTML = "Hello and welcome to the Tax Credit Application page";
} else {
document.getElementById('output').innerHTML = localStorage.message;
}
}
});
$('#btnFindClaimantbyNino').click(function() {
findClaimantByNino();
return false;
});


function findClaimantByNino() {

var nino = $('#nino').val();
localStorage.setItem("nino", nino);
// Could be global. Takes the place of all following error callbacks.
$(function() {
$.ajaxSetup({
error : function(jqXHR, exception) {
message="Incorrect National Insurance number. Please try again"
localStorage.setItem("message", message);
if (jqXHR.status === 0) {
console.log('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
console.log('404: requested page not found. [404]');
} else if (jqXHR.status == 500) {
console.log('500: internal Server Error [500].');
} else if (exception === 'parsererror') {
console.log('parsererrr: requested JSON parse failed.');
} else if (exception === 'timeout') {
console.log('timeout: time out error.');
} else if (exception === 'abort') {
console.log('abort: AJAX request aborted.');
} else {
console.log('Uncaught Error.\n' + jqXHR.responseText);
}
}
});
});

document.getElementById('ninoForm').submit();

}

10 changes: 1 addition & 9 deletions templates/ratings.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@
<div class='container'>
<h1 class='title'>NHS feedback</h1>

<div class="attendance section">
<p>Did you attend {{ name }}?</p>
<form action="" method="post">
<input type="radio" name="attended" id="TEST_1" value="YES" /> Yes
<input type="radio" name="attended" id="TEST_2" value="NO" /> No
</form>
</div>

<p>How would you rate your service at {{name}} today? (Your feedback is totally anonymous)</p>

<div class='icons section'>
Expand Down Expand Up @@ -56,5 +48,5 @@ <h1 class='title'>NHS feedback</h1>
</div>
</div>
</body>
<script src="/static/js/main3.js"></script>
<script src="/static/js/main.js"></script>
</html>
2 changes: 1 addition & 1 deletion text_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def send_messages(name, phone_number, service_id, service_name, wait_time):
)
print(message_1.sid)

# For demo purposes this is set to one minute.
# For demo purposes this is set to an arbitrary.
# In reality will be set to variable wait_time_seconds
time.sleep(15)

Expand Down

0 comments on commit 8db306b

Please sign in to comment.