Removed janky datepicker

merge-requests/237/merge
Tag 2023-02-17 17:07:23 -08:00
rodzic 2ca4a1bb28
commit 2e52b5be2a
8 zmienionych plików z 7 dodań i 434 usunięć

Wyświetl plik

@ -34,7 +34,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GridTracker</title>
<link rel="stylesheet" href="./lib/dp-dark.css" />
<link rel="stylesheet" href="./lib/ol.css" />
<link rel="stylesheet" href="./lib/style.css" />
<script src="./lib/defaults.js" type="text/javascript"></script>
@ -48,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<script src="./lib/arc.js" type="text/javascript"></script>
<script src="./lib/moment-with-locales.js" type="text/javascript"></script>
<script src="./lib/moment-timezone-with-data.js" type="text/javascript"></script>
<script src="./lib/datepicker.js"></script>
<script src="./lib/callsigns.js" type="text/javascript"></script>
<script src="./lib/jquery-3.6.1.min.js"></script>
<script src="./lib/i18n.js"></script>
@ -1594,11 +1592,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<tr>
<td id="workingDateTd" title="Date/Time is UTC">
Time<br/>
<input type="time" id="workingTimeValue" value="00:00" style="background-color: green; color: yellow;" onchange="workingDateChanged()" /><br/>
Date<br/>
<input style="display: none" type="text" id="workingDateValue" value="1970-01-01" />
<div id="pick-inline"></div>
Date <input type="date" id="workingDateValue" value="1970-01-01" style="background-color: green; color: yellow;" onchange="workingDateChanged()" />
Time <input type="time" id="workingTimeValue" value="00:00" style="background-color: green; color: yellow;" onchange="workingDateChanged()" />
</td>
</tr>
</table>

Wyświetl plik

@ -692,26 +692,6 @@
"callsigns.Downloading": "下載中...",
"callsigns.never": "從不",
"callsigns.processing": "處理中...",
"COMMENT_datepicker.js": "",
"datepicker.month.Jan": "一月",
"datepicker.month.Feb": "二月",
"datepicker.month.Mar": "三月",
"datepicker.month.Apr": "四月",
"datepicker.month.May": "五月",
"datepicker.month.Jun": "六月",
"datepicker.month.Jul": "七月",
"datepicker.month.Aug": "八月",
"datepicker.month.Sep": "九月",
"datepicker.month.Oct": "十月",
"datepicker.month.Nov": "十一月",
"datepicker.month.Dec": "十二月",
"datepicker.day.Sun": "日",
"datepicker.day.Mon": "一",
"datepicker.day.Tue": "二",
"datepicker.day.Wed": "三",
"datepicker.day.Thu": "四",
"datepicker.day.Fri": "五",
"datepicker.day.Sat": "六",
"COMMENT_gt.js": "",
"gt.gridView.live": "實時",
"gt.gridView.logbook": "日誌",

Wyświetl plik

@ -692,26 +692,6 @@
"callsigns.Downloading": "下载中...",
"callsigns.never": "Never",
"callsigns.processing": "处理中...",
"COMMENT_datepicker.js": "",
"datepicker.month.Jan": "一月",
"datepicker.month.Feb": "二月",
"datepicker.month.Mar": "三月",
"datepicker.month.Apr": "四月",
"datepicker.month.May": "五月",
"datepicker.month.Jun": "六月",
"datepicker.month.Jul": "七月",
"datepicker.month.Aug": "八月",
"datepicker.month.Sep": "九月",
"datepicker.month.Oct": "十月",
"datepicker.month.Nov": "十一月",
"datepicker.month.Dec": "十二月",
"datepicker.day.Sun": "星期日",
"datepicker.day.Mon": "星期一",
"datepicker.day.Tue": "星期二",
"datepicker.day.Wed": "星期三",
"datepicker.day.Thu": "星期四",
"datepicker.day.Fri": "星期五",
"datepicker.day.Sat": "星期六",
"COMMENT_gt.js": "",
"gt.gridView.live": "实时数据",
"gt.gridView.logbook": "日志数据",

