diff --git a/web/src/app/css/app.css b/web/src/app/css/app.css index ac76466..0e45f2a 100644 --- a/web/src/app/css/app.css +++ b/web/src/app/css/app.css @@ -30,7 +30,8 @@ img.avatar { .avatar img { background: #000; } -.list .emoji { +.list .emoji, +.person .emoji { width: 1.2em; height: 1.2em; vertical-align: middle; @@ -135,12 +136,22 @@ main { background: linear-gradient(30deg, #df00ff, pink, pink, #7c4cff); box-shadow: -6px 4px 0px #0000004f; } +#quizs .avatar.round.big, +#quiz .avatar.round.big { + width: 5em !important; + height: 5em !important; +} #quizs .avatar img, #quiz .avatar img { width: 3em; height: 3em; filter: brightness(120%); } +#quizs .avatar.big img, +#quiz .avatar.big img { + width: 5em !important; + height: 5em !important; +} #quizs .metadata .count { float: right; opacity: .5; diff --git a/web/src/app/css/base.css b/web/src/app/css/base.css index a0def68..e11b5ff 100644 --- a/web/src/app/css/base.css +++ b/web/src/app/css/base.css @@ -8,6 +8,8 @@ body { } .text-center { text-align: center } +.text-left { text-align: left } +.text-right { text-align: right } .flex { display: flex } .flex > .center { margin: auto } diff --git a/web/src/app/js/app.js b/web/src/app/js/app.js index 40b9eab..f4910f1 100644 --- a/web/src/app/js/app.js +++ b/web/src/app/js/app.js @@ -424,7 +424,10 @@ function scriptPageHandler(modname, cfg) { app.preload = { quiz: function() { app.script('pages.quiz'); - app.template.load('quiz.index'); + app.template.loadMany([ + 'quiz.index', + 'quiz.item', + ]); }, } diff --git a/web/src/app/js/pages/quiz.js b/web/src/app/js/pages/quiz.js index 2884646..73f73df 100644 --- a/web/src/app/js/pages/quiz.js +++ b/web/src/app/js/pages/quiz.js @@ -17,7 +17,7 @@ app.pages.quiz = { container.innerHTML = ''; const onDataLoaded = async function(json) { - await app.template.loadMany(['quiz.index']); + await app.template.loadMany(['quiz.index', 'quiz.item']); app.pages.quiz.data = json; app.pages.quiz.paint(json); if (getNormalizedURI() === app.vars.app_dir && @@ -31,8 +31,30 @@ app.pages.quiz = { }, paint: function(json) { json = json || app.pages.quiz.data; + if (json.from.props.age === undefined) + json.from.props.age = '??'; + if (json.from.props.gender === undefined) + json.from.props.gender = 'unspecified'; + if (json.from.props.place === undefined) + json.from.props.place = app.strings.app.the_fediverse; const container = document.getElementById('app-container'); - container.innerHTML = app.template.fill(json, app.template.get('quiz.index')); - console.log(json); + container.innerHTML = app.template.fill(json, app.template.get('quiz.index'), + function(k,v) { + if (k === 'from.name') return app.emoji.expand(capitalize(v)); + }); + const content = document.querySelector('#quiz #questions'); + content.innerHTML = ''; + for (var i in json.content) { + var item = json.content[i]; + item.index = i; + item.number = parseInt(i)+1; + var tpl = app.template.fill(item, app.template.get('quiz.item')); + content.innerHTML += tpl; + if (item.options.length > 0) { + document.querySelector(`#quiz #question-${i} .type-freetext`).remove(); + } else { + document.querySelector(`#quiz #question-${i} .type-options`).remove(); + } + } }, } diff --git a/web/src/app/js/templates/quiz/index.html b/web/src/app/js/templates/quiz/index.html index 692140e..4bc71dd 100644 --- a/web/src/app/js/templates/quiz/index.html +++ b/web/src/app/js/templates/quiz/index.html @@ -1,6 +1,35 @@ -
{.number} | +{.question} | +