move index generator to a separate file
This commit is contained in:
1 parent
b036b9289c
commit
b1a3d20de1
4 files changed
+88
-80
No files matched your search
@@ -0,0 +1,59 @@
|
||||
var apps = [
|
||||
{
|
||||
name: 'plex',
|
||||
title: 'plex.mtps.pl',
|
||||
content: "Plex Media Server. Serwer filmów, seriali, zdjęć i muzyki",
|
||||
link: 'https://plex.mtps.pl/'
|
||||
},
|
||||
{
|
||||
name: 'radio',
|
||||
title: 'radio-rolnik.mtps.pl',
|
||||
content: "Strona radia szkolnego Rolnika. Aktualna top lista utworów wybrana przez uczniów.",
|
||||
link: 'https://radio-rolnik.mtps.pl/'
|
||||
},
|
||||
{
|
||||
name: 'r',
|
||||
title: 'r.mtps.pl',
|
||||
content: "Serwer do skracania linków",
|
||||
link: 'https://r.mtps.pl/'
|
||||
},
|
||||
{
|
||||
name: 'send',
|
||||
title: 'send.mtps.pl',
|
||||
content: "Self hostowany serwer Firefox Send. Szyfrowany upload plików, z hasłem i datą wygaśnięcia",
|
||||
link: 'https://send.mtps.pl/'
|
||||
}
|
||||
]
|
||||
|
||||
const head = document.querySelector('.pane.index>.head'),
|
||||
grid = document.querySelector('.pane.index>.grid')
|
||||
|
||||
for (let app of apps) {
|
||||
let description = document.createElement('div'),
|
||||
title = document.createElement('div'),
|
||||
link = document.createElement('a'),
|
||||
content = document.createElement('div'),
|
||||
element = document.createElement('div'),
|
||||
icon = document.createElement('i')
|
||||
|
||||
description.append(title, link, content)
|
||||
element.append(app.name)
|
||||
element.append(icon)
|
||||
|
||||
description.classList.add('description', app.name)
|
||||
title.classList.add('title')
|
||||
link.classList.add('link', 'icon-link-ext')
|
||||
content.classList.add('content')
|
||||
icon.classList.add('icon-link-ext')
|
||||
|
||||
link.setAttribute('href', app.link)
|
||||
link.setAttribute('target', '_blank')
|
||||
element.setAttribute('data-target', app.name)
|
||||
element.setAttribute('data-link', app.link)
|
||||
|
||||
title.textContent = app.title
|
||||
content.textContent = app.content
|
||||
|
||||
head.append(description)
|
||||
grid.append(element)
|
||||
}
|
||||
+4
-63
@@ -15,7 +15,7 @@
|
||||
|
||||
<body>
|
||||
<div id="floating">
|
||||
<div id="nav">
|
||||
<nav>
|
||||
<img src="/media/m_stripes.svg" alt="logo" id="miniLogo">
|
||||
<span id="logoText"><span>M</span>a<span>t</span>eusz <span>P</span><span>s</span>trucha</span>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="wrapper">
|
||||
<div class="stripes primary">
|
||||
@@ -72,67 +72,8 @@
|
||||
<div class="grid">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var apps = [
|
||||
{
|
||||
name: 'plex',
|
||||
title: 'plex.mtps.pl',
|
||||
content: "Plex Media Server. Serwer filmów, seriali, zdjęć i muzyki",
|
||||
link: 'https://plex.mtps.pl/'
|
||||
},
|
||||
{
|
||||
name: 'radio',
|
||||
title: 'radio-rolnik.mtps.pl',
|
||||
content: "Strona radia szkolnego Rolnika. Aktualna top lista utworów wybrana przez uczniów.",
|
||||
link: 'https://radio-rolnik.mtps.pl/'
|
||||
},
|
||||
{
|
||||
name: 'r',
|
||||
title: 'r.mtps.pl',
|
||||
content: "Serwer do skracania linków",
|
||||
link: 'https://r.mtps.pl/'
|
||||
},
|
||||
{
|
||||
name: 'send',
|
||||
title: 'send.mtps.pl',
|
||||
content: "Self hostowany serwer Firefox Send. Szyfrowany upload plików, z hasłem i datą wygaśnięcia",
|
||||
link: 'https://send.mtps.pl/'
|
||||
}
|
||||
]
|
||||
|
||||
const head = document.querySelector('.pane.index>.head'),
|
||||
grid = document.querySelector('.pane.index>.grid')
|
||||
|
||||
for(let app of apps){
|
||||
let description = document.createElement('div'),
|
||||
title = document.createElement('div'),
|
||||
link = document.createElement('a'),
|
||||
content = document.createElement('div'),
|
||||
element = document.createElement('div'),
|
||||
icon = document.createElement('i')
|
||||
|
||||
description.append(title, link, content)
|
||||
element.append(app.name)
|
||||
element.append(icon)
|
||||
|
||||
description.classList.add('description', app.name)
|
||||
title.classList.add('title')
|
||||
link.classList.add('link', 'icon-link-ext')
|
||||
content.classList.add('content')
|
||||
icon.classList.add('icon-link-ext')
|
||||
|
||||
link.setAttribute('href', app.link)
|
||||
link.setAttribute('target', '_blank')
|
||||
element.setAttribute('data-target', app.name)
|
||||
element.setAttribute('data-link', app.link)
|
||||
|
||||
title.textContent = app.title
|
||||
content.textContent = app.content
|
||||
|
||||
head.append(description)
|
||||
grid.append(element)
|
||||
}
|
||||
</script>
|
||||
<!-- generates application list -->
|
||||
<script src="/apps.js"></script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,7 @@ const Panes = {
|
||||
clearTimeout(this.scrollTimeout)
|
||||
|
||||
let targetPane = document.querySelector(`[data-id=${target}]`)
|
||||
if(!targetPane) return
|
||||
if (!targetPane) return
|
||||
|
||||
targetPane.scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
@@ -21,36 +21,41 @@ const Panes = {
|
||||
Panes.switch(target)
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
// nav buttons handler
|
||||
document.querySelector('#nav').onclick = function (e) {
|
||||
document.querySelector('nav').onclick = function (e) {
|
||||
let target = e.target.getAttribute('data-target')
|
||||
if (target) {
|
||||
Panes.scrollTo(target)
|
||||
}
|
||||
if (target) Panes.scrollTo(target)
|
||||
}
|
||||
|
||||
// index buttons handler
|
||||
document.querySelector('.pane.index>.grid').onclick = function (e) {
|
||||
console.log(this, e.target)
|
||||
|
||||
// if pane is already open, redirect to link
|
||||
if (e.target.classList.contains('active')) {
|
||||
window.open(e.target.getAttribute('data-link'))
|
||||
return
|
||||
}
|
||||
|
||||
if (this != e.target) {
|
||||
let target = e.target.getAttribute('data-target'),
|
||||
targetEl = document.querySelector(`.head>.description.${target}`),
|
||||
activeGrid = document.querySelector('.grid>div.active')
|
||||
let targetButton = e.target,
|
||||
targetId = targetButton.getAttribute('data-target'), // target app id
|
||||
targetDescription = document.querySelector(`.head>.description.${targetId}`), // target app description
|
||||
currentButton = document.querySelector('.grid>div.active') // currently active app button
|
||||
|
||||
if (!targetEl) return
|
||||
// description doesn't exist
|
||||
if (!targetDescription) return
|
||||
|
||||
document.querySelector('.head>.description.active').classList.remove('active')
|
||||
if (activeGrid) activeGrid.classList.remove('active')
|
||||
targetEl.classList.add('active')
|
||||
e.target.classList.add('active')
|
||||
// deactivate previous
|
||||
document.querySelector('.head>.description.active').classList.remove('active') // deactivate current description
|
||||
if (currentButton) currentButton.classList.remove('active') // deactivate current app button
|
||||
|
||||
// activate new
|
||||
targetDescription.classList.add('active')
|
||||
targetButton.classList.add('active')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ body {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#nav {
|
||||
nav {
|
||||
margin: 1rem 2rem;
|
||||
margin-top: 3rem;
|
||||
user-select: none;
|
||||
@@ -246,7 +246,7 @@ body {
|
||||
font-family: 'Roboto Mono';
|
||||
margin-bottom: 2rem;
|
||||
height: 40%;
|
||||
overflow: hidden;
|
||||
/* overflow: hidden; */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@@ -272,6 +272,9 @@ body {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
margin-left: .5rem;
|
||||
position: absolute;
|
||||
left: -2.5em;
|
||||
top: 1em;
|
||||
}
|
||||
|
||||
.description > a.link:hover {
|
||||
|
||||
Reference in new issue
Block a user