Skip to content

Commit

Permalink
Merge pull request #108 from guadaltel/issue-107
Browse files Browse the repository at this point in the history
change href of the access-the-api button on menu so it loads it automatically from the config.js
  • Loading branch information
veronicamonaco authored Sep 6, 2024
2 parents 9617a29 + fd7b9a2 commit aa0eb21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 1 addition & 2 deletions home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@
class="ecl-link ecl-link--standalone ecl-menu__sublink">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
<li class="ecl-menu__subitem" data-ecl-menu-subitem="true"><span
class="ecl-menu__sublink">Validator API</span></li>
<li class="ecl-menu__subitem" data-ecl-menu-subitem="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="" onclick= "location.href=swaggerURL"
class="ecl-link ecl-link--standalone ecl-menu__sublink">Access the API</a></li>
<li class="ecl-menu__subitem" data-ecl-menu-subitem="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="api-link" class="ecl-link ecl-link--standalone ecl-menu__sublink">Access the API</a></li>
<li class="ecl-menu__subitem" data-ecl-menu-subitem="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/INSPIRE-MIF/helpdesk-validator/tree/master/training%20material/2019-10-01%2B02%20JRC%20Workshop/Step-by-step%20example%20-%20API"
class="ecl-link ecl-link--standalone ecl-menu__sublink">Example of API usage</a></li>
<li class="ecl-menu__subitem" data-ecl-menu-subitem="true"><span
Expand Down
18 changes: 17 additions & 1 deletion js/home/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,20 @@ if (validatorVersionLabel !== null && validatorVersionLabel !== undefined) {

// Insert the comment node right at the start of the head
document.head.insertBefore(commentNode, document.head.firstChild);
}
}


document.addEventListener('DOMContentLoaded', function () {
// Check if swaggerURL is defined
if (typeof swaggerURL !== 'undefined' && swaggerURL) {
// Set the href attribute of the anchor tag
const apiLink = document.getElementById('api-link');
if (apiLink) {
apiLink.href = swaggerURL;
} else {
console.warn('API link element not found.');
}
} else {
console.error('swaggerURL is not defined in config.js');
}
});

0 comments on commit aa0eb21

Please sign in to comment.