Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ok, trying again in javascript
- /*
- Psuedo code:
- if this product is a new product
- end the last product:
- if the last product had options
- use a terminator
- start a new product in the products array
- else
- keep adding to the current value:
- if this is a new option
- start a new option in the options array
- else
- keep adding to the current option
- */
- var source_data = [
- // pid, oid, oval
- [p1, o1, "val1"],
- [p1, o2, "val2"],
- [p2, o1, "val3"],
- [p2, o2, "val4"],
- [p3, o1, "val5"],
- [p3, o2, "val6"],
- ];
- var dest_data = [
- {
- "pid": p1,
- "opts": {
- o1: "val1",
- o2: "val2"
- }
- },
- {
- "pid": p2,
- "opts": {
- o1: "val3",
- o2: "val4"
- }
- },
- {
- "pid": p3,
- "opts": {
- o1: "val5",
- o2: "val6"
- }
- },
- ]
Add Comment
Please, Sign In to add comment