PageSourceSearch

https://www.shannan.gov.cn/images/tool.js

js shannan.gov.cn collected 2026-10-02 16:50:46 UTC 17,904 bytes, 590 lines download raw bytes

1/*
2 * @Author: ln 
3 * @Date: 2018-07-18 13:32:46 
4 * @Last Modified by: ln
5 * @Last Modified time: 2018-09-20 09:40:48
6 */
7"use strict";
8
9// 政府公报手动单张轮播 
10function singleLb($list, $lf, $rt, $tab, $tabItem, left, minCount) {
11    var count = 0;
12    $tab.eq(count).children().addClass('cur');
13    $tab.eq(count).find('.arrow').show();
14    $tabItem.eq(0).show();
15    if ($list.children().length > minCount) {
16
17        $rt.show();
18        $lf.hide();
19        $rt.click(function (e) {
20            
21            if($list.is(":animated")) return;
22            if (count < ($list.children().length - minCount)) {
23                count++;
24                $list.animate({ left: -left * count + 'px' }, 500);
25                $lf.show();
26            } else {
27                $rt.hide();
28            }
29            
30        });
31
32        $lf.click(function (e) {
33            if($list.is(":animated")) return;
34            if (count > 0) {
35                count--;
36                $list.stop(true,false).animate({ left: -left * count + 'px' }, 500);
37                $rt.show();
38            } else {
39                $lf.hide();
40            }
41        });
42
43    } else {
44
45        $lf.hide();
46        $rt.hide();
47
48    }
49}
50
51// 政府公报hover
52function repHover($item, $bar) {
53
54    $item.mouseenter(function () {
55        
56        $(this).addClass('cur');
57        $(this).siblings().removeClass('cur');
58
59        $bar.eq($item.index(this)).show();
60        $bar.eq($item.index(this)).siblings().hide();
61
62    });
63
64}
65
66// 元素向右缓慢移动
67function moveBar() {
68
69    var eventIn = 'mouseenter';
70    var eventOut = 'mouseleave';
71    var $item = $('.roll-item');
72    var $bar = $('.roll-item-bg');
73    var $span = $('.roll-link span');
74    $item.on(eventIn, function () {
75        if ($bar.eq($item.index(this)).is(":animated")) {
76            $bar.eq($item.index(this)).stop(true, true);
77        }
78        $bar.eq($item.index(this)).animate({ 'width': '100%' }, 400);
79        $span.eq($item.index(this)).addClass('cur');
80    });
81
82    $item.on(eventOut, function () {
83        $bar.eq($item.index(this)).animate({ 'width': '3' }, 400);
84        $span.eq($item.index(this)).removeClass('cur');
85    });
86
87    $('.roll-link').on('click', function () {
88        $(this).addClass('roll-link');
89    });
90}
91
92// 下拉列表
93function dropDown($item) {
94
95    itemEach($item, addPlus);
96
97    function itemEach($item, handler) {
98        for (var i = 0; i < $item.length; i++) {
99            handler($item.eq(i));
100        }
101    }
102
103    function recy($item) {
104
105        if ($item.hasClass('plus')) {
106
107            $item.siblings('ul').show();
108
109            $item.removeClass('plus');
110            $item.addClass('cut');
111
112            return false;
113        } else {
114
115            $item.siblings('ul').hide();
116
117            $item.removeClass('cut');
118            $item.addClass('plus');
119
120            return false;
121        }
122    }
123
124    function addPlus($item) {
125        if ($item.siblings('ul').size()) {
126            $item.addClass('plus');
127            $item.on('click', function () {
128                recy($(this));
129                itemEach($(this).siblings('ul').find('.gkml-link'), pack);
130            })
131        }
132    }
133
134    function pack($item) {
135        if ($item.hasClass('cut')) {
136            $item.siblings('ul').hide();
137
138            $item.removeClass('cut');
139            $item.addClass('plus');
140        }
141    }
142
143    tabItem3($('.gkml-titles .gkml-title'), $('.gkml-items .gkml-item'), 'click');
144    function tabItem3($item, $box, event) {
145        $box.eq(0).show();
146        var index = 0;
147        $item.on(event, function () {
148            for (var i = 0; i < $item.length; i++) {
149                if ($item[i] === $(this)[0]) {
150                    index = i;
151                }
152            }
153            $(this).addClass("cur").siblings().removeClass("cur");
154            $box.eq(index).show().siblings().hide();
155            itemEach($box.eq(index).siblings().find('.gkml-link'), pack);
156        });
157    }
158}
159
160// 日期
161function setDate(option) {
162    var calendarDate = new Date();
163    // 公历
164    var year = calendarDate.getFullYear();
165    var month = calendarDate.getMonth() + 1;
166    var date = calendarDate.getDate();
167    var day = calendarDate.getDay();
168    var dayStr = '';
169    switch (day) {
170        case 0: dayStr = '星期天'; break;
171        case 1: dayStr = '星期一'; break;
172        case 2: dayStr = '星期二'; break;
173        case 3: dayStr = '星期三'; break;
174        case 4: dayStr = '星期四'; break;
175        case 5: dayStr = '周五'; break;
176        case 6: dayStr = '星期六'; break;
177        default: dayStr = ''; break;
178    }
179    var calendarDateObj = {'year':year, 'month':month, 'date':date, 'dayStr':dayStr };
180    $(option).text(calendarDateObj.year + '-' + calendarDateObj.month + '-' + calendarDateObj.date + ' ' + calendarDateObj.dayStr);
181}
182
183// 多行文字超出用省略号显示
184function overEllipsis($list, maxCount) {
185    $list.each(function (index, item) {
186        var itemString = $(item).text();
187        if (itemString.length > maxCount) {
188            $(item).html(itemString.substring(0, maxCount) + '...');
189        }
190    });
191}
192
193// tab切换省政府文件
194function tabSwitch(option) {
195    var items = $(option.tab),
196        event = option.event||'mouseover',
197        cur = option.cur||'cur',
198        tabHead = option.tabHead,
199        tabCont = option.tabCont;
200    items.each(function (index, item) {
201        var btns = $(item).find(tabHead);
202        var cons = $(item).find(tabCont);
203        $(btns).eq(0).addClass(cur);
204        $(cons).hide();
205        $(cons).eq(0).show();
206        $(btns).on(event, function () {
207            $(this).addClass(cur).siblings().removeClass(cur);
208            $(cons).eq($(btns).index(this)).show().siblings().hide();
209        });
210        
211    });
212}
213
214// tab切换
215function tabItem(option) {
216    var items = $(option.tab),
217        event = option.event||'mouseover',
218        cur = option.cur||'cur',
219        tabHead = option.tabHead,
220        tabCont = option.tabCont;
221    items.each(function (index, item) {
222        var btns = $(item).children()[0];
223        var cons = $(item).children()[1];
224        btns = $(btns).children(tabHead);
225        cons = $(cons).children(tabCont);
226        $(btns).eq(0).addClass(cur);
227        $(cons).hide();
228        $(cons).eq(0).show();
229        $(btns).on(event, function () {
230            $(this).addClass(cur).siblings().removeClass(cur);
231            $(cons).eq($(btns).index(this)).show().siblings().hide();
232        });
233        
234    });
235}
236
237/*
238*点击展示更多
239*param参数详解如下:
240*btn:点击的元素
241*cont:显示内容的元素
242*text:提示点击文字
243*arrow:提示箭头
244*/
245function switchShow(option) {
246    var btn = option.btn||'',
247        cont = option.cont||'',
248        height = $(cont).height() + 'px',
249        text = option.text?$(option.text).text():'',
250        arrow = option.arrow||'',
251
252        textUp = '点击收起',
253        flag = false;
254    $(btn).on('click', function () {
255        flag = !flag;
256        $(arrow).css({ 'transform': 'rotate(' + -flag * 180 + 'deg)' });
257        if(flag) {
258            $(cont).css({height:'auto'});
259            $(option.text).text(textUp);
260        } else {
261            $(cont).css({height:height});
262            $(option.text).text(text);
263        }
264    });
265}
266
267// 点击改变输入框内容
268function changeInp(option) {
269    var inp = option;
270    var prompt = $(inp).val();
271    $(inp).on('click', function (e) {
272        var e = event || e;
273        $(this).val('');
274        $(this).css({color: '#333'});
275        $(document).on("click", function () {
276            if($(inp).val() =='') {
277                $(inp).css({color: '#fff'});
278                $(inp).val(prompt);
279            }
280        });
281        if(e.stopPropagation) {
282            e.stopPropagation();
283        }
284    });
285}
286
287/*
288*联动图片播放
289*大图图片数量和图片列表的图片数量要一致
290*option参数说明:没有特殊说明类型则为string
291*prev: 大图的向前播放按钮,
292*next: 大图的向后播放按钮,
293*ptNext: 图片列表向后播放按钮,
294*ptPrev: 图片列表向前播放按钮,
295*banner: 大图播放项,
296*text: 大图文字项,
297*link: 小图列表项,
298*linkSpace: 类型 number 小图之间的间距, 默认0
299*linkType: 小图移动的方向,默认: top
300*type: 大图切换方向top或left,默认:left
301*autoPlay 类型 boolean 是否轮播,默认:true;
302*playTime 类型 number 自动播放时间,默认:4000;
303*direction 大图自动播放的顺序  默认:next;
304*time  类型 number  切换过渡时间,默认:300;
305*cur 小图的效果类名, 默认: 'cur'
306*/
307function linkSwitch(option) {
308
309    var $banner = option.banner?$(option.banner):null,
310        $link = option.link?$(option.link):null,
311        $text = option.text?$(option.text):null;
312
313    var playTime = option.playTime||4000,
314        linkSpace = option.linkSpace||0,
315        direction = option.direction||'next',
316        linkType = option.linkType||'top',
317        type = option.type?option.type:'left',
318        autoPlay=option.autoPlay?option.autoPlay:true,
319        time=option.time||300,
320        cur=option.cur||'cur';
321
322    var unit = type=='top'? $banner.parent().height():$banner.parent().width(),
323        match = linkType=='top'? $link.height()+linkSpace:$link.width()+linkSpace,
324        len = $banner? $banner.length:0,
325        index = 0,
326        css={},
327        cssLink={};
328
329    init();
330
331    if(autoPlay){
332        var play=setInterval(bannerPlay,playTime);
333        $banner.hover(function(){
334            clearInterval(play);
335            play=null;
336        },function(){
337            play= setInterval(bannerPlay,playTime);
338        })
339    }
340
341    if($link) {
342        $link.click(function () {
343            if($banner.is(":animated")) return;
344            if($link.is(":animated")) return;
345            index = $(this).index();
346            configShow();
347            index=index<0?len-1:index;
348            $(this).addClass(cur).siblings().removeClass(cur);
349            move();
350        });
351    }
352
353    function init(){
354        $banner.eq(index).show().siblings().hide();
355        $link.each(function(){
356            var _i=$(this).index();
357            $(this).show();
358            cssLink[linkType]=(_i-index)*match;
359            $(this).css(cssLink);
360        });
361        configShow();
362    }
363
364    function bannerPlay(){
365        if($banner.is(":animated")) return;
366        index++;
367        index=index>=len?0:index;
368        move();
369        configShow();
370        linkPlay();
371    }
372
373    function move(){
374        $banner.eq(index).fadeIn(time).siblings().fadeOut(time);
375    }
376
377    function linkPlay() {
378        for(var i=0;i<len;i++){
379          var $item=$link.eq(i);
380          var type = linkType;
381          if($item.position()[type]<=-match){
382            var perLeft=0;
383            if(i==0){
384              perLeft=$link.eq(len-1).position()[type];
385            }else{
386              perLeft=$link.eq(i-1).position()[type];
387            }
388            cssLink[type]=perLeft+match;
389            $item.css(cssLink);
390          }
391          var nowLeft=$item.position()[type];
392          cssLink[type]=nowLeft-match;
393          $item.animate(cssLink,time);
394        } 
395    }
396 
397    function configShow() {
398        if($text) {
399            $text.eq(index).show().siblings().hide();
400        }
401        $link.eq(index).addClass(cur).siblings().removeClass(cur);
402    }
403    
404}
405
406// 点击下拉
407function navSwitch(option) {
408    var flag = false;
409    var $item = $(option.item)||null,
410        cont = option.cont||'',
411        event = option.event||'click',
412        cur = option.cur||'cur'
413    $item.on(event, function () {
414        flag = !flag;
415        $(this).parent().siblings().children(cont).hide();
416        $(this).parent().siblings().children().removeClass(cur);
417        if(flag) {
418            $(this).parent().children(cont).show();
419            $(this).addClass(cur);
420        } else {
421            $(this).parent().children(cont).hide(); 
422            $(this).removeClass(cur);
423        }
424    });
425}
426
427// 多个点击展开/收起
428function tabSwitches(option) {
429    var items = option.items,
430        btn = option.btn,
431        cont = option.cont,
432        flag = false,
433        height = $(cont).height() + 'px',
434        text = option.text?option.text:'',
435        textUp = '点击收起',
436        event = option.event||'click';
437    $(items).children(btn).on(event, function() {
438        flag = !flag;
439        if(flag) {
440            $(items).eq($(items).children(btn).index(this)).children(cont).css({height:'auto'});
441            $(this).text(textUp);
442        } else {
443            $(items).eq($(items).children(btn).index(this)).children(cont).css({height:height});
444            $(this).text(text);
445        }
446    })
447}
448
449// 点击切换
450function showTaggle(option) {
451    var items = option.items,
452        btn = option.btn,
453        cont = option.cont,
454        event = option.event||'click';
455    $(items).children().children(btn).on(event, function() {
456        if($(this).hasClass('plus')) {
457            $(items).eq($(items).children().children(btn).index(this)).children(cont).show();
458            $(this).removeClass('plus');
459            $(this).addClass('cut');
460        } else {
461            $(items).eq($(items).children().children(btn).index(this)).children(cont).hide();
462            $(this).addClass('plus');
463            $(this).removeClass('cut');
464        }
465    })
466}
467
468// 开关弹窗
469function switchPop(option) {
470    var btns = option.btns,
471        items = option.items || [],
472        flag = option.flag == undefined || option.flag == true ? true : false
473        event = option.event ? option.event : "click";
474    btns.forEach(function(item, index) {
475        $(item).on(event, function() {
476            items.forEach(function(item, index ) {
477                if(flag) {
478                    $(item).show();
479                } else {
480                    $(item).hide();
481                }
482            })
483        });
484    })
485}
486
487// 类切换
488function curTaggle(option) {
489    var btns = option.btns,
490        cur = option.cur ? option.cur : 'cur'
491        event = option.event ? option.event : "click";
492    $(btns).on(event, function () {
493        $(this).addClass(cur).siblings().removeClass(cur);
494    })
495}
496
497//背景切换
498function bgSwitch(items){
499    var curIndex=0;
500    // 大于1张图片轮播
501    if(items.length>1){
502        $(items[curIndex]).fadeIn();
503        setInterval(function () {
504            if(curIndex<items.length-1){
505                curIndex++;
506            }else {
507                curIndex=0;
508            }
509            $(items[curIndex]).fadeIn();
510            $(items[curIndex]).siblings().fadeOut();
511        },2000);
512    }
513}
514
515// 模拟单选框
516function radioSwitch(option) {
517    var items = $(option.items),
518        event = option.event||'click',
519        cur = option.cur||'cur',
520        box = option.box,
521        inp = option.inp,
522        label = option.label;
523    items.each(function (index, item) {
524        var labels = $(item).children(label);
525        $(labels).children(box).removeClass(cur);
526        $(labels).eq(0).children(box).addClass(cur);
527        $(labels).children(box).children(inp).attr('checked', false);
528        $(labels).eq(0).children(box).children(inp).attr('checked', true);
529        $(labels).on(event, function(e) {
530            if (!$(this).children(box).hasClass(cur)) {
531
532                $(this).children(box).addClass(cur);
533                $(this).children(box).children(inp).attr('checked', true);
534                $(this).siblings().children(box).removeClass("cur");
535                $(this).siblings().children(box).children(inp).attr('checked', false);
536
537                return false;
538            } else {
539               
540                return false;
541            }
542    
543            e.stopPropagation();
544        });
545    });
546}
547
548// 模拟单选项
549function radioSwitch2(option) {
550    var items = $(option.items),
551        event = option.event||'click',
552        cur = option.cur||'cur',
553        box = option.box,
554        inp = option.inp,
555        label = option.label;
556    items.each(function (index, item) {
557        var labels = $(item).children(label);
558        $(labels).children(box).removeClass(cur);
559        $(labels).eq(0).children(box).addClass(cur);
560        $(labels).children(box).children(inp).attr('checked', false);
561        $(labels).eq(0).children(box).children(inp).attr('checked', true);
562        $(labels).on(event, function(e) {
563            if (!$(this).children(box).hasClass(cur)) {
564
565                $(this).children(box).addClass(cur);
566                $(this).children(box).children(inp).attr('checked', true);
567                // $(this).siblings().children(box).removeClass("cur");
568                // $(this).siblings().children(box).children(inp).attr('checked', false);
569
570                return false;
571            } else {
572                $(this).children(box).removeClass("cur");
573                $(this).children(box).children(inp).attr('checked', false);
574                return false;
575            }
576    
577            e.stopPropagation();
578        });
579    });
580}
581
582// 模拟点击下拉
583function playSelect(option) {
584	$(option).each(function (index, item) {
585		$(item).children().children().on('click', function () {
586			$(this).parent().parent().next().children().attr('selected', false);
587			$(this).parent().parent().next().children().eq($(item).children().children().index(this)).attr('selected', true);
588		});
589	});
590}

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.