Guest User

Untitled

a guest
Apr 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. // ok, trying again in javascript
  2.  
  3. /*
  4. Psuedo code:
  5. if this product is a new product
  6. end the last product:
  7. if the last product had options
  8. use a terminator
  9. start a new product in the products array
  10. else
  11. keep adding to the current value:
  12. if this is a new option
  13. start a new option in the options array
  14. else
  15. keep adding to the current option
  16. */
  17.  
  18. var source_data = [
  19. // pid, oid, oval
  20. [p1, o1, "val1"],
  21. [p1, o2, "val2"],
  22. [p2, o1, "val3"],
  23. [p2, o2, "val4"],
  24. [p3, o1, "val5"],
  25. [p3, o2, "val6"],
  26. ];
  27.  
  28. var dest_data = [
  29. {
  30. "pid": p1,
  31. "opts": {
  32. o1: "val1",
  33. o2: "val2"
  34. }
  35. },
  36. {
  37. "pid": p2,
  38. "opts": {
  39. o1: "val3",
  40. o2: "val4"
  41. }
  42. },
  43. {
  44. "pid": p3,
  45. "opts": {
  46. o1: "val5",
  47. o2: "val6"
  48. }
  49. },
  50. ]
Add Comment
Please, Sign In to add comment