//get text from textarea let inputText = document.getElementById("thm").innerHTML; console.log(inputText); //splite new line by regex let newLineArr = inputText.split(/\n/g) //find length let newLineArrLen = newLineArr.length; //make variable let HTMLTableOutput = ""; // looping for create new line on display for (let i = 0; i < newLineArrLen; i++) { HTMLTableOutput += "" + newLineArr[i] + "" + "\n"; } //replace comma with table tag form //ชื่อเพลงและ a tag HTMLTableOutput = HTMLTableOutput.replace(/\(([^ )]*)\)<\/td><\/tr>/g, '$1'); //ข้อความแสดงท่อนหรือข้อความอื่น HTMLTableOutput = HTMLTableOutput.replace(/\[(.*?)\]/g, '$1'); //ลบแท็กที่ไม่เกี่ยวข้องกับ HTMLTableOutput = HTMLTableOutput.replace(/\\/gm, ''); HTMLTableOutput = HTMLTableOutput.replace(/\\/gm, '
"); HTMLTableOutput = HTMLTableOutput.replace(/1/g, 'ด'); HTMLTableOutput = HTMLTableOutput.replace(/%ด/g, '1'); HTMLTableOutput = HTMLTableOutput.replace(/2/g, 'ร'); HTMLTableOutput = HTMLTableOutput.replace(/3/g, 'ม'); HTMLTableOutput = HTMLTableOutput.replace(/4/g, 'ฟ'); HTMLTableOutput = HTMLTableOutput.replace(/5/g, 'ซ'); HTMLTableOutput = HTMLTableOutput.replace(/6/g, 'ล'); HTMLTableOutput = HTMLTableOutput.replace(/7/g, 'ท'); HTMLTableOutput = HTMLTableOutput.replace(/7/g, 'ท'); HTMLTableOutput = HTMLTableOutput.replace(/8/g, 'ดํ'); HTMLTableOutput = HTMLTableOutput.replace(/9/g, 'รํ'); // HTMLTableOutput = HTMLTableOutput.replace(/\+/g, 'มํ'); //สัญลักษณ์เสียงสูง HTMLTableOutput = HTMLTableOutput.replace(/\*/g, 'ํ'); //สัญลักษณ์เสียงต่ำ HTMLTableOutput = HTMLTableOutput.replace(/\./g, 'ฺ'); //ช่องว่าง HTMLTableOutput = HTMLTableOutput.replace(/\\s/g, ' '); HTMLTableOutput = HTMLTableOutput.replace(/\_/g, ' '); //โน้ตตัวเล็ก >> สำหรับการวาดเส้นโค้งที่สื่อถึงการสะบัด HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํฺ]{1,5})<\/small>/g, '$1'); //คันชักออก HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํฺ])\{/g, '$1<'); //คันชักเข้า HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํฺ])\}/g, '$1>'); //เครื่องหมายโน้ตบวก HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลท])\+/g, '$1+'); //เครื่อหมายโน้ตลบ HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลท])\_/g, '$1-'); //เครื่องหมายโน้ตกลาง HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลท])\o/g, '$1º'); //เครื่องหมายพรม HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])t/g, '$1𝆱'); //ตัวเลขแสดงตำแหน่งนิ้วซอและจะเข้ HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\([๑๒๓๔๕๖๗๘๙๐ชกน])/g, '$1$2'); //ตัวเลขแสดงตำแหน่งนิ้วซอ เลขโรมัน HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(iiiii)/g, '$15'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(iiii)/g, '$14'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(iii)/g, '$13'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(ii)/g, '$12'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(i)/g, '$11'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\(0)/g, '$10'); //ตัวเลขแสดงตำแหน่งนิ้วซอ เลขโรมัน แสดงเลขด้านล่าง HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iiiiiiii)/g, '$18'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(e)/g, '$18'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iiiiiii)/g, '$17'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iiiiii)/g, '$16'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(s)/g, '$16'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iiiii)/g, '$15'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iiii)/g, '$14'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(f)/g, '$14'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(iii)/g, '$13'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(ii)/g, '$12'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(t)/g, '$12'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/(i)/g, '$11'); HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\/([+])/g, '$1+'); //แสดงสายลวดจะเข้+มือซ้ายขิม HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])\\([+])/g, '$1$2'); ////ส่วนของการแปลงเลข สำหรับแสดงผลตัวเลข //แปลงเลขไทยเป็นอาราบิก HTMLTableOutput = HTMLTableOutput.replace(/๑/g, '1'); HTMLTableOutput = HTMLTableOutput.replace(/๒/g, '2'); HTMLTableOutput = HTMLTableOutput.replace(/๓/g, '3'); HTMLTableOutput = HTMLTableOutput.replace(/๔/g, '4'); HTMLTableOutput = HTMLTableOutput.replace(/๕/g, '5'); HTMLTableOutput = HTMLTableOutput.replace(/๖/g, '6'); HTMLTableOutput = HTMLTableOutput.replace(/๗/g, '7'); HTMLTableOutput = HTMLTableOutput.replace(/๘/g, '8'); HTMLTableOutput = HTMLTableOutput.replace(/๙/g, '9'); HTMLTableOutput = HTMLTableOutput.replace(/๐/g, '0'); //เครื่องหมายดีดเข้า HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ])v/g, '$1𝆫'); //เครื่องหมายดีดออก HTMLTableOutput = HTMLTableOutput.replace(/([ดรมฟซลทํ๑๒๓๔๕๖๗๘๙๐])\^/g, '$1𝆫'); //แปลงคำ next เป็น tag page เพื่อสร้าง page break สาหรับการพิมพ์ HTMLTableOutput = HTMLTableOutput.replace(/
next<\/td><\/tr>/gm, "") //การพิมพ์เลข HTMLTableOutput = HTMLTableOutput.replace(/%ด/g, '1'); HTMLTableOutput = HTMLTableOutput.replace(/%ร/g, '2'); HTMLTableOutput = HTMLTableOutput.replace(/%ม/g, '3'); HTMLTableOutput = HTMLTableOutput.replace(/%ฟ/g, '4'); HTMLTableOutput = HTMLTableOutput.replace(/%ซ/g, '5'); HTMLTableOutput = HTMLTableOutput.replace(/%ล/g, '6'); HTMLTableOutput = HTMLTableOutput.replace(/%ท/g, '7'); HTMLTableOutput = HTMLTableOutput.replace(/1ํ/g, '8'); HTMLTableOutput = HTMLTableOutput.replace(/2ํ/g, '9'); HTMLTableOutput = HTMLTableOutput.replace(/%0/g, '0'); //ใส่ข้อความกลับต้น HTMLTableOutput = HTMLTableOutput.replace(/\/\//g, 'repeat'); ; HTMLTableOutput = HTMLTableOutput.replace(/
repeat<\/td><\/tr>/g, '
กลับต้น
<\/td><\/tr>/g, '<\/table>'); console.log('HTMLTABLEOUTPUT', HTMLTableOutput) if (HTMLTableOutput !== "\n") { document.getElementById('thm').innerHTML = "
\n" + HTMLTableOutput + "
"; } //ตัวสร้างเครื่องหมายสะบัด // ดึงข้อมูล class "sabat" ทั้งหมด const sabats = document.querySelectorAll(".sabat"); // ลูป sabat เพื่อสร้างคุณลักษณะ sabats.forEach(cell => { // กำหนด position cell.style.position = "relative"; // สร้าง div สำหรับสร้างเส้นสะบัด ตั้งชื่อว่า curve const curve = document.createElement("div"); // สร้างเส้นสะบัด curve.style.position = "absolute"; curve.style.top = "-15%"; // ปรับค่าความสูงด้านบน curve.style.left = "50%"; curve.style.width = "20px"; // ความกว้าง curve.style.height = "20px"; // ความสูง curve.style.borderTop = "1.5px solid black"; // ความหนา curve.style.borderRadius = "50%"; // ความโค้ง curve.style.transform = "translateX(-30%)"; // // ใส่ curve ต่อไปใน cell ซึ่งอยู่ใน class sabat cell.prepend(curve); });