2023-01-29 05:35:06 +00:00
|
|
|
function prepend(html, container, before) {
|
|
|
|
if (container === undefined) {
|
|
|
|
container = document.body
|
2023-01-26 22:29:16 +00:00
|
|
|
}
|
2023-01-29 05:35:06 +00:00
|
|
|
if (before === undefined) {
|
|
|
|
before = container.firstChild
|
|
|
|
}
|
|
|
|
console.log(html, container, before)
|
|
|
|
var range = document.createRange()
|
|
|
|
range.setStart(container, 0);
|
|
|
|
container.insertBefore(
|
|
|
|
range.createContextualFragment(html),
|
|
|
|
before
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function append(html, container) {
|
|
|
|
if (container === undefined) {
|
|
|
|
container = document.body
|
2023-01-26 22:29:16 +00:00
|
|
|
}
|
2023-01-29 05:35:06 +00:00
|
|
|
var range = document.createRange()
|
|
|
|
range.setStart(container, 0);
|
|
|
|
container.appendChild(
|
2023-01-26 22:29:16 +00:00
|
|
|
range.createContextualFragment(html)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove(id) {
|
|
|
|
const old = document.getElementById(id)
|
|
|
|
if (old !== null) {
|
|
|
|
old.remove()
|
|
|
|
}
|
2023-01-28 07:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
|
|
|
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
|
|
|
|
|
|
const letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
|
|
|
|
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
|
|
|
|
|
|
|
function parseMonth(month) {
|
|
|
|
if (month > -1 && month < 26) {
|
|
|
|
return months[month]
|
|
|
|
} else {
|
|
|
|
let first = letters[month%26].toUpperCase()
|
|
|
|
let middle = letters[month*13%26]
|
|
|
|
let last = letters[month*50%26]
|
|
|
|
return first + middle + last
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseDate(date) {
|
|
|
|
return parseMonth(date.getUTCMonth()) + ' ' + date.getUTCDate() + ', ' + date.getUTCFullYear() + ' ' + date.toLocaleTimeString();
|
2023-01-26 22:29:16 +00:00
|
|
|
}
|