1// START: VIEW CART CONTROLLER 2app.controller('orderSummaryCtrl', ['$scope', '$http', '$timeout', '$log', '$compile', 'httpRequest', 'pcService', function($scope, $http, $timeout, $log, $compile, httpRequest, pcService) { 3 4 $scope.shoppingcart = []; 5 $scope.provider = ""; 6 7 $scope.blockUI = function (div, msg) { 8 $pc.blockUI.defaults.css = { 9 top: '5%', 10 left: '20%', 11 right: '20%' 12 }; 13 $pc(div).block({ 14 centerY: 0, 15 centerX: false, 16 message: '<div id="pcMain">' + msg + "</div>", 17 overlayCSS: { 18 backgroundColor: '#FFFFFF', 19 cursor: 'wait', 20 padding: '4px' 21 } 22 }); 23 }; 24 25 $scope.unblockUI = function (div) { 26 $pc(div).unblock(); 27 }; 28 29 $scope.$on('handleBroadcast', function(event, data){ 30 $scope.shoppingcart = data; 31 $scope.unblockUI('#pcCart'); 32 }); 33 $scope.refresh = function () { 34 pcService.getShoppingCart('', false); 35 }; 36 37 38 // START: Discounts 39 $scope.calculateDiscountsCart = function (rtype) { 40 41 $scope.checkSessionExpired(); 42 $scope.clearAllErrorMsg(); 43
44 httpRequest.loadAsync('opc_calculate.asp', $pc('#DiscountCode').fieldSerialize() + '&fromcart=1&rtype='+rtype).then(function (data) { 45 if (data == "SECURITY") { 46 // Session Expired 47 window.location = "msg.asp?message=1"; 48 } else { 49 if (data.indexOf("|***|OK|***|") >= 0) { 50 var tmpArr = data.split("|***|") 51 $scope.clearAllErrorMsg(); 52 $pc("#DiscountCode").val(tmpArr[2]); 53 } else { 54 var tmpArr = data.split("|***|") 55 $scope.displayMessage("#DiscountMessageBox", tmpArr[3]); 56 $pc("#DiscountCode").val(tmpArr[2]); 57 } 58 } 59 $scope.refresh(); 60 }); 61 } 62 // END: Discounts 63 64 65 // START: Check Expired Cart 66 $scope.checkSessionExpired = function (formdata) { 67 68 httpRequest.loadAsync('opc_cartcheck.asp', formdata).then(function (data) { 69 70 if (data !== "OK") { 71 window.location = "viewcart.asp"; 72 } 73 74 }); 75 76 }; 77 // END: Check Expired Cart 78 79 80 // START: Submit Est Ship Form 81 $scope.submitEstShipForm = function (rtype) { 82 httpRequest.loadAsync('estimateShipCost.asp', $pc('#shipCost').formSerialize()).then(function (data) { 83 injector = $compile(data)($scope); 84 $pc("#pcEstimateShippingArea").html(injector); 85 $scope.unblockUI('#pcOrderSummaryWrapper'); 86 }); 87 } 88 // END: Submit Est Ship Form 89 90 91 92 // START: Load Estimate Ship Form 93 $scope.LoadEstShipForm = function () { 94 httpRequest.loadAsync('estimateShipCost.asp', '').then(function (data) { 95 injector = $compile(data)($scope); 96 $pc("#pcEstimateShippingArea").html(injector); 97 $pc("#zip").keydown(function(event){ 98 if(event.keyCode == 13){ 99 event.preventDefault(); 100 $pc("#SubmitShip").click(); 101 } 102 }); 103 }); 104 } 105 // END: Load Estimate Ship Form 106 107 108 // Update Order with Selected Shipping Method 109 $scope.updateShippingMethod = function (formdata) { 110 111 $scope.checkSessionExpired(); 112 $scope.clearAllErrorMsg(); 113 114 $scope.blockUI('#pcOrderSummaryWrapper', '<div class="pcCheckoutSubTitle"><img src="images/ajax-loader1.gif" /> Updating Order Summary...</div>'); 115 116 formdata = $pc('#ShipChargeForm').formSerialize() + "&ShippingChargeSubmit=yes&f=cart"; 117 118 // Block UI 119 $scope.blockUI('#pcRatesPanelContent', '<div class="pcCheckoutSubTitle"><img src="images/ajax-loader1.gif" /> Preparing Payment Information</div>'); 120 121 httpRequest.loadAsync('opc_chooseShpmnt.asp', formdata).then(function (data) { 122 if (data == "SECURITY") { 123 // Session Expired 124 // window.location = "msg.asp?message=1"; 125 $scope.unblockUI('#pcOrderSummaryWrapper'); 126 } else { 127 //if (data == "OK") { 128 //$scope.clearAllErrorMsg(); 129 //$scope.ratingSubmit = true; 130 //$scope.checkTaxRates(); 131 //} else { 132 $scope.unblockUI('#pcOrderSummaryWrapper'); 133 //$scope.displayCustErrorMsg("#RatingMessageBox", '<img src="images/pc_icon_error_small.png" align="absmiddle"> ' + data); 134 //} 135 $scope.refresh(); 136 } 137 }); 138 }; 139 140 $scope.showEstShip = function () { 141 $pc('#pcEstimateShippingTxt').hide(); 142 $scope.LoadEstShipForm(); 143 $pc('#pcEstimateShippingArea').show(); 144 }; 145 146 $scope.getEstShipServices = function () { 147 var tmpTest=FormEst_Validator(); 148 if (tmpTest==3) 149 { 150 $scope.blockUI('#pcOrderSummaryWrapper', '<div class="pcCheckoutSubTitle"><img src="images/ajax-loader1.gif" /> Estimating Shipping...</div>'); 151 152 httpRequest.loadAsync('checkValidZip.asp', $pc('#shipCost').formSerialize()).then(function (data) { 153 if(data == "VALID") { 154 $scope.submitEstShipForm(); 155 } else { 156 $pc("#ErrorZipBox").html(data); 157 $pc("#ErrorZipBox").show(); 158 setTimeout(function(){ 159 $pc("#ErrorZipBox").fadeOut('fast'); 160 },2000); 161 $scope.unblockUI('#pcOrderSummaryWrapper'); 162 } 163 }); 164 } 165 else 166 { 167 if (tmpTest==1) 168 { 169 $pc("#ErrorZipBox").html("Please enter a value for Postal Code"); 170 } 171 else 172 { 173 if (tmpTest==2) $pc("#ErrorZipBox").html("Please enter a value for StateCode/Province"); 174 } 175 $pc("#ErrorZipBox").show(); 176 setTimeout(function(){ 177 $pc("#ErrorZipBox").fadeOut('fast'); 178 },2000); 179 $scope.unblockUI('#pcOrderSummaryWrapper'); 180 } 181 }; 182 183 $scope.getEstShipServicesS = function () { 184 if ($pc('#provider').val()!='') 185 { 186 $scope.blockUI('#pcEstimateShippingArea', '<div class="pcCheckoutSubTitle"><img src="images/ajax-loader1.gif" /> Loading Cart...</div>'); 187 $scope.submitEstShipForm(); 188 $scope.unblockUI('#pcEstimateShippingArea'); 189 } 190 }; 191 192 $scope.hideEstShip = function () { 193 $pc('#pcEstimateShippingTxt').show(); 194 $pc('#pcEstimateShippingArea').hide(); 195 }; 196 197 $scope.displayMessage = function (div, msg) { 198 $pc(div).html(msg); 199 $pc(div).show(); 200 }; 201 $scope.clearAllErrorMsg = function () { 202 203 $pc('#DiscountMessageBox').html(''); 204 $pc('#DiscountMessageBox').hide(); 205 }; 206
207 function init() { 208 $scope.blockUI('#pcCart', '<div class="pcCheckoutSubTitle"><img src="images/ajax-loader1.gif" /> Loading Cart...</div>'); 209 if (scDispDiscCart=="1") { 210 $scope.calculateDiscountsCart(''); 211 } 212 }; 213 init(); 214 215 $scope.Evaluate = function (val) { 216 if (val == 'true' || val == true) { 217 return true; 218 } else { 219 return false; 220 } 221 }; 222 223 $scope.IsEmpty = function (val) { 224 if (val) { 225 return false; 226 } else { 227 return true; 228 } 229 }; 230 231 $scope.CheckQuantityMins = function (a, b, c, d, e, f) { 232 checkproqtyNew(a, b, c, d, e, f); 233 }; 234 235 $scope.currentUpdate=''; 236 $scope.ShowUpdateButton = function (id) { 237 if ($scope.currentUpdate==id || $scope.currentUpdate=='') { 238 $pc("#pcUpdate" + id).show(); 239 } else { 240 $pc("#pcUpdate" + $scope.currentUpdate).hide(); 241 $pc("#pcUpdate" + id).show(); 242 } 243 $scope.currentUpdate = id; 244 }; 245 $scope.HideUpdateButton = function (id) { 246 var expr = '$pc("#pcUpdate' + id + '").hide();'; 247 setTimeout(expr, 200); 248 }; 249 250}]); 251// END: VIEW CART CONTROLLER 252 253 254function checkQtyChange() { 255 var i = 0; 256 for (i = 1; i <= pcCartIndex; i++) { 257 if (eval("document.recalculate.Cant" + i).value != eval("document.recalculate.SavQty" + i).value) { 258 alert(alert_recal); 259 return (false); 260 } 261 } 262 return (true); 263 264} 265 266function win(fileName) { 267 myFloater = window.open('', 'myWindow', 'scrollbars=yes,status=no,width=300,height=250') 268 myFloater.location.href = fileName; 269} 270 271function winShipPreview(fileName) { 272 myFloater = window.open('', 'myWindow', 'scrollbars=yes,status=no,width=520,height=400') 273 myFloater.location.href = fileName; 274} 275 276function validateNumber(field) { 277 var val = field.value; 278 if (!/^\d*$/.test(val) || val == 0) { 279 alert(showcart_2); 280 field.focus(); 281 field.select(); 282 } 283} 284 285function isDigit(s) { 286 var test = "" + s; 287 if (test == "0" || test == "1" || test == "2" || test == "3" || test == "4" || test == "5" || test == "6" || test == "7" || test == "8" || test == "9") { 288 return (true); 289 } 290 return (false); 291} 292 293function allDigit(s) { 294 var test = "" + s; 295 for (var k = 0; k < test.length; k++) { 296 var c = test.substring(k, k + 1); 297 if (isDigit(c) == false) { 298 return (false); 299 } 300 } 301 return (true); 302} 303 304function checkproqtyNew(id, qty, ctype, remain, MultiQty, isActive) { 305 306 if (isActive == 'true' || isActive == true) { 307 308 var fname = $pc("#" + id) 309 310 RemainIssue1 = "A"; 311 if (fname.val() == "") { 312 if (RemainIssue.indexOf('||' + id) == -1) RemainIssue = RemainIssue + '||' + id; 313 fname.focus(); 314 return (false); 315 } 316 317 if (allDigit(fname.val()) == false) { 318 alert(alert_5); 319 if (RemainIssue.indexOf('||' + id) == -1) RemainIssue = RemainIssue + '||' + id; 320 fname.focus(); 321 return (false); 322 } 323 324 if (fname.val() == "0") { 325 alert(alert_5); 326 if (RemainIssue.indexOf('||' + id) == -1) RemainIssue = RemainIssue + '||' + id; 327 fname.focus(); 328 return (false); 329 } 330 331 if (ctype > 0) { 332 TempValue = eval(fname.val()); 333 TempV1 = (TempValue / MultiQty); 334 TempV1a = TempValue * TempV1; 335 TempV2 = Math.round(TempValue / MultiQty); 336 TempV2a = TempValue * TempV2; 337 if ((TempV1a != TempV2a) || (TempV1 < 1)) { 338 alert(alert_3 + MultiQty); 339 if (RemainIssue.indexOf('||' + id) == -1) RemainIssue = RemainIssue + '||' + id; 340 fname.focus(); 341 return (false); 342 } 343 } 344 if (qty > 0) { 345 TempValue = eval(fname.val()); 346 if (TempValue < qty) { 347 alert(alert_8 + qty + alert_9); 348 if (RemainIssue.indexOf('||' + id) == -1) RemainIssue = RemainIssue + '||' + id; 349 fname.focus(); 350 return (false); 351 } 352 } 353 354 //<% 'GGG Add-on start 355 if (HaveGRAddress = 1) { 356 if ((eval(fname.val()) > remain) && (remain > 0)) { 357 alert("Your entered a quantity greater than remaining quantity."); 358 if (RemainIssue.indexOf('||' + id) == -1) RemainIssue = RemainIssue + '||' + id; 359 fname.focus(); 360 return (false); 361 } 362 } 363 364 if (RemainIssue != "") RemainIssue = RemainIssue.replace('||' + id, ''); 365 if (RemainIssue1 == "A") RemainIssue1 = ""; 366 return (true); 367 368 } 369} 370 371 372/*********************************************** 373 * Disable "Enter" key in Form script- By Nurul Fadilah([email protected]) 374 * This notice must stay intact for use
375 * Visit http://www.dynamicdrive.com/ for full source code 376 ***********************************************/ 377 378function handleEnter(field, event) { 379 var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; 380 if (keyCode == 13) { 381 var i; 382 for (i = 0; i < field.form.elements.length; i++) 383 if (field == field.form.elements[i]) 384 break; 385 i = (i + 1) % field.form.elements.length; 386 field.form.elements[i].focus(); 387 return false; 388 } else 389 return true; 390}
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.