diff --git a/assets/js/zipsack.js b/assets/js/zipsack.js index 7ace10b..1652ef3 100644 --- a/assets/js/zipsack.js +++ b/assets/js/zipsack.js @@ -4,21 +4,51 @@ Calculate fabric pattern sizes for rectangular zip sack */ -function patternSize(l,w,h) { - var zsA = 0.5; // zipper seam allowance - var sA = 0.375; // general seam allowance +function roundToEigthInch (number) { + var number = (Math.round(number * 8) / 8); + return number; +} + +// function patternSize(l,w,h) { +// var zsA = 0.5; // zipper seam allowance +// var sA = 0.375; // general seam allowance +// if (l,w,h > 0) { +// var fabricW = 2*w + 2*h + (2*zsA); +// var fabricH = 1*l + 1*h + (2*sA); +// return [fabricW, fabricH]; +// } +// } + +function patternSize(units,l,w,h) { + if (units==1) { // metric + var zsA = 1.3; // channel seam allowance + var sA = 1.0; // general seam allowance + } + else { // imperial + var zsA = 0.5; // channel seam allowance + var sA = 0.375; // general seam allowance + } if (l,w,h > 0) { var fabricW = 2*w + 2*h + (2*zsA); var fabricH = 1*l + 1*h + (2*sA); - return [fabricW, fabricH]; + + if (units==1) { + var fabricW = fabricW.toFixed(1); //trimming to closest mm + var fabricH = fabricH.toFixed(1); + } + else { + var fabricW = roundToEigthInch(fabricW); //rounding to nearest 1/8" increment + var fabricH = roundToEigthInch(fabricH); + } + + return [fabricW, fabricH]; // returns radius } } - $('document').ready(function () { - var version = "v0.2"; + var version = "v0.3"; $('.version').html(version); $('.dimension').change(function () { //when any .dimension changes (input loses focus), function runs @@ -31,22 +61,25 @@ $('document').ready(function () { } }); + var units = $( "input[type=radio][name=units]:checked" ).val(); // inches (val=0) or cm (val=1) + var length = $('#length').val(); var width = $('#width').val(); var height = $('#height').val(); if (length, width, height != "") { - var scrap = patternSize(length,width,height); + var scrap = patternSize(units, length,width,height); var fabricW = scrap[0]; var fabricH = scrap[1]; - + if (units == 1) { var unitText = " cm" } + else { var unitText = " in" } var volLiters = (vol * 0.0163871).toFixed(1); //convert cubic inches to liters //html id returns $('#volumeCuIn').html(vol); $('#volumeLiters').html(volLiters); - $('.patternHeight').html(fabricH + '"'); - $('.patternWidth').html(fabricW + '"'); + $('.patternHeight').html(fabricH + unitText); + $('.patternWidth').html(fabricW + unitText); } }); diff --git a/zpinstructions.html b/zpinstructions.html index 06232eb..d780e3d 100644 --- a/zpinstructions.html +++ b/zpinstructions.html @@ -29,7 +29,7 @@ @@ -172,8 +191,8 @@

Close Zip Pouch Ends

  1. With wrong sides out, close zipper and lay flat. Ensure zipper is parallel with edges. Zipper should be evenly spaced in the middle.
  2. -
  3. Lining up the bottom edge, sew one end closed with the 3/8 inch seam allowance. Being careful not to break your needle, sew over the zipper.
  4. -
  5. Flip around, smooth out and ensure zipper is still parallel and evenly spaced. Sew opposite end with 3/8" seam allowance.
  6. +
  7. Lining up the bottom edge, sew one end closed with the 3/8 inch (1 cm) seam allowance. Being careful not to break your needle, sew over the zipper.
  8. +
  9. Flip around, smooth out and ensure zipper is still parallel and evenly spaced. Sew opposite end with 3/8" (1 cm) seam allseam allseam allowance.
  10. If you have long zipper tape, don't make the rookie move and sew your zipper pull on the outside of the bag!
  11. Trim excess zipper tape off both ends.
  12. For bonus points, consider adding pull loops to the zipper ends. Grosgrain ribbon or excess zipper tape work great. Make sure your loops are sewn INSIDE the pouch!