PageSourceSearch

https://www.gd.gov.cn/gdywdt/ttxw/content/js/collection.js

js gd.gov.cn collected 2026-10-02 02:39:29 UTC 3,639 bytes, 103 lines download raw bytes

1$(function () {
2    $(window).on('hashchange', function () {
3        if (module.isLogin) {
4            module.updatePageKey();
5            module.fetchIsFav(function () {
6                module.setFav(module.favData);
7            });
8        }
9    });
10    var module = {
11        doms: {},
12        init: function () {
13            this.fetchUserInfo();
14            return this;
15        },
16        fetchUserInfo: function () {
17            $.ajax({
18                url: '/frontuc/user/info',
19                type: 'POST',
20                dataType: 'json',
21                success: function (data) {
22                    if (data.errcode === 401) {
23                        module.fetchRedirectUrl();
24                    } else {
25                        module.isLogin = true;
26                        module.fetchIsFav(function (data) {
27                            module.handleFavEvent(data);
28                            window._CONFIG.isFav && !data.isfav && module.$dom.trigger('click');
29                        });
30                    }
31                },
32                error: function (err) {
33                }
34            });
35        },
36        fetchIsFav: function (cb) {
37            $.ajax({
38                url: '/frontuc/page/isfav',
39                type: 'POST',
40                data: {
41                    page_key: page_key
42                },
43                dataType: 'json',
44                success: function (data) {
45                    cb && (module.favData = data.data);
46                },
47                complete: function () {
48                    module.favData = module.favData || {fav: false};
49                    cb && cb(module.favData);
50                }
51            });
52        },
53        setFav: function (data) {
54            var $dom = $('.add-fav');
55            $dom[data.isfav ? 'addClass' : 'removeClass']('with-fav').html(data.isfav ? '已收藏' : '收藏');
56            var $myFav = $('.my-fav');
57            $myFav.prop('href', window.location.href.indexOf('.southcn.') > -1 ? '//cloudtest-znzl.southcn.com/collection' : '//service.gd.gov.cn/collection');
58            $myFav.prop("target","_blank");
59            data.isfav && $myFav.show();
60            !data.isfav && $myFav.hide();
61            return $dom;
62        },
63        handleFavEvent: function () {
64            module.$dom = module.setFav(module.favData);
65            module.$dom.on('click', function () {
66                var data = module.favData;
67                $.ajax({
68                    url: data.isfav ? '/frontuc/page/unfav' : '/frontuc/page/fav',
69                    type: 'POST',
70                    data: {
71                        page_key: page_key,
72                        page_title: document.title,
73                        page_url: window.location.href
74                    },
75                    dataType: 'json',
76                    success: function (result) {
77                        data.isfav = !data.isfav;
78                        module.setFav(data);
79                    },
80                    error: function (err) {
81                    }
82                });
83            });
84        },
85        fetchRedirectUrl: function () {
86            var url = window.location.href;
87            $.ajax({
88                url: '/frontuc/gen-redirect-uri',
89                type: 'POST',
90                data: {
91                    redirect_uri: url
92                },
93                dataType: 'json',
94                success: function (data) {
95                    $('.add-fav').prop('href', data.data.url);
96                },
97                error: function (err) {
98                }
99            });
100        },
101    };
102    module.init();
103});

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.