Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. (function () {
  2. var t = {
  3. "# of Dye Lot batches": 18,
  4. "# of Dye Lots/meter": 19,
  5. "% of Cotton in the Fabric": 20,
  6. "Care label information": "",
  7. "Fabric / Yarn Mill Order #": 15,
  8. "Fabric / Yarn Mill Ref #": 16,
  9. "Fabric or Yarn Mill Name": 14,
  10. "Factory Code": 13,
  11. "Factory Name": 12,
  12. "Finished Garment Weight / Fabric GSM": 7,
  13. "Meter of Fabric Ordered for the PO": 17,
  14. "Mills Oeko Tex Ref #": 1,
  15. "Package name": "",
  16. "Previous report No": 9,
  17. "RAG BRAND": 2,
  18. "RAG PO #": 4,
  19. "RAG Style #": 3,
  20. "Shipment Date": 5,
  21. "Size": "",
  22. "Supplier Code": 11,
  23. "Supplier Name": 10,
  24. "Test request": "",
  25. "Yarn Content %": 8,
  26. "Yarn Count / Construction Required": 6
  27. };
  28.  
  29. var fluid = document.querySelectorAll("#customFieldForm .row-fluid")[2];
  30.  
  31. var adddiv = document.createElement("div");
  32. adddiv.style = "margin-bottom:10px;";
  33.  
  34. Array.from(fluid.querySelectorAll(".col-sm-5,.col-md-5,.col-sm-7")).filter(e => e.parentNode === fluid).forEach(e => {
  35. adddiv.appendChild(e.cloneNode(true));
  36. e.parentNode.removeChild(e);
  37. });
  38. fluid.appendChild(adddiv);
  39.  
  40. var saver = [], sink = [],idx = 1;
  41. fluid.querySelectorAll(".col-md-5,.col-sm-5").forEach(e => {
  42. if (t.hasOwnProperty(e.innerText)) {
  43. if (typeof t[e.innerText] == "number") {
  44. saver.push({
  45. order: t[e.innerText],
  46. html: e.parentNode.innerHTML
  47. });
  48. e.parentNode.setAttribute("id", `orderid-${idx++}`);
  49. e.parentNode.innerHTML = "";
  50. }
  51. else {
  52. sink.push(e.parentNode.cloneNode(true));
  53. fluid.removeChild(e.parentNode);
  54. }
  55. }
  56. });
  57. saver.sort((a, b) => a.order - b.order).forEach(e => {
  58. fluid.querySelector(`#orderid-${e.order}`).innerHTML = e.html;
  59. });
  60.  
  61. sink.forEach(e => {
  62. fluid.appendChild(e);
  63. });
  64. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement