MCPcopy
hub / github.com/darkreader/darkreader / locationChanged

Function locationChanged

src/ui/options/automation/automation-tab.tsx:34–70  ·  view source on GitHub ↗
(inputElement: HTMLInputElement, newValue: string, type: 'latitude' | 'longitude')

Source from the content-addressed store, hash-verified

32 }
33
34 function locationChanged(inputElement: HTMLInputElement, newValue: string, type: 'latitude' | 'longitude') {
35 if (newValue.trim() === '') {
36 inputElement.value = '';
37
38 props.actions.changeSettings({
39 location: {
40 ...locationSettings,
41 [type]: null,
42 },
43 });
44
45 return;
46 }
47
48 const min: number = values[type].min;
49 const max: number = values[type].max;
50
51 newValue = newValue.replace(',', '.').replace('°', '');
52
53 let num = Number(newValue);
54 if (isNaN(num)) {
55 num = 0;
56 } else if (num > max) {
57 num = max;
58 } else if (num < min) {
59 num = min;
60 }
61
62 inputElement.value = getLocationString(num);
63
64 props.actions.changeSettings({
65 location: {
66 ...locationSettings,
67 [type]: num,
68 },
69 });
70 }
71
72 function changeAutomationMode(mode: Automation['mode']) {
73 props.actions.changeSettings({automation: {...props.data.settings.automation, ...{mode, enabled: Boolean(mode)}}});

Callers 1

AutomationTabFunction · 0.70

Calls 2

getLocationStringFunction · 0.70
changeSettingsMethod · 0.65

Tested by

no test coverage detected