Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change href of the access-the-api button on menu so it loads it automatically from the config.js #108

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}
});