-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.js
163 lines (146 loc) · 5.12 KB
/
list.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
$(document).ready(function(){
// from beginning, hide all but first select
//$('.setup, .screen_charge, #quantity, #personalization').hide();
// load all the dropdowns
for (var i = 0; i < options.length; i++) {
var element = options[i][0];
$('.apparel').append('<option value="' + i + '">' + element + '</option>');
}
/*for (var i = 1; i < 10; i++) {
$('.setup').append('<option value=' + i + '>' + i + '</option>');
}*/
for (var i = 1; i < 7; i++) {
var tmp_value = i-1;
$('.screen_charge .content').append('<option value=' + tmp_value + '>' + i + '</option>');
} // end of loads
// CHOOSE YOUR APPAREL
$(".apparel").change(function() {
var price_position = $('.apparel option:selected').val();
price = options[price_position][1];
static_item = $('.apparel option:selected').text();
static_garment_price = price;
get_total();
$('#quantity_box').show('fast');
});
// CHOOSE YOUR QUANTITY
$( "#quantity" ).slider({
range: "min",
value: 37,
min: 1,
max: 999,
slide: function( event, ui ) {
$( "#quantity_amount" ).val(ui.value + " garments");
static_quantity = ui.value;
get_total();
$('#setup_box').show('fast');
}
});
$( "#quantity_amount" ).val($( "#quantity" ).slider( "value" ) + " garments");
// CHOOSE HOW MANY GRAPHICS (SETUPS)
$( "#setup" ).slider({
range: "min",
value: 0,
min: 0,
max: 10,
slide: function( event, ui ) {
$( "#setup_amount" ).val(ui.value + " graphics");
static_extra_setup = [];
static_numOfSetup = ui.value;
get_total();
generate_screen_box(ui.value);
}
});
$( "#setup_amount" ).val($( "#setup" ).slider( "value" ) + " graphics");
// generate screen_boxes based on number of graphics
function generate_screen_box(num_graphics) {
$('.screen_charge_boxes').html(''); // clears the boxes if # of graphics change
for (var i = 0; i < num_graphics; i++) {
var str = '';
var j = i + 1;
str += '<h3>Number of colours on Graphic #' + j + '</h3>';
str += '<div class="screen_charge">';
//str += '<select class="content"></select>';
str += '<input type="text" id="SC'+i+'" name="SC'+i+'" disabled style="border: 0; color: #f6931f; font-weight: bold;" />';
str += '<div class="sc_DIV" id="SC'+i+'slider"></div>';
str += '</div>';
$('.screen_charge_boxes').append(str);
$('#SC'+i).val('1 colour');
generate_sliders(i);
}
//staticPrice(num_graphics);
$('#personalization').show('fast');
}
function generate_sliders() {
var position = '';
$( '.sc_DIV' ).each(function(idx, elm) {
//alert('omg');
var name = elm.id.replace('slider', '');
position = name.replace('SC', '');
console.log(elm.id);
$('#' + elm.id).slider({
range: "min",
value: 1,
min: 0,
max: 6,
slide: function( event, ui ) {
$( '#' + name ).val(ui.value + " colour(s)");
screen_price_array[idx] = ui.value;
get_screen_charge(idx,ui.value);
var tmp_value = ui.value;
if (ui.value > 1) {
static_extra_setup[idx] = (ui.value - 1);
} else {
static_extra_setup[idx] = 0;
}
console.log('changes to idx ' + idx + ' and positions is ' + position + ' and colours are ' + ui.value);
get_total();
}
});
});
static_extra_setup[position] = 0;
get_screen_charge(position,1);
get_total();
}
/// inefficient way of checking the price every time... needs improvement
function get_screen_charge(screen_position, num_colours) {
var total_screencharge;
var determined_sc;
num_colours--;
if (static_quantity < 12) {
determined_sc = total_screencharge = 20 / static_quantity;
}
else if (static_quantity >= 12 && static_quantity <= 24) {
determined_sc = total_screencharge = twelve[num_colours]; }
else if (static_quantity >= 25 && static_quantity <= 50) {
determined_sc = total_screencharge = twenty_five[num_colours];}
else if (static_quantity >= 51 && static_quantity <= 99) {
determined_sc = total_screencharge = fifty_one[num_colours]; }
else if (static_quantity >= 100 && static_quantity <= 149) {
determined_sc = total_screencharge = hundred[num_colours]; }
else if (static_quantity >= 150 && static_quantity <= 249) {
determined_sc = total_screencharge = hundred_fifty[num_colours]; }
else if (static_quantity >= 250 && static_quantity <= 499) {
determined_sc = total_screencharge = two_fifty[num_colours]; }
else if (static_quantity >= 500 && static_quantity <= 999) {
determined_sc = total_screencharge = five_hundred[num_colours]; }
else if (static_quantity > 999) {
alert('Sorry, we do not accept orders over 999 of the same garment'); }
total_screencharge = determined_sc * static_quantity;
screen_price_unit[screen_position] = determined_sc;
static_screen_array[screen_position] = Math.round(total_screencharge*100)/100;
get_total();
}
// PERSONALIZATION?!
$( "#personalize" ).slider({
range: "min",
value: 0,
min: 0,
max: 700,
slide: function( event, ui ) {
$( "#personalize_amount" ).val(ui.value + " garments personalized");
static_personalization = ui.value;
get_total();
}
});
$( "#personalize_amount" ).val($( "#personalize" ).slider( "value" ) + " garments personalized");
});