PageSourceSearch

https://www.hl.gov.tw/Scripts/JQCookieToJSCookie.js

js hl.gov.tw collected 2026-09-24 09:15:48 UTC 1,847 bytes, 58 lines download raw bytes

1//JqueryCookie To JSCookie
2(function (factory) {
3    if (typeof define === 'function' && define.amd) {
4        // AMD
5        define(['js-cookie'], factory);
6    } else if (typeof exports === 'object') {
7        // CommonJS / Node
8        module.exports = factory(require('js-cookie'));
9    } else {
10        // 瀏覽器全域
11        factory(window.Cookies);
12    }
13}(function (Cookies) {
14
15    if (typeof window.$ === 'undefined') {
16        window.$ = {}; // 確保有 $
17    }
18
19    /**
20     * $.cookie API
21     * 用法:
22     *   $.cookie('name');                // 取值
23     *   $.cookie('name', 'value');       // 設定
24     *   $.cookie('name', 'value', opts); // 設定(帶選項)
25     *   $.cookie();                      // 取所有 cookies
26     */
27    $.cookie = function (name, value, options) {
28        if (typeof name === 'undefined') {
29            return Cookies.get();
30        }
31
32        if (typeof value !== 'undefined') {
33            // 特殊處理舊寫法 path: "/;SameSite=Strict"
34            if (options && typeof options.path === 'string' && options.path.includes(';SameSite=')) {
35                const parts = options.path.split(';');
36                options.path = parts[0]; // 保留真實的路徑
37                const sameSitePart = parts.find(p => p.trim().startsWith('SameSite='));
38                if (sameSitePart) {
39                    options.sameSite = sameSitePart.split('=')[1];
40                }
41            }
42            return Cookies.set(name, value, options);
43        }
44
45        return Cookies.get(name);
46    };
47
48    /**
49     * $.removeCookie API
50     * 用法:
51     *   $.removeCookie('name');
52     *   $.removeCookie('name', opts);
53     */
54    $.removeCookie = function (name, options) {
55        Cookies.remove(name, options);
56    };
57
58}))

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.