Some fixes for magprog

This commit is contained in:
Alexander Nozik 2024-03-02 20:50:35 +03:00
parent 5e207a1a64
commit be2a9499c6
4 changed files with 40 additions and 49 deletions

View File

@ -20,7 +20,7 @@
});
// Hack: Enable IE flexbox workarounds.
if (browser.name === 'ie')
if (browser.name == 'ie')
$body.addClass('is-ie');
// Play initial animations on page load.
@ -57,7 +57,7 @@
var $this = $(this);
// External link? Bail.
if ($this.attr('href').charAt(0) !== '#')
if ($this.attr('href').charAt(0) != '#')
return;
// Deactivate all links.
@ -96,7 +96,7 @@
$section.removeClass('inactive');
// No locked links? Deactivate all links and activate this section's one.
if ($sidebar_a.filter('.active-locked').length === 0) {
if ($sidebar_a.filter('.active-locked').length == 0) {
$sidebar_a.removeClass('active');
$this.addClass('active');
@ -139,7 +139,7 @@
initialize: function () {
// Deactivate section.
$(this).addClass('inactive');
// $(this).addClass('inactive');
},
enter: function () {
@ -160,7 +160,7 @@
$image.css('background-image', 'url(' + $img.attr('src') + ')');
// Set background position.
if (x === $img.data('position'))
if (x = $img.data('position'))
$image.css('background-position', x);
// Hide <img>.
@ -187,20 +187,5 @@
}
});
})(jQuery);
//From https://www.w3schools.com/howto/howto_js_collapsible.asp
const coll = document.getElementsByClassName("collapsible");
let i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
const content = this.nextElementSibling;
if (content.style.maxHeight){
content.style.maxHeight = null;
} else {
content.style.maxHeight = content.scrollHeight + "px";
}
});
}

View File

