PageSourceSearch

https://iamlouis.ai/static/js/aten/event.js?1790828209

js iamlouis.ai collected 2026-10-05 14:06:57 UTC 7,479 bytes, 279 lines download raw bytes

1function event_switch_to_login_block()
2{
3	$('#event_block_email_only').hide();
4	$('#event_block_login').show();
5}
6
7function event_switch_to_email_only_block()
8{
9	$('#event_block_login').hide();
10	$('#event_block_email_only').show();
11}
12
13function show_event_notice_me_form(event_idx)
14{
15	$.get('event/get_notice_me_form/' + event_idx, function(res)
16	{
17		$('#event_open').html(res);
18		$('#event_open').modal();
19		$('#event_open').show();
20	});
21}
22
23function show_event_notice_me_form_already_login(url)
24{
25	$.post(url, function(res)
26	{
27		if(res=='ok')
28			show_event_notice_me_completed();
29		else if(res=='existed')
30			swal(t('You are already on the list'));
31		else
32			swal(t('Server error'));
33	});
34}
35
36function event_notice_me_send_email()
37{
38	var url								= $('#event_open').data('email-only-submit-url');
39	var email							= $('#notice_me_email').val();
40
41	$.post(url,
42	{
43		email:							email,
44	}, function(res)
45	{
46		if(res=='ok')
47			show_event_notice_me_completed();
48		else if(res=='existed')
49			swal(t('You are already on the list'));
50		else
51			swal(t('Server error'));
52	});
53}
54
55function show_event_notice_me_completed()
56{
57	$.get('event/get_notice_me_completed', function(res)
58	{
59		$('#event_open').modal('hide');
60		$('#event_completed').html(res);
61		$('#event_completed').modal();
62		$('#event_completed').show();
63	});
64}
65
66function event_join(obj)
67{
68	var spec_idx			= $(obj).data('spec-idx');
69	var attendance			= $(obj).closest('.purchase-block').find('select[name=attendance]').val();
70	if(attendance==undefined || attendance=='')
71		attendance			= 1;
72
73	var url					= $(obj).data('url');
74	url						+= '?attendance=' + attendance;
75	if(spec_idx!=undefined && spec_idx!='')
76		url						+= '&spec_idx=' + spec_idx;
77	window.location			= url;
78}
79
80function event_quick_login_and_join_submit()
81{
82	var user_id							= $('input[name=user_id]').val();
83	var user_password					= $('input[name=user_password]').val();
84	var login_url						= $('#login').data('login-url');
85
86	if(user_id.length==0)				{ swal(t('Please enter your email address'));				return; }
87	if(user_password.length==0)			{ swal(t('Please enter your password'));				return; }
88
89	$.post(login_url,
90	{
91		user_id:				user_id,
92		user_password:			user_password
93	}, function(res)
94	{
95		if(res.status=='ok')
96		{
97			swal({
98				title:	t('Events'),
99				text:	t('We will notify you the next time this event is held'),
100				type:	"success",
101			}).then(function(result) {
102				$('#event_open').modal('hide');
103			});
104		}
105		else if(res.status=='err:already_join')
106		{
107			swal({
108				title:	t('Events'),
109				text:	t('You are already on the list to be notified next time'),
110				type:	"warning",
111			}).then(function(result) {
112				$('#event_open').modal('hide');
113			});
114		}
115		else if(res.status=='err:login_fail')
116		{
117			swal({
118				title:	t('Member center'),
119				text:	t('Login failed'),
120				type:	"warning",
121			}).then(function(result) {
122			});
123		}
124		else
125		{
126			swal(t('Login failed'));
127		}
128	}, 'json');
129}
130
131///////////////////////////////////////////////////////////////////////////
132// 活動購物車(多活動同結帳 Phase 2)
133///////////////////////////////////////////////////////////////////////////
134
135// 加入購物車:把這個活動票種加入活動購物車(多活動同結帳),停留原頁
136var _adding_to_event_cart = false;
137function add_to_event_cart(obj)
138{
139	if(_adding_to_event_cart) return;
140
141	var spec_idx			= $(obj).data('spec-idx');
142	var attendance			= $(obj).closest('.purchase-block').find('select[name=attendance]').val();
143	if(attendance==undefined || attendance=='')
144		attendance			= 1;
145
146	if(spec_idx==undefined || spec_idx=='')
147		return;
148
149	_adding_to_event_cart = true;
150	$.post('cart/event_cart_add',
151	{
152		spec:		spec_idx,
153		attendance:	attendance,
154	},
155	function(res)
156	{
157		_adding_to_event_cart = false;
158		if(res.status=='ok')
159		{
160			update_event_cart_badge(res.total_quantity);
161			swal({
162				title: t('Added to cart'),
163				text: t('Your cart now has %s registrations', res.total_quantity),
164				type: 'success',
165				showCancelButton: true,
166				confirmButtonText: t('View cart'),
167				cancelButtonText: t('Continue shopping'),
168			}).then(function(result){
169				// 同上:沒有 result.value 表示使用者選了「繼續選購」或關掉對話框,不該跳轉
170				if(!result || typeof result.value=='undefined')
171					return;
172				window.location			= 'cart/list';
173			}).catch(function(){});
174		}
175		else if(res.status=='err:sold_out')
176			swal(t('This event is full'));
177		else if(res.status=='err:over_max')
178			swal(t('This exceeds the maximum number of attendees per registration for this ticket type'));
179		else if(res.status=='err:event_closed')
180			swal(t('Registration for this event is not open or has closed'));
181		else if(res.status=='err:spec_error')
182			swal(t('Registration is not available for this ticket type'));
183		else
184			swal(t('Could not add to cart. Please try again later.'));
185	}, 'json');
186}
187
188function event_cart_remove(hash)
189{
190	$.post('cart/event_cart_delete', { hash: hash }, function(res)
191	{
192		window.location.reload();
193	}, 'json');
194}
195
196// 活動購物車清單頁:調整人數(+/-)
197function event_cart_change_qty(hash, delta)
198{
199	var row								= $('div[data-hash="' + hash + '"]');
200	var input							= row.find('.event-qty-input');
201	var qty								= parseInt(input.val(), 10);
202	if(isNaN(qty)) qty					= 1;
203	qty									= qty + delta;
204	if(qty < 1) qty						= 1;
205
206	$.post('cart/event_cart_update', { hash: hash, attendance: qty }, function(res)
207	{
208		window.location.reload();
209	}, 'json');
210}
211
212function update_event_cart_badge(quantity)
213{
214	var badge							= $('#event_cart_badge');
215	if(badge.length>0)
216	{
217		badge.text(quantity);
218		if(quantity>0) badge.show(); else badge.hide();
219	}
220}
221
222// 活動折扣碼(與課程 / 商品折扣碼共用同頁時,需獨立命名空間避免 id 衝突)
223function set_event_coupon_code(input_object)
224{
225	var url								= $(input_object).data('url-set-coupon-code');
226	var coupon_code						= $(input_object).val();
227	if(typeof toHalfWidth==='function')
228		coupon_code						= toHalfWidth(coupon_code);
229	if(url==undefined || url=='')		return;
230	if(coupon_code==undefined || coupon_code=='')	return;
231
232	$.post(url, { coupon_code: coupon_code }, function(res)
233	{
234		if(res.status=='ok')
235		{
236			$('#event_coupon_status').hide().html('');
237		}
238		else
239		{
240			var message					= (typeof get_message_by_coupon_error_code==='function')
241											? get_message_by_coupon_error_code(res) : t('Invalid discount code');
242			$('#event_coupon_status').html(message).show();
243			$(input_object).val('');
244		}
245		refresh_event_amount_table(res);
246	}, 'json');
247}
248
249function clear_event_coupon_code(input_object)
250{
251	$(input_object).val('');
252	if(typeof clear_pending_coupon_cookie==='function')
253		clear_pending_coupon_cookie();	// 使用者自己清掉的碼,下一頁不要再自動套回來
254	var url								= $(input_object).data('url-reset-coupon-code');
255	if(url==undefined || url=='')		return;
256
257	$.get(url, function(res)
258	{
259		$('#event_coupon_status').hide().html('');
260		refresh_event_amount_table(res);
261	}, 'json');
262}
263
264function refresh_event_amount_table(res)
265{
266	if(res.coupon_discount_value!==undefined)
267	{
268		if(res.coupon_discount_value>0)
269			$('#event_coupon_discount_block').show();
270		else
271			$('#event_coupon_discount_block').hide();
272	}
273	if(res.total_price!==undefined)
274		$('#event_total_price').html(res.total_price);
275	if(res.coupon_discount!==undefined)
276		$('#event_coupon_discount').html(res.coupon_discount);
277	if(res.final_price!==undefined)
278		$('#event_final_price').html(res.final_price);
279}

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.