To-Do-List 1.28
by velo_ninja
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dynamic Divs</title>
<style>
</style>
<script>
let counterItem = 0;
let counterNote = 0;
//-------------------------------------
function createDiv(id, title, color) {
const div = document.createElement('div');
div.id = id;
div.classList.add('cell');
div.textContent = title;
div.style.backgroundColor = color;
div.style.borderColor = color;
div.style.borderRadius = '2px';
div.style.display = 'flex';
div.style.alignItems = 'center';
div.style.justifyContent = 'center';
return div;
}
function createRepeatedBlocks(data1, data2) {
for (const key in data1) {
const rowData = data1[key];
for (let i = 0; i < rowData.ids.length; i++) {
const divId = rowData.ids[i] + '_' + i;
let title = rowData.titles[i];
const div = createDiv(divId, title, rowData.colors[i]);
if (rowData.ids[i] === 'divMain') {
divMain = div;
divMain.style.display = 'block';
document.body.appendChild(divMain);
} else if (rowData.ids[i] === 'divTask') {
divTask = div;
createRow(data2.row1, divTask); // Create rows within divTask
divMain.appendChild(divTask); // Append divTask to divMain
divTask.style.minHeight = '40px'; // Set height of divTask
divTask.id = 'divTask';
}
else if (rowData.ids[i] === 'divNote') {//-----> NOTE-SECTION <-----
divNote = div;
div.id = 'divNote';
divMain.appendChild(div);
createRow(data2.row2, div); // Create rows within divNote
const...
CSS
.row {
border-bottom: 3px solid black !important;
}
#divTask {
bottom: -5px; /* Adjust this value to control the distance of the underline from the text */
left: 0;
width: 100%;
height: 8px; /* Adjust the thickness of the underline */
background: linear-gradient(to right, rgba(0, 100, 255, 0.5), rgba(100, 250, 55, 0.4)); /* Gradient color */
border-radius: 5px; /* Rounded corners */
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.8); /* Shadow effect */
}
#divNote {
bottom: -5px; /* Adjust this value to control the distance of the underline from the text */
left: 0;
width: 100%;
height: 8px; /* Adjust the thickness of the underline */
background: linear-gradient(to right, rgba(0, 100, 255, 0.5), rgba(100, 250, 55, 0.8)); /* Gradient color */
border-radius: 5px; /* Rounded corners */
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.8); /* Shadow effect */
}
JavaScript
/*
function generate_Button(ID) {console.log('SINGLE-BUTTON returned');
const btn = document.createElement('button');
btn.id = id;
btn.classList.add('button');
btn.textContent = text;
btn.addEventListener('click', () => onClick(targetDivId));
btn.style.margin = '2px';
return btn;
}
function createButton(id, text, onClick, targetDivId) {
const btn = document.createElement('button');
btn.id = id;
btn.classList.add('button');
btn.textContent = text;
btn.addEventListener('click', () => onClick(targetDivId));
btn.style.margin = '2px';
return btn;
}
*/