PageSourceSearch

https://www.safepal.com/assets/js/download.js?v=202608211787302738890

js safepal.com collected 2026-10-01 11:45:21 UTC 8,304 bytes, 190 lines download raw bytes

1(function () {
2    "use strict";
3    // 下载页应用商店按钮 GA4 自定义事件
4    document.addEventListener('click', function (e) {
5        const el = e.target.closest('[tracker-key]');
6        if (!el) return;
7        const key = el.getAttribute('tracker-key');
8        const map = {
9            eventIosClick: 'Download_iOS',
10            eventGooglePlayClick: 'Download_APK',
11            eventAndroidClick: 'Download_Android',
12        };
13        const eventName = map[key];
14        if (!eventName || typeof gtag !== 'function') return;
15        const params = {
16            event_category: 'download',
17            event_label: key,
18            platform: key.replace(/^event|Click$/g, '').toLowerCase(),
19        };
20        const ref = getQuery('ref');
21        if (ref) params.ref = ref;
22        gtag('event', eventName, params);
23    });
24    // 获取url
25    function getQuery(name) {
26        let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
27        let r = window.location.search.substr(1).match(reg);
28        if (r == null) return null;
29        let value;
30        try {
31            value = decodeURIComponent(r[2].replace(/\+/g, " "));
32        } catch (e) {
33            return null;
34        }
35        value = value.trim();
36        if (!/^[A-Za-z0-9_-]{1,64}$/.test(value)) return null;
37        return value;
38    }
39    let product = getQuery('product');
40    if(product) {
41        $('#myTab li').find('button').removeClass('active');
42        $('#myTab li').find('button').attr('aria-selected', false);
43        $('#myTabContent').find('.tab-pane').removeClass('active');
44        $('#myTabContent').find('.tab-pane').removeClass('show');
45        if (isNaN(product)) {
46            let index = 0;
47            $('#myTab li').find('button').map((i, item) => {
48                if ($(item).attr('target') === product) {
49                    index = i
50                }
51            });
52            if (index > -1) {
53                $($('#myTabContent').find('.tab-pane')[index]).addClass('active');
54                $($('#myTabContent').find('.tab-pane')[index]).addClass('show');
55                $($('#myTab li')[index]).find('button').addClass('active');
56                $($('#myTab li')[index]).find('button').attr('aria-selected', true);
57            }
58        } else {
59            $($('#myTabContent').find('.tab-pane')[product - 1]).addClass('active');
60            $($('#myTabContent').find('.tab-pane')[product - 1]).addClass('show');
61            $($('#myTab li')[product - 1]).find('button').addClass('active');
62            $($('#myTab li')[product - 1]).find('button').attr('aria-selected', true);
63        }
64        
65    }
66    $("#btn_goback").on("click", function() {
67        onClickGoBack()   
68    });
69    function onClickGoBack() {
70        $('.firmware-tips').hide();
71        $("#query_result_box").hide();
72        $("#search_sn_input").show();
73        $("#how_to_check_device").show();
74        $("#btn_goback").hide();
75        if (isMobile()) {
76            select('#myTabContent').scrollIntoView({behavior: "smooth"});
77        }
78    }
79    // 搜索框按钮点击事件
80    $(".search-btn").on("click", function() {
81        const that = this;
82        $(that).btnLoadingStart({ text: 'Loading' })
83        searchFn().finally(() => {
84            $(that).btnLoadingEnd();
85        });
86    });
87    // pc 监听enter事件
88    if (!isMobile()) {
89        $('#snInput').on('keydown', function(e) {
90            if (event.keyCode == "13") {
91                $(".search-btn").btnLoadingStart({ text: 'Loading' })
92                searchFn().finally(() => {
93                    $(".search-btn").btnLoadingEnd();
94                });
95            }
96        })
97    }
98    // 移动端from提交事件
99    $('#form-input').on('submit', function(e) {
100        e.preventDefault();
101        searchFn();
102    })
103    function searchFn() {
104        let sn = $(".search-input").val();
105        if (sn.trim() === '') { return new Promise((reject) => {
106            reject()
107        }) }
108        return $.ajaxPromise({
109            type: "post", // 请求类型
110            url: "/upgrade/getfirmware", // 请求URL
111            data: {
112                "sn": sn.trim()
113            }, // 请求参数 即是 在Servlet中 request.getParement();可以得到的字符串
114            dataType: "json", // 数据返回类型
115        }).then(result => {
116            if (result.code === 0) {
117                let { info } = result.data[0];
118                try {
119                    let html = '';
120                    if (info&&info.length > 1) {
121                        info.map((item, index) => {
122                            html += `<div class="query-item d-flex justify-content-between align-items-start flex-column">
123                                <div>
124                                    <h3 class="title">${firmware_text || 'Firmware'} ${info&&info.length > 1 ? ['A', 'B', 'C', 'D'][index] : ''}</h3>
125                                    <div class="supported-language" style="${item.language&&item.language.length ? '' : 'display:none'}">
126                                        <p class="title">${supported_languages || 'Supported Languages'}:</p>
127                                        <div class="language-box d-flex justify-content-start align-items-center flex-wrap">
128                                            ${languageList(item.language)}
129                                        </div>
130                                    </div>
131                                    <div class="sha256">
132                                        <p>SHA256:</p>
133                                        <p style="word-break: break-all;text-align: lefet;">${item.sha256}</p>
134                                    </div>
135                                </div>
136                                <div class="download">
137                                    <button class="btn_download btn-light-green">
138                                        <a href="${item.path}">${downloadText}</a>
139                                    </button>
140                                </div>
141                            </div>`; 
142                        });
143                        $("#btn_goback[data-button=two]").show();
144                        $('.firmware-tips').show();
145                    } else {
146                        info.map(item => {
147                            html+=`<div>
148                            <div class="sha256">
149                            <p style="word-break: break-all;text-align: center;">SHA256:${item.sha256}</p>
150                        </div>
151                        <div class="btn_wrap">
152                            <button style="margin-right: 10px;" class="btn_white btn_normal transparent-light-green" id="btn_goback">${GOBACK}</button>
153                            <a class="a_download" style="margin-left: 10px;" href="${item.path}">
154                                <button class="btn_normal download btn-light-green">${downloadText}</button>
155                            </a>
156                        </div>
157                            </div>`
158                        })
159                    }
160                    $(".query_result_box_content").html('');
161                    $(".query_result_box_content").append(html);
162                    $("#query_result_box").show();
163                    $("#search_sn_input").hide();
164                    $("#btn_goback").on("click", function() {
165                        onClickGoBack()
166                    });
167                } catch (error) {
168                    $(document).dialog({
169                        titleShow: false,
170                        content: 'error',
171                    });
172                }
173                
174            } else {
175                let {code, msg} = result;
176                $(document).dialog({
177                    titleShow: false,
178                    content: code === -1 ? $please_enter_correct_sn || msg : msg,
179                });
180            }
181        });
182    };
183    function languageList(list) {
184        let result = '';
185        list.map(item => {
186            result += `<span class="language-item">${item}</span>`
187        });
188        return result;
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.