<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Tools on MC Chung</title>
    <link>https://example.com/tw/tools/</link>
    <description>Recent content in Tools on MC Chung</description>
    <generator>Hugo</generator>
    <language>tw</language>
    <lastBuildDate>Sun, 11 Feb 2024 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://example.com/tw/tools/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>安排座位</title>
      <link>https://example.com/tw/tools/arrangeseat/</link>
      <pubDate>Sun, 11 Feb 2024 00:00:00 +0000</pubDate>
      <guid>https://example.com/tw/tools/arrangeseat/</guid>
      <description>&lt;ul&gt;&#xD;&#xA;    &lt;li&gt;&#xD;&#xA;        請直接上傳由 NTU COOL 上下載的學生名單&#xD;&#xA;    &lt;/li&gt;&#xD;&#xA;&lt;/ul&gt;&lt;br&gt;&#xD;&#xA;&#xD;&#xA;&lt;form id=&#34;info&#34;&gt;&#xD;&#xA;    &lt;div&gt;&#xD;&#xA;        &lt;input type=&#34;file&#34; id=&#34;studentList&#34; accept=&#34;.xlsx, .csv&#34; required /&gt;&#xD;&#xA;    &lt;/div&gt;&#xD;&#xA;    &lt;div style=&#34;margin-top: 20px;&#34;&gt;&#xD;&#xA;        &lt;select name=&#34;classroom&#34; id=&#34;classroom&#34; required&gt;&#xD;&#xA;            &lt;option value=&#34;&#34; disabled selected=&#34;selected&#34;&gt;請選擇一間教室&lt;/option&gt;&#xD;&#xA;        &lt;/select&gt;&#xD;&#xA;    &lt;/div&gt;&#xD;&#xA;    &lt;div style=&#34;margin-top: 20px;&#34;&gt;&#xD;&#xA;        &lt;select name=&#34;method&#34; id=&#34;method&#34; required&gt;&#xD;&#xA;            &lt;option value=&#34;&#34; disabled selected=&#34;selected&#34;&gt;請選擇一種排法&lt;/option&gt;&#xD;&#xA;            &lt;option value=&#34;method1&#34;&gt;方法一&lt;/option&gt;&#xD;&#xA;            &lt;!-- &lt;option value=&#34;method2&#34;&gt;方法二&lt;/option&gt; --&gt;&#xD;&#xA;        &lt;/select&gt;&#xD;&#xA;    &lt;/div&gt;&#xD;&#xA;    &lt;div style=&#34;margin-top: 20px;&#34;&gt;&#xD;&#xA;        &lt;label for=&#34;seatTitle&#34;&gt;標題:&lt;/label&gt;&#xD;&#xA;        &lt;input type=&#34;text&#34; id=&#34;seatTitle&#34; placeholder=&#34;(optional)&#34; /&gt;&#xD;&#xA;    &lt;/div&gt;&#xD;&#xA;    &lt;div style=&#34;margin-top: 20px;&#34;&gt;&#xD;&#xA;        &lt;button type=&#34;submit&#34;&gt;送出&lt;/button&gt;&#xD;&#xA;        &lt;button type=&#34;button&#34; id=&#34;printBtn&#34; style=&#34;display: none;&#34; onclick=&#34;printTable()&#34;&gt;列印&lt;/button&gt;&#xD;&#xA;    &lt;/div&gt;&#xD;&#xA;&#xD;&#xA;    &lt;div id=&#34;printElement&#34; style=&#34;display: none;&#34;&gt;&#xD;&#xA;        &lt;div class=&#34;seat&#34;&gt;&#xD;&#xA;            &lt;table id=&#34;table1&#34;&gt;&#xD;&#xA;            &lt;/table&gt;&#xD;&#xA;        &lt;/div&gt;&#xD;&#xA;    &lt;/div&gt;&#xD;&#xA;&lt;/form&gt;&#xD;&#xA;&lt;script src=&#34;https://example.com/js/arrangeSeat.js&#34;&gt;&lt;/script&gt;&#xD;&#xA;&lt;script src=&#34;https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.3/xlsx.full.min.js&#34;&gt;&lt;/script&gt;&#xD;&#xA;&lt;script src=&#34;https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js&#34;&gt;&lt;/script&gt;&#xD;&#xA;&lt;script src=&#34;https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.fonts.js&#34;&gt;&lt;/script&gt;&#xD;&#xA;&lt;script src=&#34;https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.8.1/jspdf.plugin.autotable.min.js&#34;&gt;&lt;/script&gt;&#xD;&#xA;&lt;script&gt;&#xD;&#xA;    document.getElementById(&#39;info&#39;).addEventListener(&#39;submit&#39;, function (event) {&#xD;&#xA;        event.preventDefault()&#xD;&#xA;        submit()&#xD;&#xA;    });&#xD;&#xA;    addOptions();&#xD;&#xA;    var numberOfStudents = 0;&#xD;&#xA;&#xD;&#xA;    function submit() {&#xD;&#xA;        var studentList = document.getElementById(&#39;studentList&#39;).files[0]&#xD;&#xA;        var reader = new FileReader()&#xD;&#xA;&#xD;&#xA;        reader.onload = function (file) {&#xD;&#xA;            var data = new Uint8Array(file.target.result)&#xD;&#xA;            var workbook = XLSX.read(data, { type: &#39;array&#39; })&#xD;&#xA;            var sheet_name = workbook.SheetNames[0]&#xD;&#xA;            var sheet = workbook.Sheets[sheet_name]&#xD;&#xA;            jsonData = XLSX.utils.sheet_to_json(sheet, { header: 1 })&#xD;&#xA;            var studentNames = []&#xD;&#xA;            for (var i = 1; i &lt; jsonData.length; i++) {&#xD;&#xA;                studentNames.push(jsonData[i][4].split(&#34; &#34;)[0])&#xD;&#xA;            }&#xD;&#xA;            dataProcess(studentNames)&#xD;&#xA;        }&#xD;&#xA;&#xD;&#xA;        reader.readAsArrayBuffer(studentList);&#xD;&#xA;    }&#xD;&#xA;&#xD;&#xA;    function dataProcess(studentNames) {&#xD;&#xA;        numberOfStudents = studentNames.length&#xD;&#xA;        var sampleNames = sample(studentNames, studentNames.length)&#xD;&#xA;        var classroom = getClassroom();&#xD;&#xA;&#xD;&#xA;        var result;&#xD;&#xA;        var method = document.getElementById(&#39;method&#39;).value;&#xD;&#xA;        switch (method) {&#xD;&#xA;            case &#39;method1&#39;:&#xD;&#xA;                result = method1(sampleNames, classroom)&#xD;&#xA;                break;&#xD;&#xA;            case &#39;method2&#39;:&#xD;&#xA;                result = method1(sampleNames, classroom)&#xD;&#xA;                break;&#xD;&#xA;            default:&#xD;&#xA;                break;&#xD;&#xA;        }&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;        console.log(result)&#xD;&#xA;&#xD;&#xA;        createTable(result)&#xD;&#xA;&#xD;&#xA;        var printBtn = document.getElementById(&#39;printBtn&#39;);&#xD;&#xA;        printBtn.style.display = &#39;&#39;;&#xD;&#xA;    }&#xD;&#xA;&#xD;&#xA;    function createTable(tableData) {&#xD;&#xA;        var table = document.getElementById(&#39;table1&#39;);&#xD;&#xA;        var tableBody = document.createElement(&#39;tbody&#39;);&#xD;&#xA;&#xD;&#xA;        tableData.forEach(function (rowData, rIndex) {&#xD;&#xA;            var row = document.createElement(&#39;tr&#39;);&#xD;&#xA;&#xD;&#xA;            rowData.forEach(function (cellData, cIndex) {&#xD;&#xA;                var cell = document.createElement(&#39;td&#39;);&#xD;&#xA;                if (cellData === &#34;AA&#34;)&#xD;&#xA;                    cell.classList.add(&#39;aisle&#39;);&#xD;&#xA;                if (rIndex == 0 || cIndex == 0)&#xD;&#xA;                    cell.classList.add(&#39;index&#39;);&#xD;&#xA;                cell.appendChild(document.createTextNode(cellData));&#xD;&#xA;                row.appendChild(cell);&#xD;&#xA;            });&#xD;&#xA;&#xD;&#xA;            tableBody.appendChild(row);&#xD;&#xA;        });&#xD;&#xA;&#xD;&#xA;        table.replaceChildren(tableBody);&#xD;&#xA;    }&#xD;&#xA;&#xD;&#xA;    &#xD;&#xA;&#xD;&#xA;&lt;/script&gt;</description>
    </item>
  </channel>
</rss>