Wyświetl plik

@ -692,26 +692,6 @@
"callsigns.Downloading": "Downloading...",
"callsigns.never": "Never",
"callsigns.processing": "Processing...",
"COMMENT_datepicker.js": "",
"datepicker.month.Jan": "Jan",
"datepicker.month.Feb": "Feb",
"datepicker.month.Mar": "Mar",
"datepicker.month.Apr": "Apr",
"datepicker.month.May": "May",
"datepicker.month.Jun": "Jun",
"datepicker.month.Jul": "Jul",
"datepicker.month.Aug": "Aug",
"datepicker.month.Sep": "Sep",
"datepicker.month.Oct": "Oct",
"datepicker.month.Nov": "Nov",
"datepicker.month.Dec": "Dec",
"datepicker.day.Sun": "Sun",
"datepicker.day.Mon": "Mon",
"datepicker.day.Tue": "Tue",
"datepicker.day.Wed": "Wed",
"datepicker.day.Thu": "Thur",
"datepicker.day.Fri": "Fri",
"datepicker.day.Sat": "Sat",
"COMMENT_gt.js": "",
"gt.gridView.live": "Live",
"gt.gridView.logbook": "Logbook",

Wyświetl plik

@ -18,17 +18,6 @@ Not entirely part of openlayers, but conglomerated together from other stuff:
- lib/shadow.js
## DatePicker - calendar display
- https://code-boxx.com/simple-datepicker-pure-javascript-css/
- https://code-boxx.com/wp-content/uploads/2020/06/datepicker-js.zip
- lib/datepicker.js
- lib/dp-dark.css
Code has been hacked a bit, origin not reflected in version control so be
careful when upgrading.
## Other Third Party routines
lib/third-party.js

Wyświetl plik

