PageSourceSearch

https://booking.whiteheadbbq.hk/salespage/scripts/app/order/noSet/noSet.js?20211213

js whiteheadbbq.hk collected 2026-10-02 15:34:44 UTC 11,539 bytes, 333 lines download raw bytes

1'use strict';
2angular.module('whiteheadBbqApp').controller('OrderNoSetController', function ($rootScope, $scope, $state, $http, $filter, $modal, $translate, bbqDataService) {
3  // handle when from roomSet page
4  $rootScope.inputModel.selectedSet = 0;
5  $scope.displayedDate = $rootScope.inputModel.selectedDate;
6  $scope.isBookingTooEarlyWithPig = false;
7  $scope.closed = false;
8  $scope.isShowLoader = true;
9  $scope.isDiscountedMonth = false;
10  $scope.open = function ($event) {
11    $scope.status.opened = true;
12  };
13
14  // watch date changed
15  // watch the rootscope variable change
16  $scope.$watch(function () {
17    return $scope.displayedDate;
18  }, function () {
19    $rootScope.inputModel.selectedDate = $filter('date')($scope.displayedDate, 'yyyy-MM-dd');
20  }, true);
21
22  $scope.addOrder = function (obj) {
23    $rootScope.inputModel[obj] += 1;
24    // auto add 'lu' for set
25    if (obj != 'lu' && obj != 'pig' && obj != 'duck' && obj != 'chick' && obj != 'lamp' && obj != 'knuckle') {
26      $rootScope.inputModel['lu'] += 1
27    }
28    $scope.isBookingTooEarlyWithPig = bbqDataService.checkPig();
29  }
30
31  $scope.reduceOrder = function (obj) {
32    if ($rootScope.inputModel[obj] > 0) {
33      $rootScope.inputModel[obj] -= 1;
34      // auto reduct 'lu'
35      if (obj != 'lu' && obj != 'pig' && obj != 'duck' && obj != 'chick' && $rootScope.inputModel['lu'] > 0) {
36        $rootScope.inputModel['lu'] -= 1
37      }
38    }
39    $scope.isBookingTooEarlyWithPig = bbqDataService.checkPig();
40  }
41  // init min order pig date for comparison
42  var minPigOrderDate = new moment();
43
44  // action when date is changed.
45  $scope.$watch('inputModel.selectedDate', function () {
46    
47    // show discount text
48    var date = $rootScope.inputModel.selectedDate;
49    // $scope.isDiscountedMonth = date.substring(5,7) === '04' || date.substring(5,7) === '05' || date.substring(5,7) === '06' || date.substring(5,7) === '07' || date.substring(5,7) === '08';
50    
51    
52    $scope.isBookingTooEarlyWithPig = bbqDataService.checkPig();
53    // set lu to min=1
54    //if($rootScope.inputModel['lu'] === 0) $rootScope.inputModel['lu'] = 1;
55    if ($rootScope.inputModel.selectedDate) bbqDataService.checkNotePopUp($rootScope.inputModel.selectedDate, true);
56    var keepGoing = true;
57    $scope.closed = false;
58
59    if (
60      $rootScope.inputModel.selectedDate === '2024-12-12'
61    ) {
62      $scope.closed = true;
63    }
64    keepGoing = true;
65    angular.forEach($rootScope.inputModel.set4, function (item) {
66      if (keepGoing) {
67        if (item.dateb === $rootScope.inputModel.selectedDate) {
68          $rootScope.inputModel.selectedSet4Price = item.price;
69          keepGoing = false;
70        }
71      }
72    });
73    keepGoing = true;
74    angular.forEach($rootScope.inputModel.set2, function (item) {
75      if (keepGoing) {
76        if (item.dateb === $rootScope.inputModel.selectedDate) {
77          $rootScope.inputModel.selectedSet2Price = item.price;
78          keepGoing = false;
79        }
80      }
81    });
82    keepGoing = true;
83    angular.forEach($rootScope.inputModel.set10, function (item) {
84      if (keepGoing) {
85        if (item.dateb === $rootScope.inputModel.selectedDate) {
86          $rootScope.inputModel.selectedSet10Price = item.price;
87          //                    if(item.dateb==='2017-10-04'){
88          //                      $rootScope.inputModel.selectedSet10Price = item.price - 50;
89          //                    }
90          keepGoing = false;
91
92          // Just check 1 data 'closed' is OK. others are set too.
93          if (item.closed !== '') {
94            $scope.closed = true;
95          }
96        }
97      }
98    });
99    keepGoing = true;
100    angular.forEach($rootScope.inputModel.set5, function (item) {
101      if (keepGoing) {
102        if (item.dateb === $rootScope.inputModel.selectedDate) {
103          $rootScope.inputModel.selectedSet5Price = item.price;
104          keepGoing = false;
105        }
106      }
107    });
108    keepGoing = true;
109    angular.forEach($rootScope.inputModel.set10Special, function (item) {
110      if (keepGoing) {
111        if (item.dateb === $rootScope.inputModel.selectedDate) {
112          $rootScope.inputModel.selectedSpecialSet10Price = item.price;
113          keepGoing = false;
114        }
115      }
116    });
117    keepGoing = true;
118    angular.forEach($rootScope.inputModel.set5Special, function (item) {
119      if (keepGoing) {
120        if (item.dateb === $rootScope.inputModel.selectedDate) {
121          $rootScope.inputModel.selectedSpecialSet5Price = item.price;
122          keepGoing = false;
123        }
124      }
125    });
126    keepGoing = true;
127    $scope.t5_check2 = false;
128    $scope.t10_check2 = false;
129    $scope.c2_check2 = false;
130    $scope.c4_check2 = false;
131    $scope.c5_check2 = false;
132    $scope.c10_check2 = false;
133    $scope.pig_check2 = false;
134    $scope.pipa_check2 = false;
135    $scope.gu_check2 = false;
136    $scope.yougu_check2 = false;
137    $scope.deguo_check2 = false;
138    $scope.c2_note = '';
139    $scope.c4_note = '';
140    $scope.t5_note = '';
141    $scope.t10_note = '';
142    $scope.c5_note = '';
143    $scope.c10_note = '';
144    $scope.pig_note = '';
145    $scope.pipa_note = '';
146    $scope.gu_note = '';
147    $scope.yougu_note = '';
148    $scope.deguo_note = '';
149
150    // common check for 5/10 set, pig
151    angular.forEach($rootScope.inputModel.bbData, function (item) {
152      if (keepGoing) {
153        if (item.dateb === $rootScope.inputModel.selectedDate) {
154          // hide everything
155          if (item.lufull_note !== ""){
156            $scope.closed = true;
157            alert('當日爐位已訂滿,多謝支持!');
158          }
159          // hide the 2/4 set
160          if (item.c2_check2 === "1") {
161            $rootScope.inputModel.seafoodSet2 = 0;
162            $scope.c2_check2 = true;
163            $scope.c2_note = item.c2_note;
164            if($translate.use()==="en"){
165              $scope.c2_note = item.c2_note_e;
166            }
167          }
168          if (item.c4_check2 === "1") {
169            $rootScope.inputModel.seafoodSet4 = 0;
170            $scope.c4_check2 = true;
171            $scope.c4_note = item.c4_note;
172            if($translate.use()==="en"){
173              $scope.c4_note = item.c4_note_e;
174            }
175          }
176          // hide the 5/10 set
177          if (item.t5_check2 === "1") {
178            $rootScope.inputModel.specialSet5 = 0;
179            $scope.t5_check2 = true;
180            $scope.t5_note = item.t5_note;
181            if($translate.use()==="en"){
182                $scope.t5_note = item.t5_note_e;
183              }
184          }
185          if (item.t10_check2 === "1") {
186            $rootScope.inputModel.specialSet10 = 0;
187            $scope.t10_check2 = true;
188            $scope.t10_note = item.t10_note;
189            if($translate.use()==="en"){
190                $scope.t10_note = item.t10_note_e;
191              }
192          }
193          if (item.c5_check2 === "1") {
194            $rootScope.inputModel.seafoodSet5 = 0;
195            $scope.c5_check2 = true;
196            $scope.c5_note = item.c5_note;
197            if($translate.use()==="en"){
198                $scope.c5_note = item.c5_note_e;
199              }
200          }
201          if (item.c10_check2 === "1") {
202            $rootScope.inputModel.seafoodSet10 = 0;
203            $scope.c10_check2 = true;
204            $scope.c10_note = item.c10_note;
205            if($translate.use()==="en"){
206                $scope.c10_note = item.c10_note_e;
207              }
208          }
209          if (item.pig_check2 === "1") {
210            $rootScope.inputModel.pig = 0;
211            $scope.pig_check2 = true;
212            $scope.pig_note = item.pig_note;
213            if($translate.use()==="en"){
214                $scope.pig_note = item.pig_note_e;
215              }
216          }
217          if (item.pipa_check2 === "1") {
218            $rootScope.inputModel.duck = 0;
219            $scope.pipa_check2 = true;
220            $scope.pipa_note = item.pipa_note;
221            if($translate.use()==="en"){
222              $scope.pipa_note = item.pipa_note_e;
223            }
224          }
225          if (item.gu_check2 === "1") {
226            $rootScope.inputModel.chick = 0;
227            $scope.gu_check2 = true;
228            $scope.gu_note = item.gu_note;
229            if($translate.use()==="en"){
230              $scope.gu_note = item.gu_note_e;
231            }
232          }
233          if (item.yougu_check2 === "1") {
234            $rootScope.inputModel.lamp = 0;
235            $scope.yougu_check2 = true;
236            $scope.yougu_note = item.yougu_note;
237            if($translate.use()==="en"){
238              $scope.yougu_note = item.yougu_note_e;
239            }
240          }
241          if (item.deguo_check2 === "1") {
242            $rootScope.inputModel.knuckle = 0;
243            $scope.deguo_check2 = true;
244            $scope.deguo_note = item.deguo_note;
245            if($translate.use()==="en"){
246              $scope.deguo_note = item.deguo_note_e;
247            }
248          }
249          keepGoing = false;
250        }
251      }
252    });
253
254    //special handling for not allowed to book set
255    if ($rootScope.inputModel.selectedDate === '2017-12-23') {
256      $rootScope.inputModel.specialSet5 = 0;
257      $rootScope.inputModel.specialSet10 = 0;
258    }
259  });
260  // Set calendar
261  $scope.firstDatetoBook = new moment();
262  $scope.lastDatetoBook = new moment();
263  $scope.lastDatetoBook.add($rootScope.configData.ALLOW_BOOK_MONTH - 1, 'months');
264  $scope.lastDatetoBook.endOf("month");
265  // color setting for the special dates
266  $scope.events = [
267    {
268      date: new Date('2016-07-20'),
269      status: 'preBookDiscount'
270            }
271        ];
272  $scope.getDayClass = function (date, mode) {
273    if (mode === 'day') {
274      var dayToCheck = new Date(date).setHours(0, 0, 0, 0);
275      for (var i = 0; i < $scope.events.length; i++) {
276        var currentDay = new Date($scope.events[i].date).setHours(0, 0, 0, 0);
277        if (dayToCheck === currentDay) {
278          return $scope.events[i].status;
279        }
280      }
281    }
282    return '';
283  };
284  // init room data if set5 (check set 5 is enough) is empty
285  if (!$rootScope.inputModel.set2) {s
286    bbqDataService.loadSeaFoodSetData();
287    bbqDataService.loadSpecialSetData();
288  }
289
290  // watch the rootscope variable change
291  $scope.$watch(function () {
292    return $rootScope.isSet5Set10LoadComplete;
293  }, function () {
294    if ($rootScope.isSet5Set10LoadComplete) $scope.isShowLoader = false;
295  }, true);
296
297  // final check if no. of lu = no. of set
298  $scope.finalCheck = function () {
299    var totalNumSet = $rootScope.inputModel.specialSet5 + $rootScope.inputModel.specialSet10 + $rootScope.inputModel.seafoodSet5 + $rootScope.inputModel.seafoodSet10;
300    if (totalNumSet === 0 && $rootScope.inputModel['lu'] >= 1) {
301      $state.go('order/confirm');
302    } else if (totalNumSet != $rootScope.inputModel['lu']) {
303      var modalInstance = $modal.open({
304        animation: true,
305        templateUrl: 'luAlertModalContent.html',
306        controller: 'ModalInstanceCtrl'
307      });
308    } else {
309      $state.go('order/confirm');
310    }
311  }
312});
313angular.module('whiteheadBbqApp').config(function (BASE_PATH, $stateProvider) {
314  $stateProvider.state('order/noSet', {
315    parent: 'order',
316    url: '/order/noSet',
317    data: {
318      pageTitle: 'bbqSet.title.10'
319    },
320    views: {
321      'content@': {
322        templateUrl: BASE_PATH + 'app/order/noSet/noSet.html?20171204',
323        controller: 'OrderNoSetController'
324      }
325    },
326    resolve: {
327      translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
328        $translatePartialLoader.addPart('order');
329        return $translate.refresh();
330                    }]
331    }
332  });
333});

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.