DIR : /home/kozerus/public_html/mking/datelist2tables.html

/home/kozerus/public_html/mking

<html>
<head>

	<title>datelist2tables</title>


	<script id=script_datelist2tables>
		function datelist2tables(datelist) {
// Process the input list and sort it in descending order of yymmdd
			const sortedList = [...datelist]
        .map(entry => ({ ...entry, date: entry.date })) // Extract date for sorting
        .sort((a, b) => {
            const aDate = a.date;
            const bDate = b.date;
            return bDate.localeCompare(aDate);
        })
        .map(entry => ({ date: entry.date, description: entry.description }));

    // Group by yyMM
    const yyMMddMap = new Map();
    for (const entry of sortedList) {
        const yyMM = entry.date.substr(0, 4); // Extract the first four characters as yyMM
        if (!yyMMddMap.has(yyMM)) {
            yyMMddMap.set(yyMM, []);
        }
        yyMMddMap.get(yyMM).push({ date: entry.date, description: entry.description });
    }

    // Function to create a table for a specific yyMM group
    function createTable(divId, entries) {
        if (!entries.length) return; // No entries to process

        const table = `
            <table id="table_${divId}">
                <thead>
                    <tr>
                        <th>YYYYMM</th>
                        <th>Description</th>
                    </tr>
                </thead>
                <tbody>
                    ${entries.map(entry => `
                        <tr>
                            <td>${entry.date}</td>
                            <td>${entry.description}</td>
                        </tr>
                    `).join('')}
                </tbody>
            </table>
        `;
        
        const targetDiv = document.getElementById(divId);
        targetDiv.innerHTML = table;
    }

    // Process each yyMM group and create its table
    for (const [yyMM, entries] of yyMMddMap) {
        const divId = `div_${yyMM}`; // Assuming the divid is built as 'divid_yymm'
        createTable(divId, entries);
    }
}


		</script id=datelist2tables_end>


	<script id=script_startup>
		function startup(args) {

			alert( "BUGS_100 startup_args="+args );
			const datelist=
[
    { date: '220120', description: 'Date 1' },
    { date: '220102', description: 'Date 2' },
    { date: '250102', description: 'Date 3' },
    { date: '250201', description: 'Date 4' },
    { date: '250302', description: 'Date 5' }
]

			alert( "BUGS_101 datelist="+datelist );
const myObject = { name: "John", age: 30, city: "New York" };

// Using Object.keys() and Object.values()
console.log("Keys:", Object.keys(myObject)); // ["name", "age", "city"]
console.log("Values:", Object.values(myObject)); // ["John", 30, "New York"]

// Using Object.entries() and for...of loop
for (const [key, value] of Object.entries(myObject)) {
  console.log(`${key}: ${value}`);
}
// Output: 
// name: John
// age: 30
// city: New York

// Using JSON.stringify() to display as a string
console.log(JSON.stringify(myObject)); // {"name":"John","age":30,"city":"New York"}
			return(args);
			}
		</script id=script_startup_end>

<body bgcolor=linen onload="startup('onload'); false;" >

	<div id=div_datelist2tables>
		<h1>div_datelist2tables</h1>

		<div id_div_datelist2tables_end>

	</body>
	</html>

//


koh5_pano



Your browser does not support the HTML5 canvas element.


Drag mouse to navigate.

Navigation





17.Aug.2010, Martin Wengenmayer