PageSourceSearch

https://oss.miaoroom.com/wp-content/themes/b2/Assets/fontend/single.js?ver=5.9.41

js miaoroom.com collected 2026-09-25 13:59:09 UTC 53,438 bytes, 1,607 lines download raw bytes

1function b2prettyPrint(){
2    if(b2_global.prettify_load == '0') return
3	let classArr =  document.getElementsByTagName('pre');//替换标签class
4	if(typeof(classArr)=="object"){		
5		for(var i = 0;i < classArr.length;i++){			
6			if(classArr[i].className.indexOf('prettyprint') <= -1){
7				classArr[i].className = "prettyprint linenums";		
8			}
9		}
10	}
11	prettyPrint();
12}
13
14window.onload = b2prettyPrint()
15
16function autohclass(){
17
18    const tocbox = document.querySelector('.b2-tab-content');
19
20    if(!tocbox || B2ClientWidth < 768) return;
21
22    const dom = document.querySelectorAll('.entry-content > h1,.entry-content > h2,.entry-content > h3')
23    if(dom.length == 0){
24        document.querySelector('.b2-widget-toc').remove()
25        return
26    }
27
28    b2loadScript(b2_global.site_info.site_uri+'/Assets/fontend/library/tocbot.min.js','',()=>{
29
30        setTimeout(() => {
31            Array.from(dom).forEach((el,i) => {
32                console.log(el,i)
33                el.id = el.tagName + '-'+i
34              });
35        
36            tocbot.init({
37                // Where to render the table of contents.
38                tocSelector: '.b2-tab-content',
39                // Where to grab the headings to build the table of contents.
40                contentSelector: '.entry-content',
41                // Which headings to grab inside of the contentSelector element.
42                headingSelector: '.entry-content > h1,.entry-content > h2,.entry-content > h3',
43                collapseDepth: 3,
44                scrollSmooth: true,
45                scrollSmoothDuration: 450,
46                // scrollEndCallback: function (e) {
47                //     window.scrollTo(window.scrollX, window.scrollY + 80);
48                // },
49                orderedList: true,
50            });
51        }, 100);
52    })
53    
54}
55
56autohclass()
57
58var b2SingleMeta = new Vue({
59    el:'#post-meta',
60    data:{
61        following:false,
62        self:true,
63        showMeta:false,
64        locked:false,
65        postData:[]
66    },
67    computed:{
68        userData(){
69            return this.$store.state.userData;
70        }
71    },
72    mounted(){
73        if(!b2_global.author_id) return
74       
75        this.$http.post(b2_rest_url+'checkFollowing','user_id='+b2_global.author_id+'&post_id='+b2_global.post_id).then(res=>{
76            this.self = res.data.self
77            this.following = res.data.following
78            this.postData = res.data
79            b2DsBox.user = res.data.current_user
80            b2DsBox.author = res.data.author
81            b2Ds.data = res.data.ds_data
82
83            if(typeof postAuthor == 'object'){
84
85                postAuthor.following = res.data.following
86
87            }
88
89            if(typeof askInv == 'object'){
90                askInv.postData = res.data
91                askSingleTop.excerpt = res.data.excerpt
92                askSingleBottom.answer_count = res.data.answer_count
93                askSingleBottom.favorites = res.data.favorites
94                askSingleBottom.favorites_isset = res.data.favorites_isset
95                askSingleBottom.views = res.data.views
96                askTop.metas = res.data.metas
97                askAnswerList.best = res.data.best
98                askAnswerList.inv = res.data.inv
99                askSingleBottom.canEdit = res.data.can_edit
100                askSingleBottom.status = res.data.post_status
101                document.querySelector('.ask-single-gujia').style.display = 'none'
102                document.querySelector('.ask-single-info').style.display = 'block'
103            }
104
105            if(typeof askList == 'object'){
106                askList.inv = res.data.inv
107                askList.best = res.data.best
108            }
109
110            this.$nextTick(()=>{
111                b2tooltip('.b2tooltipbox')
112                if (typeof window.contentFooter !== 'undefined') window.contentFooter.updateSticky()
113            })
114            
115            payCredit.user = res.data.current_user
116            payCredit.author = res.data.author
117        })
118    },
119    methods:{
120        followingAc(){
121            
122            if(!b2token){
123                login.show = true
124            }else{
125                this.$http.post(b2_rest_url+'AuthorFollow','user_id='+b2_global.author_id).then(res=>{
126                    this.following = !this.following
127                }).catch(err=>{
128                    Qmsg['warning'](err.response.data.message,{html:true});
129                })
130            }
131        },
132        dmsg(){
133            
134            if(!b2token){
135                login.show = true
136            }else{
137                b2Dmsg.userid = b2_global.author_id
138                b2Dmsg.show = true
139            }
140        },
141        scroll(){
142            this.$scrollTo('#download-box', 300, {offset: -50})
143        }
144    }
145})
146
147Vue.component('post-gg', {
148    props: ['show','title','content'],
149    template: b2_global.post_gg,
150    methods:{
151        close(){
152            this.$emit('close')
153        },
154    }
155})
156
157var postGG = new Vue({
158    el:'#post-gg',
159    data:{
160        show:false,
161        title:'',
162        content:''
163    },
164    mounted(){
165        this.getGGData()
166    },
167    methods:{
168        getGGData(){
169            this.$http.post(b2_rest_url+'getPostGG','post_id='+b2_global.post_id).then(res=>{
170                if(res.data.title || res.data.content){
171                    this.title = res.data.title
172                    this.content = res.data.content
173                    this.close()
174                }
175            })
176        },
177        close(){
178            this.show = !this.show
179        },
180    }
181})
182
183var postType5 = new Vue({
184    el:'.post-style-5-top',
185    data:{
186        videos:[],
187        user:'',
188        player:'',
189        index:0,
190        show:true,
191        title:'',
192        showViews:false,
193        url:'',
194        canGuest:false
195    },
196    mounted(){
197        
198        if(!this.$refs.postType5) return
199        let post_id = this.$refs.postType5.getAttribute('data-id')
200
201        let order_id = b2getCookie('b2_guest_buy_'+post_id+'_v')
202        if(order_id){
203            order_id = JSON.parse(order_id)
204            order_id = order_id[0]['order_id']
205        }
206
207        this.$http.post(b2_rest_url+'getPostVideos','post_id='+post_id+'&order_id='+order_id).then(res=>{
208            this.videos = res.data.videos
209            postVideoList.videos = this.videos
210            
211            if(this.videos.length <= 1){
212                this.$refs.videoList.style.display = 'none'
213            }
214
215            this.user = res.data.user
216
217            if(this.user.allow){
218                this.show = false
219            }
220            this.canGuest = this.user.can_guest === '0' ? false : true
221            this.list = res.data.list
222            this.title = res.data.title
223            if(this.videos.length > 0){
224
225                this.selectVideo(0,res)
226 
227            }
228            b2playerInit()
229        })
230
231    },
232    methods:{
233        getLastItem(thePath){
234            return new URL(thePath).pathname.split('/').filter(Boolean).pop().replace('.html','');
235        },
236        updateStats() {
237            var text = 'P2P正在为您加速' + (_totalP2PDownloaded/1024).toFixed(2)
238                + 'MB 已分享' + (_totalP2PUploaded/1024).toFixed(2) + 'MB' + ' 连接节点' + _peerNum + '个';
239            document.getElementById('stats').innerText = text
240        },
241        lochostVideo(index){
242            if(!this.videos[index].url) return false;
243            return !(this.videos[index].url.indexOf('bilibili.com')!==-1 || this.videos[index].url.indexOf('v.qq.com')!==-1 || this.videos[index].url.indexOf('ixigua.com')!==-1 || this.videos[index].url.indexOf('youtube.com')!==-1)
244        },
245        setIframe(index){
246
247            let data = this.getVideoData(index)
248            console.log(data)
249
250            if(data.type == 'bilibili'){
251                iframe = '<iframe src="//player.bilibili.com/player.html?bvid='+data.id+'&cid=&page='+data.p+'&high_quality=1&danmaku=0" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>'
252            }else if(data.type == 'qq'){
253                iframe = '<iframe frameborder="0" src="//v.qq.com/txp/iframe/player.html?vid='+data.id+'" allowFullScreen="true"></iframe>'
254            }else if(data.type == 'xigua'){
255                iframe = `<iframe frameborder="0" src="//www.ixigua.com/iframe/${data.id}?autoplay=0" referrerpolicy="unsafe-url" allowfullscreen></iframe>`
256            }else if(data.type == 'youtube'){
257                iframe = `<iframe src="//www.youtube.com/embed/${data.id}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>`
258            }
259            
260            document.getElementById('post-style-5-player').innerHTML = iframe
261            document.querySelector('.post-video-list').style.height = document.querySelector('.post-style-5-video-box-in').clientHeight+'px'
262        },
263        getQueryFromUrl(url){
264            var str = url.split('?')[1];
265            if(!str) return {}
266            var keys = str.split('&');
267            var obj = {};
268            keys.forEach((item, idx, data)=>{
269                var arr = item.split('=');
270                obj[arr[0]] = arr[1];
271            });
272            return obj;
273        },
274        getVideoData(index){
275            let type,id
276
277            if(this.videos[index].url.indexOf('bilibili.com')!==-1){
278                type = 'bilibili'
279            }else if(this.videos[index].url.indexOf('v.qq.com')!==-1){
280                type = 'qq'
281            }else if(this.videos[index].url.indexOf('ixigua.com')!==-1){
282                type = 'xigua'
283            }else if(this.videos[index].url.indexOf('youtube.com')!==-1){
284                type = 'youtube'
285            }
286
287            if(type =='youtube'){
288                id = this.getQueryFromUrl(this.videos[index].url)['v']
289                p = ''
290            }else{
291                id = this.getLastItem(this.videos[index].url)
292
293                p = this.getQueryFromUrl(this.videos[index].url)['p']
294            }
295
296            return {
297                type:type,
298                id:id,
299                p:p ? p : 1
300            }
301        },
302        selectVideo(index,res){
303       
304            if(this.videos[index].url && !this.lochostVideo(index)){
305                this.setIframe(index)
306            }else{
307                this.setVideo(index,res)
308            }
309        },
310        getDogeVideo(data){
311            return new Promise(resolve => {
312                this.$http.post(b2_rest_url+'getDogeVideo','id='+data.id+'&token='+data.token).then(res=>{
313                    resolve(res.data);
314                }).catch(err=>{
315                    Qmsg['warning'](err.response.data.message,{html:true});
316                })
317            });
318        },
319        async setVideo(index,res){
320            if(this.user.allow){
321                if(this.videos[index].id){
322                    this.url = await this.getDogeVideo(this.videos[index]);
323                }else{
324                    this.url = this.videos[index].url
325                }
326
327            }else{
328                this.url = this.videos[index].view
329                if(this.url){
330                    this.showViews = true
331                }else{
332                    this.showViews = false
333                }
334            }
335
336            let type = 'auto';
337            
338            let playerVideoConfig = {
339                url: this.url,
340                autoplay: true,
341                screenshot:true,
342                pic: this.videos[index].poster,
343                type: type
344            }
345            if(this.url && this.url.indexOf('.m3u8')!==-1){
346                playerVideoConfig['type'] = 'customHls';
347                playerVideoConfig['customType'] = {
348                    'customHls': function (video, player) {
349                        let hls = new Hls();
350                        hls.loadSource(video.src);
351                        hls.attachMedia(video);
352                    }
353                }
354            }
355
356            this.player = new DPlayer({
357                container: document.getElementById('post-style-5-player'),
358                screenshot: false,
359                video: playerVideoConfig,
360                preload:'metadata',
361                contextmenu:[],
362                airplay:true,
363                mutex:true,
364                hotkey:true,
365                preload:res && res.data.auto === '1' ? 'auto' : 'none',
366                logo:b2_global.default_video_logo,
367                autoplay:res && res.data.auto && this.url ? true : false,
368                // customType: {
369                //     'customHls': function (video, player) {
370                //         const hls = new Hls({
371                //             debug: true,
372                //             // Other hlsjsConfig options provided by hls.js
373                //             p2pConfig: {
374                //                 live: true,        // 如果是点播设为false
375                //                 // Other p2pConfig options provided by CDNBye
376                //             }
377                //         });
378                //         hls.loadSource(video.src);
379                //         hls.attachMedia(video);
380                //         hls.p2pEngine.on('stats', function (stats) {
381                //             _totalP2PDownloaded = stats.totalP2PDownloaded;
382                //             _totalP2PUploaded = stats.totalP2PUploaded;
383                //             updateStats();
384                //         }).on('peerId', function (peerId) {
385                //             _peerId = peerId;
386                //         }).on('peers', function (peers) {
387                //             _peerNum = peers.length;
388                //             this.updateStats();
389                //         });
390                //     }
391                // }
392            })
393
394            document.querySelector('.post-video-list').style.height = document.querySelector('.post-style-5-video-box-in').clientHeight+'px'
395
396            if(this.videos.length >= 1){
397                //视频播放结束,切换下一条
398                this.player.on('ended',()=>{
399                    if(this.index+1 < this.videos.length){
400                        this.index = this.index + 1
401                        postVideoList.index = this.index
402                        this.select(this.index)
403                    }
404                })
405
406                this.player.on('playing',()=>{
407                    this.player.controller.setAutoHide();
408                    document.getElementById('post-style-5-player').querySelectorAll('.dplayer-video-current')[0].style="object-fit:contain"
409                })
410            }
411        },
412        select(index){
413            this.index = index
414            postVideoList.index = this.index
415
416            let url = this.videos[index].url
417  
418            if(!this.lochostVideo(index)){
419                this.selectVideo(index)
420            }else{
421                if(!this.video){
422                    this.setVideo(index,{data:{data:{auto:1}}})
423                }else{
424                    document.getElementById('post-style-5-player').querySelectorAll('.dplayer-video-current')[0].style="object-fit:cover"
425                    if(this.user.allow){
426                        this.url = this.videos[index].url
427                    }else{
428                        this.url = this.videos[index].view
429                    }
430                    this.player.switchVideo({
431                        url:this.url,
432                        pic:this.videos[index].poster
433                    })
434        
435                    if(this.user.allow){
436                        this.player.play()
437                    }else{
438                        this.show = true
439                    }
440                }
441            }
442
443        },
444        goComment(){
445            this.$scrollTo('#comments', 300, {offset: -50})
446        },
447        showAc(){
448            this.show = !this.show
449            if(this.show === true){
450                this.player.pause()
451            }
452        },
453        listSlide(){
454            var flkty = new Flickity(this.$refs.videoListIn, {
455                cellAlign: 'left',
456                contain: true
457              });
458        },
459        play(){
460            this.show = false
461            this.player.play()
462        },
463        pay(){
464            
465            if(!b2token && !this.canGuest){
466                login.show = true
467            }else{
468                b2DsBox.data = {
469                    'title':this.title,
470                    'order_price':this.user.role.value,
471                    'order_type':'v',
472                    'post_id':b2_global.post_id
473                }
474                b2DsBox.show = true;
475                b2DsBox.showtype = 'normal'
476            }
477        },
478        credit(){
479            
480            if(!b2token){
481                login.show = true
482            }else{
483                payCredit.data = {
484                    'title':this.title,
485                    'order_price':this.user.role.value,
486                    'order_type':'v',
487                    'post_id':b2_global.post_id
488                }
489                payCredit.show = true;
490            }
491        },
492        login(type){
493            login.show = true
494            login.loginType = type
495        }
496    }
497})
498
499function b2playerInit(){
500    let player = document.querySelectorAll('.dplayer-video');
501    if(player.length > 0){
502        for (let i = 0; i < player.length; i++) {
503            player[i].setAttribute('x5-video-player-type','h5-page')
504            player[i].setAttribute('x5-video-player-fullscreen','true')
505            player[i].setAttribute('playsinline','true')
506            player[i].setAttribute('webkit-playsinline','true')
507        }
508    }
509    
510}
511
512//播放远程视频
513function b2SingleVideo(){
514    let boxes = document.querySelectorAll('.entry-content .content-video-box');
515
516    if(boxes.length > 0){
517        boxes.forEach(e => {
518            e.onclick = (even)=>{
519                let url = even.target.parentNode.getAttribute('data-video-url');
520                if(url){
521                    axios.post(b2_rest_url+'getVideoHtml','url='+encodeURIComponent(url)).then((res)=>{
522                        if(res.data.indexOf('class="smartideo"') !== -1){
523                            e.innerHTML = res.data
524                        }
525                    })
526                }
527            }
528        });
529    }
530}
531b2SingleVideo()
532
533//文章内部图片点击放大
534function b2ImgZooming(sele){
535
536    if(!b2_global.show_slider || b2_global.show_slider == '0') return
537
538    let att = document.querySelectorAll('.attachment img')
539    for (let _i = 0; _i < att.length; _i++) {
540        b2zoom.listen(att[_i])
541    }
542
543    var imgs = document.querySelectorAll(sele)
544
545    for (let i = 0; i < imgs.length; i++) {
546        if(
547            imgs[i].className.indexOf('po-img-big') !== -1 || 
548            imgs[i].className.indexOf('alignnone') !== -1 || 
549            imgs[i].className.indexOf('alignleft') !== -1 ||
550            imgs[i].className.indexOf('alignright') !== -1 ||
551            imgs[i].className.indexOf('aligncenter') !== -1 ||
552            imgs[i].className.indexOf('gallery-image') !== -1 ||
553            imgs[i].className.indexOf('size-full') !== -1 ||
554            imgs[i].className.indexOf('wp-image-') !== -1 
555        ){
556            b2zoom.listen(imgs[i]);
557        }
558        
559    }
560
561    var img2 = document.querySelectorAll('.entry-content figure img')
562    for (let i = 0; i < img2.length; i++) {
563        b2zoom.listen(img2[i]);
564    }
565
566    var img3 = document.querySelectorAll('.entry-content > p > img')
567    for (let i = 0; i < img3.length; i++) {
568        b2zoom.listen(img3[i]);
569    }
570
571}
572document.addEventListener('DOMContentLoaded', function () {
573    b2ImgZooming('.entry-content img')
574})
575
576//附件下载,复制解压码
577function b2FileDown(){
578    let code = document.querySelectorAll('.entry-content .file-down-pass span');
579    code.forEach(e => {
580        e.onclick = (ev)=>{
581
582            let input = ev.target.firstElementChild;
583            input.select()
584
585            if(document.execCommand('copy')){
586
587                ev.target.firstChild.data = b2_global.copy.success
588                setTimeout(()=>{
589                    ev.target.firstChild.data = b2_global.copy.text
590                },1000)
591
592            }else{
593                ev.target.firstChild.data = b2_global.copy.error
594            }
595
596            window.getSelection().removeAllRanges();
597        }
598    });
599}
600b2FileDown()
601
602//显示隐藏短代码内容
603function showHideContent(){
604    let box = document.querySelectorAll('.entry-content .content-show-roles');
605
606    if(box.length > 0){
607
608        let h_axios = axios
609        if(b2token){
610            h_axios.defaults.headers.common['Authorization'] = 'Bearer ' + b2token
611        }
612
613        let order_id = b2getCookie('b2_guest_buy_'+b2_global.post_id+'_w')
614
615        if(order_id){
616            order_id = JSON.parse(order_id)
617            order_id = order_id[0]['order_id']
618        }
619        h_axios.post(b2_rest_url+'getHiddenContent','id='+b2_global.post_id+'&order_id='+order_id).then((res)=>{
620
621            if(res.status == 200){
622                for (let i = 0; i < box.length; i++) {
623
624                    if(typeof(res.data) == 'object'){
625                        box[i].innerHTML = res.data[i]
626                        box[i].parentNode.parentNode.style.height = 'auto'
627                    }else{
628                        box[i].innerHTML = res.data
629                    }
630
631                    Vue.nextTick(()=>{
632                        b2prettyPrint()
633                        b2VideoReset('.content-hidden .b2-player')
634                        b2SidebarSticky()
635                        if (typeof window.contentFooter !== 'undefined') window.contentFooter.updateSticky()
636                    })
637                }
638            }
639
640            setTimeout(()=>{
641                b2AfterInnterHtml()
642            },100)
643        })
644     
645    }
646}
647showHideContent()
648
649function b2AfterInnterHtml(){
650    b2FileDown()
651    b2SingleVideo()
652    b2ImgZooming('.entry-content .content-show-roles img')
653}
654
655Vue.component('poster-box', {
656    props: ['show'],
657    template:b2_global.poster_box,
658    data(){
659        return {
660            poster:'',
661            isWeixin:false,
662            data:'',
663            loadedjs:false,
664            locked:false,
665            showLong:false,
666            thumb:'',
667            logo:''
668        }
669    },
670    computed:{
671        userData(){
672            return this.$store.state.userData;
673        }
674    },
675    methods:{
676        ready(){
677            this.isWeixin = b2isWeixin()
678
679            const qr = new QRious({
680                value: this.data.link,
681                size:100,
682                level:'L'
683            });
684            this.data.qrcode = this.base64ToBlob(qr.toDataURL('image/jpeg'))
685
686            var clipboard = new ClipboardJS('.fuzhi');
687            clipboard.on('success', e=>{
688
689                Qmsg['success'](b2_global.js_text.global.copy_success,{html:true});
690            });
691            clipboard.on('error', e=> {
692
693                Qmsg['warning'](b2_global.js_text.global.copy_select,{html:true});
694            });
695
696            this.$nextTick(()=>{
697                this.getImgLoadEd()
698            })
699    
700        },
701        getImgLoadEd() {
702            // 查询容器下所有图片
703            let images = this.$refs.posterContent.querySelectorAll('img');
704
705            // Array.prototype.slice.call将images类数组转换成合法数组
706            const promises = Array.prototype.slice.call(images).map(node => {
707     
708                return new Promise((resolve, reject) => {
709                    let loadImg = new Image();
710                    loadImg.src = node.src;
711
712                    loadImg.onload = () => {
713                        resolve(node);
714                    }
715                });
716            });
717         
718            // 利用Promise.all监听所有图片加载完成
719            Promise.all(promises).then(results => {
720                this.html2canvas()
721            }).catch(e => {
722                Qmsg['warning'](e,{html:true});
723            })
724        },
725        close(val){
726            this.$emit('close-form',val)
727        },
728        openWin(url,type){
729            if(type == 'weibo'){
730                url = url+'&pic='+this.data.thumb
731            }else{
732                url = url+'&pics='+this.data.thumb
733            }
734
735            openWin(url,type,500,500)
736        },
737        html2canvas(){
738            var dom = this.$refs.posterContent,
739                w = dom.clientWidth,
740                h = dom.clientHeight;
741
742            domtoimage.toPng(dom)
743            .then((dataUrl1)=>{
744                domtoimage.toPng(dom,{ 
745                    quality:0.95,height:h*2,width:w*2,bgcolor:'#fafafa',
746                    style: {
747                        transform: `scale(2)`, // 元素放大
748                        transformOrigin: '0 0',
749                    }
750                })
751                .then((dataUrl)=>{
752                    this.poster = this.base64ToBlob(dataUrl);
753                });
754            });
755        },
756        download(){
757            var link = document.createElement('a');
758            link.download = this.data.title+'.jpg';
759            link.href = this.poster;
760            link.click();
761        },
762        base64ToBlob(code) {
763            code = code.replace(/(\r\n)|(\n)|(\r)/g, '')
764            if(this.isWeixin){
765                return code;
766            }
767            var parts = code.split(';base64,');
768            var contentType = parts[0].split(':')[1];
769            var raw = window.atob(parts[1]);
770            var rawLength = raw.length;
771
772            var uInt8Array = new Uint8Array(rawLength);
773
774            for (var i = 0; i < rawLength; ++i) {
775                uInt8Array[i] = raw.charCodeAt(i);
776            }
777
778            return URL.createObjectURL(new Blob([uInt8Array], {type: contentType}));
779        },
780        getData(){
781            this.$http.post(b2_rest_url+'getPosterData','post_id='+b2_global.post_id).then(res=>{
782                this.data = res.data
783                this.ready()
784            }).catch(err=>{
785                Qmsg['warning'](err.response.data.message,{html:true});
786            })
787        }
788    },
789    watch:{
790        show(val){
791            if(val && !this.loadedjs){
792                b2loadScript(b2_global.site_info.site_uri+'/Assets/fontend/library/dom-to-image.min.js','',()=>{
793                    this.loadedjs = true
794                    this.getData()
795                })
796            }
797        }
798    }
799})
800
801var posterBox = new Vue({
802    el:'#poster-box',
803    data:{
804        show:false,
805        data:[]
806    },
807    methods:{
808        close(val){
809            this.show = val
810        }
811    }
812})
813
814var postVideoTable = new Vue({
815    el:'.post-video-table',
816    data:{
817        table:'content'
818    },
819    methods:{
820        tab(type){
821            this.table = type
822        }
823    },
824    watch:{
825       table(val){
826            if(val === 'comment'){
827                document.querySelector('#post-5-list').style.display = 'none'
828                document.querySelector('.single-article').style.display = 'none'
829                document.querySelector('.comments-box').style.display = 'block'
830            }else if(val === 'list'){
831                document.querySelector('#post-5-list').style.display = 'block'
832                document.querySelector('.single-article').style.display = 'none'
833                document.querySelector('.comments-box').style.display = 'none'
834            }else{
835                document.querySelector('#post-5-list').style.display = 'none'
836                document.querySelector('.single-article').style.display = 'block'
837                document.querySelector('.comments-box').style.display = 'none'
838            }
839       }
840    }
841})
842
843var postVideoList = new Vue({
844    el:'#post-5-list',
845    data:{
846        videos:[],
847        index:0
848    },
849    methods:{
850        select(i){
851            postType5.select(i)
852        }
853    }
854})
855
856//内页底部
857var b2ContentFooter = new Vue({
858    el:'.content-footer',
859    data:{
860        showPoster:false,
861        postData:[],
862        locked:false
863    },
864    mounted(){
865        let footer = document.querySelector('.post-content-footer');
866        if(footer && B2ClientWidth <= 768){
867            footer.classList.remove('post-content-footer');
868            footer.style.display = 'flex'
869        }else{
870            setTimeout(() => {
871                if(footer && B2ClientWidth > 768){
872                    window.contentFooter = new StickySidebar('.post-content-footer', {
873                        topSpacing: 0,
874                    });
875                }
876            }, 10);
877        }
878    },
879    methods:{
880        openPoster(){
881            posterBox.show = true;
882        },
883        goComment(){
884            this.$scrollTo('#comments', 300, {offset: -50})
885        },
886        postFavoriteAc(){
887            
888            if(!b2token){
889                login.show = true
890            }else{
891                if(this.locked == true) return
892                this.locked = true
893
894                this.$http.post(b2_rest_url+'userFavorites','post_id='+b2_global.post_id).then(res=>{
895                    if(res.data == true){
896                        this.postData.favorites_isset = true
897                    }else{
898                        this.postData.favorites_isset = false
899                    }
900                    this.locked = false
901                }).catch(err=>{
902
903                    Qmsg['warning'](err.response.data.message,{html:true});
904                    this.locked = false
905                })
906            }
907        },
908        vote(type){
909            
910            if(!b2token){
911                login.show = true
912            }else{
913                if(this.locked == true) return
914                this.locked = true
915
916                this.$http.post(b2_rest_url+'postVote','type='+type+'&post_id='+b2_global.post_id).then(res=>{
917
918                    this.postData.up = parseInt(this.postData.up) + parseInt(res.data.up)
919                    this.postData.down = parseInt(this.postData.down) + parseInt(res.data.down)
920                    
921                    if(res.data.up > 0){
922                        this.postData.up_isset = true
923                    }else{
924                        this.postData.up_isset = false
925                    }
926
927                    if(res.data.down > 0){
928                        this.postData.down_isset = true
929                    }else{
930                        this.postData.down_isset = false
931                    }
932
933                    if(typeof b2infomationSingle != 'undefined'){
934                        b2infomationSingle.getSingleData()
935                    }
936
937                    this.locked = false
938                }).catch(err=>{
939
940                    Qmsg['warning'](err.response.data.message,{html:true});
941                    this.locked = false
942                })
943            }
944        }
945    }
946})
947
948//评论列表
949var b2CommentList = new Vue({
950    el:'#comments',
951    data:{
952        selecter:'.comment-list',
953        opt:{
954            'post_id':b2_global.post_id
955        },
956        api:'getCommentList',
957        options:[],
958        tips:'',
959        canSticky:false,
960        data:[],
961        content:'',
962        show:{
963            info:false,
964            smile:false,
965            image:false
966        },
967        focus:false,
968        //图片上传
969        parentId:0,
970        progress:0,
971        locked:false,
972        commentData:{
973            imgUrl:'',
974            imgId:''
975        },
976        subLocked:false,
977        sketchpad:'',
978        drawing:false,
979        sketchpadOpt:{
980            color:'#121212',
981            penSize:'2'
982        },
983        b2token:false,
984        voteData:{}
985    },
986    computed:{
987        userData(){
988            return this.$store.state.userData
989        },
990        canImg(){
991            return this.$store.state.canImg
992        }
993    },
994    mounted(){
995
996        
997            this.listImg()
998            this.checkVote()
999            this.getTips()
1000
1001        if(this.$refs.respond){
1002            this.b2token = b2token
1003            this.resetUserInfo()
1004            setTimeout(()=>{
1005                autosize(this.$refs.textarea_box);
1006                this.buildSketchpad()
1007                b2tooltip('.comment-type button')
1008                b2tooltip('.d-replay button')
1009            })
1010        }
1011        
1012    },
1013    methods:{
1014        buildSketchpad(){
1015            if(!this.$refs.sketchpad) return
1016            this.sketchpad = new Sketchpad({
1017                element: '#sketchpad',
1018                width: this.$refs._textarea_box.offsetWidth - 20,
1019                height: 200,
1020                color:'#121212',
1021                penSize:2
1022            });
1023        },
1024        resetUserInfo(){
1025            
1026            if(!b2token){
1027                this.data = JSON.parse(this.$refs.formData.getAttribute('data-commenter'))
1028                
1029                this.show.info = this.data.name && this.data.user_email ? false : true
1030            }
1031        },
1032        undo(){
1033            this.sketchpad.undo()
1034        },
1035        redo(){
1036            this.sketchpad.redo()
1037        },
1038        color(color){
1039            this.sketchpadOpt.color = color
1040            this.sketchpad.color = color
1041        },
1042        penSize(size){
1043            this.sketchpadOpt.penSize = size
1044            this.sketchpad.penSize = size
1045        },
1046        animate(){
1047            this.sketchpad.animate(2)
1048        },
1049        addSmile(val){
1050            grin(val,document.querySelector('#textarea'))
1051        },
1052        resetmove(){
1053            if(this.subLocked || this.locked) return
1054            this.parentId = 0
1055            document.querySelector('#comment-form').appendChild(this.$refs.respond)
1056            if(this.$refs.fileInput){
1057                this.$refs.fileInput.value = null
1058            }
1059            this.commentData.imgUrl = ''
1060            this.commentData.imgId = ''
1061            this.show.image = false
1062            this.progress = 0
1063            this.resetWidth()
1064        },
1065        resetWidth(){
1066            if(!this.$refs.sketchpad) return
1067            setTimeout(() => {
1068                this.sketchpad.width = this.$refs._textarea_box.offsetWidth - 20
1069                this.sketchpad.reset(this.sketchpad.width)
1070            }, 10);
1071        },
1072        submit(){
1073            if(this.drawing){
1074                if(this.sketchpad.strokes.length == 0){
1075                    Qmsg['warning'](b2_global.js_text.global.sketchpad_empty,{html:true});
1076                    return
1077                }
1078            }
1079
1080            if(this.subLocked == true || this.Locked == true) return
1081            this.subLocked = true
1082
1083            let data = {
1084                'comment_post_ID':b2_global.post_id,
1085                'author':this.data.name,
1086                'email':this.data.user_email,
1087                'comment':this.$refs.textarea_box.value,
1088                'comment_parent':this.parentId,
1089                'img':this.commentData
1090            }
1091
1092            if(this.drawing){
1093                this.updateDrawing(data)
1094            }else{
1095                this.submitAction(data)
1096            }
1097
1098        },
1099        updateDrawing(data){
1100            this.$refs.sketchpad.toBlob((blob)=>{
1101
1102                let formData = new FormData()
1103
1104                formData.append('file',blob,'comment-drawing.jpg')
1105                formData.append("post_id", b2_global.post_id)
1106                formData.append("type", 'comment_drawing')
1107
1108                this.$http.post(b2_rest_url+'fileUpload',formData).then(res=>{
1109
1110                    if(res.data.status == 401){
1111                        Qmsg['warning'](res.data.message,{html:true});
1112                        this.subLocked = false
1113                        return
1114                    }else{
1115                        data['comment'] = b2_global.js_text.global.tuya+'['+res.data.id+']'
1116                        data['img'] = {
1117                            imgUrl:res.data.url,
1118                            imgId:res.data.id
1119                        }
1120                        this.submitAction(data)
1121                    }
1122
1123                }).catch(err=>{
1124                    Qmsg['warning'](err.response.data.message,{html:true});
1125                    this.subLocked = false
1126                    return
1127                })
1128              },'image/png');
1129        },
1130        submitAction(data){
1131            this.$http.post(b2_rest_url+'commentSubmit',Qs.stringify(data)).then(res=>{
1132                if(this.parentId){
1133                    this.$el.querySelector('#comment-children-'+this.parentId).innerHTML = res.data.list
1134                }else{
1135                    b2CommentList.$refs.commentList.insertAdjacentHTML('afterbegin', res.data.list)
1136                }
1137                this.$refs.textarea_box.value = ''
1138                this.subLocked = false
1139       
1140                this.resetmove()
1141                this.listImg()
1142                if(this.$refs.noneComment){
1143                    this.$refs.noneComment.remove()
1144                }
1145                if(!this.$refs.sketchpad) return
1146                this.sketchpad.clearAll()
1147                
1148                
1149                this.$nextTick(()=>{
1150                    lazyLoadInstance.update()
1151                    this.checkVote()
1152                })
1153            }).catch(err=>{
1154                if(typeof err.response.data.message == 'string'){
1155                    Qmsg['warning'](err.response.data.message,{html:true});
1156                }else{
1157                    Qmsg['warning'](err.response.data.message[0],{html:true});
1158                }
1159                
1160                this.subLocked = false
1161              
1162            })
1163        },
1164        deleteImage(){
1165            this.commentData.imgUrl = ''
1166            this.commentData.imgId = ''
1167            this.progress = 0
1168            this.$refs.fileInput.value = null
1169        },
1170        getFile(event){
1171            if(event.target.files.length <= 0) return
1172            if(this.locked == true) return
1173            this.locked = true
1174
1175            this.commentData.imgUrl = ''
1176            this.commentData.imgId = ''
1177
1178            this.progress = 0
1179
1180            let file = event.target.files[0]
1181
1182            this.show.image = true
1183
1184            let formData = new FormData()
1185
1186            formData.append('file',file,file.name)
1187            formData.append("post_id", b2_global.post_id)
1188            formData.append("type", 'comment')
1189
1190            let config = {
1191                onUploadProgress: progressEvent=>{
1192                    this.progress = progressEvent.loaded / progressEvent.total * 100 | 0
1193                }
1194            }
1195
1196            this.$http.post(b2_rest_url+'fileUpload',formData,config).then(res=>{
1197                if(res.data.status == 401){
1198
1199                    Qmsg['warning'](res.data.message,{html:true});
1200                    this.show.image = false
1201                    this.progress = 0
1202                }else{
1203                    this.commentData.imgUrl = res.data.url
1204                    this.commentData.imgId = res.data.id
1205                }
1206                this.$refs.fileInput.value = null
1207                this.locked = false;
1208            }).catch(err=>{
1209
1210                Qmsg['warning'](err.response.data.message,{html:true});
1211                this.locked = false
1212                this.show.image = false
1213                this.progress = 0
1214                this.$refs.fileInput.value = null
1215            })
1216        },
1217        showLogin(){
1218            login.show = true
1219        },
1220        listImg(){
1221            let img = document.querySelectorAll('.comment-img-box img');
1222            if(img.length > 0){
1223                for (let index = 0; index < img.length; index++) {
1224                    b2zoom.listen(img[index]);
1225                }
1226            }
1227        },
1228        getTips(){
1229            this.$https.get(b2_rest_url+'getCommentTips').then(res=>{
1230                this.tips = res.data
1231            })
1232        },
1233        showSticky(){
1234            if(this.canSticky){
1235                let zd = document.querySelectorAll('.comment-zd');
1236                if(zd.length > 0){
1237                    for (let index = 0; index < zd.length; index++) {
1238                        zd[index].className = zd[index].className.replace(' comment-zd','')
1239                    }
1240                }
1241            }
1242        },
1243        sticky(comment_id){
1244            this.$http.post(b2_rest_url+'commentSticky','post_id='+b2_global.post_id+'&comment_id='+comment_id).then(res=>{
1245                this.$refs.commentPageNav.go(1,'comment',true)
1246                this.resetmove()
1247            })
1248        },
1249        vote(e,type,comment_id){
1250
1251            
1252            if(!b2token){
1253                login.show = true
1254            }else{
1255                this.$http.post(b2_rest_url+'commentVote','type='+type+'&comment_id='+comment_id).then(res=>{
1256                    // let _type;
1257                    // if(type === 'comment_up'){
1258                    //     _type = 'comment_down'
1259                    // }else{
1260                    //     _type = 'comment_up'
1261                    // }
1262
1263                    // this.$set(this.voteData.list[comment_id].vote,type,res.data[type]+this.voteData.list[comment_id].vote[type])
1264                    // this.$set(this.voteData.list[comment_id].vote,_type,res.data[_type]+this.voteData.list[comment_id].vote[_type])
1265
1266                    // this.$set(this.voteData.list[comment_id],'isset',false)
1267
1268                    // if(res.data[_type] >0){
1269                    //     this.$set(this.voteData.list[comment_id],'isset',_type)
1270                    // }
1271
1272                    // if(res.data[type] >0){
1273                    //     this.$set(this.voteData.list[comment_id],'isset',type)
1274                    // }
1275
1276                    this.checkVote()
1277                    
1278                }).catch(err=>{
1279                    
1280                    Qmsg['warning'](err.response.data.message,{html:true});
1281                    
1282                })
1283            }
1284            
1285        },
1286        finish(){
1287            this.checkVote()
1288        },
1289        checkVote(){
1290            
1291            // if(!b2token) return
1292            let dom = document.querySelectorAll('.reply')
1293
1294            if(dom.length == 0 ) return
1295
1296            let ids = []
1297
1298            for (let i = 0; i < dom.length; i++) {
1299
1300                ids.push(dom[i].getAttribute('data-id'))
1301            }
1302
1303            let data = {
1304                'ids':ids,
1305                'post_id':b2_global.post_id
1306            }
1307
1308            this.$https.post(b2_rest_url+'commentVoteData',Qs.stringify(data)).then(res=>{
1309
1310                if(res.data){
1311                    Object.keys(res.data.list).forEach(function (key) {
1312
1313                        let up = document.querySelector('#comment-up'+'-'+key),
1314                            down = document.querySelector('#comment-down'+'-'+key)
1315
1316                            up.className = up.className.replace(' voted','')
1317                            down.className = down.className.replace(' voted','')
1318        
1319                        if(res.data.list[key].isset == 'comment_up'){
1320                            up.className += ' voted'
1321                        }
1322
1323                        if(res.data.list[key].isset == 'comment_down'){
1324                            down.className += ' voted'
1325                        }
1326                        
1327                        document.querySelector('#comment-up-'+key+' span').innerText = res.data.list[key].vote.comment_up
1328                        document.querySelector('#comment-down-'+key+' span').innerText = res.data.list[key].vote.comment_down
1329                    })
1330                }
1331
1332                this.canSticky = res.data.can_sticky
1333                this.showSticky()
1334            })
1335        },
1336        move(comment_id){
1337            if(this.subLocked || this.locked) return
1338            this.parentId = comment_id
1339            document.querySelector('#comment-form-'+comment_id).appendChild(this.$refs.respond)
1340            
1341            this.resetWidth()
1342            
1343        }
1344    },
1345    watch:{
1346        drawing(val){
1347            if(val){
1348                this.resetWidth()
1349            }
1350        },
1351        userData(val){
1352            if(val && b2token){
1353                this.data = val
1354            }
1355        }
1356    }
1357})
1358
1359function b2ContentImageLoaded(){
1360    imagesLoaded( document.querySelectorAll('.entry-content'), function( instance ) {
1361        if (typeof window.contentFooter !== 'undefined') window.contentFooter.updateSticky()
1362    });
1363}
1364
1365b2ContentImageLoaded()
1366
1367var b2DownloadBox = new Vue({
1368    el:'#download-box',
1369    data:{
1370        list:'',
1371        cLogin:false,
1372        picked:0
1373    },
1374    mounted(){
1375        if(this.$refs.downloadBox){
1376            
1377            if(!b2token){
1378                this.cLogin = false
1379            }else{
1380                this.cLogin = true
1381            }
1382            this.getList()
1383
1384            if(this.$refs.downloadTitleBox){
1385                const ps = new PerfectScrollbar('.item-name-box', {
1386                    wheelSpeed: 2,
1387                    wheelPropagation: true,
1388                    minScrollbarLength: 10
1389                });
1390            }
1391            
1392        }
1393    },
1394    methods:{
1395        getList(){
1396
1397            let guest = b2getCookie('b2_guest_buy_'+b2_global.post_id+'_x')
1398                guest = JSON.parse(guest)
1399            let data = {
1400                'post_id':b2_global.post_id,
1401                'guest':guest
1402            }
1403
1404            this.$http.post(b2_rest_url+'getDownloadData',Qs.stringify(data)).then(res=>{
1405                this.list = res.data
1406                if(typeof b2WidgetDownload != 'undefined' && b2WidgetDownload.$refs.wdlist){
1407                    b2WidgetDownload.list = res.data
1408                    b2WidgetDownload.$refs.gujia.style.display = 'none'
1409                    b2WidgetDownload.$refs.wdlist.style.display = 'block'
1410                    // this.$refs.downloadBox.style.display = 'none'
1411                    // document.querySelector('.single-button-download').style.display = 'none'
1412                }
1413                
1414                let show = false
1415
1416                if(document.body.clientWidth > 720){
1417                    show = true
1418                }
1419
1420                for (let i = 0; i < this.list.length; i++) {
1421                    this.list[i].show_role = show
1422                }
1423                
1424                this.$refs.gujia.style = "display:none"
1425
1426                this.$nextTick(()=>{
1427                    b2SidebarSticky()
1428                
1429                    if (typeof window.contentFooter !== 'undefined') window.contentFooter.updateSticky()
1430
1431                })
1432            })
1433        },
1434        login(){
1435            login.show = true
1436        },
1437        go(link,allow,item,index){
1438
1439            if(item.current_user.lv.lv.lv === 'dark_room'){
1440
1441                Qmsg['warning'](b2_global.js_text.global.dark_room_down,{html:true});
1442                return
1443            }
1444
1445
1446
1447            if(!this.cLogin && !allow && !item.current_user.guest){
1448                login.show = true
1449            }else if(!allow){
1450                if(item.current_user.can.type == 'comment'){
1451
1452                    Qmsg['warning'](b2_global.js_text.global.comment_down,{html:true});
1453                }else if(item.current_user.can.type == 'credit'){
1454                    this.credit(index)
1455                }else if(item.current_user.can.type == 'money'){
1456                    this.pay(index)
1457                }else{
1458
1459                    Qmsg['warning'](b2_global.js_text.global.role_down,{html:true});
1460                }
1461                return 
1462
1463            }else{
1464                window.open(link)
1465            }
1466        },
1467        pay(index){
1468            if(this.list[index].current_user.can.type == 'money'){
1469                b2DsBox.data = {
1470                    'title':this.list[index].name,
1471                    'order_price':this.list[index].current_user.can.value,
1472                    'order_type':'x',
1473                    'post_id':b2_global.post_id,
1474                    'order_key':index
1475                }
1476                b2DsBox.show = true;
1477                b2DsBox.showtype = 'normal'
1478            }
1479        },
1480        credit(index){
1481            if(!this.cLogin){
1482                login.show = true
1483            }else{
1484                if(this.list[index].current_user.can.type == 'credit'){
1485                    payCredit.data = {
1486                        'title':this.list[index].name,
1487                        'order_price':this.list[index].current_user.can.value,
1488                        'order_type':'x',
1489                        'post_id':b2_global.post_id,
1490                        'order_key':index
1491                    }
1492                    payCredit.show = true;
1493                }
1494            }
1495        }
1496    }
1497})
1498
1499var b2WidgetDownload = new Vue({
1500    el:'.b2-widget-download',
1501    data:{
1502        list:'',
1503    },
1504    methods:{
1505        show(index){
1506            this.$set(this.list[index],'show',!this.list[index].show)
1507        },
1508        go(link,allow,item,index) {
1509            b2DownloadBox.go(link,allow,item,index) 
1510        }
1511    }
1512})
1513
1514b2VideoReset('.b2-player')
1515function b2VideoReset(classname){
1516    if(!classname) return
1517    let videos = document.querySelectorAll(classname);
1518    if(videos.length > 0){
1519        if(!document.querySelector('.player-js')){
1520            b2loadScript(b2_global.site_info.site_uri+'/Assets/fontend/library/flv.min.js','',()=>{
1521                b2loadScript(b2_global.site_info.site_uri+'/Assets/fontend/library/hls.min.js','',()=>{
1522                    b2loadScript(b2_global.site_info.site_uri+'/Assets/fontend/library/DPlayer.min.js','',()=>{
1523                        b2VideoFor(videos)
1524                    })
1525                })
1526            })
1527        }else{
1528            b2VideoFor(videos)
1529        }
1530    }
1531}
1532
1533function b2VideoFor(videos){
1534    var player = [];
1535    for (let i = 0; i < videos.length; i++) {
1536        let data = JSON.parse(videos[i].getAttribute('data-video'));
1537        if(data.url){
1538            player[i] = new DPlayer({
1539                container: videos[i],
1540                screenshot: false,
1541                mutex:true,
1542                hotkey:true,
1543                preload:'none',
1544                contextmenu:[],
1545                video: {
1546                    url: data.url,
1547                    pic: data.poster,
1548                },
1549                logo:data.logo != '' ? data.logo : b2_global.site_info.site_uri+'/Assets/fontend/images/xg-logo-default.png',
1550                autoplay:false
1551            });
1552            player[i].on('play',()=>{
1553                player[i].controller.setAutoHide();
1554                videos[i].querySelectorAll('.dplayer-video-current')[0].style="object-fit:contain"
1555            })
1556            player[i].oncontextmenu = ()=>{
1557                return false
1558            }
1559        } 
1560    }
1561}
1562
1563if(typeof b2SingleMeta !== 'undefined'){
1564    let postData = b2SingleMeta.$watch('postData',(newVal,oldVal)=>{
1565        if(typeof b2ContentFooter !== 'undefined'){
1566            b2ContentFooter.postData = newVal
1567        }
1568        if(typeof B2ShopSingle !== 'undefined'){
1569            if(B2ShopSingle.$refs.shopSingle){
1570                B2ShopSingle.postData = newVal
1571            }
1572        }
1573        if(typeof documentVote !== 'undefined'){
1574            documentVote.postData = newVal
1575        }
1576    })
1577}
1578
1579var postAuthor = new Vue({
1580    el:'.b2-widget-author',
1581    data:{
1582        following:false
1583    },
1584    methods:{
1585        followingAc(){
1586            
1587            if(!b2token){
1588                login.show = true
1589            }else{
1590                this.$http.post(b2_rest_url+'AuthorFollow','user_id='+b2_global.author_id).then(res=>{
1591                    this.following = !this.following
1592                }).catch(err=>{
1593                    Qmsg['warning'](err.response.data.message,{html:true});
1594                })
1595            }
1596        },
1597        dmsg(){
1598            
1599            if(!b2token){
1600                login.show = true
1601            }else{
1602                b2Dmsg.userid = b2_global.author_id
1603                b2Dmsg.show = true
1604            }
1605        },
1606    }
1607})

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.