Skip to content
This repository has been archived by the owner on Dec 5, 2020. It is now read-only.

Commit

Permalink
Switch javascript:void(0) to preventDefault
Browse files Browse the repository at this point in the history
Stack Exchange says this is a better solution.
  • Loading branch information
aghorler committed Sep 22, 2017
1 parent 455799b commit d4d6d66
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
17 changes: 6 additions & 11 deletions public/js/custom.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* Generic function to toggle the display of an element. */
function toggleDisplay(){
event.preventDefault();

var element = document.getElementById(event.target.id + "-content");

if(element.style.display == "none"){
Expand All @@ -25,7 +27,7 @@ function randomiseTeam(){
/* https://stackoverflow.com/a/6274381 */
function shuffle(a){
var j, x, i;
for (i = a.length; i; i--) {
for(i = a.length; i; i--){
j = Math.floor(Math.random() * i);
x = a[i - 1];
a[i - 1] = a[j];
Expand Down Expand Up @@ -61,20 +63,11 @@ function randomiseTeam(){

/* Function to automatically populate relevant fields when student checkbox is checked on registration page. */
function studentFill(){
if(document.getElementById("student").checked){
if(this.checked){
document.getElementById("title").value = "Student";
document.getElementById("title").readOnly = true;
document.getElementById("sector").value = "None";
document.getElementById("sector").readOnly = true;
document.getElementById("experience").value = 0;
}
else{
document.getElementById("title").value = null;
document.getElementById("title").readOnly = false;
document.getElementById("sector").value = null;
document.getElementById("sector").readOnly = false;
document.getElementById("experience").value = null;
}
}

/* Function to submit POST data to server with form in the background. */
Expand All @@ -85,6 +78,8 @@ function submitForm(){

/* Function to autofill skills from GitHub. */
function autoFill(){
event.preventDefault();

document.getElementById("github-error-generic").style.display = "none";
document.getElementById("github-error-username").style.display = "none";

Expand Down
2 changes: 1 addition & 1 deletion resources/views/auth/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@

<div class="form-group">
<p align ="center">
<a href="javascript:void(0)" id="autofill-btn" class="btn btn-primary">
<a id="autofill-btn" class="btn btn-primary">
Autofill skills from GitHub
</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@

<div class="form-group">
<p align ="center">
<a href="javascript:void(0)" id="autofill-btn" class="btn btn-primary">
<a id="autofill-btn" class="btn btn-primary">
Autofill skills from GitHub
</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<div id="confirm-delete-content" style="display: none;">
<p>
Confirm deletion: <a id="really-confirm-delete" class="text-danger" href="javascript:void(0)">I really want to delete my account.</a>
Confirm deletion: <a id="really-confirm-delete" class="text-danger" href="#">I really want to delete my account.</a>
</p>

<div id="really-confirm-delete-content" style="display: none;">
Expand Down

0 comments on commit d4d6d66

Please sign in to comment.