- Commentboxes work (marginals) + mouseover

- Basic Briefe Controller
- Generic XML reader
This commit is contained in:
schnulller
2022-05-19 01:09:49 +02:00
parent f1743fcf39
commit 2ed7265869
23 changed files with 1179 additions and 193 deletions

View File

@@ -0,0 +1,101 @@
@* Javascript gets inlined because it ain't much (but it's honest work) *@
@* Only put PRODUCTION JavaScript here *@
<script>
const openmenu = function () {
var x = document.getElementById("ha-topnav");
if (x !== null) x.className += " ha-topnav-collapsed";
let oldbutton = document.getElementById("openmenubutton");
if (oldbutton !== null) oldbutton.setAttribute('class', 'hidden');
let newbutton = document.getElementById("closemenubutton");
if (newbutton !== null) newbutton.setAttribute('class', '');
}
const closemenu = function () {
var x = document.getElementById("ha-topnav");
if (x !== null) x.className = "ha-topnav";
let oldbutton = document.getElementById("closemenubutton");
if (oldbutton !== null) oldbutton.setAttribute('class', 'hidden');
let newbutton = document.getElementById("openmenubutton");
if (newbutton !== null) newbutton.setAttribute('class', '');
}
const markactive_startswith = function (element) {
// Marks links as active which target URL starts with the current URL
var all_links = element.getElementsByTagName("a"),
i = 0, len = all_links.length,
full_path = location.href.split('#')[0].toLowerCase(); //Ignore hashes
for (; i < len; i++) {
if (full_path.startsWith(all_links[i].href.toLowerCase())) {
all_links[i].className += " active";
}
}
}
const markactive_exact = function (element) {
var all_links = element.getElementsByTagName("a"),
i = 0, len = all_links.length,
full_path = location.href.split('#')[0].toLowerCase(); //Ignore hashes
for (; i < len; i++) {
if (full_path == all_links[i].href.toLowerCase()) {
all_links[i].className += " active";
}
}
}
const getLineHeight = function (element) {
var temp = document.createElement(element.nodeName), ret;
temp.setAttribute("class", element.className);
temp.innerHTML = "A";
element.parentNode.appendChild(temp);
ret = temp.clientHeight;
temp.parentNode.removeChild(temp);
return ret;
}
/* TODO: need a resize watcher to undo and reapply the effect on breakpoint */
const overlappingboxcollapse = function (selector) {
let boxes = document.querySelectorAll(selector);
let clientrects = [];
let lineheight = 1;
if (boxes.length >= 1) {
lineheight = getLineHeight(boxes[0]);
}
for (element of boxes) {
clientrects.push([element, element.getBoundingClientRect()]);
}
for (var i = 0; i < clientrects.length; i++) {
if (i < clientrects.length-1) {
if (clientrects[i][1].bottom >= clientrects[i+1][1].top) {
let overlap = clientrects[i][1].bottom - clientrects[i+1][1].top;
let newlength = clientrects[i][1].height - overlap;
let remainder = newlength % lineheight;
newlength = newlength - remainder;
clientrects[i][0].style.height = newlength + 'px';
clientrects[i][0].style.overflowX = "hidden";
clientrects[i][0].style.overflowY = "scroll";
}
}
}
}
window.addEventListener('load', function() {
document.getElementById("openmenubutton").addEventListener('click', openmenu);
document.getElementById("closemenubutton").addEventListener('click', closemenu);
markactive_startswith(document.getElementById("ha-topnav"));
markactive_exact(document.getElementById("ha-register-nav"));
overlappingboxcollapse(".ha-neuzeit .ha-letlinks");
overlappingboxcollapse(".ha-forschung .ha-letlinks");
})
</script>

View File

@@ -9,12 +9,22 @@
<title>HKB: @ViewData["Title"]</title>
<!-- crossorigin is a workaround to prevent double downloading bugs in chrome -->
<link rel="preload" href="/css/output.css" as="style" />
<!-- also, the graphite versions of the font are available for use:
<link rel="preload" href="/fonts/LinLibertine_R_G.ttf" as="font" crossorigin/>
<link rel="preload" href="/fonts/LinBiolinum_R_G.ttf" as="font" crossorigin/>
-->
<link rel="preload" href="/css/output.css" as="style" asp-append-version="true"/>
<link rel="preload" href="/img/subtlenet2.png" as="image" />
<link rel="preload" href="/fonts/LinBiolinum_R_G.ttf" as="font" crossorigin/>
<link rel="preload" href="/fonts/LinLibertine_R_G.ttf" as="font" crossorigin/>
<link rel="preload" href="/fonts/LinBiolinum_R.woff" as="font" crossorigin/>
<link rel="preload" href="/fonts/LinLibertine_R.woff" as="font" crossorigin/>
<link rel="preload" href="/fonts/LinLibertine_RI.woff" as="font" crossorigin/>
<link rel="preload" href="/fonts/LinLibertine_RB.woff" as="font" crossorigin/>
<link rel="stylesheet" href="/css/output.css" />
<link rel="stylesheet" href="/css/output.css" asp-append-version="true" />
<environment include="Development">
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
</head>
@@ -24,11 +34,12 @@
<main role="main" class="pb-3 w-full desktop:max-w-screen-desktop mx-auto">
@RenderBody()
</main>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
@await Html.PartialAsync("/Views/Shared/_Footer.cshtml")
<environment exclude="Development">
@await Html.PartialAsync("/Views/Shared/_Javascript.cshtml")
</environment>
</body>
</html>