@ -1,273 +0,0 @@
// FIXME ****************************************************************************** //
// The datepicker's "Time" section doesn't work. This really needs to be fixed before
// the next big RTTY Roundup or Field Day where there may be a lot of hams that want
// to use this feature to only reference their log starting when the contest starts.
// Which isn't always 00:00 UTC.
// ************************************************************************************ //
var picker = {
attach: function (opt)
{
// attach() : attach datepicker to target
// opt : options (object)
// target : datepicker will populate this field
// container : datepicker will be generated in this container
// startmon : start on Monday (default false)
// disableday : array of days to disable, e.g. [2,7] to disable Tue and Sun
// (A) Create new datepicker
var dp = document.createElement("div");
dp.dataset.target = opt.target;
dp.dataset.fire = opt.fire;
dp.dataset.startmon = opt.startmon ? "1" : "0";
dp.classList.add("picker");
if (opt.disableday)
{
dp.dataset.disableday = JSON.stringify(opt.disableday);
}
// (B) Default to current month + year
// ! NOTE: UTC+0 !
var today = new Date(0),
thisMonth = today.getUTCMonth(), // Note: Jan is 0
thisYear = parseInt(today.getUTCFullYear()),
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
// (C) Month select
var select = document.createElement("select"),
option = null;
select.classList.add("picker-m");
for (var mth in months)
{
option = document.createElement("option");
option.value = parseInt(mth) + 1;
option.text = months[mth];
select.appendChild(option);
}
select.selectedIndex = thisMonth;
select.addEventListener("change", function() { picker.draw(this); });
dp.appendChild(select);
// (D) Year select
var yRange = 100; // Year range to show, I.E. from thisYear-yRange to thisYear+yRange
select = document.createElement("select");
select.classList.add("picker-y");
for (var y = thisYear; y < thisYear + yRange; y++)
{
option = document.createElement("option");
option.value = y;
option.text = y;
select.appendChild(option);
}
select.selectedIndex = 0;
select.addEventListener("change", function() { picker.draw(this); });
dp.appendChild(select);
// (E) Day select
var days = document.createElement("div");
days.classList.add("picker-d");
dp.appendChild(days);
// (F) Attach date picker to target container + draw the dates
picker.draw(select);
// (F1) Popup datepicker
if (opt.container == 1)
{
// Mark this as a "popup"
var uniqueID = 0;
while (document.getElementById("picker-" + uniqueID) != null)
{
uniqueID = Math.floor(Math.random() * (100 - 2)) + 1;
}
dp.dataset.popup = "1";
dp.dataset.dpid = uniqueID;
// Create wrapper
var wrapper = document.createElement("div");
wrapper.id = "picker-" + uniqueID;
wrapper.classList.add("picker-wrap");
wrapper.appendChild(dp);
// Attach onclick to show/hide datepicker
var target = document.getElementById(opt.target);
target.dataset.dp = uniqueID;
target.onfocus = function ()
{
document.getElementById("picker-" + this.dataset.dp).classList.add("show");
};
wrapper.addEventListener("click", function (evt)
{
if (evt.target.classList.contains("picker-wrap"))
{
this.classList.remove("show");
}
});
// Attach popup datepicker to document
document.documentElement.appendChild(wrapper);
}
// (F2) Inline datepicker
else
{
document.getElementById(opt.container).appendChild(dp);
}
},
draw: function (el)
{
// draw() : draw the days in month
// el : HTML reference to either year or month selector
// (A) Get date picker components
var parent = el.parentElement,
year = parent.getElementsByClassName("picker-y")[0].value,
month = parent.getElementsByClassName("picker-m")[0].value,
days = parent.getElementsByClassName("picker-d")[0];
// (B) Date range calculation
// ! NOTE: UTC+0 !
var daysInMonth = new Date(Date.UTC(year, month, 0)).getUTCDate(),
startDay = new Date(Date.UTC(year, month - 1, 1)).getUTCDay(), // Note: Sun = 0
endDay = new Date(Date.UTC(year, month - 1, daysInMonth)).getUTCDay(),
startDay = startDay == 0 ? 7 : startDay,
endDay = endDay == 0 ? 7 : endDay;
// (C) Generate date squares (in array first)
var squares = [],
disableday = null;
if (parent.dataset.disableday)
{
disableday = JSON.parse(parent.dataset.disableday);
}
// (C1) Empty squares before first day of month
if (parent.dataset.startmon == "1" && startDay != 1)
{
for (var i = 1; i < startDay; i++) { squares.push("B"); }
}
if (parent.dataset.startmon == "0" && startDay != 7)
{
for (var i = 0; i < startDay; i++) { squares.push("B"); }
}
// (C2) Days of month
// All days enabled, just add
if (disableday == null)
{
for (var i = 1; i <= daysInMonth; i++) { squares.push([i, false]); }
}
// Some days disabled
else
{
var thisday = startDay;
for (var i = 1; i <= daysInMonth; i++)
{
// Check if day is disabled
var disabled = disableday.includes(thisday);
// Day of month, disabled
squares.push([i, disabled]);
// Next day
thisday++;
if (thisday == 8) { thisday = 1; }
}
}
// (C2) Empty squares after last day of month
if (parent.dataset.startmon == "1" && endDay != 7)
{
for (var i = endDay; i < 7; i++) { squares.push("B"); }
}
if (parent.dataset.startmon == "0" && endDay != 6)
{
for (var i = endDay; i < (endDay == 7 ? 13 : 6); i++) { squares.push("B"); }
}
// (D) Draw HTML
var daynames = ["Mon", "Tue", "Wed", "Thur", "Fri", "Sat"];
if (parent.dataset.startmon == "1") { daynames.push("Sun"); }
else { daynames.unshift("Sun"); }
// (D1) Header
var table = document.createElement("table"),
row = table.insertRow()
cell = null;
row.classList.add("picker-d-h");
for (let d of daynames)
{
cell = row.insertCell();
cell.innerHTML = d;
}
// (D2) Date cells
var total = squares.length;
row = table.insertRow();
for (var i = 0; i < total; i++)
{
if (i != total && i % 7 == 0) { row = table.insertRow(); }
cell = row.insertCell();
if (squares[i] == "B")
{
cell.classList.add("picker-d-b");
}
else
{
cell.innerHTML = squares[i][0];
// Not allowed to choose this day
if (squares[i][1])
{
cell.classList.add("picker-d-dd");
}
// Allowed to choose this day
else
{
cell.classList.add("picker-d-d");
cell.addEventListener("click", function() { picker.pick(this); });
}
}
}
// (D3) Attach new calendar to datepicker
days.innerHTML = "";
days.appendChild(table);
},
pick: function (el)
{
// pick() : choose a date
// el : HTML reference to selected date cell
// (A) Get all components
var parent = el.parentElement;
while (!parent.classList.contains("picker"))
{
parent = parent.parentElement;
}
// (B) Get full selected year month day
var year = parent.getElementsByClassName("picker-y")[0].value,
month = parent.getElementsByClassName("picker-m")[0].value,
day = el.innerHTML;
// YYYY-MM-DD Format
// ! CHANGE FORMAT HERE IF YOU WANT !
if (parseInt(month) < 10) { month = "0" + month; }
if (parseInt(day) < 10) { day = "0" + day; }
var fullDate = year + "-" + month + "-" + day;
// (C) Update selected date
document.getElementById(parent.dataset.target).value = fullDate;
if (parent.dataset.fire.length > 0)
{
window[parent.dataset.fire]();
}
// (D) Popup only - close the popup
if (parent.dataset.popup == "1")
{
document.getElementById("picker-" + parent.dataset.dpid).classList.remove("show");
}
}
};

Wyświetl plik

@ -1,74 +0,0 @@
/* [POPUP] */
.picker-wrap {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
opacity: 0;
visibility: hidden;
transition: opacity 0.2s;
}
.picker-wrap.show {
opacity: 1;
visibility: visible;
}
.picker-wrap .picker {
margin: 50vh auto 0 auto;
transform: translateY(-50%);
}
/* [CONTAINER] */
.picker {
max-width: 200px;
border: 1px solid #444;
-webkit-border-radius: 6px;
background: #444;
border-style: outset;
padding: 5px;
}
.picker:hover {
border: 1px solid #888;
}
/* [MONTH + YEAR] */
.picker-m,
.picker-y {
width: 25%;
padding: 5px;
box-sizing: border-box;
/*font-size: 16px;*/
}
/* [DAY] */
.picker-d table {
color: #fff;
border-collapse: separate;
width: 100%;
margin-top: 5px;
}
.picker-d table td {
width: 2em; /* 7 equal columns */
padding: 2px;
text-align: center;
}
/* Header cells */
.picker-d-h td {
font-weight: bold;
}
/* Blank dates */
.picker-d-b {
background: #4e4e4e;
}
/* Pickable Dates */
.picker-d-d:hover {
cursor: pointer;
background: #a33c3c;
}
/* Unpickable Dates */
.picker-d-dd {
color: #888;
background: #4e4e4e;
}

Wyświetl plik

@ -11429,6 +11429,11 @@ function workingDateChanged()
{
workingTimeValue.value = "00:00";
}
if (workingTimeValue.value.length == 0)
{
workingTimeValue.value = "1970-01-01";
}
var fields = workingDateValue.value.split("-");
var time = workingTimeValue.value.split(":");
@ -16049,15 +16054,6 @@ function makeScreenshots()
);
}
window.addEventListener("load", function ()
{
picker.attach({
target: "workingDateValue",
container: "pick-inline",
fire: "workingDateChanged"
});
});
function refreshSpotsNoTx()
{
redrawSpots();