Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattk70 committed Mar 22, 2024
2 parents cb249f2 + bc86311 commit db04274
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
12 changes: 10 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ <h5 class="modal-title" id="locationModalLabel">Set Location</h5>
<script src="./js/ui.js" type="module"></script>
<script type="module" defer>
import { config, displayLocationAddress, LOCATIONS } from './js/ui.js';
let map, marker;
let map, marker, clickTimer = 0;
async function onMapClick(e) {
const {lat, lng} = e.latlng;
const target = map.getContainer().id;
Expand Down Expand Up @@ -1278,7 +1278,15 @@ <h5 class="modal-title" id="locationModalLabel">Set Location</h5>
const latEl = document.getElementById(latTxt);
const lonEl = document.getElementById(lonTxt);
showMap(divID);
map.on('click', onMapClick);
map.on('click', (e) => {
clearTimeout(clickTimer);
//Wait for doubleclick
clickTimer = setTimeout(() => {onMapClick(e)}, 250);
})
// don't call onMapClick if doubleclicked
map.on('dblclick', (e) => {
clearTimeout(clickTimer);
})
}

window.placeMap = placeMap;
Expand Down
8 changes: 7 additions & 1 deletion js/listWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,13 @@ class Model {
includedIDs.push(...selectedIndexes);
}
} else {
sname === 'Unknown Sp.' || messages.push(`Cannot find '${sname}' (at line ${line} of the custom list) in the ${this.model} list`);
sname === 'Unknown Sp.' || messages.push(`Cannot find '${sname}' (at line ${line} of the custom list) in the <strong>${this.model}</strong> list.
<strong>Tips:</strong>
<ol>
<li>Is your list for the <strong>${this.model}</strong> model? If not, change the model in settings</li>
<li>Check for a typo in your species name</li>
</ol>
`);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions js/tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ function trackEvent(uuid, event, action, name, value){
const t = new Date()
name = name ? `&e_n=${name}` : '';
value = value ? `&e_v=${value}` : '';
fetch(`https://analytics.mattkirkland.co.uk/matomo.php?h=${t.getHours()}&m=${t.getMinutes()}&s=${t.getSeconds()}
fetch(`https://analytics.mattkirkland.co.uk/matomo.php?h=${t.getHours()}&m=${t.getMinutes()}&s=${t.getSeconds()}
&action_name=Settings%20Change&idsite=${ID_SITE}&rand=${Date.now()}&rec=1&uid=${uuid}&apiv=1
&e_c=${event}&e_a=${action}${name}${value}`)
.then(response => {
if (! response.ok) throw new Error('Network response was not ok', response);
})
})
.catch(error => console.log('Error posting tracking:', error))
}

Expand Down
2 changes: 2 additions & 0 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,8 @@ function onChartData(args) {
let action = e.code;
if (action in GLOBAL_ACTIONS) {
if (document === e.target || document.body === e.target || e.target.attributes["data-action"]) {}
const modifier = e.shiftKey ? 'Shift' : e.ctrlKey ? 'Control' : e.metaKey ? 'Alt' : 'no';
trackEvent(config.UUID, 'KeyPress', action, modifier );
GLOBAL_ACTIONS[action](e);
}

Expand Down
2 changes: 1 addition & 1 deletion js/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ case "update-list": {
// Clear the LIST_CACHE & STATE.included kesy to force list regeneration
LIST_CACHE = {}; //[`${lat}-${lon}-${week}-${STATE.model}-${STATE.list}`];
delete STATE.included?.[STATE.model]?.[STATE.list];
await setIncludedIDs(lat, lon, week )
LIST_WORKER && await setIncludedIDs(lat, lon, week )
args.refreshResults && await Promise.all([getResults(), getSummary()]);
break;
}
Expand Down

0 comments on commit db04274

Please sign in to comment.