1'use strict'; 2 3var Utils = require('../../core/utils.js'), 4 Like = require('../../core/like.js'); 5var project_id = $('#project_id').val(); 6var project_url = $('#project_url').val(); 7var more = require('../../core/load-more.js'); 8var moment = require('../../libs/moment/moment.js'); 9var Ajax = require('../../core/ajax.js'); 10 11if (CSJS.Config.currUserId) { 12 var SendEventView = require('../../core/send-event-view.js').init('post', '.short-item'); 13} 14 15require('../../libs/datepicker/datepicker.js'); 16 17more('/project/' + project_id + '/more-posts/', 'short-post.ejs', updatePost); 18 19var postsDate = []; 20 21Ajax.getJSON('/project/' + project_id + '/get-post-dates/', function(data) { 22 postsDate = data.response; 23 24 var filterDate = $('.post_date'); 25 26 $.each(filterDate, function (k) { 27 $(filterDate[k]).datepicker({ 28 timepicker: false, 29 inline: true, 30 changeYear: true, 31 changeMonth: true, 32 defaultDate: new Date(), 33 onRenderCell: function (date, cellType) { 34 var currentDate = moment(date).format('YYYY-MM-DD'); 35 36 if (cellType === 'day' && postsDate.indexOf(currentDate) !== -1) { 37 38 return { 39 html: '<i class="post-on" data-count="' + _.countBy(postsDate)[currentDate] + '">'+ parseInt(moment(date).format('DD')) + '</i>' 40 } 41 } 42 } 43 }); 44 45 if ($(filterDate[k]).data('date')) { 46 var dateArray = $(filterDate[k]).data('date').split('-'); 47 48 $(filterDate[k]).data('datepicker').selectDate( 49 new Date(dateArray[0] + '-' + parseInt(parseInt( dateArray[1]) + 1 ) + '-' + dateArray[2]) 50 ); 51 52 $(filterDate[k]).data('datepicker').selectDate( 53 new Date(dateArray[0] + '-' + dateArray[1] + '-' + dateArray[2]) 54 ); 55 } 56 57 $(filterDate[k]).datepicker({ 58 onSelect: function onSelect(formattedDate, date) { 59 updateFilter('post_date', changeTimezone(new Date(date))); 60 }, 61 }); 62 63 }) 64}); 65function changeTimezone(date) { 66 var invdate = new Date(date.toLocaleString('en-US', { 67 timeZone: 'Europe/Moscow' 68 })); 69 var diff = date.getTime() - invdate.getTime(); 70 return date.getTime() + diff; 71} 72$('#sort').on('input', function () { 73 updateOrder($(this).val()); 74}); 75 76$(document).on('click', '#show-all-tags', function(e) { 77 e.preventDefault(); 78 79 $('.filter-tag').removeClass('hidden-tag'); 80 $(this).remove(); 81}); 82 83$('#tag-list .filter-tag').click(function(e) { 84 e.preventDefault(); 85 86 var $tag = $(this); 87 if ($tag.hasClass('active')) { 88 $tag.removeClass('active') 89 updateFilter('tag_id', null); 90 } else { 91 $('#tag-list .filter-tag').removeClass('active'); 92 updateFilter('tag_id', $tag.data('id')); 93 $tag.addClass('active') 94 } 95}); 96 97$('#level-list').change(function() { 98 updateFilter('level_id', $(this).val() || null); 99}); 100 101 102function updateFilter(name, value) { 103 var params = {}; 104 105 if (value !== null) { 106 params[name] = value; 107 } 108 109 var query = Utils.objectToQuery(params); 110 if (query) { 111 query = '?' + query; 112 } 113 114 var order = (window.location.search).split('order_by=')[1]; 115 116 var urlPath = '/' + project_url + '/'; 117 if (name === 'tag_id' && value !== null) { 118 urlPath = '/' + project_url + '/olddesign2024/'; 119 } 120 121 window.history.pushState({}, '', urlPath + query + (order ? '&order_by=' + order : '')); 122 window.filterChange(); 123} 124function updateOrder(val) { 125 var query = Utils.parseQueryString(window.location.search) 126 127 query.order_by = val; 128 query = Utils.objectToQuery(query); 129 130 window.history.pushState({}, '', '/' + project_url + '/?' + query); 131 window.filterChange(); 132} 133 134updatePost(); 135 136function updatePost() { 137 $('.post-con:not([data-fixed="1"])').each(function() { 138 var $post = $(this).addClass('show-all no-transaction').attr('data-fixed', '1'); 139 140 if ($post.height() <= 80) { 141 $post.parent().find('input.show-more').prop('checked', true); 142 } 143 144 $post.removeClass('show-all'); 145 }); 146 147 setTimeout(function() { 148 $('.no-transaction').removeClass('no-transaction'); 149 }, 20); 150 151 if (SendEventView) { 152 SendEventView.addItems(); 153 } 154} 155 156$(document).on('click', '.post-meta .like', function(e) { 157 e.preventDefault(); 158 159 var $like = $(this); 160 Like($like,{ 161 project_id: project_id, 162 post_id: $like.data('pid') 163 }); 164}); 165 166function setTab(tab) { 167 var tabs = $('.post-tab-nav-left'); 168 var currentTab = tabs.find('.active').data('tab'); 169 170 var tabProject = null; 171 172 if ((currentTab === 'project' && tab === 'project') || (!currentTab && tab === 'project')) { 173 174 tabProject = tabs 175 .find('a') 176 .parent() 177 .find('[data-tab="'+ tab +'"]') 178 .toggleClass('active'); 179 180 if (tabProject.hasClass('active')) { 181 document.cookie = 'projectDesc'+ project_id +'=1; path=/;'; 182 } else { 183 document.cookie = 'projectDesc'+ project_id +'=0; path=/;'; 184 } 185 186 } else { 187 tabs 188 .find('a') 189 .removeClass('active') 190 .parent() 191 .find('[data-tab="'+ tab +'"]') 192 .addClass('active') 193 ; 194 } 195 196 $('.post-tab-cont > div').removeClass('active').hide(); 197 198 199 200 var tabContent = $('.post-tab-cont > div[data-tab="' + tab + '"]'); 201 if (tabProject) { 202 if (tabProject.hasClass('active')) { 203 tabContent.addClass('active').show(); 204 } else { 205 tabContent.removeClass('active').hide(); 206 } 207 } else { 208 tabContent.addClass('active').show(); 209 } 210 211} 212 213$('.post-tab-nav-left a').on('click', function (e) { 214 var tab = $(this).data('tab'); 215 216 var currentUrl = window.location.pathname; 217 var regex = /^\/[A-Za-z0-9_]+\/[A-Za-z0-9_]+(?:\/olddesign2024)?\/?$/; 218 var oldDesign = Utils.getCookie('olddesign2025'); 219 220 if (oldDesign === 'false' && tab === 'review' && regex.test(currentUrl)) { 221 window.location.href = '/' + project_url + '/'; 222 } 223 224 if (['contacts_new', 'project', 'levels_new', 'playlists_new'].includes(tab)) { 225 return; 226 } else { 227 e.preventDefault(); 228 } 229 230 $('.public-posts-not-found').hide(); 231 setTab($(this).data('tab')); 232});
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.