adding url params vaccine and symptom
This commit is contained in:
@@ -35,21 +35,25 @@
|
||||
<script src="./js/PrrByKeyTableView.js"></script>
|
||||
<script src="./js/PrrByVaccineTableView.js"></script>
|
||||
<script src="./js/PrrBySymptomTableView.js"></script>
|
||||
<script src="./js/Select2.js"></script>
|
||||
<script>
|
||||
document.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
event => {
|
||||
const urlSearchParams = new URLSearchParams(window.location.search);
|
||||
const name = 'Drug';
|
||||
PageInitializer.initializePage(
|
||||
{
|
||||
symptom: {
|
||||
symptomSelectElement: $('#symptomSelect'),
|
||||
selectSymptom: UIUtils.getSearchParam(urlSearchParams, 'symptom', null),
|
||||
prrByVaccineTableElement: $('#prrByVaccineTable'),
|
||||
downloadPrrByVaccineTableButton: document.querySelector("#downloadPrrByVaccineTable"),
|
||||
keyColumnName: name
|
||||
},
|
||||
vaccine: {
|
||||
vaccineSelectElement: $('#vaccineSelect'),
|
||||
selectVaccine: UIUtils.getSearchParam(urlSearchParams, 'vaccine', null),
|
||||
prrBySymptomTableElement: $('#prrBySymptomTable'),
|
||||
downloadPrrBySymptomTableButton: document.querySelector("#downloadPrrBySymptomTable"),
|
||||
valueName: name
|
||||
@@ -14317,25 +14321,11 @@
|
||||
<a class="a2a_button_email"></a>
|
||||
</div>
|
||||
<script>
|
||||
// adapted from https://www.addtoany.com/buttons/customize/events#modify-share
|
||||
function my_addtoany_onshare(share_data) {
|
||||
const hash_pi = '#3.1459';
|
||||
const old_url = share_data.url;
|
||||
let new_url = old_url;
|
||||
if (old_url.indexOf(hash_pi, old_url.length - hash_pi.length) === -1) {
|
||||
new_url = old_url + hash_pi;
|
||||
}
|
||||
if (new_url != old_url) {
|
||||
return {
|
||||
url: new_url,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var a2a_config = a2a_config || {};
|
||||
a2a_config.callbacks = a2a_config.callbacks || [];
|
||||
a2a_config.callbacks.push({
|
||||
share: my_addtoany_onshare,
|
||||
// FK-TODO: use selected symptom and vaccine for url
|
||||
share: _ => ({ url: window.location.href }),
|
||||
});
|
||||
</script>
|
||||
<script async src="https://static.addtoany.com/menu/page.js"></script>
|
||||
|
||||
@@ -5,34 +5,25 @@ class PageInitializer {
|
||||
PageInitializer.#configureVaccine(vaccine);
|
||||
}
|
||||
|
||||
static #configureSymptom({ symptomSelectElement, prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName }) {
|
||||
static #configureSymptom({ symptomSelectElement, selectSymptom, prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName }) {
|
||||
const prrByVaccineTableView = new PrrByVaccineTableView(prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName);
|
||||
PageInitializer.#initializeSelectElement(
|
||||
Select2.initializeSelectElement(
|
||||
{
|
||||
selectElement: symptomSelectElement,
|
||||
textOfOption2Select: selectSymptom,
|
||||
onValueSelected: (id, text) => prrByVaccineTableView.displayPrrByVaccineTable4Symptom(id, text),
|
||||
minimumInputLength: 0
|
||||
});
|
||||
}
|
||||
|
||||
static #configureVaccine({ vaccineSelectElement, prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName }) {
|
||||
static #configureVaccine({ vaccineSelectElement, selectVaccine, prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName }) {
|
||||
const prrBySymptomTableView = new PrrBySymptomTableView(prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName);
|
||||
PageInitializer.#initializeSelectElement(
|
||||
Select2.initializeSelectElement(
|
||||
{
|
||||
selectElement: vaccineSelectElement,
|
||||
textOfOption2Select: selectVaccine,
|
||||
onValueSelected: (id, text) => prrBySymptomTableView.displayPrrBySymptomTable4Vaccine(id, text),
|
||||
minimumInputLength: 0
|
||||
});
|
||||
}
|
||||
|
||||
static #initializeSelectElement({ selectElement, onValueSelected, minimumInputLength }) {
|
||||
selectElement.select2({ minimumInputLength: minimumInputLength });
|
||||
selectElement.on(
|
||||
'select2:select',
|
||||
function (event) {
|
||||
const id = event.params.data.id;
|
||||
const text = event.params.data.text;
|
||||
onValueSelected(id, text);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
45
docs/SymptomsCausedByDrugs/js/Select2.js
Normal file
45
docs/SymptomsCausedByDrugs/js/Select2.js
Normal file
@@ -0,0 +1,45 @@
|
||||
class Select2 {
|
||||
|
||||
// FK-TODO: rename onValueSelected to onSelectOptionHavingValueAndText
|
||||
static initializeSelectElement({ selectElement, textOfOption2Select, onValueSelected, minimumInputLength }) {
|
||||
selectElement.select2({ minimumInputLength: minimumInputLength });
|
||||
selectElement.on(
|
||||
'select2:select',
|
||||
function (event) {
|
||||
const id = event.params.data.id;
|
||||
const text = event.params.data.text;
|
||||
onValueSelected(id, text);
|
||||
});
|
||||
Select2.#selectOptionHavingText(selectElement, textOfOption2Select);
|
||||
}
|
||||
|
||||
static #selectOptionHavingText(selectElement, text) {
|
||||
const option = Select2.#getOptionHavingText(selectElement, text);
|
||||
if (option === undefined) {
|
||||
return;
|
||||
}
|
||||
Select2.#selectOption(selectElement, option);
|
||||
}
|
||||
|
||||
static #getOptionHavingText(selectElement, text) {
|
||||
if (text === null) {
|
||||
return undefined;
|
||||
}
|
||||
return Array
|
||||
.from(selectElement[0].options)
|
||||
.find(option => option.text == text);
|
||||
}
|
||||
|
||||
static #selectOption(selectElement, option) {
|
||||
selectElement.val(option.value).trigger('change');
|
||||
selectElement.trigger({
|
||||
type: 'select2:select',
|
||||
params: {
|
||||
data: {
|
||||
"id": option.value,
|
||||
"text": option.text
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,13 @@
|
||||
<script src="../../Utils.js"></script>
|
||||
<script src="../../UIUtils.js"></script>
|
||||
<script src="../../NumberWithBarElementFactory.js"></script>
|
||||
<script src="../js/PrrByKey2CsvConverter.js"></script>
|
||||
<script src="../js/PageInitializer.js"></script>
|
||||
<script src="../js/PrrByVaccineProvider.js"></script>
|
||||
<script src="../js/PrrByKeyTable.js"></script>
|
||||
<script src="../js/PrrByKeyTableView.js"></script>
|
||||
<script src="../js/PrrByVaccineTableView.js"></script>
|
||||
<script src="../js/PrrBySymptomTableView.js"></script>
|
||||
<script src="../../SymptomsCausedByDrugs/js/PrrByKey2CsvConverter.js"></script>
|
||||
<script src="../../SymptomsCausedByDrugs/js/PageInitializer.js"></script>
|
||||
<script src="../../SymptomsCausedByDrugs/js/PrrByVaccineProvider.js"></script>
|
||||
<script src="../../SymptomsCausedByDrugs/js/PrrByKeyTable.js"></script>
|
||||
<script src="../../SymptomsCausedByDrugs/js/PrrByKeyTableView.js"></script>
|
||||
<script src="../../SymptomsCausedByDrugs/js/PrrByVaccineTableView.js"></script>
|
||||
<script src="../../SymptomsCausedByDrugs/js/PrrBySymptomTableView.js"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.17.2.css">
|
||||
<script src="https://code.jquery.com/qunit/qunit-2.17.2.js"></script>
|
||||
<script type="text/javascript" src="./jshamcrest.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user