1/** 2 * 2007-2018 Mondial relay 3 * 4 * NOTICE OF LICENSE 5 * 6 * This source file is subject to the Academic Free License (AFL 3.0) 7 * that is bundled with this package in the file LICENSE.txt. 8 * It is also available through the world-wide-web at this URL: 9 * http://opensource.org/licenses/afl-3.0.php 10 * If you did not receive a copy of the license and are unable to 11 * obtain it through the world-wide-web, please send an email 12 * to Mondial relay so we can send you a copy immediately. 13 * 14 * DISCLAIMER 15 * 16 * Do not edit or add to this file if you wish to upgrade Mondial relay to newer 17 * versions in the future. If you wish to customize Mondial relay for your 18 * needs please refer to Mondial relay for more information. 19 * 20 * @author Mondial relay 21 * @copyright 2007-2018 Mondial relay 22 * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 23 * International Registered Trademark & Property of Mondial relay 24 */ 25function getNumeric(val) { 26 var reg = new RegExp("[0-9]+", "g"); 27 var res = reg.exec(val); 28 if (isNaN(res)) 29 return 0; 30 else 31 return res; 32} 33 34function checkToDisplayRelayList() 35{ 36 if (typeof PS_MRData != 'undefined') 37 { 38 //============================================================ 39 // auto display fancybox if radio already check 40 //============================================================ 41 if($('.MR-Widget').is(':visible')) 42 return; 43 PS_MRSelectedRelayPoint['relayPointNum'] = PS_MRData.pre_selected_relay; 44 // PS_VERSION < '1.5' 45 if (PS_MRData.PS_VERSION < '1.5') 46 { 47 // Bind id_carrierX to an ajax call 48 $.each(PS_MRData.carrier_list, function (i, carrier) { 49 PS_MRCarrierMethodList[carrier.id_carrier] = carrier.id_mr_method; 50 if ($('#id_carrier' + carrier.id_carrier).attr('checked')) { 51 PS_MRSelectedRelayPoint['carrier_id'] = carrier.id_carrier; 52 PS_MRDisplayWidget(carrier.id_carrier); 53 setProtectRelaySelected(); 54 } 55 }); 56 57 } 58 else if (PS_MRData.PS_VERSION >= '1.5' 59 && typeof PS_MRData.carrier != 'undefined' 60 ) 61 { // 1.5 way 62 // CUSTOM - Bugfix radio sélectioné retourne undefined 63 // var carrier_selected = $('input[class=delivery_option_radio]:checked').val(); 64 var carrier_selected = $('.delivery_option_radio:checked').val(); 65 $.each(PS_MRData.carrier_list, function (i, carrier) { 66 PS_MRCarrierMethodList[carrier.id_carrier] = carrier.id_mr_method; 67 if (carrier.id_carrier + ',' == carrier_selected || carrier.id_carrier == carrier_selected) { 68 overrideUpdateExtraCarrier(carrier_selected, id_address); 69 PS_MRSelectedRelayPoint['carrier_id'] = carrier.id_carrier; 70 PS_MRDisplayWidget(carrier.id_carrier); 71 setProtectRelaySelected(); 72 } 73 }); 74 } 75 //============================================================ 76 // Handle input click of the other input to hide the previous relay point list displayed 77 $('input[name=id_carrier], input.delivery_option_radio').click(function (e) { 78 displayPickupPlace(0); 79 }); 80 } 81 //return false; 82} 83 84function isMRCarrier(id_carrier) { 85 var carrier_list = PS_MRData.carrier_list; 86 for (i in carrier_list) { 87 var MR_carrier = carrier_list[i]; 88 if (MR_carrier.id_carrier == id_carrier) { 89 return MR_carrier; 90 } 91 } 92 return false; 93} 94 95function hideRelaySelectedBox(_this) { 96 // Hide MR input if one of them is not selected 97 if (PS_MRCarrierMethodList[_this.val()] == undefined) { 98 // 1.5 way 99 var id = getNumeric(_this.val()); 100 if (PS_MRCarrierMethodList[id] == undefined) { 101 displayPickupPlace(0); 102 PS_MRSelectedRelayPoint['carrier_id'] = 0; 103 PS_MRDisplayWidget(0); 104 PS_MRSelectedRelayPoint['relayPointNum'] = 0; 105 } 106 else { 107 PS_MRSelectedRelayPoint['carrier_id'] = id; 108 PS_MRDisplayWidget(id); 109 } 110 } 111 else { 112 PS_MRSelectedRelayPoint['carrier_id'] = _this.val(); 113 PS_MRDisplayWidget(_this.val()); 114 } 115 return false;
116} 117 118function PS_MRDisplayWidget(carrier_id) { 119 var dlv_mode = ''; 120 $.each(PS_MRData.carrier_list, function (i, carrier) { 121 if (carrier.id_carrier == carrier_id) 122 dlv_mode = carrier.dlv_mode; 123 PS_MRSelectedRelayPoint['relayPointNum'] = -1; 124 PS_MRAddSelectedCarrierInDB(carrier_id); 125 } 126 ); 127 if (carrier_id) { 128 if (dlv_mode != 'LD1' && dlv_mode != 'LDS' && dlv_mode != 'HOM') { 129 loadMR_Map("#Zone_Widget", dlv_mode); 130 $("#link_zone_widget").click(); 131 if (PS_MRSelectedRelayPoint['relayPointNum'] == -1) 132 PS_MRSelectedRelayPoint['relayPointNum'] = 0; 133 } 134 else 135 displayPickupPlace(0); 136 } 137 return false; 138} 139 140 141function overrideUpdateExtraCarrier(id_delivery_option, id_address) 142{ 143 if (PS_MRData.PS_VERSION < '1.5') 144 return false; 145 146 var url = ""; 147 var method = 'updateExtraCarrier'; 148 var params = ''; 149 if (typeof (orderOpcUrl) !== 'undefined') { 150 method = 'updateCarrierAndGetPayments'; 151 params += '&recyclable=' + (($('#recyclable:checked').val() != undefined) ? 1 : 0); 152 params += '&gift=' + (($('#gift:checked').val() != undefined) ? 1 : 0); 153 params += '&gift_message=' + $('#gift_message').val(); 154 params += '&delivery_option[' + id_address + ']=' + id_delivery_option; 155 url = orderOpcUrl; 156 } 157 else 158 url = orderUrl; 159 160 $.ajax({ 161 type: 'POST', 162 headers: {"cache-control": "no-cache"}, 163 url: url + '?rand=' + new Date().getTime(), 164 async: false, 165 cache: false, 166 dataType: "json", 167 data: 'ajax=true' 168 + '&method=' + method 169 + params 170 + '&id_address=' + id_address 171 + '&id_delivery_option=' + id_delivery_option 172 + '&token=' + static_token 173 + '&allow_refresh=1', 174 success: function (jsonData) 175 { 176 //$('#HOOK_EXTRACARRIER_'+id_address).html(jsonData['content']); 177 setProtectRelaySelected(); 178 return false; 179 } 180 }); 181 return false; 182} 183 184function displayPickupPlace(info) { 185 var id = "relay_point_selected_box"; 186 187 if (!info) { 188 $('#' + id).hide(); 189 $('#' + id).remove(); 190 return false; 191 } 192 193 if (PS_MRData.PS_VERSION < '1.5') 194 { 195 var block_carrier = $('#carrierTable'); 196 } 197 else { 198 var block_carrier = $('.delivery_options_address'); 199 } 200 if ($('#' + id).length !== 0) { 201 $('#' + id).html('<h3>' + relay_point_selected_box_label + '</h3>' + info); 202 $('#' + id).show(); 203 } 204 else { 205 $('<div id="' + id + '"><h3>' + relay_point_selected_box_label + '</h3>' + info + '</div>').insertAfter(block_carrier); 206 } 207 return false; 208} 209 210function PS_MRAddSelectedCarrierInDB(id_carrier) 211{ 212 // Make the request 213 $.ajax({ 214 type: 'POST', 215 url: MR_ajax_url, 216 data: {'method': 'addSelectedCarrierToDB', 217 'id_carrier': id_carrier, 218 'id_mr_method': PS_MRCarrierMethodList[id_carrier], 219 'mrtoken': mrtoken}, 220 success: function (json) 221 { 222 return false; 223 } 224 }); 225 return false; 226} 227 228$(document).ready(function () 229{ 230 231 if (typeof PS_MRData != 'undefined') 232 { 233 if (PS_MRData.PS_VERSION < '1.5') { 234 $('input[name="id_carrier"]').click(function () { 235 checkToDisplayRelayList(); 236 }); 237 } else { 238 $(document).on('click', 'input[name^="delivery_option"]', function(){ 239 checkToDisplayRelayList(); 240 }); 241 } 242 } 243});
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.