PageSourceSearch

https://jsmg.cn/templates/default/static/js/main.js

js jsmg.cn collected 2026-10-02 21:19:19 UTC 4,897 bytes, 129 lines download raw bytes

1/*====================================================
2  TABLE OF CONTENT
3  1. function declearetion
4  2. Initialization
5====================================================*/
6/*===========================
7 1. function declearetion
8 ==========================*/
9var themeApp = {
10    featuredMedia: function () {
11        $(".post").each(function () {
12            var thiseliment = $(this);
13            var media_wrapper = $(this).find('featured');
14            var media_content_image = media_wrapper.find($('img'));
15            var media_content_embeded = media_wrapper.find('iframe');
16            if (media_content_image.length > 0) {
17                $(media_content_image).insertAfter(thiseliment.find('.post-head')).wrap("<div class='featured-media'></div>");
18                thiseliment.addClass('post-type-image');
19                media_wrapper.remove();
20            }
21            else if (media_content_embeded.length > 0) {
22                $(media_content_embeded).insertAfter(thiseliment.find('.post-head')).wrap("<div class='featured-media'></div>");
23                thiseliment.addClass('post-type-embeded');
24            }
25        });
26    },
27    responsiveIframe: function () {
28        //$('.post').fitVids();
29    },
30    sidebarConfig: function () {
31        if (sidebar_left == true) {
32            $('.main-content').addClass('col-md-push-4');
33            $('.sidebar').addClass('col-md-pull-8');
34        }
35    },
36    recentPost: function () {
37        var feed_url = "/rss/";
38        var code = String('');
39        $.get(feed_url, function (data) {
40            $(data).find('item').slice(0, recent_post_count).each(function () {
41                var full = $(this).find('description').text();
42                var content = $(this).contentSnippet;
43                var link = $(this).find('link').text();
44                var title = $(this).find('title').text();
45                var published_date = $(this).find('pubDate').text();
46                function format_date(dt) {
47                    var d = new Date(dt);
48                    var month_name = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
49                    var month = month_name[d.getMonth()];
50                    var date = d.getDate();
51                    var year = d.getFullYear();
52                    var formatted_dt = month + ' ' + date + ',' + ' ' + year;
53                    return formatted_dt;
54                }
55                code += '<div class="recent-single-post">';
56                code += '<a href="' + link + '" class="post-title">' + title + '</a><div class="date">' + format_date(published_date) + '</div>';
57                code += '</div>';
58            });
59            $(".recent-post").html(code);
60        });
61    },
62    highlighter: function () {
63        $('pre code').each(function (i, block) {
64            hljs.highlightBlock(block);
65        });
66    },
67    backToTop: function () {
68        $(window).scroll(function () {
69            if ($(this).scrollTop() > 100) {
70                $('#back-to-top').fadeIn();
71            }
72            else {
73                $('#back-to-top').fadeOut();
74            }
75        });
76        $('#back-to-top').on('click', function (e) {
77            e.preventDefault();
78            $('html, body').animate({ scrollTop: 0 }, 1000);
79            return false;
80        });
81    },
82    init: function () {
83        themeApp.featuredMedia();
84        themeApp.responsiveIframe();
85        // themeApp.sidebarConfig();
86        // themeApp.recentPost();
87        themeApp.highlighter();
88        themeApp.backToTop();
89    }
90};
91/*===========================
922. Initialization
93==========================*/
94$(document).ready(function () {
95    themeApp.init();
96});
97/**
98 * 动态加载CSS
99 * @param {string} url 样式地址
100 */
101function dynamicLoadCss(url) {
102    var head = document.getElementsByTagName('head')[0];
103    var link = document.createElement('link');
104    link.type = 'text/css';
105    link.rel = 'stylesheet';
106    link.href = url;
107    head.appendChild(link);
108}
109/**
110 * 动态加载JS
111 * @param {string} url 脚本地址
112 * @param {function} callback  回调函数
113 */
114function dynamicLoadJs(url, callback) {
115    var head = document.getElementsByTagName('head')[0];
116    var script = document.createElement('script');
117    script.type = 'text/javascript';
118    script.src = url;
119    if (typeof (callback) == 'function') {
120        script.onload = script.onreadystatechange = function () {
121            if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
122                callback();
123                script.onload = script.onreadystatechange = null;
124            }
125        };
126    }
127    head.appendChild(script);
128}
129//# sourceMappingURL=main.js.map

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.