@ -20,8 +20,8 @@
b.push(
'<a ' +
'class="link depth-' + indent + '"' +
( (typeof target !== 'undefined' && target !== '') ? ' target="' + target + '"' : '') +
( (typeof href !== 'undefined' && href !== '') ? ' href="' + href + '"' : '') +
( (typeof target !== 'undefined' && target != '') ? ' target="' + target + '"' : '') +
( (typeof href !== 'undefined' && href != '') ? ' href="' + href + '"' : '') +
'>' +
'<span class="indent-' + indent + '"></span>' +
$this.text() +
@ -42,7 +42,7 @@
$.fn.panel = function(userConfig) {
// No elements?
if (this.length === 0)
if (this.length == 0)
return $this;
// Multiple elements?
@ -153,7 +153,7 @@
href = $a.attr('href'),
target = $a.attr('target');
if (!href || href === '#' || href === '' || href === '#' + id)
if (!href || href == '#' || href == '' || href == '#' + id)
return;
// Cancel original event.
@ -166,7 +166,7 @@
// Redirect to href.
window.setTimeout(function() {
if (target === '_blank')
if (target == '_blank')
window.open(href);
else
window.location.href = href;
@ -287,7 +287,7 @@
if (config.hideOnEscape)
$window.on('keydown', function(event) {
if (event.keyCode === 27)
if (event.keyCode == 27)
$this._hide(event);
});
@ -307,7 +307,7 @@
return $(this);
// No elements?
if (this.length === 0)
if (this.length == 0)
return $this;
// Multiple elements?
@ -329,8 +329,8 @@
var i = $(this);
if (i.val() === ''
|| i.val() === i.attr('placeholder'))
if (i.val() == ''
|| i.val() == i.attr('placeholder'))
i
.addClass('polyfill-placeholder')
.val(i.attr('placeholder'));
@ -343,7 +343,7 @@
if (i.attr('name').match(/-polyfill-field$/))
return;
if (i.val() === '')
if (i.val() == '')
i
.addClass('polyfill-placeholder')
.val(i.attr('placeholder'));
@ -356,7 +356,7 @@
if (i.attr('name').match(/-polyfill-field$/))
return;
if (i.val() === i.attr('placeholder'))
if (i.val() == i.attr('placeholder'))
i
.removeClass('polyfill-placeholder')
.val('');
@ -377,16 +377,16 @@
.replace(/type=password/i, 'type=text')
);
if (i.attr('id') !== '')
if (i.attr('id') != '')
x.attr('id', i.attr('id') + '-polyfill-field');
if (i.attr('name') !== '')
if (i.attr('name') != '')
x.attr('name', i.attr('name') + '-polyfill-field');
x.addClass('polyfill-placeholder')
.val(x.attr('placeholder')).insertAfter(i);
if (i.val() === '')
if (i.val() == '')
i.hide();
else
x.hide();
@ -398,7 +398,7 @@
var x = i.parent().find('input[name=' + i.attr('name') + '-polyfill-field]');
if (i.val() === '') {
if (i.val() == '') {
i.hide();
x.show();
@ -442,7 +442,7 @@
if (i.attr('name').match(/-polyfill-field$/))
i.attr('name', '');
if (i.val() === i.attr('placeholder')) {
if (i.val() == i.attr('placeholder')) {
i.removeClass('polyfill-placeholder');
i.val('');
@ -478,7 +478,7 @@
x = i.parent().find('input[name=' + i.attr('name') + '-polyfill-field]');
if (i.val() === '') {
if (i.val() == '') {
i.hide();
x.show();
}
@ -498,7 +498,7 @@
case 'textarea':
i.val(i.attr('defaultValue'));
if (i.val() === '') {
if (i.val() == '') {
i.addClass('polyfill-placeholder');
i.val(i.attr('placeholder'));
}
@ -538,7 +538,7 @@
$parent = $e.parent();
// No parent? Bail.
if ($parent.length === 0)
if ($parent.length == 0)
return;
// Not moved? Move it.
@ -552,7 +552,7 @@
$p = $e.prev();
// Couldn't find anything? Means this element's already at the top, so bail.
if ($p.length === 0)
if ($p.length == 0)
return;
// Move element to top of parent.

View File

@ -3,6 +3,7 @@ package center.sciprog
import io.ktor.server.application.Application
import io.ktor.server.application.call
import io.ktor.server.application.install
import io.ktor.server.application.log
import io.ktor.server.plugins.forwardedheaders.ForwardedHeaders
import io.ktor.server.plugins.forwardedheaders.XForwardedHeaders
import io.ktor.server.response.respondRedirect
@ -46,7 +47,7 @@ fun Application.spcModule() {
}
siteData.forEach { namedData ->
println("${namedData.name}: ${namedData.meta[FileData.FILE_PATH_KEY]}")
log.debug("Loading data {} from {}", namedData.name, namedData.meta[FileData.FILE_PATH_KEY])
}
routing {

View File

@ -5,6 +5,9 @@ import kotlinx.html.*
import space.kscience.dataforge.data.Data
import space.kscience.dataforge.data.await
import space.kscience.dataforge.data.getByType
import space.kscience.dataforge.io.Binary
import space.kscience.dataforge.io.readWith
import space.kscience.dataforge.io.yaml.YamlMetaFormat
import space.kscience.dataforge.meta.Meta
import space.kscience.dataforge.meta.get
import space.kscience.dataforge.meta.getIndexed
@ -45,7 +48,7 @@ private fun wrapSection(
id: String,
title: String,
sectionContent: FlowContent.() -> Unit,
): MagProgSection = MagProgSection(id, title, "wrapper style1 fullscreen fade-up") {
): MagProgSection = MagProgSection(id, title, "wrapper style1 fullscreen") {
div("inner") {
h2 { +title }
sectionContent()
@ -69,7 +72,7 @@ private val ENROLL_PATH: Name = CONTENT_NODE_NAME + "enroll"
private val CONTACTS_PATH: Name = CONTENT_NODE_NAME + "contacts"
private val PROGRAM_PATH: Name = CONTENT_NODE_NAME + "program"
private val RECOMMENDED_COURSES_PATH: Name = CONTENT_NODE_NAME + "recommendedCourses"
private val PARTNERS_PATH: Name = CONTENT_NODE_NAME + "partners"
private val PARTNERS_PATH: Name = CONTENT_NODE_NAME + "partners.yaml".asName()
private val programSection = PageFragment {
val programBlock = data.resolveHtmlOrNull(PROGRAM_PATH)!!
@ -90,8 +93,10 @@ private val programSection = PageFragment {
private val partners = PageFragment {
//val partnersData: Meta = resolve<Any>(PARTNERS_PATH)?.meta ?: Meta.EMPTY
val partnersData: Meta = runBlocking { data.getByType<Meta>(PARTNERS_PATH)?.await() } ?: Meta.EMPTY
val partnersData: Meta = runBlocking {
//TODO add meta reading step to data preparation
data.getByType<Binary>(PARTNERS_PATH)?.await()?.readWith(YamlMetaFormat)
} ?: Meta.EMPTY
div("inner") {
h2 { +"Партнеры" }
div("features") {
@ -317,7 +322,7 @@ internal val spcMasters = HtmlSite {
MagProgSection(
id = "partners",
title = "Партнеры",
style = "wrapper style3 fullscreen fade-up"
style = "wrapper style3 fullscreen"
) {
fragment(partners)
},
@ -332,7 +337,7 @@ internal val spcMasters = HtmlSite {
MagProgSection(
id = "program",
title = "Учебная программа",
style = "wrapper style3 fullscreen fade-up"
style = "wrapper style3 fullscreen"
) {
fragment(programSection)
},