-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DMF-6369: Factorize search listener js code
- Loading branch information
Showing
6 changed files
with
28 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function registerSearchListener(formId) { | ||
if (window.wem) { | ||
document.addEventListener('DOMContentLoaded', () => { | ||
document.getElementById(formId).addEventListener('submit', function (event) { | ||
console.log(event.target); | ||
const searchTermInput = event.target.elements['searchTerm']; | ||
const languageInput = event.target.querySelector('[name="src_languages.values"]'); | ||
const searchEvent = window.wem.buildSearchEvent(formId, event.target, searchTermInput.value, languageInput.value); | ||
window.wem.collectEvent(searchEvent, | ||
() => console.debug('[Collecting search event] search formEvent sent'), | ||
() => console.debug('[Collecting search event] oups search formEvent was not handled properly') | ||
); | ||
}); | ||
}); | ||
} else { | ||
console.debug('Wem does not exist'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,4 @@ | |
</div> | ||
</div> | ||
</div> | ||
</c:if> | ||
</c:if> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters