PageSourceSearch

https://en.nokov.com/js/new/common.js

js nokov.com collected 2026-09-24 11:44:16 UTC 20,528 bytes, 488 lines download raw bytes

1/**
2 * 新版英文站页面,自定义的js通用文件
3 */
4$(function () {
5    //搜索
6    $(".dl_nav_search_main a").click(function () {
7        var _word = $(".dl_nav_search_main input").val();
8        var reg = new RegExp("-", "g");
9        _word = _word.replace(reg, '');
10        window.location.href = '/index/search/' + _word + '.html';
11    });
12
13    //搜索,点击回车键提交
14    $(".dl_nav_search_main input").keypress(function (e) {
15        if (e.keyCode == 13) {
16            var _word = $(".dl_nav_search_main input").val();
17            var reg = new RegExp("-", "g");
18            _word = _word.replace(reg, '');
19            window.location.href = '/index/search/' + _word + '.html';
20        }
21    });
22
23    //订阅按钮提交
24    $("#subscribe_btn").click(function () {
25        var _email = $("#subscribe").val();
26        var reg = new RegExp(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/);
27        if (!reg.test(_email) || _email == '') {
28            showTips("Please enter the correct e-mail");
29            return false;
30        }
31        fetch('https://hook.jijyun.cn/v1/accept/data/webhook_accept_first/CR0IQVp1sJouNg9TqOYfmhb8yXAKjwW6', {
32            method: 'POST', headers: {
33                'Content-Type': 'application/json'
34            }, body: JSON.stringify({
35                email: _email,
36                site: 'en'
37            })
38        }).then(response => response.json())
39            .then(data => {
40                if (data.Code == 200) {
41                    showTips("We will notify you when your subscription is successful!");
42                } else {
43                    showTips("Subscription failed, please try again later!");
44                }
45            })
46    });
47
48    //隐私弹窗
49    var privacy_policy_cookie = getCookie('privacy_policy_cookie');
50    if (!privacy_policy_cookie) {
51        $("#buttonModal").show();
52    }
53
54    //详情页面,右侧小按钮功能
55    $(".dl_casep_server.caseTools > a").each(function (index) {
56        $(this).click(function () {
57            var current_url = window.location.href;
58
59            switch (index) {
60                case 0: // 打印页面
61                    window.print();
62                    break;
63
64                case 1: // 复制链接到剪贴板
65                    var dummy = document.createElement('input');
66                    document.body.appendChild(dummy);
67                    dummy.value = current_url;
68                    dummy.select();
69                    document.execCommand('copy');
70                    document.body.removeChild(dummy);
71                    showTips('Link copied to clipboard!');
72                    break;
73
74                case 2: // 分享到 LinkedIn
75                    window.open(`https://www.linkedin.com/shareArticle?mini=true&url=${current_url}`);
76                    break;
77
78                case 3: // 分享到 Twitter
79                    window.open(`https://twitter.com/intent/tweet?url=${current_url}`);
80                    break;
81                case 4:
82                    window.open(`https://www.youtube.com/@nokovmocap`);
83                    break;
84            }
85        });
86    });
87
88    //faqs和case页面站内搜索
89    $("#site_search").keypress(function (e) {
90        if (e.keyCode == 13) {
91            var _word = $("#site_search").val();
92            //获取input里的data-type属性
93            var type = $(this).attr('data-type');
94            var _category = $(this).attr('data-category');
95            var reg = new RegExp("-", "g");
96            _word = _word.replace(reg, '');
97            if (!_word) {
98                return;
99            }
100            window.myCollect.$customClick({
101                action: 'search',
102                props: {
103                    search_keyword: _word,
104                    search_site: 'en',
105                    search_type: type
106                }
107            })
108
109            if (type == 'case') {
110                //window.open('/index/search/' + _word + '/' + type + '.html');
111                if (_category != '') {
112                    _category = `/${_category}`;
113                }
114                window.location.href = `/resources/motion-capture-showcases${_category}/${_word}.html`;
115            } else if (type == 'faqs') {
116                if (_category != '') {
117                    _category = `/${_category}`;
118                }
119                window.location.href = `/support/FAQ${_category}/${_word}.html`;
120            }else if (type == 'integrations') {
121                if (_category != '') {
122                    _category = `/${_category}`;
123                }
124                window.location.href = `/products/integrations${_category}/${_word}.html`;
125            }
126
127
128        }
129    });
130
131    //右下角 ai bot 提示框(等待HelpLookSdk初始化)
132    function isMobile() {
133        return window.innerWidth <= 768;
134    }
135
136    var chatbot_cookie = getCookie('chatbot_cookie');
137    if (!chatbot_cookie) {
138        $("#chatbot").show();
139    }
140
141    var helplook_cookie = getCookie('helplook_cookie');
142    if (helplook_cookie && isMobile()) {
143        $("#HelpLookSdk").hide();
144    }
145
146    $(".chatbot-footer").click(function(e) {
147        e.preventDefault();
148        e.stopPropagation();
149        $("#chatbot").hide();
150        $("#HelpLookSdk").hide();
151        $("#HelpLookSdkDragOverlay").hide();
152        var exp = new Date();
153        exp.setTime(exp.getTime() + 5 * 24 * 60 * 60 * 1000);
154        document.cookie = 'chatbot_cookie' + "=" + escape(1) + ";expires=" + exp.toGMTString() + ";path=/";
155        document.cookie = 'helplook_cookie' + "=" + escape(1) + ";expires=" + exp.toGMTString() + ";path=/";
156    });
157    var hasAppliedInitialHelpLookStyles = false;
158    var hasHookedHelpLookSwitchState = false;
159    var hasSetupDragger = false;
160    var dragConfig = {
161        fullScreen: true
162    };
163    var savedPosition = null;
164
165    function setupDragger() {
166        if (!isMobile() || hasSetupDragger) return;
167
168        var iframe = document.querySelector('#HelpLookSdk');
169        var chatbot = document.querySelector('#chatbot');
170        if (!iframe) return;
171
172        var overlay = document.createElement('div');
173        overlay.id = 'HelpLookSdkDragOverlay';
174        overlay.style.cssText = 'position: fixed; z-index: 2147483647; width: 44px; height: 44px; right: 6px; left: auto; top: calc(50% - 100px); bottom: auto; touch-action: none; background: transparent;';
175        document.body.appendChild(overlay);
176
177        var syncPosition = function() {
178            var rect = iframe.getBoundingClientRect();
179            if (rect.width > 0 && rect.height > 0) {
180                overlay.style.left = rect.left + 'px';
181                overlay.style.top = rect.top + 'px';
182                overlay.style.bottom = 'auto';
183                overlay.style.width = rect.width + 'px';
184                overlay.style.height = rect.height + 'px';
185            }
186        };
187
188        setTimeout(syncPosition, 500);
189        setTimeout(syncPosition, 1000);
190        setTimeout(syncPosition, 2000);
191
192        var dragState = { isDragging: false, startY: 0, startX: 0, startIframeTop: 0, startIframeLeft: 0, startChatbotTop: 0, startChatbotLeft: 0, startTime: 0 };
193
194        overlay.addEventListener('touchstart', function(e) {
195            dragState.isDragging = true;
196            dragState.startY = e.touches[0].clientY;
197            dragState.startX = e.touches[0].clientX;
198            dragState.startTime = Date.now();
199            dragState.startIframeTop = iframe.getBoundingClientRect().top;
200            dragState.startIframeLeft = iframe.getBoundingClientRect().left;
201            if (chatbot) {
202                dragState.startChatbotTop = chatbot.getBoundingClientRect().top;
203                dragState.startChatbotLeft = chatbot.getBoundingClientRect().left;
204            }
205        }, { passive: true });
206
207        document.addEventListener('touchmove', function(e) {
208            if (!dragState.isDragging) return;
209            e.preventDefault();
210            var deltaY = e.touches[0].clientY - dragState.startY;
211            var deltaX = e.touches[0].clientX - dragState.startX;
212            var maxY = window.innerHeight - 60;
213            var screenW = window.innerWidth;
214
215            if (dragConfig.fullScreen) {
216                var newIframeTop = Math.max(0, Math.min(dragState.startIframeTop + deltaY, maxY));
217                var newIframeLeft = Math.max(0, Math.min(dragState.startIframeLeft + deltaX, screenW - 50));
218                iframe.style.setProperty('top', newIframeTop + 'px', 'important');
219                iframe.style.setProperty('left', newIframeLeft + 'px', 'important');
220                iframe.style.setProperty('bottom', 'auto', 'important');
221                iframe.style.setProperty('right', 'auto', 'important');
222                overlay.style.top = newIframeTop + 'px';
223                overlay.style.left = newIframeLeft + 'px';
224                overlay.style.bottom = 'auto';
225
226                if (chatbot) {
227                    var isRightSide = newIframeLeft > screenW / 2;
228                    var chatbotWidth = 220;
229                    var newChatbotTop, newChatbotLeft;
230
231                    if (isRightSide) {
232                        newChatbotLeft = screenW - chatbotWidth - 5;
233                        newChatbotTop = Math.max(0, Math.min(newIframeTop - 10, maxY - 70));
234                        newIframeLeft = screenW - 50;
235                        iframe.style.setProperty('left', newIframeLeft + 'px', 'important');
236                        overlay.style.left = newIframeLeft + 'px';
237                    } else {
238                        newChatbotTop = Math.max(0, Math.min(dragState.startChatbotTop + deltaY, maxY - 70));
239                        newChatbotLeft = Math.max(0, Math.min(dragState.startChatbotLeft + deltaX, screenW - chatbotWidth));
240                    }
241
242                    chatbot.style.setProperty('top', newChatbotTop + 'px', 'important');
243                    chatbot.style.setProperty('left', newChatbotLeft + 'px', 'important');
244                    chatbot.style.setProperty('bottom', 'auto', 'important');
245                    chatbot.style.setProperty('right', 'auto', 'important');
246                }
247            } else {
248                var newIframeTop = Math.max(0, Math.min(dragState.startIframeTop + deltaY, maxY));
249                iframe.style.setProperty('top', newIframeTop + 'px', 'important');
250                iframe.style.setProperty('bottom', 'auto', 'important');
251                overlay.style.top = newIframeTop + 'px';
252                overlay.style.bottom = 'auto';
253
254                if (chatbot) {
255                    var newChatbotTop = Math.max(0, Math.min(dragState.startChatbotTop + deltaY, maxY - 70));
256                    chatbot.style.setProperty('top', newChatbotTop + 'px', 'important');
257                    chatbot.style.setProperty('bottom', 'auto', 'important');
258                }
259            }
260        }, { passive: false });
261
262        overlay.addEventListener('touchend', function(e) {
263            if (!dragState.isDragging) return;
264            dragState.isDragging = false;
265
266            var endTime = Date.now();
267            var duration = endTime - dragState.startTime;
268            var deltaY = Math.abs(e.changedTouches[0].clientY - dragState.startY);
269            var deltaX = Math.abs(e.changedTouches[0].clientX - dragState.startX);
270
271            if (duration < 300 && deltaY < 10 && deltaX < 10) {
272                overlay.style.pointerEvents = 'none';
273                var clickEvent = new MouseEvent('click', {
274                    bubbles: true,
275                    cancelable: true,
276                    clientX: e.changedTouches[0].clientX,
277                    clientY: e.changedTouches[0].clientY
278                });
279                iframe.dispatchEvent(clickEvent);
280                setTimeout(function() {
281                    overlay.style.pointerEvents = 'auto';
282                }, 100);
283            }
284        }, { passive: true });
285
286        hasSetupDragger = true;
287    }
288
289    var sdkConfig = {
290        desktop: {
291            closed: { width: '66px', height: '66px', top: '90px', right: '0', left: 'auto', bottom: 'auto', btnSize: '60px', iconSize: '50px' },
292            opened: { top: '90px', right: '0', left: 'auto', bottom: 'auto' }
293        },
294        mobile: {
295            closed: { width: '44px', height: '44px', top: 'calc(50% - 100px)', right: '6px', left: 'auto', bottom: 'auto', btnSize: '34px', iconSize: '30px' },
296            opened: { top: 'auto', right: 'auto', left: '10px', bottom: '60px' }
297        }
298    };
299
300    function scheduleApplyHelpLookSdkStyles(isOpen) {
301        setTimeout(function() {
302            applyHelpLookSdkStyles(isOpen);
303        }, 0);
304
305        requestAnimationFrame(function() {
306            applyHelpLookSdkStyles(isOpen);
307            requestAnimationFrame(function() {
308                applyHelpLookSdkStyles(isOpen);
309            });
310        });
311    }
312
313    function applyHelpLookSdkStyles(isOpen) {
314        const sdkWrap = document.querySelector('#hl-sdk-wrap');
315        const iframe = document.querySelector('#HelpLookSdk');
316        if (!sdkWrap && !iframe) {
317            return false;
318        }
319
320        var mode = isMobile() ? 'mobile' : 'desktop';
321        var state = isOpen ? 'opened' : 'closed';
322        var cfg = sdkConfig[mode][state];
323
324        if (isOpen) {
325            var dragOverlay = document.getElementById('HelpLookSdkDragOverlay');
326            if (dragOverlay && isMobile()) {
327                savedPosition = {
328                    top: iframe.style.getPropertyValue('top'),
329                    left: iframe.style.getPropertyValue('left'),
330                    bottom: iframe.style.getPropertyValue('bottom'),
331                    right: iframe.style.getPropertyValue('right')
332                };
333                dragOverlay.style.display = 'none';
334            }
335            if (sdkWrap) {
336                sdkWrap.style.setProperty('top', cfg.top, 'important');
337                sdkWrap.style.setProperty('right', cfg.right, 'important');
338                sdkWrap.style.setProperty('left', cfg.left, 'important');
339                sdkWrap.style.setProperty('bottom', cfg.bottom, 'important');
340            }
341            if (iframe) {
342                iframe.style.setProperty('top', cfg.top, 'important');
343                iframe.style.setProperty('right', cfg.right, 'important');
344                iframe.style.setProperty('left', cfg.left, 'important');
345                iframe.style.setProperty('bottom', cfg.bottom, 'important');
346            }
347        } else {
348            var dragOverlay = document.getElementById('HelpLookSdkDragOverlay');
349            if (dragOverlay) {
350                dragOverlay.style.display = 'block';
351            }
352            if (sdkWrap) {
353                sdkWrap.style.removeProperty('top');
354                sdkWrap.style.removeProperty('bottom');
355            }
356
357            if (!iframe) {
358                return false;
359            }
360
361            iframe.style.setProperty('height', sdkConfig[mode].closed.height, 'important');
362            iframe.style.setProperty('width', sdkConfig[mode].closed.width, 'important');
363
364            if (savedPosition && isMobile()) {
365                iframe.style.setProperty('top', savedPosition.top, 'important');
366                iframe.style.setProperty('left', savedPosition.left, 'important');
367                iframe.style.setProperty('bottom', savedPosition.bottom, 'important');
368                iframe.style.setProperty('right', savedPosition.right, 'important');
369
370                setTimeout(function() {
371                    var rect = iframe.getBoundingClientRect();
372                    dragOverlay.style.left = rect.left + 'px';
373                    dragOverlay.style.top = rect.top + 'px';
374                    dragOverlay.style.bottom = 'auto';
375                    dragOverlay.style.width = rect.width + 'px';
376                    dragOverlay.style.height = rect.height + 'px';
377                }, 50);
378            } else {
379                iframe.style.setProperty('right', sdkConfig[mode].closed.right, 'important');
380                iframe.style.setProperty('top', sdkConfig[mode].closed.top, 'important');
381                iframe.style.setProperty('left', sdkConfig[mode].closed.left, 'important');
382                iframe.style.setProperty('bottom', sdkConfig[mode].closed.bottom, 'important');
383            }
384        }
385
386        if (!iframe) {
387            return false;
388        }
389
390        const innerDoc = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document);
391        if (!innerDoc) {
392            return false;
393        }
394
395        const floatBtn = innerDoc.querySelector('.icon-wrap');
396        const initIcon = floatBtn && floatBtn.querySelector('.init-icon');
397
398        if (isOpen) {
399            return !!(floatBtn && initIcon);
400        }
401
402        if (floatBtn) {
403            floatBtn.style.setProperty('width', sdkConfig[mode].closed.btnSize, 'important');
404            floatBtn.style.setProperty('height', sdkConfig[mode].closed.btnSize, 'important');
405            if (initIcon) {
406                initIcon.style.setProperty('max-height', sdkConfig[mode].closed.iconSize, 'important');
407                initIcon.style.setProperty('max-width', sdkConfig[mode].closed.iconSize, 'important');
408            }
409        }
410
411        return !!(floatBtn && initIcon);
412    }
413    var checkInterval = setInterval(function() {
414        if (window.HelpLookSdk){
415            console.log("loaded helplooksdk")
416            hasAppliedInitialHelpLookStyles = applyHelpLookSdkStyles(!!window.HelpLookSdk.state);
417
418            var helplook_cookie = getCookie('helplook_cookie');
419            if (helplook_cookie && isMobile()) {
420                $("#HelpLookSdk").hide();
421            } else {
422                setupDragger();
423            }
424        }
425
426        if (!hasHookedHelpLookSwitchState && window.HelpLookSdk && window.HelpLookSdk.switchState) {
427            var originalSwitchState = window.HelpLookSdk.switchState;
428
429            window.HelpLookSdk.switchState = function(e) {
430
431                // 判断最终状态
432                var finalState = (e === undefined) ? !this.state : e;
433
434                if (finalState) {
435                    console.log('✅ 💬 对话框打开了');
436                    var exp = new Date();
437                    exp.setTime(exp.getTime() + 5 * 24 * 60 * 60 * 1000);
438                    document.cookie = 'chatbot_cookie' + "=" + escape(1) + ";expires=" + exp.toGMTString() + ";path=/";
439                    $("#chatbot").animate({
440                        width: 0,
441                        height: 0,
442                        opacity: 0,
443                        marginLeft: $("#chatbot").outerWidth(),
444                        marginTop: $("#chatbot").outerHeight()
445                    }, 600, function() {
446                        $(this).hide();
447                    });
448                }else{
449                    console.log('❌ 💬 对话框关闭了');
450                }
451
452                var result = originalSwitchState.apply(this, arguments);
453                scheduleApplyHelpLookSdkStyles(finalState);
454                return result;
455            };
456
457            hasHookedHelpLookSwitchState = true;
458        }
459
460        if (hasAppliedInitialHelpLookStyles && hasHookedHelpLookSwitchState) {
461            clearInterval(checkInterval);
462        }
463    }, 100);
464
465    window.addEventListener('resize', function() {
466        if (window.HelpLookSdk) {
467            scheduleApplyHelpLookSdkStyles(!!window.HelpLookSdk.state);
468        }
469    });
470
471});
472function getCookie(cName) {
473    const name = cName + "=";
474    const cDecoded = decodeURIComponent(document.cookie); //to be careful
475    const cArr = cDecoded.split('; ');
476    let res;
477    cArr.forEach(val => {
478        if (val.indexOf(name) === 0) res = val.substring(name.length);
479    })
480    return res;
481}
482
483function hideButtonModal() {
484    $("#buttonModal").hide().fadeOut();
485    var exp = new Date();
486    exp.setTime(exp.getTime() + 365 * 24 * 60 * 60 * 1000);
487    document.cookie = 'privacy_policy_cookie' + "=" + escape(1) + ";expires=" + exp.toGMTString() + ";path=/";
488}

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.