<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://horizonffxi.wiki/w/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AFFXIWeatherForecast.js</id>
	<title>MediaWiki:FFXIWeatherForecast.js - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://horizonffxi.wiki/w/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AFFXIWeatherForecast.js"/>
	<link rel="alternate" type="text/html" href="https://horizonffxi.wiki/w/index.php?title=MediaWiki:FFXIWeatherForecast.js&amp;action=history"/>
	<updated>2026-04-28T03:41:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://horizonffxi.wiki/w/index.php?title=MediaWiki:FFXIWeatherForecast.js&amp;diff=61837&amp;oldid=prev</id>
		<title>Starfox9507: Created page with &quot;// ref: https://stackoverflow.com/questions/10683712/html-table-sort  const table = document.querySelector(&#039;special-weatherforecast-table&#039;); //get the table to be sorted console.log(&#039;test&#039;, table);  // table.querySelectorAll(&#039;th&#039;) // get all the table header elements //   .forEach((element, columnNo)=&gt;{ // add a click handler for each //     element.addEventListener(&#039;click&#039;, event =&gt; { //         sortTable(table, columnNo); //call a function which sorts the table by a gi...&quot;</title>
		<link rel="alternate" type="text/html" href="https://horizonffxi.wiki/w/index.php?title=MediaWiki:FFXIWeatherForecast.js&amp;diff=61837&amp;oldid=prev"/>
		<updated>2024-09-14T20:59:11Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;// ref: https://stackoverflow.com/questions/10683712/html-table-sort  const table = document.querySelector(&amp;#039;special-weatherforecast-table&amp;#039;); //get the table to be sorted console.log(&amp;#039;test&amp;#039;, table);  // table.querySelectorAll(&amp;#039;th&amp;#039;) // get all the table header elements //   .forEach((element, columnNo)=&amp;gt;{ // add a click handler for each //     element.addEventListener(&amp;#039;click&amp;#039;, event =&amp;gt; { //         sortTable(table, columnNo); //call a function which sorts the table by a gi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;// ref: https://stackoverflow.com/questions/10683712/html-table-sort&lt;br /&gt;
&lt;br /&gt;
const table = document.querySelector(&amp;#039;special-weatherforecast-table&amp;#039;); //get the table to be sorted&lt;br /&gt;
console.log(&amp;#039;test&amp;#039;, table);&lt;br /&gt;
&lt;br /&gt;
// table.querySelectorAll(&amp;#039;th&amp;#039;) // get all the table header elements&lt;br /&gt;
//   .forEach((element, columnNo)=&amp;gt;{ // add a click handler for each&lt;br /&gt;
//     element.addEventListener(&amp;#039;click&amp;#039;, event =&amp;gt; {&lt;br /&gt;
//         sortTable(table, columnNo); //call a function which sorts the table by a given column number&lt;br /&gt;
//     })&lt;br /&gt;
//   })&lt;br /&gt;
&lt;br /&gt;
function sortTable(table, sortColumn){&lt;br /&gt;
    // get the data from the table cells&lt;br /&gt;
    const tableBody = table;&lt;br /&gt;
    const tableData = table2data(tableBody);&lt;br /&gt;
    // sort the extracted data&lt;br /&gt;
    tableData.sort((a, b)=&amp;gt;{&lt;br /&gt;
      if(a[sortColumn] &amp;gt; b[sortColumn]){&lt;br /&gt;
        return 1;&lt;br /&gt;
      }&lt;br /&gt;
      return -1;&lt;br /&gt;
    })&lt;br /&gt;
    // put the sorted data back into the table&lt;br /&gt;
    data2table(tableBody, tableData);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
// this function gets data from the rows and cells&lt;br /&gt;
// within an html tbody element&lt;br /&gt;
function table2data(tableBody){&lt;br /&gt;
    const tableData = []; // create the array that&amp;#039;ll hold the data rows&lt;br /&gt;
    tableBody.querySelectorAll(&amp;#039;tr&amp;#039;)&lt;br /&gt;
      .forEach(row=&amp;gt;{  // for each table row...&lt;br /&gt;
        const rowData = [];  // make an array for that row&lt;br /&gt;
        row.querySelectorAll(&amp;#039;td&amp;#039;)  // for each cell in that row&lt;br /&gt;
          .forEach(cell=&amp;gt;{&lt;br /&gt;
            rowData.push(cell.innerText);  // add it to the row data&lt;br /&gt;
          })&lt;br /&gt;
        tableData.push(rowData);  // add the full row to the table data&lt;br /&gt;
      });&lt;br /&gt;
    return tableData;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // this function puts data into an html tbody element&lt;br /&gt;
  function data2table(tableBody, tableData){&lt;br /&gt;
    tableBody.querySelectorAll(&amp;#039;tr&amp;#039;) // for each table row...&lt;br /&gt;
      .forEach((row, i)=&amp;gt;{&lt;br /&gt;
        const rowData = tableData[i]; // get the array for the row data&lt;br /&gt;
        row.querySelectorAll(&amp;#039;td&amp;#039;)  // for each table cell ...&lt;br /&gt;
          .forEach((cell, j)=&amp;gt;{&lt;br /&gt;
            cell.innerText = rowData[j]; // put the appropriate array element into the cell&lt;br /&gt;
          })&lt;br /&gt;
      });&lt;br /&gt;
  }&lt;br /&gt;
  sortTable(table, 1);&lt;/div&gt;</summary>
		<author><name>Starfox9507</name></author>
	</entry>
</feed>