let gds = { settings: { enableTrace: true, enableDebug: true }, convertPage: function(pageTitle) { var listboxOptions = []; this.changePageTitle(pageTitle); this.changeFormTitle(); this.runMutationObserver(listboxOptions); this.styleErrors(); this.changeSecurityErrorText(); this.changeFieldLabels(); this.changeTextareas(); this.changeTextInputs(); this.changeEmailInput(); this.changePageToDotGovTemplate(); this.changeRadioInputs(); this.changeNextButton(); this.changeUpdateButton(); this.changeNavBarToRemoveSignIn(); this.changeBackground(); this.removeAdditionalCSSClasses(); this.removeConfilctingCSSClasses(); this.relocateAndRestyleBackButton(); this.errorHandling(); this.moveInstructions(); this.characterCounter(); this.removeEmptyTableRows(); this.clearErrorsOnNewInput(); this.validateContactDetails(); this.accordionUpdatesForJAWS(); this.removeXSNavBar(); listboxOptions = []; }, convertReviewPage: function(pageTitle) { this.changePageTitle(pageTitle); this.changeReviewFormTitle(); this.changeReviewFieldLabels(); this.changePageToDotGovTemplate(); this.changeNavBarToRemoveSignIn(); this.changeBackground(); this.hideBlankReviewRows(); this.replaceReviewAnswerDisplays(); this.addRowStyling(); this.removeAdditionalCSSClasses(); this.errorHandling(); this.runMutationObserverReviewPage(); this.removeConfilctingCSSClasses(); this.clearErrorsOnNewInput(); this.accordionUpdatesForJAWS(); this.removeXSNavBar(); }, changePageTitle: function(pageTitle) { // Change name in the header and hide additional text $(".headercontent1").text(pageTitle); $(".headercontent2").remove(); $('title').text(pageTitle - $('.tab-title').text()); console.log($('title').text(`${$('.tab-title').text()} - ${pageTitle}`)); }, changeFormTitle: function() { // Change the form title to match GDS and wrap in legend var title = $("h2.tab-title"); var locationName = sessionStorage.serviceName; if (title.length > 0) { if (title[0].innerHTML.contains("the service") && locationName != "") { title[0].innerHTML = title[0].innerText.replace("the service", locationName); } title.replaceWith(``); $("legend").next(`div`).addBack().wrapAll(`
`); } }, changeReviewFormTitle: function() { // Change the form title to match GDS and wrap in legend var title = $("h2.tab-title"); title.replaceWith(``); $("legend").next(`div`).addBack().wrapAll(``); }, changeFieldLabels: function() { // Style field labels $('.field-label').addClass('govuk-label'); $('.field-label').removeClass('field-label'); }, changeReviewFieldLabels: function() { // Style field labels for review page $('.field-label').unwrap(); $('.field-label').wrap(''); $('.field-label').addClass('govuk-summary-list govuk-summary-list__key'); $('.field-label').removeClass('field-label'); }, changeTextareas: function() { // Change textareas to match GDS var textArea = $('textarea.textarea'); if (textArea.length > 0) { textArea.addClass('govuk-textarea'); textArea.removeClass('textarea form-control'); //textArea.css('height', 'fit-content'); } }, changeTextInputs: function() { // Change text inputs to match GDS $('input[type="text"]').each(function() { $(this).attr('class', 'govuk-input govuk-border-important govuk-background-important'); var checkCaptcha = $(this).parent().parent().parent().parent(); if (checkCaptcha.hasClass("captcha-cell")) { $(this).addClass('gds-captcha'); $(this).parent().attr('class', 'd-flex flex-column-reverse'); $(this).parent().append('This box contains 7 characters
'); $(this).parent().prepend(`
');
$('#NextButton').val("Start");
if ($('p.govuk-label').length == 0) {
$('.captcha-cell').prepend('To continue, please enter the characters below
'); } $('label').text("Type the characters here"); $('label').addClass('govuk-label mt-3'); }, styleErrors: function() { //$('.govuk-form-group--error').removeClass('govuk-form-group--error'); $('span.fa-info-circle').remove(); $('span.fa-exclamation-triangle').remove(); $('.validation-header').replaceWith('${text}
Give Feedback On Care
'); } }