Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Remove unused JS

Uku Tahtbf4355f55a2c
diff --git a/assets/js/app.js b/assets/js/app.js
index 3a17c5aa03..4d53e4903f 100644
--- a/assets/js/app.js
+++ b/assets/js/app.js
@@ -1,7 +1,6 @@
import css from "../css/app.css"
import "./polyfills/closest"
import "./stats"
-import "./timeframe-selector"
import "phoenix_html"
const triggers = document.querySelectorAll('[data-dropdown-trigger]')
diff --git a/assets/js/timeframe-selector.js b/assets/js/timeframe-selector.js
deleted file mode 100644
index b9421ae984..0000000000
--- a/assets/js/timeframe-selector.js
+++ /dev/null
@@ -1,71 +0,0 @@
-const selector = document.querySelector('[data-timeframe-select]')
-
-if (selector) {
- selector.addEventListener('change', function(e) {
- if (e.target.value === 'Day') {
- document.location = '?period=day'
- } else if (e.target.value === 'Week') {
- document.location = '?period=week'
- } else if (e.target.value === 'Month') {
- document.location = '?period=month'
- } else if (e.target.value === 'Last 3 Months') {
- document.location = '?period=3mo'
- } else if (e.target.value === 'Last 6 Months') {
- document.location = '?period=6mo'
- } else if (e.target.value === 'Custom') {
- const parent = e.target.closest('div')
- parent.classList.add('hidden')
- parent.nextElementSibling.classList.remove('hidden')
- }
- })
-}
-
-function getQueryVariable(variable) {
- var query = window.location.search.substring(1);
- var vars = query.split('&');
- for (var i = 0; i < vars.length; i++) {
- var pair = vars[i].split('=');
- if (decodeURIComponent(pair[0]) == variable) {
- return decodeURIComponent(pair[1]);
- }
- }
-}
-
-function defaultDate() {
- const from = getQueryVariable("from")
- const to = getQueryVariable("to")
- return [Date.parse(from), Date.parse(to)]
-}
-
-function dateToISOString(date) {
- const year = date.getFullYear();
- let month = date.getMonth()+1;
- let dt = date.getDate();
-
- if (dt < 10) {
- dt = '0' + dt;
- }
- if (month < 10) {
- month = '0' + month;
- }
-
- return year + '-' + month + '-'+ dt;
-}
-
-const dateRangeTrigger = document.querySelector('#custom-daterange-trigger')
-
-if (dateRangeTrigger) {
- const picker = flatpickr('#custom-daterange-trigger', {
- mode: "range",
- dateFormat: "M j",
- maxDate: 'today',
- onChange: function(selectedDates, dateStr) {
- if (selectedDates.length === 2) {
- dateRangeTrigger.innerHTML = dateStr
- const from = dateToISOString(selectedDates[0])
- const to = dateToISOString(selectedDates[1])
- document.location = '?period=custom&from=' + from + '&to=' + to
- }
- },
- })
-}