PageSourceSearch

https://tutorcircle.hk/vendor/js/include.js

js tutorcircle.hk collected 2026-10-02 10:15:43 UTC 6,517 bytes, 257 lines download raw bytes

1function addLoading(){
2    $(function() {
3        // Action on Click
4        $.isLoading({text: "處理中,請稍候"});
5    });
6}
7
8function removeLoading(){
9    $(function() {
10        // Action on Click
11        $.isLoading("hide");
12    });
13}
14
15function validatePassword(pw,pw2){
16	if (pw && pw2 && pw!=pw2){
17		return '密碼𣎴符';
18	}
19	if (pw || pw2){
20		var patt = /^[0-9a-zA-Z]{8,16}$/;
21		var patt2 = /^[0-9]+$/;
22		var patt3 = /^[a-zA-Z]+$/;
23		var invalidpatt = false;
24		if ((pw && !patt.test(pw)) || (pw2 && !patt.test(pw2)))
25			invalidpatt = true;
26		if (patt2.test(pw) || patt3.test(pw) || patt2.test(pw2) || patt3.test(pw2))
27			invalidpatt = true;
28		if (invalidpatt)
29			return '密碼需為8-16位數字及英文字母組合';
30	}
31	return '';
32}
33
34function validateEmail(email){
35	if (email){
36		var patt = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
37		if (!patt.test(email)) {
38      errormsg = '電郵無效';
39    }
40    else {
41      data = {email: email};
42      var errormsg = '';
43      $.ajax({
44        type: "POST",
45        cache: false,
46        async: false,
47        url: 'vendor/php/EmailValidation.php',
48        data: data,
49        success: function(res){
50          data = JSON.parse(res);
51          if (data['err']){
52            errormsg = data['errmsg']['all'];
53          }
54        }
55      });
56    }
57    if (errormsg == '已登記電郵') {
58      $('#forget-pw').show();
59    }
60    else {
61      $('#forget-pw').hide();
62    }
63    return errormsg;
64	}
65}
66
67function validatePhoneno(phoneno){
68	if (phoneno){
69		var format_patt = /^\d+$/;
70		var number_patt = /\d{8}/;
71		if (!format_patt.test(phoneno)){
72			errormsg = '請輸入有效電話號碼';
73		}
74		else if(!number_patt.test(phoneno)){
75			errormsg = '請輸入8位數字電話號碼';
76		}
77    else {
78      data = {phoneno: phoneno};
79      var errormsg = '';
80      $.ajax({
81        type: "POST",
82        cache: false,
83        async: false,
84        url: 'vendor/php/PhoneNumberValidation.php',
85        data: data,
86        success: function(res){
87          data = JSON.parse(res);
88          if (data['err']){
89            errormsg = data['errmsg']['all'];
90          }
91        }
92      });
93    }
94    if (errormsg == '已登記電話號碼') {
95      $('#forget-pw').show();
96    }
97    else {
98      $('#forget-pw').hide();
99    }
100    return errormsg;
101	}
102	return '';
103}
104
105function validateLoginName(name){
106	if (name){
107		var patt = /^[0-9a-zA-Z]{4,16}$/;
108		if (!patt.test(name))
109			return '登入名稱需為4-16位數字或英文字母組合';
110	}
111	return '';
112}
113
114function parseErrorMsg(err_arr){
115	for (var key in err_arr){
116		$("#err_" + key).html(err_arr[key]);
117		$("#" + key).addClass('errfield');
118	}
119}
120
121function removeErrorMsg(form){
122	$('#' + form + ' .errmsg').html('');
123	$('#' + form + ' input').removeClass('errfield');
124}
125
126function showStappsDownloadPopup(isApplyPage){
127	swal({
128		title: "登記個案",
129		text: "此乃Tutor Circle x Stapps 獨家合作個案,立即下載Stapps登記個案!",
130		type: "info",
131		showCancelButton: true,
132		showConfirmButton: true,
133		cancelButtonText: `返回`,
134		confirmButtonText: `下載`,
135	}).then((result) => {
136		if(isApplyPage){
137			if (result.value) {
138				window.location.href = 'https://stapps.app.link/DmIBsrP78Bb'
139			} else {
140				window.location.href = '/case-list.php'
141			}
142		} else {
143			// assume default case-list.php
144			if (result.value) {
145				window.open('https://stapps.app.link/DmIBsrP78Bb', '_blank')
146			}
147		}
148	});
149}
150
151$('.btn-reg-case').click(function(){
152	switch($('#fullfunc').val()){
153		case '1':
154			if ($('#user_profile').data('role') == 'tutor'){
155				var caseid = $(this).parent().parent().data('caseid');
156				var tutorname = $('#user_profile').data('name');
157				var tutoremail = $('#user_profile').data('email');
158				var selfintro = $('#ts_selfintro').val();
159				swal({
160					html: true,
161					type: "input",
162					title: "請確認是否登記個案?",
163					text: "<div style='text-align:left'>個案編號:" + caseid + "<br>登記導師:" + tutorname + " <br>電郵:" + tutoremail + "</div>",
164					showCancelButton: true,
165					closeOnConfirm: false,
166					inputPlaceholder: "自我介紹",
167					inputValue: selfintro,
168				}, function(inputValue){
169					if (inputValue === false)
170						return false;
171					if (inputValue === "") {
172						swal.showInputError("請輸入自我介紹");
173						return false;
174					}
175					/*if (inputValue.length > 100) {
176						swal.showInputError("自我介紹不可超過100字");
177						return false;
178					}*/
179					addLoading();
180					data = {caseid:caseid,intro:inputValue};
181					$.ajax({
182						type: "POST",
183				        cache: false,
184						url: 'vendor/php/TakeCase.php',
185						data: data,
186						success: function(res){
187							data = JSON.parse(res);
188							removeLoading();
189							if (data['err']){
190								swal.showInputError(data['errmsg']['all']);
191								return false;
192							} else {
193								swal("登記成功!", "我們會從登記導師中揀選最合適的導師並另行通知。", "success");
194								return true;
195							}
196						},
197						error: function(xhr,status,error){
198							removeLoading();
199							swal.showInputError("登記失敗,請稍後再試");
200						},
201					});
202				});
203			} else {
204				swal({
205					title: "",
206					text: "請先註冊導師帳戶並開通您的帳號,以啟用登記個案功能。",
207					},function(){
208						window.location.href = 'tutor_login.php';
209					});
210				}
211			break;
212		case '2':
213			swal({
214				title: "",
215				text: "請先查看郵件箱並開通您的帳號,以啟用登記個案功能。",
216				});
217			break;
218		default:
219			swal({
220				title: "",
221				text: "請先註冊導師帳戶並開通您的帳號,以啟用登記個案功能。",
222				},function(){
223					window.location.href = 'tutor_login.php';
224				});
225			break;
226	}
227});
228
229var resendActivation = function resendActivation(){
230	addLoading();
231	url = 'vendor/php/ResendActivation.php';
232	$.ajax({
233		type: "POST",
234        cache: false,
235        data: {mode:2},
236		url: url,
237		success: function(res){
238			data = JSON.parse(res);
239			removeLoading();
240			if (data['err']){
241				swal("發送失敗!", "電郵未能發送,請稍後再試。", "error");
242			} else {
243				swal("發送成功!", "確認電郵已經發送,請查看郵件箱並開通您的帳號,以啟用各種導師功能。", "success");
244			}
245			console.log(res);
246		},
247		error: function(xhr,status,error){
248			removeLoading();
249			swal("發送失敗!", "電郵未能發送,請稍後再試。", "error");
250		},
251	});
252}
253
254$("#resend_activation").click(function(e){
255	e.preventDefault()
256	resendActivation();
257});

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.