PageSourceSearch

https://liketeashop.com/resources/js/devtool.js

js liketeashop.com collected 2026-09-26 03:39:19 UTC 3,578 bytes, 142 lines download raw bytes

1// CSRF
2$.ajaxSetup({
3    headers: {
4        'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
5    }
6});
7
8// Global error
9$(document).ajaxError(function(event, xhr, settings, thrownError) {
10	switch (xhr.status) {
11        case 403:
12            res = $.parseJSON(xhr.responseText);
13
14            if (res['error'] == '') {
15                location.href = res['location'];
16            } else {
17                alert_box(res['error']);
18                $('#alert_area .close').click(function(event) { location.href = res['location']; });
19            }
20
21            break;
22		case 405:
23			alert_box('連線逾時,請重新操作(Please re-operate when the connection expires)');
24			$('#alert_area .close').click(function(event) { history.go(0); });
25
26			break;
27		case 422:
28        	var message = '';
29
30        	$.each($.parseJSON(xhr.responseText), function(key, value) {
31        		message += value + '<br>';
32        	})
33
34        	alert_box(message);
35
36            if (typeof grecaptcha === "object") {
37                grecaptcha.reset();
38            }
39
40            return false;
41			break;
42		default:
43			alert_box('發生錯誤,Status code:' + xhr.status);
44			$('#alert_area .close').click(function(event) { history.go(0); });
45	}
46});
47
48/**
49 * 警告視窗
50 */
51function alert_box($string, $close_time) {
52	if(typeof $string == 'string') {
53		if($string != '') {
54        	$('#alert_area').find('i.content').html($string);
55        	$('#alert_area').addClass('active');
56
57        	if ($close_time != undefined) {
58	        	setTimeout(function() {
59	        		$('#alert_area').removeClass('active');
60	        	}, $close_time);
61        	}
62		}
63	}
64}
65
66/**
67 * 驗證器
68 *
69 * @param  string $form
70 * @param  string $rule
71 * @param  string $rule_message
72 * @param  string $validate_path
73 * @param  boolen $submit
74 */
75function validate($form, $rule, $rule_message, $validate_path, $submit) {
76    var formData = new FormData($($form)[0]);
77    var check = false;
78
79    if ($submit == undefined) {
80        $submit = true;
81    }
82
83    formData.append('rule', $rule);
84    formData.append('rule_message', $rule_message);
85    formData.append('validate_path', $validate_path);
86
87    $.ajax({
88        url: base_path + 'tool-ajax-validate',
89        dataType: 'json',
90        type:'POST',
91        data: formData,
92        async: false,
93        cache: false,
94        contentType: false,
95        processData: false,
96        error: function(xhr) {},
97        success: function(response) {
98            if($submit) {
99                $($form).submit();
100            } else {
101                check = true;
102            }
103        }
104    });
105
106    return check;
107};
108
109/**
110 * 圖片編輯視窗
111 *
112 * image_url 請先利用 base64_encode 傳進來, js本身的需要另外裝js或者原生函數(只支援IE10以上)
113 */
114function image_editor_box($image_url) {
115	$.colorbox({
116		href: base_path + 'image-editor/' + $image_url,
117		iframe: true,
118		innerWidth: 1000,
119		innerHeight: 640,
120	});
121}
122
123function temp_input($form, $key_string) {
124    var formData = new FormData($($form)[0]);
125
126    formData.append('key_string', $key_string);
127
128    $.ajax({
129        url: base_path + 'tool-ajax-temp-input',
130        dataType: 'json',
131        type:'POST',
132        data: formData,
133        async: false,
134        cache: false,
135        contentType: false,
136        processData: false,
137        error: function(xhr) {},
138        success: function(response) {
139            // console.log('save');
140        }
141    });
142};

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.