Staging
This commit is contained in:
33
frontend/logbook.ts
Normal file
33
frontend/logbook.ts
Normal file
@ -0,0 +1,33 @@
|
||||
/*document.addEventListener('DOMContentLoaded', function() {
|
||||
setDistance('.set-distance-js');
|
||||
});
|
||||
|
||||
function setDistance(selector: string) {
|
||||
const fields = document.querySelectorAll(selector);
|
||||
if(fields) {
|
||||
Array.prototype.forEach.call(fields, (field: HTMLInputElement) => {
|
||||
if(field.dataset.relation){
|
||||
const relatedField = <HTMLInputElement>document.getElementById(field.dataset.relation);
|
||||
|
||||
if(relatedField) {
|
||||
field.addEventListener('input', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const dataList = <HTMLDataListElement>document.getElementById('destinations');
|
||||
if(dataList) {
|
||||
var option = Array.prototype.find.call(dataList.options, function(option) {
|
||||
return option.value === field.value;
|
||||
});
|
||||
|
||||
// Get distance
|
||||
const distance = option.getAttribute('distance');
|
||||
if(distance) relatedField.value = distance;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
export {}
|
Reference in New Issue
Block a user