@@ -9,55 +9,45 @@ function roundToEigthInch (number) {
9
9
return number ;
10
10
}
11
11
12
- function patternSize ( units , collar , bL , bW , h ) {
12
+ function patternSize ( units , bL , bW , h ) {
13
13
if ( units == 1 ) { // METRIC
14
- var csA = 4 ; // cord channel height (4cm)
15
- var rt = 9 ; // roll top height (9 cm)
16
- var hemA = 1 ; // single fold hem allowance on each end of channel (1 cm)
17
- var hemRt = 4 ; // double fold hem allowance at top edge of roll top for 20mm webbing
18
- var sA = 1 ; // general seam allowance (1 cm)
14
+ var rt = 12 ; // roll-top collar height (12 cm)
15
+ var hem = 4 ; // double fold hem allowance at top of collar (20 mm webbing)
16
+ var sA = 1.5 ; // general seam allowance (1.5 cm) for french seams
19
17
}
20
18
else { // IMPERIAL
21
- var csA = 1.5 ; // cord channel height (1.5")
22
- var rt = 3.5 ; // roll top height (3.5")
23
- var hemA = 0.5 ; // single fold hem allowance on each end of channel (0.5")
24
- var hemRt = 1.5 ; // double fold hem allowance at top edge of roll top for 3/4" webbing
25
- var sA = 0.5 ; // general seam allowance (0.5")
19
+ var rt = 4.5 ; // roll-top collar height (4.5") 3/4" webbing rolled 4 times
20
+ var hem = 1.5 ; // double fold hem allowance at top of collar (0.75" webbing)
21
+ var sA = 5 / 8 ; // general seam allowance (5/8") for french seams
26
22
}
27
23
28
- if ( collar == 1 ) { // roll-top
29
- var collarh = rt ; // open height minus roll top
30
- var channelH = collarh + 2 * hemRt + sA ; //roll top height with hem and SA
31
- var fabricH = h + bW + ( 2 * sA ) ; // height
32
- }
33
- else { // drawcord cinch
34
- var collarh = 2 * csA ; // cSA folded on itself
35
- var channelH = collarh + ( 2 * sA ) ; // SA on top and bottom
36
- var fabricH = h + bW - csA + ( 2 * sA ) ; // height accounts for width and channel
37
- }
38
24
39
- if ( bL , bW > 0 ) {
40
- //main body fabric panel
41
- var fabricL = 2 * bL + 2 * bW + 2 * sA ;
42
-
43
- // separate cord channel
44
- var channelL = 2 * bL + 2 * bW + 2 * hemA ; //hem on each end
25
+ // body fabric panel
26
+ var fabricL = 2 * bL + ( 2 * bW ) + ( 2 * sA ) ;
27
+ var rollTopH = rt + hem ; // roll-top height + top hem
28
+ var webbingL = bL + bW + 2 * hem ; //adds hem on each end to fold under
45
29
46
- if ( units == 1 ) {
47
- var fabricL = fabricL . toFixed ( 1 ) ; //trimming to closest mm
48
- var fabricH = fabricH . toFixed ( 1 ) ;
49
- var channelL = channelL . toFixed ( 1 ) ;
50
- var channelH = channelH . toFixed ( 1 ) ;
30
+ if ( bW > 3 ) { // add material so top will close when bW is wide
31
+ var fabricH = h + bW + sA + rollTopH ; // adds (1/2bW) to top of fabricH to make up additional width
32
+ }
33
+ else {
34
+ var fabricH = h + ( 0.5 * bW ) + sA + rollTopH ; // 1/2bW is the corner cut off bottom to make rectangular
51
35
}
52
- else {
53
- var fabricL = roundToEigthInch ( fabricL ) ; //rounding to nearest 1/8" increment
54
- var fabricH = roundToEigthInch ( fabricH ) ;
55
- var channelL = roundToEigthInch ( channelL ) ;
56
- var channelH = roundToEigthInch ( channelH ) ;
57
- }
58
-
59
- return [ fabricL , fabricH , channelL , channelH , sA ] ; //
36
+
37
+
38
+
39
+ // rounding dimensions for output
40
+ if ( units == 1 ) {
41
+ var fabricL = fabricL . toFixed ( 1 ) ; //trimming to closest mm
42
+ var fabricH = fabricH . toFixed ( 1 ) ;
60
43
}
44
+ else {
45
+ var fabricL = roundToEigthInch ( fabricL ) ; //rounding to nearest 1/8" increment
46
+ var fabricH = roundToEigthInch ( fabricH ) ;
47
+ }
48
+
49
+ return [ fabricL , fabricH , sA , hem , webbingL ] ;
50
+
61
51
} ;
62
52
63
53
@@ -71,34 +61,42 @@ $('document').ready(function () {
71
61
$ ( '.dimension' ) . change ( function ( ) { //when any .dimension changes (input loses focus), function runs
72
62
73
63
var units = $ ( "input[type=radio][name=units]:checked" ) . val ( ) ; // inches (val=0) or cm (val=1)
74
- var collar = $ ( "input[type=radio][name=collar]:checked" ) . val ( ) ; // cinch (val=0) or roll-top (val=1)
75
64
76
- // assign variables based on input id values from html form
77
- var bottomLength = Number ( $ ( '#bottomLength' ) . val ( ) ) ;
78
- var bottomWidth = Number ( $ ( '#bottomWidth' ) . val ( ) ) ;
79
- var totalHeight = Number ( $ ( '#height' ) . val ( ) ) ;
65
+ // assign variables based on input id values from html form.
66
+ //Ensure object is number otherwise arithmetic is screwy
67
+ var bottomLength = Number ( $ ( '#bottomLength' ) . val ( ) ) ;
68
+ var bottomWidth = Number ( $ ( '#bottomWidth' ) . val ( ) ) ;
69
+ var sackHeight = Number ( $ ( '#height' ) . val ( ) ) ;
70
+
71
+ var halfBottomWidth = bottomWidth / 2 ; //used to size bottom corner within instructions
72
+ var halfTop = bottomLength + bottomWidth ; //used to size length of webbing along roll-top
80
73
81
- if ( bottomLength , bottomWidth , totalHeight != 0 ) {
82
- var scrap = patternSize ( units , collar , bottomLength , bottomWidth , totalHeight ) ;
74
+ if ( bottomLength > 1 && bottomWidth > 0 && sackHeight > 1 ) { // html input min=1, crappy validation but works
75
+ var scrap = patternSize ( units , bottomLength , bottomWidth , sackHeight ) ;
83
76
var fabricL = scrap [ 0 ] ;
84
77
var fabricH = scrap [ 1 ] ;
85
- var channelL = scrap [ 2 ] ;
86
- var channelH = scrap [ 3 ] ;
87
78
if ( units == 1 ) {
88
79
var unitText = " cm" ;
89
- var sA = scrap [ 4 ] ;
80
+ var sA = scrap [ 2 ] ;
81
+ var hem = scrap [ 3 ] ;
90
82
}
91
83
else {
92
84
var unitText = " in" ;
93
- var sA = scrap [ 4 ] ;
85
+ var sA = "5/8" ;
86
+ var hem = scrap [ 3 ] ;
94
87
}
88
+ var webbingLength = scrap [ 4 ] ;
95
89
96
- /* html id returns */
90
+ // html id returns
97
91
$ ( '.patternLength' ) . html ( fabricL + unitText ) ;
98
92
$ ( '.patternHeight' ) . html ( fabricH + unitText ) ;
99
- $ ( '.channelLength' ) . html ( channelL + unitText ) ;
100
- $ ( '.channelHeight' ) . html ( channelH + unitText ) ;
101
93
$ ( '.sA' ) . html ( sA + unitText ) ;
94
+ $ ( '.hem' ) . html ( hem + unitText ) ;
95
+ $ ( '.bottomWidth' ) . html ( bottomWidth + unitText ) ;
96
+ $ ( '.halfBottomWidth' ) . html ( halfBottomWidth + unitText ) ;
97
+ $ ( '.bottomLength' ) . html ( bottomLength + unitText ) ;
98
+ $ ( '.webbingLength' ) . html ( webbingLength + unitText ) ;
99
+ $ ( '.halfTop' ) . html ( halfTop + unitText ) ;
102
100
103
101
}
104
102
} ) ;
0 commit comments