Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var oTable = document.getElementsByClassName("alternating")[0];
- var rowLength = oTable.rows.length;
- var tabGenerated = "[code][table]\n[**]";
- var resTot = 0;
- //loops through rows
- for (i = 0; i < rowLength; i++){
- /*if(i == 1) {
- i = 3;
- }*/
- //gets cells of current row
- var oCells = oTable.rows.item(i).cells;
- //gets amount of cells of current row
- var cellLength = oCells.length;
- //loops through each cell in current row
- for(var j = 0; j < cellLength; j++){
- // get your cell info here
- var cellVal = oCells.item(j).innerHTML;
- if(i == 0) {
- var myRegexp = /.*">\s*(.*)<\/.*/g;
- var match = myRegexp.exec(cellVal);
- if(match != null) {
- cellVal = match[1];
- }
- if(j != cellLength-1) {
- tabGenerated = tabGenerated + cellVal + "[||]";
- }else {
- tabGenerated = tabGenerated + cellVal + "[/**]";
- }
- }else {
- if(j == 0) {
- tabGenerated = tabGenerated + "\n[*]" + cellVal.trim();
- } else if(j == 1) {
- var myRegexp = /.*">(.*)<\/.*/g;
- var match = myRegexp.exec(cellVal);
- if(match != null) {
- cellVal = match[1];
- }
- tabGenerated = tabGenerated + "[|]" + "[player]" + cellVal + "[/player]";
- }else {
- tabGenerated = tabGenerated + "[|][b]" + parseInt(cellVal.trim()).toLocaleString('en').replace(/,/g," ") + "[/b]";
- if(j == cellLength-1) {
- resTot += parseInt(cellVal.trim());
- }
- }
- }
- //console.log(cellVal);
- }
- }
- tabGenerated += "\n[/table]";
- totWood = document.getElementById("wood").innerHTML;
- totStone = document.getElementById("stone").innerHTML;
- totIron = document.getElementById("iron").innerHTML;
- console.log(tabGenerated+"\n[table]\n[**]"+"TOTAL[||]"+parseInt(resTot).toLocaleString('en').replace(/,/g," ")+"[/**][/table]"+"\n[table]\n[**]"+"BOIS[||]ARGILE[||]FER[/**]\n[*]"+totWood+"[|]"+totStone+"[|]"+totIron+"[/table][/code]");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement