namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\User;
class TestController extends Controller
{
public function show($id)
{
$user = User::findOrFail($id);
}
}
const $elems = document.querySelector('.js-cards').children;
let banners = [];
[...$elems].forEach(($elem, index) => {
if ( !('card' in $elem.dataset) ) {
banners.push({
elem: $elem,
index: index - banners.length
})
}
});
console.log(banners);
$(document).on('click', '.dropdown-toggle', function () {
$(this).closest('.dropdown')
.find('.dropdown-toggle-arrow').toggleClass('rotate').end()
.find('.dropdown-content').slideToggle();
});
document.addEventListener('click', handleCheckBtnClick);
function handleCheckBtnClick() {
if ( !event.target.classList.contains('btn') ) return;
const $questionRoot = event.target.closest('.answer-item');
const $feedbackBox = $questionRoot.querySelector('.correctly');
const userAnswer = $questionRoot.querySelector('.user-answer').value;
const answer = $questionRoot.querySelector('.prompt').textContent;
if ( !userAnswer ) {
answerPlease($feedbackBox);
} else if (userAnswer === answer) {
youAreRight($feedbackBox);
} else {
youAreMistaken($feedbackBox);
}
}
function answerPlease($feedbackBox) {
$feedbackBox.textContent = 'Нет варианта?';
$feedbackBox.style.color = 'brown';
}
function youAreRight($feedbackBox) {
$feedbackBox.textContent = 'Правильно!';
$feedbackBox.style.color = 'green';
}
function youAreMistaken($feedbackBox) {
$feedbackBox.textContent = 'Ответ неверный, попробуйте еще раз';
$feedbackBox.style.color = 'red';
}