PageSourceSearch

https://www.famdvd.com.br/js/freteproduto/index.js?q=1747660137

js famdvd.com.br collected 2026-09-25 09:01:54 UTC 6,435 bytes, 215 lines download raw bytes

1var freteproduto = {
2
3	init: function(twofields){
4	
5		if(twofields){
6			var validnumbers = /^[0-9]*$/;
7			jQuery("#postcode").mask("99999");
8			jQuery("#postcode2").mask("999").removeClass("no-display");
9				 jQuery('#postcode').keyup(function(){
10	                    if(jQuery(this).val().length == 5 && jQuery(this).val().search(validnumbers) != -1){
11	                        jQuery('#postcode2').focus();
12	                    }
13	              });
14			
15		}else{
16			jQuery("#postcode").mask("99999-999");
17		}
18
19	},
20
21	/*Retorna Url Base*/
22	baseurl : function(param){
23		myurl= (window.location);
24        splited_url = (myurl.toString().split("/"));
25        final_url = splited_url[0] + "//" + splited_url[2];
26   		if(this.islocalhost(document.location.hostname))
27   			final_url = splited_url[0] + "//" + splited_url[2] + "/" + splited_url[3];
28   		else
29   			final_url = splited_url[0] + "//" + splited_url[2];
30	    return final_url+"/"+param;
31	},
32
33	/*Valida se é localhost*/
34	islocalhost:function(hostname){
35		if(hostname == 'localhost'){
36			return true
37		}else{
38			exploded = hostname.split('.');
39			for(var k = 0 ; k < exploded.length; k++){
40				if(isNaN(exploded[k])) // se for numero
41					return false;
42			}
43		}
44		return true;
45	},
46
47	
48	 // Ao capturar a tecla enter...
49    onEnter: function(evt){
50        var key_code = evt.keyCode  ? evt.keyCode  :
51                       evt.charCode ? evt.charCode :
52                       evt.which    ? evt.which    : void 0;
53        if (key_code == 13) {
54            return true;
55        }
56    },
57
58    // Captura tecla enter da tela de login
59    enterrateevent: function(evt){
60    	  if(evt.keyCode == 13) { // enter
61				jQuery(".btn-frete").click();
62			    return false; 
63		}
64    },
65
66    collectrates : function() {
67    	var form = new VarienForm('product_addtocart_form');
68		
69		if (form.validator.validate()) {
70
71			//verifica se é bundle e monta os parâmetros
72			var form_bundle = jQuery('form#product_addtocart_form').serializeArray();
73			var isBundle = 0;
74			bundle_objects = new Array(); 
75			form_bundle.each(function(object){
76				if(object.name.substring(0, 17) == "bundle_option_qty"){
77					isBundle = 1;
78					bundle_objects.push(object); 
79				}
80			});
81
82			if(isBundle){
83				var product_id = jQuery(".product-id").val();
84				var postcode = jQuery("#postcode").val();
85				var qty = jQuery("#qty").val();
86				if(qty === undefined){qty = 1;}
87				data_to = {product_id: product_id,qty: qty, postcode: postcode, bundle: bundle_objects}
88			}else{
89
90				var option = [];
91				var option_text = {};
92				var radios = [];
93				
94				jQuery( ".product-custom-option" ).each(function(index) {
95					if(jQuery(this).attr('type') == 'radio'){
96						var theRadioName = jQuery(this).attr('name');
97						if(radios.indexOf(theRadioName) == -1 && jQuery(this).attr('checked') == 'checked'){
98							if(jQuery(this).val() != ''){
99								option[option.length] = jQuery(this).val();
100								radios[radios.length] = theRadioName;
101							}
102						}
103					}else if(jQuery(this).attr('type') == 'checkbox'){
104						if(jQuery(this).is(':checked')){
105							option[option.length] = jQuery(this).val();
106						}
107					}else if(jQuery(this).attr('multiple') == 'multiple'){
108						jQuery(this).children().each(function(index){
109							if(this.selected){
110								option[option.length] = jQuery(this).val();
111							}
112						});
113					}else if(jQuery(this).attr('type') == 'text' || jQuery(this).is('textarea')){
114						var name = jQuery(this)[0].name;
115						var codAttr = parseInt(name.replace(/[options\[\]]/g, ''));
116						
117						option_text[codAttr] = jQuery(this)[0].value;
118					}else{
119						if(jQuery(this).val() != ''){
120							option[option.length] = jQuery(this).val();
121						}
122					} 
123				});
124				
125				//Verifica se é produto configuravel,
126				
127				//Busca o option da Cor selecionada se houver.
128				var color_option = jQuery('.selected-color').attr('data-color');
129				if(color_option != 'undefined'){
130					option[option.length] = color_option;
131				}
132
133				//Verifica se o produto com preço em promoção
134				var price;
135				if (jQuery(".product-shop .special-price .price").length > 0) {
136					price = jQuery(".product-shop .special-price .price").html();
137				}
138				else {
139					price = jQuery('.product-shop .regular-price > .price').html();
140				}
141				
142				var qty = jQuery("#qty").val();
143				if(qty === undefined){qty = 1;}
144
145				data_to = "product_id=" + jQuery(".product-id").val();
146				data_to += "&postcode="+jQuery("#postcode").val();
147				data_to += "&qty="+qty;
148				data_to += "&option="+option;
149				data_to += "&price="+price;
150				data_to += "&option_text="+JSON.stringify(option_text);
151				
152				getattr = freteproduto.getattributesvalue();
153				
154				if (getattr != ""){
155					data_to += "&" + getattr;
156				}
157			}
158				
159				jQuery("#fp-loader").css("display", "block");
160				jQuery("#shipping-rates").css("display", "none");
161				
162			ajax_request = jQuery.ajax({
163				url  : freteproduto.baseurl('freteproduto/index/index'),
164				type : "POST",
165				data : data_to
166			});
167			
168			ajax_request.done(function(response){
169				var obj = eval('(' + response + ')');
170				jQuery("#shipping-rates li").remove();
171				for(var k = 0; k < obj.length; k++){
172					ul = jQuery("#shipping-rates");
173					li = jQuery("<li></li>");
174					li.html(obj[k]);
175					ul.append(li);
176					jQuery("#fp-loader").css("display", "none");
177					jQuery("#shipping-rates").css("display", "block");
178				}
179			});
180		}else{
181			campos = jQuery('.campos_atributo');
182			validar = true;
183			var alerta_texto = '';
184			campos.each(function(indice){
185				codigo = jQuery(this).attr('data-campocode');
186				jQuery(this).parent().find('.error-msg').remove();
187				if(jQuery(this).val() == ''){
188					alertano = "#dados_" + codigo;
189					alerta_texto += '<div class="error-msg">Selecione uma opção para: <b>' + jQuery(this).attr('data-campolabel') + '\n </b> </div><br>';
190					validar = false;
191				}
192			});
193
194			swal({
195				title: "Ops!",
196				text: alerta_texto,
197				html: true,
198				type: 'error'
199			});
200		}
201	},
202
203	getattributesvalue : function() {
204		var attrsshipping = jQuery(".attrshipping");
205		var v_string = '';
206		for (var k = 0; k < attrsshipping.length; k++) {
207			if (attrsshipping.length == (k + 1))
208				v_string += "attr" + attrsshipping.eq(k).html() + "=" + jQuery("#attribute" + attrsshipping.eq(k).html()).val();
209			else
210				v_string += "attr" + attrsshipping.eq(k).html() + "=" + jQuery("#attribute" + attrsshipping.eq(k).html()).val() + "&";
211		}
212		return v_string;
213	}
214};
215

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.