PageSourceSearch

https://greenrock.com.tw/bk/js/contact.js?100602

js greenrock.com.tw collected 2026-10-05 18:30:31 UTC 7,125 bytes, 190 lines download raw bytes

1import { bk_method } from "./../bk_method.js";
2$.ajaxSetup({
3    headers: {
4        'X-CSRF-TOKEN': $('#_token').val()
5    }
6});
7let Action = {};
8Action.ajaxSend = false;
9Action.page = 1;
10Action.tab = 'news';
11Action.selectClass = 0;
12Action.init = function () {
13    Action.click();
14}
15
16Action.click = function () {
17    // $('.form-clear').on('click', function () {
18    //     $(".error-info").addClass('d-none');
19    //     $('.form-group').removeClass('error');
20    //     $('.form-group input').val('');
21    //     $('.form-group textarea').val('');
22    //     $('.option-item .text').removeClass('active');
23    //     _g.clearFunction();
24    // });
25    $('.form-submit').on('click', function () {
26        $(".error-group").addClass('d-none');
27        $('.form-group').removeClass('error');
28        let formData = $('.wdd-form')[0].value;
29        let error = 0;
30        let errorMsg = [];
31        if ($('[form-field="name"]').val().trim().replace(/\s/g, "") == "") {
32            $('[form-field="name"]').closest('.form-group').addClass('error'); error++;
33            errorMsg.push($('[form-field="name"]').attr('data-error'));
34        }
35        if(formData['title']['value'] == ""){
36            $('[form-field="title"]').closest('.form-group').addClass('error'); error++;
37            errorMsg.push($('[form-field="title"]').attr('data-error'));
38        }
39        if ($('[form-field="phone"]').val().trim().replace(/\s/g, "") == "") {
40            $('[form-field="phone"]').closest('.form-group').addClass('error'); error++;
41            errorMsg.push($('[form-field="phone"]').attr('data-error'));
42        }
43        if ($('[form-field="email"]').val().trim().replace(/\s/g, "") == "") {
44            $('[form-field="email"]').closest('.form-group').addClass('error'); error++;
45            errorMsg.push($('[form-field="email"]').attr('data-error'));
46        }else{
47            if (!bk_method.Validate_Email($('[form-field="email"]').val())) {
48                $('[form-field="email"]').closest('.form-group').addClass('error'); error++;
49                errorMsg.push($('[form-field="email"]').attr('data-error'));
50            }
51        }
52        if(formData['purpose']['value'] == ""){
53            $('[form-field="purpose"]').closest('.form-group').addClass('error'); error++;
54            errorMsg.push($('[form-field="purpose"]').attr('data-error'));
55        }
56        if ($('[form-field="description"]').val().trim().replace(/\s/g, "") == "") {
57            $('[form-field="description"]').closest('.form-group').addClass('error'); error++;
58            errorMsg.push($('[form-field="description"]').attr('data-error'));
59        }
60        if ($('[form-field="verifyCode"]').val().trim().replace(/\s/g, "") == "") {
61            $('[form-field="verifyCode"]').closest('.form-group').addClass('error'); error++;
62            errorMsg.push($('[form-field="verifyCode"]').attr('data-error'));
63        }
64        if (error > 0) {
65            Action.refresh_vcode();
66            $(".error-group").removeClass('d-none');
67            let string = errorMsg.map(item => `<span>${item};</span>`).join('');
68            $(".error-info").html(string);
69        }else{
70            if (Action.ajaxSend) {
71                return false;
72            }
73            Action.ajaxSend = true;
74            $.ajax({
75                type: "POST",
76                url: location.href,
77                data: {
78                    ajax: true,
79                    formData: formData
80                },
81                dataType: 'JSON',
82                cache: false,
83            }).done(function (response) {
84                if (response.code == 1) {
85                    location.href = response.url;
86                } else {
87                    Action.refresh_vcode();
88                    $('[form-field="verifyCode"]').closest('.form-group').addClass('error');
89                }
90                Action.ajaxSend = false;
91            }).fail(function () {
92                Action.refresh_vcode();
93                Action.ajaxSend = false;
94            });
95
96        }
97
98    });
99    $(".refresh-btn").on('click', function () {
100        Action.refresh_vcode();
101    });
102    Action.refresh_vcode = function () {
103        var d = new Date();
104        var src = $('.refresh-btn').find('img').prop('src').split('?')[0] + '?t=' + d.getMilliseconds();
105        $('.refresh-btn').find('img').prop('src', src);
106        $('[form-field="verifyCode"]').val('');
107    }
108}
109Action.change = function (class_id, set_page, check, needpush, url_path) {
110    if (check && Action.selectClass == class_id) {
111        return;
112    }
113    Action.selectClass = class_id;
114    Action.page = set_page;
115    if (needpush) {
116        Action.pushindex = Action.pushindex + 1;
117        history.pushState({ class_id: class_id, url_path: url_path, index: Action.pushindex }, null, url_path);
118    } else {
119        // let _option = $('multipurpose-nav .item[data-id="' + class_id + '"]').attr('data-option');
120        // $('multipurpose-nav').attr('m4-status', _option);
121    }
122
123    $.ajax({
124        type: "POST",
125        url: location.href,
126        data: {
127            ajax: true,
128            class_id: class_id,
129            page: Action.page
130        },
131        dataType: 'JSON',
132        cache: false,
133    }).done(function (response) {
134        if (check) {
135            $("." + Action.tab + '-list .row').html('');
136        }
137        if (response.count == 0) {
138            $('.no-data').removeClass('d-none');
139            $(".see-more").addClass('d-none');
140        } else {
141            $('.no-data').addClass('d-none');
142            $("." + Action.tab + '-list .row').append(response.html);
143            if (!response.hasNext) {
144                $(".see-more").addClass('d-none');
145            } else {
146                $(".see-more").removeClass('d-none');
147            }
148        }
149        _g.ajaxUpdate();
150        Action.ajaxSend = false;
151    });
152}
153
154$(function () {
155    Action.init();
156    // if(screen.width <= 1024){
157    //     $('.news-box-wrap:hidden').filter(':lt(1)').removeClass('d-none');
158    // }
159
160    let select_item = $(".categoryOptions .item.active");
161    let class_id = select_item.data('id');
162    Action.selectClass = class_id;
163    // let url_name = select_item.data('option');
164    // let url_path = select_item.data('url');
165    // let title = select_item.find('.category').text();
166    // if($("main").data('class') != ""){
167    //     Anchor4.run({
168    //         target: '.category-block'
169    //     });
170    //     if($(".news-box-wrap." + class_id).length > 5){
171    //         $(".btn-expand").removeClass('d-none');
172    //     }else{
173    //         $(".btn-expand").addClass('d-none');
174    //     }
175    // }
176    window.addEventListener("popstate", function (e) {
177        var oState = e.state;
178        if (oState) {
179            Action.change(e.state.class_id, 1, true, false, e.state.url_path);
180        } else {
181            //Action.change(class_id,url_name,url_path,title, false);
182        }
183    });
184
185    if(location.search != ""){
186        let _go = location.search.replace('?go=','');
187        _g.goToTarget("." + _go);
188        history.pushState({ }, null, location.href.replace(location.search,""));
189      }
190});

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.