How to use lookup method in pyshould

Best Python code snippet using pyshould_python

lookup.js

Source:lookup.js Github

copy

Full Screen

1/**2 * @author Interprise Solutions3 */4define([5 'jquery', 6 'underscore', 7 'backbone', 8 'model/lookupcriteria',9 'model/cartItem',10 'collection/cart', 11 'view/common/enum',12 'view/common/global', 13 'view/common/service',14 'view/common/shared',15 'view/common/method',16 'view/common/preference',17 'view/lookup/boxItem',18 'view/lookup/cartItem',19 'view/lookup/shipmentItem',20 'view/lookup/lookupItem',21 'text!template/lookup/lookup.tpl.html',22 'js/libs/iscroll.js'23],function($, _, Backbone,24 LookupCriteriaModel, CartItemModel,25 CartCollection, 26 Enum, Global, Service, Shared, Method, Preference,27 BoxItemView, CartItemView, ShipmentItemView, LookupItemView,28 LookupTemplate){ 29 30 var LookupView = Backbone.View.extend({31 _template : _.template( LookupTemplate ), 32 33 events: { 34 "keypress #textSearch" : "textSearch_KeyPress"35 },36 37 CountryCode: null,38 CurrentTransaction: null,39 Criteria: null,40 LookupMode: Enum.LookupMode.Default,41 ShippingMode: null,42 initialize: function () {43 Global.IsPrePackMode = false; 44 }, 45 46 textSearch_KeyPress: function (e) {47 if (e.keyCode === 13) {48 var criteria = $("#textSearch").val(); 49 switch (this.LookupMode) {50 case Enum.LookupMode.Box:51 this.IsShowAllBoxes = false;52 this.LoadBoxes(criteria);53 break;54 case Enum.LookupMode.ShippingAddress:55 this.Criteria = criteria;56 switch (this.ShippingMode) { 57 case "country":58 this.LoadCountryLookup();59 break;60 case "postal":61 this.LoadPostalLookup();62 break; 63 }64 break;65 default:66 this.LoadTransactions(criteria);67 break;68 69 }70 }71 },72 73 buttonSearch_tap : function(e) {74 var criteria = $("#textSearch").val();75 76 switch (this.LookupMode) {77 case Enum.LookupMode.Box:78 this.IsShowAllBoxes = false;79 this.LoadBoxes(criteria);80 break;81 case Enum.LookupMode.ShippingAddress:82 this.Criteria = criteria;83 switch (this.ShippingMode) { 84 case "country":85 this.LoadCountryLookup();86 break;87 case "postal":88 this.LoadPostalLookup();89 break;90 }91 break;92 default:93 this.LoadTransactions(criteria);94 break;95 } 96 }, 97 98 AnimateLookup: function (isAnimate) {99 this.ProgressScreen = Shared.ShowProgress(this.ProgressScreen, isAnimate, "lookupSection", false); 100 },101 AnimateBoxLookup: function (isAnimate) {102 if (isAnimate) {103 $('#buttonMoreLookup').html("loading..");104 }105 else {106 $('#buttonMoreLookup').html("load more");107 }108 },109 110 ClearCart : function() { 111 this.$("#cartListContainer tbody").html("");112 },113 GeneratePrePackButtonHTML: function () {114 return "<button id=\"buttonPrePack\" class=\"btn-belize\"> \115 <ul> \116 <li><i class=\"icon-archive icon-2\"></i></li> \117 <li><span>prepack</span></li> \118 <li><span id=\"textPrepackQuantities\">(0)</span></li> \119 </ul> \120 </button>";121 },122 123 GoBack : function(e) {124 window.location.hash = "dashboard";125 },126 HighLightItem: function (self, cartItemView, current) { 127 if (self.LookupMode != Enum.LookupMode.Shipment) {128 $("td").removeClass("highlight");129 $("." + cartItemView.cid).addClass("highlight"); 130 } else { 131 $("#icon" + cartItemView.cid).toggleClass("icon-ok shipment-icon-oncheck clear-padding");132 $("." + cartItemView.cid + " ul").toggleClass('listitem-3 listitem-6');133 $("." + cartItemView.cid).toggleClass("highlight");134 135 if ($("#icon" + cartItemView.cid).hasClass('icon-ok')) Global.CurrentTransactions.add(cartItemView.model);136 else Global.CurrentTransactions.remove(cartItemView.model);137 }138 //if (self.myLastTap == null) self.myLastTap = new Date().getTime();139 //var now = new Date().getTime();140 //var timeSince = (now - self.myLastTap);141 //if ((timeSince < 600) && (timeSince > 0)) {142 // var nowCID = cartItemView.cid;143 // var currentCID = null;144 switch (self.LookupMode)145 {146 case Enum.LookupMode.Box:147 self.CurrentBox = current;148 this.trigger("boxSelected", this);149 break;150 case Enum.LookupMode.ShippingAddress:151 this.trigger("itemSelected", current);152 default:153 if (self.CurrentTransaction == null) self.CurrentTransaction = current;154 if (self.LookupMode == Enum.LookupMode.Shipment155 || self.LookupMode == Enum.LookupMode.Pick156 || self.LookupMode == Enum.LookupMode.Pack) {157 Global.CurrentTransactions.add(cartItemView.model);158 }159 self.ProcessSelectedTransaction();160 break;161 }162 if (self.LookupMode != Enum.LookupMode.Box) {163 self.CurrentTransaction = current;164 self.CurrentTransaction.CID = cartItemView.cid;165 }166 self.myLastTap = new Date().getTime();167 },168 InitializeBoxCollection: function () {169 if (this.boxCollection) {170 this.boxCollection.reset();171 }172 else {173 this.boxCollection = new CartCollection();174 this.boxCollection.on("reset", this.ClearCart, this);175 }176 },177 InitializeLookupCollection: function () {178 if (this.lookupCollection) {179 this.lookupCollection.reset();180 }181 else {182 this.lookupCollection = new CartCollection();183 this.lookupCollection.on("reset", this.ClearCart, this);184 }185 },186 InitializeTransactionCollection: function () {187 if (this.transactionCollection) {188 this.transactionCollection.reset();189 }190 else {191 this.transactionCollection = new CartCollection();192 this.transactionCollection.on("reset", this.ClearCart, this);193 }194 },195 InitializeChildViews: function () { 196 if (this.LookupMode == Enum.LookupMode.Box) {197 this.RenderLookup();198 this.InitializeBoxCollection();199 this.LoadBoxes();200 }201 else if (this.LookupMode == Enum.LookupMode.ShippingAddress) {202 this.RenderLookup();203 this.InitializeLookupCollection();204 switch (this.ShippingMode) {205 case "country":206 this.LoadCountryLookup();207 break;208 case "postal":209 this.LoadPostalLookup();210 break;211 }212 }213 else {214 this.$el.html(this._template);215 this.RenderLookup();216 this.WireEvents();217 this.InitializeTransactionCollection();218 this.LoadTransactions();219 }220 Shared.Focus('#textSearch');221 },222 LoadBoxes: function (criteria) {223 var lookupModel = new LookupCriteriaModel();224 var self = this; 225 lookupModel.url = Global.ServiceUrl + Service.SOP + Method.CARRIERPACKAGINGLOOKUP;226 lookupModel.set({227 CarrierCode: this.CarrierCode,228 ShippingMethodCode: this.ShippingMethodCode,229 WarehouseCode: Global.CurrentLocation230 });231 232 if (criteria) lookupModel.set({ CriteriaString: criteria });233 var animateElem = "";234 if (this.IsShowAllBoxes) {235 animateElem = "buttonMoreLookup";236 lookupModel.set({ IsShowAllBoxes: true });237 $('#containerTable').removeClass('iscroll-lookup-2').addClass('iscroll-lookup');238 $('#buttonMoreLookup').hide();239 } else {240 animateElem = "lookupBody";241 lookupModel.set({ IsShowAllBoxes: false });242 this.ShowButtonMoreLookup();243 }244 this.AnimateBoxLookup(true);245 lookupModel.save(null, {246 success: function (model, response, options) {247 self.AnimateBoxLookup(false);248 if (!model.get("hasError")) {249 self.PopulateCartByBoxes(response.Packages);250 }251 },252 error: function (model, error, options) {253 self.ShowButtonMoreLookup();254 self.AnimateBoxLookup(false);255 }256 }); 257 },258 LoadCountryLookup: function () {259 var lookupModel = new LookupCriteriaModel();260 var self = this;261 lookupModel.url = Global.ServiceUrl + Service.CUSTOMER + Method.COUNTRYCODELOOKUP + "30";262 if (this.Criteria) {263 lookupModel.set({264 StringValue: this.Criteria265 });266 }267 this.AnimateLookup(true);268 lookupModel.save(null, {269 success: function (model, response, options) { 270 if (!model.get("hasError")) {271 self.PopulateCartByCountries(response.Countries);272 }273 },274 progress: this.ProgressScreen275 }); 276 },277 LoadPostalLookup: function () {278 var lookupModel = new LookupCriteriaModel();279 var self = this;280 lookupModel.url = Global.ServiceUrl + Service.CUSTOMER + Method.ZIPCODELOOKUP + "30/" + this.CountryCode;281 if (this.Criteria) {282 lookupModel.set({283 StringValue: this.Criteria284 });285 }286 this.AnimateLookup(true);287 lookupModel.save(null, {288 success: function (model, response, options) { 289 if (!model.get("hasError")) {290 self.PopulateCartByPostal(response.Postals);291 }292 },293 progress: this.ProgressScreen294 }); 295 },296 LoadiScroll: function () {297 this.myScroll = Shared.LoadiScroll(this.myScroll, "");298 },299 LoadPrePackItems: function (itemCount) {300 if (itemCount > 0) {301 Global.IsPrePackMode = true;302 Global.TransactionCode = "";303 if (this.LookupMode == Enum.LookupMode.Pick) window.location.hash = "pick";304 else if (this.LookupMode == Enum.LookupMode.Shipment) window.location.hash = "prepack";305 }306 else {307 Shared.BeepError();308 if (this.LookupMode == Enum.LookupMode.Pick) Shared.NotifyError("There are no items to pick.", "Prepack items");309 else if (this.LookupMode == Enum.LookupMode.Shipment) Shared.NotifyError("There are no labels to print.", "Prepack labels"); 310 }311 },312 LoadTransactions: function (criteria) {313 var lookupModel = new LookupCriteriaModel();314 var self = this; 315 316 switch (this.LookupMode) {317 case Enum.LookupMode.Pack:318 lookupModel.url = Global.ServiceUrl + Service.SOP + Method.PACKTRANSACTIONLOOKUP;319 lookupModel.set({ TransactionType: Preference.PackSourceTransaction });320 break;321 case Enum.LookupMode.Pick:322 lookupModel.url = Global.ServiceUrl + Service.SOP + Method.PICKTRANSACTIONLOOKUP; 323 lookupModel.set({324 TransactionType: Preference.PickSourceTransaction,325 IsPrePackMode: Preference.PrePackIsEnable326 }); 327 break;328 case Enum.LookupMode.Receive:329 lookupModel.url = Global.ServiceUrl + Service.PRODUCT + Method.RECEIVELOOKUP;330 break;331 case Enum.LookupMode.Stock:332 lookupModel.url = Global.ServiceUrl + Service.PRODUCT + Method.LOADGOODSRECEIVELOOKUP;333 break;334 case Enum.LookupMode.Shipment:335 lookupModel.url = Global.ServiceUrl + Service.SOP + Method.SHIPMENTLOOKUP;336 lookupModel.set({337 TransactionType: Preference.LabelSourceTransaction,338 HasTrackingNumber: false,339 IsPrePackMode: Preference.PrePackIsEnable340 });341 break; 342 };343 if (criteria) {344 lookupModel.set({ CriteriaString : criteria });345 }346 347 lookupModel.set({ WarehouseCode: Preference.DefaultLocation });348 349 this.AnimateLookup(true);350 lookupModel.save(null, {351 success: function (model, response, options) { 352 if (!model.get("hasError")) { 353 switch (self.LookupMode) {354 case Enum.LookupMode.Pack: 355 self.PopulateCartByTransaction(response.Packs, criteria, 0);356 break;357 case Enum.LookupMode.Pick:358 if (Preference.PrePackIsEnable) self.PopulateCartByTransaction(response.Picks, criteria, response.ItemCount);359 else self.PopulateCartByTransaction(response.Picks, criteria, 0);360 break;361 case Enum.LookupMode.Receive:362 self.PopulateCartByTransaction(response.PurchaseOrders, criteria, 0);363 break;364 case Enum.LookupMode.Stock:365 self.PopulateCartByTransaction(response.PurchaseReceiptCollection, criteria, 0);366 break;367 case Enum.LookupMode.Shipment:368 if (Preference.PrePackIsEnable) self.PopulateCartByTransaction(response.Packs, criteria, response.ItemCount);369 else self.PopulateCartByTransaction(response.Packs, criteria, 0);370 break;371 };372 }373 },374 progress: this.ProgressScreen375 }); 376 },377 378 ProcessSelectedTransaction : function() {379 if (this.CurrentTransaction) { 380 switch (this.LookupMode) {381 case Enum.LookupMode.Pack:382 Global.TransactionCode = this.CurrentTransaction.TransactionCode;383 window.location.hash = "pack";384 break;385 case Enum.LookupMode.Pick:386 Global.TransactionCode = this.CurrentTransaction.TransactionCode;387 window.location.hash = "pick";388 break;389 case Enum.LookupMode.Receive:390 Global.TransactionCode = this.CurrentTransaction.PurchaseOrderCode;391 window.location.hash = "receive";392 break;393 case Enum.LookupMode.Stock:394 Global.TransactionCode = this.CurrentTransaction.PurchaseReceiptCode;395 Global.TransferMode = "Stock";396 Global.PreviousPage = "stocklookup";397 window.location.hash = "stock";398 break;399 case Enum.LookupMode.Shipment:400 Global.TransactionCode = this.CurrentTransaction.TransactionCode;401 Global.PackMode = "Label";402 Global.PreviousPage = "shipmentlookup";403 window.location.hash = "label";404 break;405 }; 406 }407 },408 409 PopulateCartByCountries: function (countries) {410 this.lookupCollection.reset();411 if (countries && countries.length > 0) {412 var self = this;413 var counter = 1;414 _.each(countries, function (current) {415 if (countries.length == 1) { 416 self.trigger("itemSelected", current);417 } else {418 counter = counter + 1;419 var lookupItemModel = new CartItemModel();420 lookupItemModel.set({421 RowData1: current.CountryCode,422 RowData2: current.ThreeISOCode,423 RowData3: "",424 CountryCode: current.CountryCode,425 ThreeISOCode: current.ThreeISOCode,426 RowNumber: counter - 1427 });428 self.lookupCollection.add(lookupItemModel);429 var lookupItemView = new LookupItemView({ model: lookupItemModel });430 self.$("#cartListContainer tbody").append(lookupItemView.render());431 Shared.AddRemoveHandler("." + lookupItemView.cid, 'tap', function (e) { self.HighLightItem(self, lookupItemView, current); });432 }433 });434 this.LoadiScroll();435 }436 else Shared.BeepError();437 },438 PopulateCartByBoxes : function(packages) {439 this.boxCollection.reset();440 441 if (packages && packages.length > 0) {442 var self = this;443 var counter = 1;444 var criteria = $("#textSearch").val();445 var filterToAdd = Array();446 var len = packages.length447 while (len--) {448 var filterValue;449 var packagingType;450 var current = packages[len];451 packagingType = current.PackagingType == undefined ? null : current.PackagingType;452 packagingType = packagingType == null ? 'null' : packagingType.toString().toLowerCase();453 // filter by PackagingType454 filterValue = packagingType;455 if (filterToAdd.indexOf(filterValue) < 0) {456 filterToAdd.push(filterValue);457 }458 else {459 if (len > -1) packages.splice(len, 1);460 }461 }462 _.each(packages, function (current) {463 current.ServiceCode = current.ServiceType;464 current.PackagingCode = current.PackagingType;465 if (criteria && packages.length == 1) {466 self.CurrentBox = current; 467 self.trigger("boxSelected", self);468 } else { 469 counter = counter + 1;470 var boxModel = new CartItemModel();471 var dimension = current.Height + "x" + current.Length + "x" + current.Width472 boxModel.set({473 PackagingCode: current.PackagingCode,474 CarrierCode: current.CarrierCode,475 CarrierDescription: current.CarrierDescription,476 Dimension: dimension,477 Length: current.Length,478 Width: current.Width,479 Height: current.Height,480 WeightInLbs: current.WeightLbs,481 RowNumber: counter - 1, 482 ServiceCode: current.ServiceCode,483 IsCustom: current.IsCustom484 });485 self.boxCollection.add(boxModel);486 var boxItemView = new BoxItemView({ model: boxModel });487 self.$("#cartListContainer tbody").append(boxItemView.render());488 Shared.AddRemoveHandler("." + boxItemView.cid, 'tap', function (e) { self.HighLightItem(self, boxItemView, current); });489 }490 });491 this.LoadiScroll();492 }493 else Shared.BeepError();494 },495 PopulateCartByPostal: function (postals) {496 this.lookupCollection.reset();497 if (postals && postals.length > 0) {498 var self = this;499 var counter = 1;500 _.each(postals, function (current) {501 if (postals.length == 1) { 502 self.trigger("itemSelected", current);503 } else {504 counter = counter + 1;505 var lookupItemModel = new CartItemModel();506 lookupItemModel.set({507 RowData1: current.PostalCode,508 RowData2: current.City,509 RowData3: current.County,510 PostalCode: current.PostalCode,511 City: current.City,512 CountryCode: current.CountryCode,513 County: current.County,514 StateCode: current.StateCode,515 RowNumber: counter - 1516 });517 self.lookupCollection.add(lookupItemModel);518 var lookupItemView = new LookupItemView({ model: lookupItemModel });519 self.$("#cartListContainer tbody").append(lookupItemView.render());520 Shared.AddRemoveHandler("." + lookupItemView.cid, 'tap', function (e) { self.HighLightItem(self, lookupItemView, current); });521 }522 });523 this.LoadiScroll();524 }525 else Shared.BeepError();526 },527 PopulateCartByTransaction : function(transactions, lookupCriteria, itemCount) {528 this.transactionCollection.reset();529 var self = this;530 531 if ((this.LookupMode == Enum.LookupMode.Pick && Preference.PrePackIsEnable) || this.LookupMode == Enum.LookupMode.Shipment && Preference.PrePackIsEnable) {532 this.$("#cartListContainer tbody").append(this.GeneratePrePackButtonHTML());533 this.UpdatePrepackQuantities(itemCount);534 Shared.AddRemoveHandler('#buttonPrePack', 'tap', function () { self.LoadPrePackItems(itemCount); });535 } 536 if (transactions && transactions.length > 0) {537 if (transactions.length == 1) {538 var criteria = $("#textSearch").val();539 if (criteria != null && criteria != "") {540 this.CurrentTransaction = transactions[0];541 this.ProcessSelectedTransaction();542 return true;543 }544 }545 this.$("#textSearch").val("");546 var counter = 1;547 _.each(transactions, function (current) {548 counter = counter + 1;549 var transactionModel = new CartItemModel();550 switch (self.LookupMode) {551 case Enum.LookupMode.Pack:552 case Enum.LookupMode.Pick:553 var dueDate = "Ship: " + Shared.FormatDate(current.ShippingDate, "L");554 var salesOrderDate = Shared.FormatDate(current.TransactionDate, "L");555 transactionModel.set({556 TransactionCode: current.TransactionCode,557 CustomerCode: current.BillToCode,558 Name: current.BillToName,559 BillToCode: current.BillToCode,560 BillToName: current.BillToName,561 ShiptoCode: current.ShiptoCode,562 ShippingDate: current.ShippingDate,563 SalesOrderDate: current.TransactionDate,564 Date: salesOrderDate,565 WarehouseCode: current.WarehouseCode,566 Status: dueDate,567 RowNumber: counter - 1,568 IsPriority: current.IsPriority569 });570 if (self.LookupMode == Enum.LookupMode.Pack) transactionModel.set({ ServiceCode: current.ServiceCode });571 Global.CurrentTransactions = new CartCollection();572 break;573 case Enum.LookupMode.Receive:574 var poDate = Shared.FormatDate(current.PODate, "L");575 transactionModel.set({576 TransactionCode: current.PurchaseOrderCode,577 SupplierCode: current.SupplierCode,578 Name: current.SupplierName,579 Status: current.OrderStatus,580 Date: poDate,581 RowNumber: counter - 1,582 IsPriority: null583 });584 break;585 case Enum.LookupMode.Stock:586 var poDate = Shared.FormatDate(current.PRDate, "L");587 transactionModel.set({588 TransactionCode: current.PurchaseReceiptCode,589 SupplierCode: current.SupplierName,590 Name: current.SupplierName,591 Status: "",592 Date: poDate,593 RowNumber: counter - 1,594 IsPriority: null595 });596 break;597 case Enum.LookupMode.Shipment:598 var shipmentDate = Shared.FormatDate(current.ShipmentDate, "L");599 transactionModel.set({600 TransactionCode: current.TransactionCode, 601 ShipFromName: current.ShipFromName,602 ShipToName: current.ShipToName,603 Date: shipmentDate,604 RowNumber: counter - 1,605 isChecked: false,606 ShipmentView: null,607 IsPriority: null608 });609 Global.CurrentTransactions = new CartCollection();610 break;611 }612 self.transactionCollection.add(transactionModel);613 var itemView = null;614 if (self.LookupMode == Enum.LookupMode.Shipment) itemView = new ShipmentItemView({ model: transactionModel });615 else itemView = new CartItemView({ model: transactionModel });616 self.$("#cartListContainer tbody").append(itemView.render());617 Shared.AddRemoveHandler("." + itemView.cid, 'tap', function (e) { self.HighLightItem(self, itemView, current); });618 });619 }620 else {621 if (lookupCriteria && lookupCriteria != "") {622 Shared.BeepError();623 }624 }625 this.LoadiScroll();626 }, 627 628 Render: function () {629 return this.$el.html(this._template);630 },631 RenderLookup: function () {632 this.$('#buttonNew').hide();633 this.$('#buttonBack').hide();634 this.$('#buttonMoreLookup').hide();635 this.$('#buttonSlideDown').hide();636 switch (this.LookupMode) {637 case Enum.LookupMode.Pick:638 if (Preference.PickSourceTransaction == "invoice") this.$('#lookupTitle').text('select invoice');639 else this.$('#lookupTitle').text('select order');640 break;641 case Enum.LookupMode.Pack:642 if (Preference.PackSourceTransaction == "invoice") this.$('#lookupTitle').text('select invoice');643 else this.$('#lookupTitle').text('select order');644 break;645 case Enum.LookupMode.Receive:646 this.$('#lookupTitle').text('purchase orders');647 break;648 case Enum.LookupMode.Stock:649 this.$('#lookupTitle').text('goods received');650 this.$('#buttonNew').show();651 var newStock = function (e) {652 Global.TransferMode = "NewStock";653 Global.PreviousPage = "stocklookup";654 window.location.hash = "stock";655 };656 Shared.AddRemoveHandler('#buttonNew', 'tap', newStock);657 break;658 case Enum.LookupMode.Shipment:659 this.$('#lookupTitle').text('shipments'); 660 break;661 case Enum.LookupMode.Box:662 var self = this;663 this.$('#lookupTitle').text('select box to add');664 this.$('#buttonMenu').hide();665 this.$('#buttonBack').show();666 this.$('#buttonMoreLookup').show();667 this.$('#containerTable').removeClass('iscroll-lookup').addClass('iscroll-lookup-2');668 this.$('#textSearch').attr('placeholder', 'enter box to search');669 Shared.AddRemoveHandler('#buttonBack', 'tap', function (e) { self.ShowPackSection(e); });670 Shared.AddRemoveHandler('#buttonSearch', 'tap', function (e) { self.buttonSearch_tap(e); });671 Shared.AddRemoveHandler('#buttonMoreLookup', 'tap', function (e) {672 self.IsShowAllBoxes = true;673 self.LoadBoxes(null);674 });675 break;676 case Enum.LookupMode.ShippingAddress:677 var self = this;678 this.$('#lookupSection').addClass("slideDownReady");679 680 switch (this.ShippingMode) {681 case "country":682 this.$('#lookupTitle').text('select a country');683 this.$('#textSearch').attr('placeholder', 'enter country to search');684 break;685 case "postal":686 this.$('#lookupTitle').text('select a postal');687 this.$('#textSearch').attr('placeholder', 'enter postal to search');688 break;689 }690 this.$('#buttonMenu').hide();691 this.$('#buttonSlideDown').show();692 Shared.AddRemoveHandler('#buttonSearch', 'tap', function (e) { self.buttonSearch_tap(e); });693 Shared.AddRemoveHandler('#buttonSlideDown', 'tap', function (e) { self.SlideDownLookup(e); });694 break;695 } 696 },697 ShowButtonMoreLookup: function () {698 $('#containerTable').removeClass('iscroll-lookup').addClass('iscroll-lookup-2');699 $('#buttonMoreLookup').show();700 },701 702 ShowPackSection: function () {703 $('#packSection').show();704 $('#lookupSectionContainer').removeClass('section-show').addClass('section-close');705 $('#boxSectionContainer').removeClass('section-show').addClass('section-close'); 706 },707 SlideDownLookup: function () {708 this.trigger("slideDownLookup", this);709 },710 711 UpdatePrepackQuantities: function (itemCount) {712 if (itemCount == 0) itemCount = "none";713 else if (itemCount > 99) itemCount = "99+" 714 this.$('#textPrepackQuantities').text("(" + itemCount + ")");715 },716 717 WireEvents: function () {718 var self = this; 719 Shared.AddRemoveHandler('#buttonMenu', 'tap', function (e) { self.GoBack(e); });720 Shared.AddRemoveHandler('#buttonSearch', 'tap', function (e) { self.buttonSearch_tap(e); });721 },722 });723 return LookupView;...

Full Screen

Full Screen

fieldlookup.js

Source:fieldlookup.js Github

copy

Full Screen

...100function call_fieldlookup3(target, target2, viewName, presentation) {101 var fieldLookup = new fieldLookup2(target, target2, arguments, presentation);102 fieldLookup.popup2(viewName);103}104function call_fieldlookup(target, viewName, formName, viewWidth, viewheight) {105 var fieldLookup = new fieldLookup1(target);106 if (!viewWidth) {107 viewWidth = 350;108 }109 if (!viewheight) {110 viewheight = 200;111 }112 fieldLookup.popup(viewName, formName, viewWidth, viewheight);113}114function call_fieldlookup2(target, viewName, presentation) {115 var fieldLookup = new fieldLookup1(target, arguments, presentation);116 fieldLookup.popup2(viewName);117}118function CollapsePanel(link, areaId) {...

Full Screen

Full Screen

dawg.test.js

Source:dawg.test.js Github

copy

Full Screen

...10 t.throws(function() { dawg.insert(null) }, /first argument must be a String/, "validates inserted value");11 t.throws(function() { dawg.insert({}) }, /first argument must be a String/, "validates inserted value");12 t.throws(function() { dawg.insert(1.0) }, /first argument must be a String/, "validates inserted value");13 t.throws(function() { dawg.insert(function(){}) }, /first argument must be a String/, "validates inserted value");14 t.throws(function() { dawg.lookup(null) }, /first argument must be a String/, "validates inserted value");15 t.throws(function() { dawg.lookupPrefix(null) }, /first argument must be a String/, "validates inserted value");16 t.throws(function() { dawg.insert('') }, /empty string passed to insert/, "validates inserted value");17 dawg.finish();18 var compactDawg = dawg.toCompactDawg();19 t.assert(compactDawg.lookup() == '');20 t.assert(compactDawg.lookupPrefix() == '');21 t.assert(compactDawg.lookup({}) == '');22 t.assert(compactDawg.lookupPrefix({}) == '');23 t.end();24});25var resp, dawg, wordSet;26var words = [];27test('Prepare for DAWG tet', function (t) {28 var q = queue();29 ['test_words.txt.gz', 'nonlatin_words.txt.gz'].forEach(function(file) {30 q.defer(function(callback) {31 request.get({url: "http://mapbox.s3.amazonaws.com/apendleton/" + file, encoding: null}, function(err, response, body) {32 if (err) throw "S3 fetch failed";33 zlib.gunzip(body, function(err, data) {34 if (err) throw ("Zlib decompression failed: " + err);35 resp = data.toString();36 words = words.concat(resp.trim().split("\n"));37 callback();38 })39 })40 });41 });42 q.awaitAll(function() {43 words.sort();44 t.end();45 });46});47test('Read-write DAWG test', function(t) {48 wordSet = FastSet(words);49 dawg = new jsdawg.Dawg();50 for (var i = 0; i < words.length; i++) {51 dawg.insert(words[i]);52 }53 t.pass("dawg created");54 var exactLookup = true;55 for (var i = 0; i < words.length; i++) {56 exactLookup = exactLookup && dawg.lookup(words[i]);57 }58 t.assert(exactLookup, "dawg contains all words");59 var prefixLookup = true;60 for (var i = 0; i < words.length; i++) {61 prefixLookup = prefixLookup && dawg.lookupPrefix(words[i]);62 }63 t.assert(prefixLookup, "dawg contains all words as prefixes");64 var prefixLookup = true;65 for (var i = 0; i < words.length; i++) {66 if (words[i].length == 1) continue;67 var prefix = words[i].substring(0, words[i].length - 1);68 prefixLookup = prefixLookup && dawg.lookupPrefix(prefix);69 }70 t.assert(prefixLookup, "dawg contains prefixes of all words as prefixes");71 var lookupFailure = true;72 for (var i = 0; i < words.length; i++) {73 if (dawg.lookup(words[i] + "qzz") || dawg.lookupPrefix(words[i] + "qzz")) console.log(words[i]);74 lookupFailure = lookupFailure && (!dawg.lookup(words[i] + "qzz"));75 lookupFailure = lookupFailure && (!dawg.lookupPrefix(words[i] + "qzz"));76 }77 t.assert(lookupFailure, "dawg does not contain any words with 'qzz' added to the end as term or prefix");78 var prefixLookup = true;79 for (var i = 0; i < words.length; i++) {80 if (words[i].length == 1) continue;81 var prefix = words[i].substring(0, words[i].length - 1);82 // if this prefix is also a word, skip83 if (wordSet.contains(prefix)) continue;84 prefixLookup = prefixLookup && (!dawg.lookup(prefix));85 }86 t.assert(prefixLookup, "dawg does not contain prefixes of all words as terms");87 t.assert(!dawg.lookup(""), "dawg does not contain the empty string as a term");88 t.assert(dawg.lookupPrefix(""), "dawg does contain the empty string as a prefix");89 t.end();90});91test('Compact DAWG test', function(t) {92 dawg.finish();93 var compactDawg = dawg.toCompactDawg(false);94 t.pass("compact dawg created")95 var exactLookup = true;96 for (var i = 0; i < words.length; i++) {97 exactLookup = exactLookup && compactDawg.lookup(words[i]);98 }99 t.assert(exactLookup, "compact dawg contains all words");100 var prefixLookup = true;101 for (var i = 0; i < words.length; i++) {102 prefixLookup = prefixLookup && compactDawg.lookupPrefix(words[i]);103 }104 t.assert(prefixLookup, "compact dawg contains all words as prefixes");105 var prefixLookup = true;106 for (var i = 0; i < words.length; i++) {107 if (words[i].length == 1) continue;108 var prefix = words[i].substring(0, words[i].length - 1);109 prefixLookup = prefixLookup && compactDawg.lookupPrefix(prefix);110 }111 t.assert(prefixLookup, "compact dawg contains prefixes of all words as prefixes");112 var compactDawgWords = [];113 var compactDawg = dawg.toCompactDawg();114 forOf(compactDawg, function(value) { compactDawgWords.push(value); });115 var iteratorLookup = true;116 for (var i = 0; i < words.length; i++) {117 iteratorLookup = iteratorLookup && (words[i] == compactDawgWords[i]);118 }119 t.assert(iteratorLookup, "compact dawg iterator reproduces original list");120 var prefixWords = [];121 var prefixIterator = compactDawg.iterator("test");122 var priNext = prefixIterator.next();123 while (!priNext.done) {124 prefixWords.push(priNext.value);125 priNext = prefixIterator.next();126 }127 t.equal(prefixWords.length, 82, "got 82 results for prefix 'test'");128 t.assert(prefixWords.indexOf("test") == 0, "submitted prefix 'test' is included in results");129 var prefixWords = [];130 var prefixIterator = compactDawg.iterator("阿");131 var priNext = prefixIterator.next();132 while (!priNext.done) {133 prefixWords.push(priNext.value);134 priNext = prefixIterator.next();135 }136 t.equal(prefixWords.length, 9, "got 82 results for prefix '阿'");137 t.assert(prefixWords.indexOf("阿") == -1, "submitted prefix '阿' is not included in results");138 var prefixWords = [];139 var prefixIterator = compactDawg.iterator("testac");140 var priNext = prefixIterator.next();141 while (!priNext.done) {142 prefixWords.push(priNext.value);143 priNext = prefixIterator.next();144 }145 t.equal(prefixWords.length, 7, "got 7 results for prefix 'testac'");146 t.assert(prefixWords.indexOf("testac") == -1, "submitted prefix 'testac' is not included in results");147 var prefixWords = [];148 var prefixIterator = compactDawg.iterator("testaaa");149 var priNext = prefixIterator.next();150 while (!priNext.done) {151 prefixWords.push(priNext.value);152 priNext = prefixIterator.next();153 }154 t.equal(prefixWords.length, 0, "got 0 results for prefix 'testaaa'");155 var lookupFailure = true;156 for (var i = 0; i < words.length; i++) {157 lookupFailure = lookupFailure && (!compactDawg.lookup(words[i] + "qzz"));158 lookupFailure = lookupFailure && (!compactDawg.lookupPrefix(words[i] + "qzz"));159 }160 t.assert(lookupFailure, "compact dawg does not contain any words with 'qzz' added to the end as term or prefix");161 var prefixLookup = true;162 for (var i = 0; i < words.length; i++) {163 if (words[i].length == 1) continue;164 var prefix = words[i].substring(0, words[i].length - 1);165 // if this prefix is also a word, skip166 if (wordSet.contains(prefix)) continue;167 prefixLookup = prefixLookup && (!compactDawg.lookup(prefix));168 }169 t.assert(prefixLookup, "compact dawg does not contain prefixes of all words as terms");170 t.assert(!compactDawg.lookup(""), "compact dawg does not contain the empty string as a term");171 t.assert(compactDawg.lookupPrefix(""), "compact dawg does contain the empty string as a prefix");172 t.end();173});174test('Compact DAWG test with embedded counts', function(t) {175 dawg.finish();176 var compactDawg = dawg.toCompactDawg(true);177 t.pass("compact dawg created with counts")178 var exactLookup = true;179 var exactIndexes = true;180 for (var i = 0; i < words.length; i++) {181 var match = compactDawg.lookupCounts(words[i]);182 exactLookup = exactLookup && match.found;183 exactIndexes = exactIndexes && (match.index == i);184 }185 t.assert(exactLookup, "compact dawg contains all words");186 t.assert(exactIndexes, "compact dawg's indexes match insertion word order");187 var inverseLookup = true;188 var inverseText = true;189 for (var i = 0; i < words.length; i++) {190 var match = compactDawg.lookupCounts(i);191 inverseLookup = inverseLookup && match.found;192 inverseText = inverseText && (match.text == words[i]);193 }194 t.assert(inverseLookup, "compact dawg lookup by index retrieves all words");195 t.assert(inverseText, "compact dawg retrieved word text is correct");196 var prefixLookup = true;197 var prefixIndexes = true;198 for (var i = 0; i < words.length; i++) {199 var match = compactDawg.lookupPrefixCounts(words[i]);200 prefixLookup = prefixLookup && match.found;201 prefixIndexes = prefixIndexes && (match.index == i);202 }203 t.assert(prefixLookup, "compact dawg contains all words as prefixes");204 t.assert(prefixIndexes, "compact dawg's indexes match insertion word order on prefix lookup");205 var prefixLookup = true;206 var prefixIndexes = true;207 for (var i = 0; i < words.length; i++) {208 if (words[i].length == 1) continue;209 var prefix = words[i].substring(0, words[i].length - 1);210 var match = compactDawg.lookupPrefixCounts(prefix);211 // here we would expect either the indexes to match, or the index that is returned212 // to be lower and to point to a word that shares a prefix213 prefixIndexes = prefixIndexes && (214 match.index == i ||215 (match.index < i && words[match.index].substring(0, prefix.length) == prefix)216 );217 prefixLookup = prefixLookup && match.found;218 }219 t.assert(prefixLookup, "compact dawg contains prefixes of all words as prefixes");220 t.assert(prefixIndexes, "compact dawg prefixes have expected indexes");221 var testMatch = compactDawg.lookupPrefixCounts("test");222 t.assert(testMatch.found, "'test' found");223 t.assert(testMatch.index == words.indexOf("test"), "'test' index is correct");224 t.assert(testMatch.suffixCount == 82, "'test' has 82 suffixes");225 var blea_idx;226 for (blea_idx = 0; blea_idx < words.length; blea_idx++) {227 if (words[blea_idx].substr(0, 4) == 'blea') break;228 }229 var blea_count = 0;230 while (words[blea_idx + blea_count].substr(0, 4) == 'blea') blea_count += 1;231 testMatch = compactDawg.lookupPrefixCounts("blea");232 t.assert(testMatch.found, "'blea' found");233 t.assert(testMatch.index == blea_idx, "'blea' index is correct");234 t.assert(testMatch.suffixCount == blea_count, "'blea' has correct number of suffixes");235 var compactDawgWords = [];236 var compactDawg = dawg.toCompactDawg();237 forOf(compactDawg, function(value) { compactDawgWords.push(value); });238 var iteratorLookup = true;239 for (var i = 0; i < words.length; i++) {240 iteratorLookup = iteratorLookup && (words[i] == compactDawgWords[i]);241 }242 t.assert(iteratorLookup, "compact dawg iterator reproduces original list");243 var prefixWords = [];244 var prefixIterator = compactDawg.iterator("test");245 var priNext = prefixIterator.next();246 while (!priNext.done) {247 prefixWords.push(priNext.value);248 priNext = prefixIterator.next();249 }250 t.equal(prefixWords.length, 82, "got 82 results for prefix 'test'");251 t.assert(prefixWords.indexOf("test") == 0, "submitted prefix 'test' is included in results");252 var prefixWords = [];253 var prefixIterator = compactDawg.iterator("阿");254 var priNext = prefixIterator.next();255 while (!priNext.done) {256 prefixWords.push(priNext.value);257 priNext = prefixIterator.next();258 }259 t.equal(prefixWords.length, 9, "got 9 results for prefix '阿'");260 t.assert(prefixWords.indexOf("阿") == -1, "submitted prefix '阿' is not included in results");261 var prefixWords = [];262 var prefixIterator = compactDawg.iterator("testac");263 var priNext = prefixIterator.next();264 while (!priNext.done) {265 prefixWords.push(priNext.value);266 priNext = prefixIterator.next();267 }268 t.equal(prefixWords.length, 7, "got 7 results for prefix 'testac'");269 t.assert(prefixWords.indexOf("testac") == -1, "submitted prefix 'testac' is not included in results");270 var prefixWords = [];271 var prefixIterator = compactDawg.iterator("testaaa");272 var priNext = prefixIterator.next();273 while (!priNext.done) {274 prefixWords.push(priNext.value);275 priNext = prefixIterator.next();276 }277 t.equal(prefixWords.length, 0, "got 0 results for prefix 'testaaa'");278 var lookupFailure = true;279 for (var i = 0; i < words.length; i++) {280 lookupFailure = lookupFailure && (!compactDawg.lookup(words[i] + "qzz").found);281 lookupFailure = lookupFailure && (!compactDawg.lookupPrefix(words[i] + "qzz").found);282 }283 t.assert(lookupFailure, "compact dawg does not contain any words with 'qzz' added to the end as term or prefix");284 var prefixLookup = true;285 for (var i = 0; i < words.length; i++) {286 if (words[i].length == 1) continue;287 var prefix = words[i].substring(0, words[i].length - 1);288 // if this prefix is also a word, skip289 if (wordSet.contains(prefix)) continue;290 prefixLookup = prefixLookup && (!compactDawg.lookupCounts(prefix).found);291 }292 t.assert(prefixLookup, "compact dawg does not contain prefixes of all words as terms");293 t.assert(!compactDawg.lookupCounts("").found, "compact dawg does not contain the empty string as a term");294 t.assert(compactDawg.lookupPrefixCounts("").found, "compact dawg does contain the empty string as a prefix");...

Full Screen

Full Screen

proto.js

Source:proto.js Github

copy

Full Screen

...10 .filter(f => f.endsWith('.proto'))11// Load synchronously each protobuf file.12root = root.loadSync(files)13// Payload lookup.14const SCPayload = root.lookup('SCPayload')15const SCPayloadActions = root.lookup('Action').values16const SCPayloadFields = root.lookup('Action').parent.fields17// Users lookup.18const SystemAdmin = root.lookup('SystemAdmin')19const CompanyAdmin = root.lookup('CompanyAdmin')20const Operator = root.lookup('Operator')21const CertificationAuthority = root.lookup('CertificationAuthority')22// Types lookup.23const TaskType = root.lookup('TaskType')24const ProductType = root.lookup('ProductType')25const EventParameterType = root.lookup('EventParameterType')26const EventType = root.lookup('EventType')27const PropertyType = root.lookup('PropertyType')28// Entities lookup.29const Company = root.lookup('Company')30const Field = root.lookup('Field')31const Event = root.lookup('Event')32const Batch = root.lookup('Batch')33// Other messages lookup.34const Shared = root.lookup('Shared')35const Proposal = root.lookup('Proposal')36const Certificate = root.lookup('Certificate')37// Actions lookup.38const UpdateSystemAdminAction = root.lookup('UpdateSystemAdminAction')39const CreateTaskTypeAction = root.lookup('CreateTaskTypeAction')40const CreateProductTypeAction = root.lookup('CreateProductTypeAction')41const CreateEventParameterTypeAction = root.lookup('CreateEventParameterTypeAction')42const CreateEventTypeAction = root.lookup('CreateEventTypeAction')43const CreatePropertyTypeAction = root.lookup('CreatePropertyTypeAction')44const CreateCertificationAuthorityAction = root.lookup('CreateCertificationAuthorityAction')45const CreateCompanyAction = root.lookup('CreateCompanyAction')46const CreateFieldAction = root.lookup('CreateFieldAction')47const CreateOperatorAction = root.lookup('CreateOperatorAction')48const CreateDescriptionEventAction = root.lookup('CreateDescriptionEventAction')49const CreateTransformationEventAction = root.lookup('CreateTransformationEventAction')50const AddBatchCertificateAction = root.lookup('AddBatchCertificateAction')51const RecordBatchPropertyAction = root.lookup('RecordBatchPropertyAction')52const CreateProposalAction = root.lookup('CreateProposalAction')53const AnswerProposalAction = root.lookup('AnswerProposalAction')54const FinalizeBatchAction = root.lookup('FinalizeBatchAction')55module.exports = {56 root,57 SCPayload,58 SCPayloadActions,59 SCPayloadFields,60 SystemAdmin,61 CompanyAdmin,62 Operator,63 CertificationAuthority,64 TaskType,65 ProductType,66 EventParameterType,67 EventType,68 PropertyType,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyshould automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful