ansel0926
2022-05-16 cee67c9f4623f287ce96901763963d50cdc24736
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
var GlobalConfig={
    msg_type:"toastr",//消息提示样式,可选的有toastr和layer
    msg_type_toastr:"toastr",
    msg_type_layer:"layer",
}
/**
 * 判断非空
 * @param val
 * @returns {Boolean}
 */
function isEmpty(val) {
    val = $.trim(val);
    if (val == null)
        return true;
    if (val == undefined || val == 'undefined')
        return true;
    if (val == "")
        return true;
    if (val.length == 0)
        return true;
    if (!/[^(^\s*)|(\s*$)]/.test(val))
        return true;
    return false;
}
function isNotEmpty(val) {
    return !isEmpty(val);
}
function isEmail(v) {
    var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
    if (!myreg.test(v))//对输入的值进行判断
    {
        return false;
    }
    return true;
}
function isQQ(v){
    if(/^[0-9]{5,10}$/.test(v)){
        return true;
    }else{
        return false;
    }
}
function  addFav(title,url) {//  加入收藏夹
    if(document.all)
    {
        window.external.addFavorite(url,title);
    }
    else if(window.sidebar)
    {
        window.sidebar.addPanel(title,url,  "" );
    }
}
 
String.prototype.endsWith = function (str){
    return this.slice(-str.length) == str;
};
 
$(function(){
    baseMotheds.init();
});
var baseMotheds = function(){
    // lazyLoad
    var lazyLoad = function(){
        try{
            $("img.lazy").lazyload({threshold: 100,effect: "fadeIn"});
        }catch (ex){}
    };
    var imgError = function(){
        document.addEventListener("error", function (e) {
            var elem = e.target;
            if (elem.tagName.toLowerCase() == "img") {
                elem.src = "/resources/myblog/assets/i/f10.jpg";
            }
        }, true);
    };
    var imgNull = function(){
        $('img.lazy').each(function(){
            var _newImg = '/resources/myblog/assets/i/f10.jpg';
            var _thisSrc = $(this).attr('src');
            if(_thisSrc == '' || _thisSrc == undefined){
                $(this).attr('src',_newImg);
            }
        });
        document.addEventListener("error", function (e) {
            var elem = e.target;
            if (elem.tagName.toLowerCase() == "img") {
                elem.src = "/resources/myblog/assets/i/f10.jpg";
            }
        }, true);
    };
    var goTop=function(){// 返回顶部
        $('.to-top').toTop({
            autohide: true,//返回顶部按钮是否自动隐藏。可以设置true或false。默认为true
            offset: 100,//页面滚动到距离顶部多少距离时隐藏返回顶部按钮。默认值为420
            speed: 500,//滚动和渐隐的持续时间,默认值为500
            right: 25,//返回顶部按钮距离屏幕右边的距离,默认值为15
            bottom: 50//返回顶部按钮距离屏幕顶部的距离,默认值为30
        });
    }
    var bubble=function () {
        if ($.bubble) {
            $.bubble.init();
        }
    }
    var websocket=function(){
        if ($.websocket) {
            var host=window.location.host;
            host="ws://" + host + "/websocket";
            $.websocket.open({
                host: host,
                reconnect: true,
                callback: function (result) {
                    var resultJson = JSON.parse(result);
                    wesocketMsgResolver[resultJson["fun"]](resultJson["msg"]);
                }
            });
        }
    }
    return{
        init: function(){
 
            lazyLoad();
            //imgError();
            //imgNull();
            goTop();
            bubble();
            //websocket();
        }
    }
}();
/**
 * websocket消息解析器
 *
 * @type {{online: wesocketMsgResolver.online}}
 */
var wesocketMsgResolver = {
    online: function (value) {
        value && $(".onlineNum").html(value);
    },
    notification: function (value) {
        value && Fast.msg_info(decodeURIComponent(value));
    }
};
 
 
//  格式化文件大小
function renderFileSize(value){
    if(null==value||value==''){
        return "0 Bytes";
    }
    var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
    var index=0,
        srcsize = parseFloat(value);
    index=Math.floor(Math.log(srcsize)/Math.log(1024));
    var size =srcsize/Math.pow(1024,index);
    //  保留的小数位数
    size=size.toFixed(2);
    return size+unitArr[index];
}
function getCookie(name){
    //获取cookie字符串
    var strCookie=document.cookie;
    //将多cookie切割为多个名/值对
    var arrCookie=strCookie.split("; ");
    var value="";
    //遍历cookie数组,处理每个cookie对
    for(var i=0;i<arrCookie.length;i++){
        var arr=arrCookie[i].split("=");
        if(name==arr[0]){
            value=arr[1];
            break;
        }
    }
    return value;
}
function randomInt(min, max){
    return Math.floor((Math.random() * max) + min);
}
 
(function ($) {
    $.extend({
        layer:{
            msg: function(content, type,options) {
                if(isNotEmpty(options)&&isNotEmpty(options.oparent)){
                    var opts={ icon: type, time: 2000, shift: randomInt(1, 5) };
                    if(isNotEmpty(options)){
                        opts= $.extend(opts,options);
                    }
                    if (isNotEmpty(type)) {
                        opts.icon=type;
                    }
                    options.oparent.layer.msg(content,opts);
                }else{
                    var opts={ icon: type, time: 2000, shift: randomInt(1, 5) };
                    if(isNotEmpty(options)){
                        opts= $.extend(opts,options);
                    }
                    if (isNotEmpty(type)) {
                        opts.icon=type;
                    }
                    layer.msg(content,opts);
                }
 
            },
            msg_top:function(content, type,options){
                options=$.extend({offset:1},options);
                $.layer.msg(content, type,options);
            },
            msg_right:function(content,oparent){
                $.layer.msg(content, 1,{oparent:oparent});
            },
            msg_wrong:function(content,oparent){
                $.layer.msg(content, 2,{oparent:oparent});
            },
            msg_ask:function(content,oparent){
                $.layer.msg(content, 3,{oparent:oparent});
            },
            msg_locked:function(content,oparent){
                $.layer.msg(content, 4,{oparent:oparent});
            },
            msg_cry:function(content,oparent){
                $.layer.msg(content, 5,{oparent:oparent});
            },
            msg_smile:function(content,oparent){
                $.layer.msg(content, 6,{oparent:oparent});
            },
            msg_warning:function(content,oparent){
                $.layer.msg(content, 7,{oparent:oparent});
            },
            alert:function(content,options){
                var callback;
                if(isNotEmpty(options)&&typeof (options.callback)=='function'){
                    callback=options.callback;
                }
                if(typeof options=='function'){
                    callback=options;
                }
                var opts = $.extend({
                    skin:layer_skin,
                    shade: [0.1,'#000'],
                    shadeClose: true
                    // shift:2/*动画类型2为从下向上出现*/
                },options);
 
                layer.alert(content, opts,callback );
            },
            alert_right:function(content,options){
                options=$.extend({icon:1},options);
                $.layer.alert(content,options);
            },
            alert_wrong:function(content,options){
                options=$.extend({icon:2},options);
                $.layer.alert(content,options);
            },
            alert_ask:function(content,options){
                options=$.extend({icon:3},options);
                $.layer.alert(content,options);
            },
            alert_locked:function(content,options){
                options=$.extend({icon:4},options);
                $.layer.alert(content,options);
            },
            alert_cry:function(content,options){
                options=$.extend({icon:5},options);
                $.layer.alert(content,options);
            },
            alert_smile:function(content,options){
                options=$.extend({icon:6},options);
                $.layer.alert(content,options);
            },
            alert_warning:function(content,options){
                options=$.extend({icon:7},options);
                $.layer.alert(content,options);
            },
            //询问框
            confirm:function(content,callbackOK,callbackCancel){
                var options={
                    btn: ['确定','取消'],
                    icon: 3,
                    title:'询问',
                    shade: [0.3,'#000']
                };
                layer.confirm(content,options , function (index) {
                        layer.close(index);
                        if(typeof(callbackOK)=='function' ){
                            callbackOK();
                        }
                    }, callbackCancel
                );
            },
            //打开一个Iframe页面
            open_page: function (title, url,options) {
                var w,h;
                if(isEmpty(options)||isEmpty(options.w)){
                    w="70%";
                }else{
                    w=options.w;
                }
                if(isEmpty(options)||isEmpty(options.h)){
                    h="70%";
                }else{
                    h=options.h;
                };
                if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {
                    w = 'auto';
                    h = 'auto';
                }
                var  opts={
                    type: 2,
                    area: [w, h],
                    fix: false, //不固定
                    maxmin: true,
                    shadeClose:true,
                    shade:0.4,
                    btn: ['确定', '关闭'],
                    title: title,
                    yes: function(index,layero){
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = window[layero.find('iframe')[0]['name']];
                        iframeWin.save();
                    },
                    content: url
                };
                if(isNotEmpty(options)&&isNotEmpty(options.endCallBack)&& typeof (options.endCallBack)=='function'){
                    $.extend(opts,{end:endCallBack});
                }
                opts= $.extend(opts,options);
                if (isEmpty(title)) {
                    opts.title=false;
                };
                if(isNotEmpty(options)&&isNotEmpty(options.oparent)){
                    options.oparent.layer.open(opts);
                }else{
                    layer.open(opts);
                }
            },
            //打开即全屏
            open_page_full: function (title, url,options) {
                var w,h;
                if(isEmpty(options)||isEmpty(options.w)){
                    w="70%";
                };
                if(isEmpty(options)||isEmpty(options.h)){
                    h="70%";
                };
                if (navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) {
                    w = 'auto';
                    h = 'auto';
                }
                var  opts={
                    type: 2,
                    area: [w, h],
                    fix: false, //不固定
                    maxmin: true,
                    shadeClose:true,
                    shade:0.4,
                    btn: ['确定', '关闭'],
                    title: title,
                    yes: function(index,layero){
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = window[layero.find('iframe')[0]['name']];
                        iframeWin.save();
                    },
                    content: url
                };
                if(isNotEmpty(options)&&isNotEmpty(options.endCallBack)&& typeof (options.endCallBack)=='function'){
                    $.extend(opts,{end:endCallBack});
                }
                opts= $.extend(opts,options);
                if (isEmpty(title)) {
                    opts.title=false;
                };
                var index;
                if(isNotEmpty(options)&&isNotEmpty(options.oparent)){
                    index=options.oparent.layer.open(opts);
                }else{
                    index=layer.open(opts);
                }
                layer.full(index);
            },
            // 打开遮罩层
            loading: function () {
                var loadType=1;
                var opts= {
                    area:['37px','37px'],
                    shade: [0.1,'#000']
                };
                layer.load(loadType,opts);
            },
            // 关闭遮罩层
            closeLoading: function () {
                setTimeout(function(){
                    //layer.closeAll(); //疯狂模式,关闭所有层
                    //layer.closeAll('dialog'); //关闭信息框
                    //layer.closeAll('page'); //关闭所有页面层
                    //layer.closeAll('iframe'); //关闭所有的iframe层
                    layer.closeAll('loading'); //关闭加载层
                    //layer.closeAll('tips'); //关闭所有的tips层
                }, 50);
            },
            tips:function(msg,attachment,position){
                layer.tips(msg, attachment, {
                    tips: [position, '#3595CC'],
                    time:5000
                });
            }
 
        }
        ,
        toastr:{
            config:{
                "closeButton": true,
                "debug": false,
                "newestOnTop": false,
                "progressBar": false,
                "positionClass": "toast-top-right",
                "preventDuplicates": false,
                "onclick": null,
                "showDuration": "300",
                "hideDuration": "1000",
                "timeOut": "5000",
                "extendedTimeOut": "1000",
                "showEasing": "swing",
                "hideEasing": "linear",
                "showMethod": "fadeIn",
                "hideMethod": "fadeOut"
            },
            info:function(msg,title){
                toastr.options=$.toastr.config;
                toastr.info(msg,title);
            },
            success:function(msg,title){
                toastr.options=$.toastr.config;
                toastr.success(msg,title);
            },
            warning:function(msg,title){
                toastr.options=$.toastr.config;
                toastr.warning(msg,title);
            },
            error:function(msg,title){
                toastr.options=$.toastr.config;
                toastr.error(msg,title);
            }
        }
    });
 
    var Fast={
        confirm:function(title,okFunction,cancelFunction){
            var index = layer.confirm(
                title,
                {icon: 3, title:"询问", shadeClose: false, btn: ["确定","取消"]},
                function () {
                    if(typeof okFunction=='function'){
                        okFunction();
                    }
                    layer.close(index);
                },function(){
                    if(typeof cancelFunction=='function'){
                        cancelFunction();
                    }
                    layer.close(index);
                }
            );
            return index;
        },
        msg:function(msg){
            if(GlobalConfig.msg_type==GlobalConfig.msg_type_toastr){
                $.toastr.info(msg);
            }else{
                layer.msg(msg);
            }
        },
        msg_success:function(msg){
            if(GlobalConfig.msg_type==GlobalConfig.msg_type_toastr){
                $.toastr.success(msg);
            }else{
                $.layer.msg_right(msg);
            }
        },
        msg_error:function(msg){
            if(GlobalConfig.msg_type==GlobalConfig.msg_type_toastr){
                $.toastr.error(msg);
            }else{
                $.layer.msg_wrong(msg);
            }
        },
        msg_warning:function(msg){
            if(GlobalConfig.msg_type==GlobalConfig.msg_type_toastr){
                $.toastr.warning(msg);
            }else{
                $.layer.msg_warning(msg);
            }
        },
        msg_info:function(msg){
            if(GlobalConfig.msg_type==GlobalConfig.msg_type_toastr){
                $.toastr.info(msg);
            }else{
                $.layer.msg_warning(msg);
            }
        },
        isExist:function (url){
            var flag=false;
            if(url.indexOf("http")==-1){
                var host=window.location.host;
                var protocol=window.location.protocol;
                url=protocol+"//"+host+url;
            }
            $.ajax({async:false,type:"GET",url:url,error:function(data,status){
                    //这里需要覆盖ajaxSetup中的方法
                },complete:function(XMLHttpRequest, textStatus) {
                    if(textStatus=="success"){
                        flag= true;
                    }
                }
            });
            return flag;
        },
        /*changeUrlArg:function(url, arg, val){//有bug,不用了
            var pattern = arg+'=([^&]*)';
            var replaceText = arg+'='+val;
            return url.match(pattern) ? url.replace(eval('/('+ arg+'=)([^&]*)/gi'), replaceText) : (url.match('[\?]') ? url+'&'+replaceText : url+'?'+replaceText);
        },*/
        getUri:function(){
            var url=  window.location.href;
            var host=window.location.host;
            var protocol=window.location.protocol;
            var uri=url.replace(protocol+"//"+host,"");
            if(uri.indexOf("?")>0){
                uri=uri.substring(0,uri.indexOf("?"));
            }
            return uri;
        }
    };
    window.Fast=Fast;
})(jQuery);
 
(function ($) {
    $.extend({
        websocket: {
            _this: null,
            _initialized: false,
            init: function (options) {
                if (!this.isSupported()) {
                    // console.error('Not support websocket');
                    return;
                }
                var op = $.extend({
                    callback: function () {
                    },
                    host: null,
                    reconnect: false
                }, options);
                if (!op.host) {
                    // console.error("初始化WebSocket失败,无效的请求地址");
                    return;
                }
                try {
                    this._this = new WebSocket(op.host);
                } catch (error) {
                    return;
                }
                this._initialized = true;
                //连接发生错误的回调方法
                this._this.onerror = function () {
                    // console.log("与服务器连接失败...");
                };
 
                //连接成功建立的回调方法
                this._this.onopen = function (event) {
                    // console.log("与服务器连接成功...");
                };
 
                //接收到消息的回调方法
                this._this.onmessage = function (event) {
                    // dwz.notification.show({notification: event.data});
                    op.callback(event.data);
                    // console.log("接收到服务器端推送的消息:" + event.data);
                };
 
                //连接关闭的回调方法
                this._this.onclose = function () {
                    $.websocket._initialized = false;
                    // console.log("已关闭当前链接");
                    if (op.reconnect) {
                        // 自动重连
                        setTimeout(function () {
                            $.websocket.open(op);
                        }, 5000);
                    }
                }
            },
            open: function (options) {
                var op = $.extend({
                    callback: function () {
                    },
                    host: null,
                    reconnect: false
                }, options);
 
                if (this._initialized) {
                    this.close();
                }
                this.init(options);
                //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
                window.onbeforeunload = function () {
                    // console.log("窗口关闭了");
                    $.websocket.close();
                }
            },
            isSupported: function () {
                return 'WebSocket' in window;
            },
            send: function (message) {
                if (!this._this) {
                    return;
                }
                this._this.send(message);
            },
            close: function () {
                if (!this._this) {
                    return;
                }
                this._this.close();
            }
        }
    });
})(jQuery);
/* 鼠标点击向上冒泡弹出提示动画 */
$.extend({
    bubble: {
        _tip: ['法制', '爱国', '敬业', '诚信', '友善', '富强', '民主', '文明', '和谐', '自由', '平等', '公正'],
        init: function () {
            var bubbleIndex = 0;
            $('body').click(function (e) {
                bubbleIndex = bubbleIndex >= $.bubble._tip.length ? 0 : bubbleIndex;
                if (!e.originalEvent) {
                    return;
                }
                var x = e.originalEvent.x || e.originalEvent.layerX || 0;
                var y = e.originalEvent.y || e.originalEvent.layerY || 0;
                var html = '<span style="position: fixed;z-index:9999;left: ' + x + 'px;top: ' + y + 'px;"></span>';
                var $box = $(html).appendTo($(this));
                $box.effectBubble({
                    y: -100,
                    className: 'thumb-bubble',
                    fontSize: 0.5,
                    content: '<i class="fa fa-smile-o"></i>' + $.bubble._tip[bubbleIndex]
                });
                setTimeout(function () {
                    $box.remove();
                }, 1002);
                bubbleIndex++;
            });
        },
        unbind: function (duration) {
            $("body").unbind('click');
            if (duration && !isNaN(duration = parseInt(duration))) {
                setTimeout(function () {
                    $.bubble.init();
                }, duration);
            }
        }
    }
});
 
/* 鼠标点击弹出提示动画 */
 
$.fn.extend({
    // 文字向上冒泡
    effectBubble: function (options) {
        var op = $.extend({
            content: '+1',
            y: -100,
            duration: 1000,
            effectType: 'ease',
            className: '',
            fontSize: 2
        }, options);
 
        return this.each(function () {
            var $box = $(this), flyId = 'effect-fly-' + (new Date().getTime());
 
            var tpl = '<span id="#flyId#" class="effect-bubble-fly #class#" style="opacity: 1;top:#top#px;left:#left#px;font-size: #fontSize#rem;">#content#</span>';
            var html = tpl.replaceAll('#left#', 12).replaceAll('#top#', -8)
                .replaceAll('#flyId#', flyId).replaceAll('#content#', op.content)
                .replaceAll('#class#', op.className).replaceAll('#fontSize#', op.fontSize);
 
            var $fly = $(html).appendTo($box);
            $fly.fadeIn(100, "swing", function () {
                $fly.animate({top: op.y, opacity: 0}, 100, function () {
                    $fly.fadeOut(op.duration, function () {
                        $fly.remove();
                    });
                });
            });
        });
    }
});
/**
 * 扩展String方法
 */
$.extend(String.prototype, {
    trim: function () {
        return this.replace(/(^\s*)|(\s*$)|\r|\n/g, "");
    },
    startsWith: function (str) {
        return new RegExp("^" + str).test(this);
    },
    endsWith: function (str) {
        return new RegExp(str + "$").test(this);
    },
    replaceAll: function (os, ns) {
        return this.replace(new RegExp(os, "gm"), ns);
    }
});
 
/* 返回顶部插件 */
(function ($) {
    $.fn.toTop = function (opt) {
        //variables
        var elem = this;
        var win = $(window);
        var doc = $('html, body');
        var options = opt;
        //如果没有配置自定义的参数,则使用默认
        if (!options) {
            options = $.extend({
                autohide: true,
                offset: 100,
                speed: 500,
                right: 15,
                bottom: 50
            }, opt);
        }
        elem.css({
            'position': 'fixed',
            'right': options.right,
            'bottom': options.bottom,
            'cursor': 'pointer'
        });
        if (options.autohide) {
            elem.css('display', 'none');
        }
        elem.click(function () {
            doc.animate({scrollTop: 0}, options.speed);
        });
        win.scroll(function () {
            var scrolling = win.scrollTop();
            if (options.autohide) {
                if (scrolling > options.offset) {
                    elem.fadeIn(options.speed);
                }
                else elem.fadeOut(options.speed);
            }
        });
    };
})(jQuery);
/* 返回顶部插件 end */