//get text from textarea let inputText = document.getElementById("thm").innerHTML; //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 += "
/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(/\[(.*?)\]/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(/([ดรมฟซลทํ])\\([+])/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, "END<\/td><\/tr>/g, '<\/table> | กลับต้น<\/div>');
HTMLTableOutput = HTMLTableOutput.replace(/ END<\/td><\/tr>/g, ' | | | | | | | | กลับต้น | |