const id_user = '1541357'
                    if (location.host != 'dev.epochtimes.ru' && location.host != 'www.epochtimes.ru'){location.href = "https://ntdtv.ru"}
			        var url_json = 'https://ntdposts.ser0.ru/get_post_list/'+id_user+'/7/'
			        var start_vue = new Vue({
                    	el: '#app',
                    	data:{
                        	posts: [],
                        },
                        template:
                        `<div id="app" class="video_block">
                            <div class="header_h2_blow">
                                <div class="sq_orange"></div>
                                <div class="dev_h2">Видео</div>
                            </div>
                            <template v-for="(post, index) in posts">
                                <template v-if="index==0">
                                    <div class="big_video" style="cursor:pointer;">
                                        <img width="100%" :src="post.img_url" :alt="post.title" @click="clickPost(post.id_post, index)" />
                                    </div>
                                </template>
                                <template v-if="index>0">
                                    <div class="small_video" style="cursor:pointer;">
                                        <img width="100%" :src="post.img_url" :alt="post.title" @click="clickPost(post.id_post, index)" />
                                        <p class="country_side_title"><a style="" href="" @click.prevent="clickPost(post.id_post, index)">{{post.title}}</a></p>
                                    </div>
                                </template>
                            </template>
                        </div>`,
                    	mounted() { // when the Vue app is booted up, this is run automatically.
                        	var self = this // create a closure to access component in the callback below
                        	jQuery.getJSON(url_json, function(data) {
                            	self.posts = data;
                        	});
                            this.stat_visible_user()
                        },
                        methods: {
                            clickPost: function(id_post, index) {
                                location.href= "/contacts/#/ntd/"+id_post
                            },
                            set_statistic: function(){
                                jQuery.getJSON("https://ntdposts.ser0.ru/get_view_stats", function(data) {
                                var infoStat = data
                                infoStat.url = location.href
                                infoStat.id_client = id_user
                                console.log("infoStatView=", infoStat)
                                jQuery.post("https://ntdposts.ser0.ru/statistic_views", infoStat)
                                    })
                            },
                            stat_visible_user: function(){
								document.addEventListener('scroll', this.onScroll)
							},
							onScroll: function(){
								const vis_user = document.getElementById('app')
								const posTop = vis_user.getBoundingClientRect().top
  								if(posTop + vis_user.clientHeight <= window.innerHeight && posTop >= 0) {
									console.log("Visible block=", posTop)
									document.removeEventListener('scroll', this.onScroll);
									this.set_statistic()
  								}
							},
                        },
                	});